git: 6e4b7753610d - stable/13 - uma: Permit specifying max of cache line and some custom alignment

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Thu, 21 Dec 2023 13:44:00 UTC
The branch stable/13 has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=6e4b7753610d2594740d73120fe6251ce7f66a61

commit 6e4b7753610d2594740d73120fe6251ce7f66a61
Author:     Olivier Certner <olce.freebsd@certner.fr>
AuthorDate: 2023-10-13 15:05:34 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2023-12-21 13:40:09 +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
    Sponsored by:           The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D42265
    
    (cherry picked from commit 733e0abd2897289e2acf70f7c72e31a5a560394a)
    
    Approved by:    markj (mentor)
---
 sys/vm/uma.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/vm/uma.h b/sys/vm/uma.h
index 852473d69c27..2a305d87ca34 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. */