]> www.infradead.org Git - users/jedix/linux-maple.git/commit
posix-timers: Avoid false cacheline sharing
authorThomas Gleixner <tglx@linutronix.de>
Sat, 8 Mar 2025 16:48:42 +0000 (17:48 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 13 Mar 2025 11:07:18 +0000 (12:07 +0100)
commit5fa75a432f1a6b1402edd8802ecc14f8bbb90e49
treefd5e1a68caeee78748c2a7276e7701f1f6ea6705
parent781764e0b4394fbd8e8eb39195f8a076b60808b3
posix-timers: Avoid false cacheline sharing

struct k_itimer has the hlist_node, which is used for lookup in the hash
bucket, and the timer lock in the same cache line.

That's obviously bad, if one CPU fiddles with a timer and the other is
walking the hash bucket on which that timer is queued.

Avoid this by restructuring struct k_itimer, so that the read mostly (only
modified during setup and teardown) fields are in the first cache line and
the lock and the rest of the fields which get written to are in cacheline
2-N.

Reduces cacheline contention in a test case of 64 processes creating and
accessing 20000 timers each by almost 30% according to perf.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/all/20250308155624.341108067@linutronix.de
include/linux/posix-timers.h
kernel/time/posix-timers.c