diff options
-rw-r--r-- | sys/vm/uma.h | 14 | ||||
-rw-r--r-- | sys/vm/uma_core.c | 14 |
2 files changed, 26 insertions, 2 deletions
diff --git a/sys/vm/uma.h b/sys/vm/uma.h index 0027177..c082e96 100644 --- a/sys/vm/uma.h +++ b/sys/vm/uma.h @@ -236,7 +236,7 @@ uma_zone_t uma_zsecond_create(char *name, uma_ctor ctor, uma_dtor dtor, #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 (16 - 1) /* Cache line size align */ +#define UMA_ALIGN_CACHE (0 - 1) /* Cache line size align */ /* * Destroys an empty uma zone. If the zone is not empty uma complains loudly. @@ -388,6 +388,18 @@ void uma_startup2(void); void uma_reclaim(void); /* + * Sets the alignment mask to be used for all zones requesting cache + * alignment. Should be called by MD boot code prior to starting VM/UMA. + * + * Arguments: + * align The alignment mask + * + * Returns: + * Nothing + */ +void uma_set_align(int align); + +/* * Switches the backing object of a zone * * Arguments: diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index fa2cb05..eb00bfe 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -111,6 +111,9 @@ static uma_zone_t slabrefzone; /* With refcounters (for UMA_ZONE_REFCNT) */ */ static uma_zone_t hashzone; +/* The boot-time adjusted value for cache line alignment. */ +static int uma_align_cache = 16 - 1; + static MALLOC_DEFINE(M_UMAHASH, "UMAHash", "UMA Hash Buckets"); /* @@ -1707,13 +1710,22 @@ 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; + args.align = (align == UMA_ALIGN_CACHE) ? uma_align_cache : align; args.flags = flags; args.zone = zone; return (uma_zalloc_internal(kegs, &args, M_WAITOK)); } /* See uma.h */ +void +uma_set_align(int align) +{ + + if (align != UMA_ALIGN_CACHE) + uma_align_cache = align; +} + +/* See uma.h */ uma_zone_t uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor, uma_init uminit, uma_fini fini, int align, u_int32_t flags) |