From nobody Thu Nov 16 20:54:42 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SWXN31Yfvz515DF; Thu, 16 Nov 2023 20:54:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SWXN313M6z4Grr; Thu, 16 Nov 2023 20:54:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700168083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vAoMqvuRn33xpmVXhiDqHDXQrSJlG3CltfFnjDb0awE=; b=S0bDXqqRA3OK5oWFFz9r3hN7IF6wZ+DtHA9USKvhIF+KovnZQSNVYsrbQ9FbAJXabFOudd HU133W8Ihm4T/b82i4klx4SnVq0kTBSRgFJTVojhgE2s0YZlmYz2m5STow6iZGBVKjuLFw rX2d5hcHNCsXXSucHu8+Lu1c2se06l6xXwTluDpIbFR4UsfCY4ybO186Ds30mHiqpMyeRY rYQh0yPlTGIna3rUeXeWI6RjbqQox2MkrG6H3jcCAjGX+bUyH18Q27Y6X9cVuZMzBAo/lz FJbkajWrumYLettdKmeIMYru3TgQlQtM/j1Y+JUXoZfKcgwuvi6MxXn+aWLmDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700168083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vAoMqvuRn33xpmVXhiDqHDXQrSJlG3CltfFnjDb0awE=; b=ZeB2Qc9/PCv4jedk6kzlIvEXob7OP/wm7vu+7xyQsfbHfFl2wVYQOPPWuzQAKQKyO0UlWQ taUJ6JAcxIEyTZ/J3V4z2bAzBlE5U3s2X4xhICpnSsxdCC/jQyibNwRsQpj9kaSy5lYYG5 WnqXSufjfNzAYw8uiaPNCzaIY5jcQ4VEaaThgCnWdGrALhkBtwG3IFH3kxoV7ZMGCHYTWQ gKTpamltCYxUJANQrvbv0F6KaCwMdDE7qbYeJy9KocXfIVGSYWmDGGEywol5sfCKgzc7jj 3CZaXmOQEbgeWQ49pDRUz8aAk8Jsc0h/2rD42jJW6ylxMQX7P/EMKhmZvGEJ/g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700168083; a=rsa-sha256; cv=none; b=KvzAk/cfPbMdcFapVsXvMsBKV/xobYKL+RKZdjuUeaCptu9Zq6gy3LaZcGP2AG38SqL/Xi miYagvqjIBNXoJrImYIyCW76HkWq61WoPH4PDyuv1+Ip9ubkTlY4ns4l/ZmhnD/dlE/Yjf uuN65L0o+Qmr0DooOFHYAu7LdhNjKChgUA8tXmsVqc+k1PpOk7J0ac/GRNA+VS8baoLK+Y lJzs23hIMuTpCUbDN8NxWoDpqaglpSTt1ViKHR2AbV1ZJOUw8kJ/XtpwDccces/uyj008j ELKYWzq5zpg8GchZrtVvcvMmcRCJ66aj32U/6Zv5AGUG9GGoRBvREUUvaHF8ZQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SWXN30690z1NL; Thu, 16 Nov 2023 20:54:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AGKsgBw053801; Thu, 16 Nov 2023 20:54:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AGKsgcT053798; Thu, 16 Nov 2023 20:54:42 GMT (envelope-from git) Date: Thu, 16 Nov 2023 20:54:42 GMT Message-Id: <202311162054.3AGKsgcT053798@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 690ca45aeb8c - stable/14 - uma: Make the cache alignment mask unsigned List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 690ca45aeb8c3f521d43246159bd24e15d31500c Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=690ca45aeb8c3f521d43246159bd24e15d31500c commit 690ca45aeb8c3f521d43246159bd24e15d31500c Author: Olivier Certner AuthorDate: 2023-10-13 12:49:11 +0000 Commit: Mark Johnston CommitDate: 2023-11-16 15:07:16 +0000 uma: Make the cache alignment mask unsigned In uma_set_align_mask(), ensure that the passed value doesn't have its highest bit set, which would lead to problems since keg/zone alignment is internally stored as signed integers. Such big values do not make sense anyway and indicate some programming error. A future commit will introduce checks for this case and other ones. Reviewed by: kib, markj MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42262 (cherry picked from commit 3d8f548b9e5772ff6890bdc01f7ba7b76203857d) --- sys/arm/arm/cpufunc.c | 6 +++--- sys/vm/uma.h | 2 +- sys/vm/uma_align_mask.h | 2 +- sys/vm/uma_core.c | 15 ++++++++++----- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/sys/arm/arm/cpufunc.c b/sys/arm/arm/cpufunc.c index 42f718b9773e..e94565cdc61f 100644 --- a/sys/arm/arm/cpufunc.c +++ b/sys/arm/arm/cpufunc.c @@ -61,8 +61,8 @@ /* PRIMARY CACHE VARIABLES */ -int arm_dcache_align; -int arm_dcache_align_mask; +unsigned int arm_dcache_align; +unsigned int arm_dcache_align_mask; #ifdef CPU_MV_PJ4B static void pj4bv7_setup(void); @@ -170,7 +170,7 @@ get_cachetype_cp15(void) : : "r" (sel)); __asm __volatile("mrc p15, 1, %0, c0, c0, 0" : "=r" (csize)); - arm_dcache_align = 1 << + arm_dcache_align = 1U << (CPUV7_CT_xSIZE_LEN(csize) + 4); } if (type == CACHE_ICACHE || type == CACHE_SEP_CACHE) { diff --git a/sys/vm/uma.h b/sys/vm/uma.h index 4bf23534ed27..8193df16b904 100644 --- a/sys/vm/uma.h +++ b/sys/vm/uma.h @@ -475,7 +475,7 @@ void uma_zone_reclaim_domain(uma_zone_t, int req, int domain); * Returns: * Nothing */ -void uma_set_cache_align_mask(int mask); +void uma_set_cache_align_mask(unsigned int mask); #include diff --git a/sys/vm/uma_align_mask.h b/sys/vm/uma_align_mask.h index 666633350b9d..b4e9ac835d93 100644 --- a/sys/vm/uma_align_mask.h +++ b/sys/vm/uma_align_mask.h @@ -31,6 +31,6 @@ #ifndef _VM_UMA_ALIGN_MASK_H_ #define _VM_UMA_ALIGN_MASK_H_ -int uma_get_cache_align_mask(void) __pure; +unsigned int uma_get_cache_align_mask(void) __pure; #endif /* !_VM_UMA_ALIGN_MASK_H_ */ diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index b74fbd57e77f..a27dba4b01f1 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -150,7 +150,7 @@ static uma_zone_t slabzones[2]; static uma_zone_t hashzone; /* The boot-time adjusted value for cache line alignment. */ -static int uma_cache_align_mask = 64 - 1; +static unsigned int uma_cache_align_mask = 64 - 1; static MALLOC_DEFINE(M_UMAHASH, "UMAHash", "UMA Hash Buckets"); static MALLOC_DEFINE(M_UMA, "UMA", "UMA Misc"); @@ -3252,15 +3252,20 @@ uma_kcreate(uma_zone_t zone, size_t size, uma_init uminit, uma_fini fini, /* Public functions */ /* See uma.h */ void -uma_set_cache_align_mask(int mask) +uma_set_cache_align_mask(unsigned int mask) { - if (mask >= 0) - uma_cache_align_mask = mask; + /* + * Make sure the stored align mask doesn't have its highest bit set, + * which would cause implementation-defined behavior when passing it as + * the 'align' argument of uma_zcreate(). Such very large alignments do + * not make sense anyway. + */ + uma_cache_align_mask = mask & ~(1U << 31); } /* Returns the alignment mask to use to request cache alignment. */ -int +unsigned int uma_get_cache_align_mask(void) { return (uma_cache_align_mask);