git: c98dded0c762 - stable/14 - uma: UMA_ALIGN_CACHE: Resolve the proper value at use point
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 16 Nov 2023 20:54:40 UTC
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c98dded0c76266740e94ac53e8a2f02be1d61e4f commit c98dded0c76266740e94ac53e8a2f02be1d61e4f Author: Olivier Certner <olce.freebsd@certner.fr> AuthorDate: 2023-10-13 12:13:30 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2023-11-16 15:07:11 +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 (cherry picked from commit e557eafe7233f8231c1f5f5b098e4bab8e818645) --- 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; }