]> 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)
committerMark Johnston <markj@FreeBSD.org>
Thu, 2 Nov 2023 13:30:03 +0000 (09:30 -0400)
commit7d1469e555bdce32b3dfc898478ae5564d5072b1
tree141a99095024ca4078a826c48d6c0b65da00a21a
parent733e0abd2897289e2acf70f7c72e31a5a560394a
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
MFC after:              2 week
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42266
sys/kern/kern_thread.c