HomeFreeBSD

Ensure 'struct thread' is aligned to a cache line

Description

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

Details

Provenance
olceAuthored on Oct 13 2023, 8:52 AM
markjCommitted on Nov 2 2023, 1:30 PM
Reviewer
markj
Differential Revision
D42266: Ensure 'struct thread' is aligned to a cache line
Parents
rG733e0abd2897: uma: Permit specifying max of cache line and some custom alignment
Branches
Unknown
Tags
Unknown