uma: Permit specifying max of cache line and some custom alignment

To be used for structures for which we want to enforce that pointers to
them have some number of lower bits always set to 0, while still
ensuring we benefit from cache line alignment to avoid false sharing
between structures and fields within the structures (provided they are
properly ordered).

First candidate consumer that comes to mind is 'struct thread', see next
commit.

Reviewed by:            markj, kib
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42265
This commit is contained in:
Olivier Certner 2023-10-13 17:05:34 +02:00 committed by Mark Johnston
parent 2c7dd66d09
commit 733e0abd28

View file

@ -302,6 +302,8 @@ uma_zone_t uma_zcache_create(const char *name, int size, uma_ctor ctor,
#define UMA_ALIGN_SHORT (sizeof(short) - 1) /* "" short */
#define UMA_ALIGN_CHAR (sizeof(char) - 1) /* "" char */
#define UMA_ALIGN_CACHE (uma_get_cache_align_mask()) /* Cache line size align */
/* Align both to cache line size and an explicit alignment (through mask). */
#define UMA_ALIGN_CACHE_AND_MASK(mask) (uma_get_cache_align_mask() | (mask))
#define UMA_ALIGNOF(type) (_Alignof(type) - 1) /* Alignment fit for 'type' */
#define UMA_ANYDOMAIN -1 /* Special value for domain search. */