aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Certner <olce.freebsd@certner.fr>2023-10-13 12:13:30 +0000
committerOlivier Certner <olce@FreeBSD.org>2023-12-21 13:39:34 +0000
commit4e00940e9f1f7dc1210a094d916ef930ff447e4a (patch)
tree10e52aa6ca60c6b25476895c5aa00972e70230af
parent56c53cc8fb3edaed82678440da5cf8e0dc482d03 (diff)
downloadsrc-4e00940e9f1f7dc1210a094d916ef930ff447e4a.tar.gz
src-4e00940e9f1f7dc1210a094d916ef930ff447e4a.zip
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 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42259 (cherry picked from commit e557eafe7233f8231c1f5f5b098e4bab8e818645) Approved by: markj (mentor)
-rw-r--r--sys/vm/uma.h2
-rw-r--r--sys/vm/uma_core.c3
2 files changed, 2 insertions, 3 deletions
diff --git a/sys/vm/uma.h b/sys/vm/uma.h
index 4225bd83ba23..c748a7843374 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 506bc63033ba..19ea5433559d 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -3182,7 +3182,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));
@@ -3195,7 +3195,6 @@ uma_set_cache_align_mask(int mask)
{
if (mask >= 0)
- /* UMA_ALIGN_CACHE is also not permitted here. */
uma_cache_align_mask = mask;
}