Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Nov 2023 13:40:06 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: e557eafe7233 - main - uma: UMA_ALIGN_CACHE: Resolve the proper value at use point
Message-ID:  <202311021340.3A2De6gq028197@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=e557eafe7233f8231c1f5f5b098e4bab8e818645

commit e557eafe7233f8231c1f5f5b098e4bab8e818645
Author:     Olivier Certner <olce.freebsd@certner.fr>
AuthorDate: 2023-10-13 12:13:30 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-11-02 13:30:03 +0000

    uma: UMA_ALIGN_CACHE: Resolve the proper value at use point
    
    Having a special value of -1 that is resolved internally to
    'uma_align_cache' provides no significant advantages and prevents
    changing that variable to an unsigned type, which is natural for an
    alignment mask.  So suppress it and replace its use with a call to
    uma_get_align_mask().  The small overhead of the added function call is
    irrelevant since UMA_ALIGN_CACHE is only used when creating new zones,
    which is not performance critical.
    
    Reviewed by:            markj, kib
    MFC after:              2 weeks
    Sponsored by:           The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D42259
---
 sys/vm/uma.h      | 2 +-
 sys/vm/uma_core.c | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/sys/vm/uma.h b/sys/vm/uma.h
index 793f9af3dace..4bf23534ed27 100644
--- a/sys/vm/uma.h
+++ b/sys/vm/uma.h
@@ -301,7 +301,7 @@ uma_zone_t uma_zcache_create(const char *name, int size, uma_ctor ctor,
 #define UMA_ALIGN_INT	(sizeof(int) - 1)	/* "" int */
 #define UMA_ALIGN_SHORT	(sizeof(short) - 1)	/* "" short */
 #define UMA_ALIGN_CHAR	(sizeof(char) - 1)	/* "" char */
-#define UMA_ALIGN_CACHE	(0 - 1)			/* Cache line size align */
+#define UMA_ALIGN_CACHE	(uma_get_cache_align_mask()) /* Cache line size align */
 #define	UMA_ALIGNOF(type) (_Alignof(type) - 1)	/* Alignment fit for 'type' */
 
 #define	UMA_ANYDOMAIN	-1	/* Special value for domain search. */
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index 6e83a27bab27..b74fbd57e77f 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -3243,7 +3243,7 @@ uma_kcreate(uma_zone_t zone, size_t size, uma_init uminit, uma_fini fini,
 	args.size = size;
 	args.uminit = uminit;
 	args.fini = fini;
-	args.align = (align == UMA_ALIGN_CACHE) ? uma_cache_align_mask : align;
+	args.align = align;
 	args.flags = flags;
 	args.zone = zone;
 	return (zone_alloc_item(kegs, &args, UMA_ANYDOMAIN, M_WAITOK));
@@ -3256,7 +3256,6 @@ uma_set_cache_align_mask(int mask)
 {
 
 	if (mask >= 0)
-		/* UMA_ALIGN_CACHE is also not permitted here. */
 		uma_cache_align_mask = mask;
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202311021340.3A2De6gq028197>