Re: [patch V3 14/18] posix-timers: Avoid false cacheline sharing
From: Frederic Weisbecker
Date: Tue Mar 11 2025 - 09:53:45 EST
Le Sat, Mar 08, 2025 at 05:48:42PM +0100, Thomas Gleixner a écrit :
> 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@xxxxxxxxxxxxx>
Impressive what a fields reshuffle and alignement can achieve!
Reviewed-by: Frederic Weisbecker <frederic@xxxxxxxxxx>