git: 733e0abd2897 - main - uma: Permit specifying max of cache line and some custom alignment

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 02 Nov 2023 13:40:11 UTC
The branch main has been updated by markj:

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

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

    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
---
 sys/vm/uma.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/vm/uma.h b/sys/vm/uma.h
index 8193df16b904..38865df7ae02 100644
--- a/sys/vm/uma.h
+++ b/sys/vm/uma.h
@@ -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. */