]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Ensure 'struct thread' is aligned to a cache line
authorOlivier Certner <olce.freebsd@certner.fr>
Fri, 13 Oct 2023 08:52:31 +0000 (10:52 +0200)
committerOlivier Certner <olce@FreeBSD.org>
Thu, 21 Dec 2023 13:40:10 +0000 (14:40 +0100)
commit7063038299682f421a3b56ade0dbd40c2ce69292
tree3c7090d7503fcea6c636ffdb9032c65db6033f02
parent6e4b7753610d2594740d73120fe6251ce7f66a61
Ensure 'struct thread' is aligned to a cache line

Using the new UMA_ALIGN_CACHE_AND_MASK() facility, which allows to
simultaneously guarantee a minimum of 32 bytes of alignment (the 5 lower
bits are always 0).

For the record, to this day, here's a (possibly non-exhaustive) list of
synchronization primitives using lower bits to store flags in pointers
to thread structures:
- lockmgr, rwlock and sx all use the 5 bits directly.
- rmlock indirectly relies on sx, so can use the 5 bits.
- mtx (non-spin) relies on the 3 lower bits.

Reviewed by:            markj, kib
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42266

(cherry picked from commit 7d1469e555bdce32b3dfc898478ae5564d5072b1)

Approved by:    markj (mentor)
sys/kern/kern_thread.c