[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <od57wrws3tmcwuyi3rkbgoysg73vdtq6czstwbq4zjr6qrd6ns@zpwvqdiyfvfp>
Date: Mon, 17 Mar 2025 11:50:19 +0530
From: "Nysal Jan K.A." <nysal@...ux.ibm.com>
To: Thomas Gleixner <tglx@...utronix.de>, LKML <linux-kernel@...r.kernel.org>
Cc: Anna-Maria Behnsen <anna-maria@...utronix.de>,
Frederic Weisbecker <frederic@...nel.org>,
Benjamin Segall <bsegall@...gle.com>,
Eric Dumazet <edumazet@...gle.com>, Andrey Vagin <avagin@...nvz.org>,
Pavel Tikhomirov <ptikhomirov@...tuozzo.com>,
Peter Zijlstra <peterz@...radead.org>,
Cyrill Gorcunov <gorcunov@...il.com>
Subject: Re: [patch V3 14/18] posix-timers: Avoid false cacheline sharing
On Sat, Mar 08, 2025 at 05:48:42PM +0100, Thomas Gleixner wrote:
> ---
> V2: New patch
> ---
> include/linux/posix-timers.h | 21 ++++++++++++---------
> kernel/time/posix-timers.c | 4 ++--
> 2 files changed, 14 insertions(+), 11 deletions(-)
>
> --- a/include/linux/posix-timers.h
> +++ b/include/linux/posix-timers.h
> @@ -177,23 +177,26 @@ static inline void posix_cputimers_init_
> * @rcu: RCU head for freeing the timer.
> */
> struct k_itimer {
> - struct hlist_node list;
> - struct hlist_node ignored_list;
> + /* 1st cacheline contains read-mostly fields */
> struct hlist_node t_hash;
> - spinlock_t it_lock;
> - const struct k_clock *kclock;
> - clockid_t it_clock;
> + struct hlist_node list;
> timer_t it_id;
> + clockid_t it_clock;
> + int it_sigev_notify;
> + enum pid_type it_pid_type;
> + struct signal_struct *it_signal;
> + const struct k_clock *kclock;
> +
> + /* 2nd cacheline and above contain fields which are modified regularly */
On architectures like powerpc where cache line size is 128 bytes, we might still
run into false sharing. Perhaps rearranging it towards the end of the struct might
help avoid it? Is the benchmark code public? I can collect perf c2c data on powerpc.
> + spinlock_t it_lock;
> int it_status;
> bool it_sig_periodic;
> s64 it_overrun;
> s64 it_overrun_last;
> unsigned int it_signal_seq;
> unsigned int it_sigqueue_seq;
> - int it_sigev_notify;
> - enum pid_type it_pid_type;
> ktime_t it_interval;
> - struct signal_struct *it_signal;
> + struct hlist_node ignored_list;
> union {
> struct pid *it_pid;
> struct task_struct *it_process;
> @@ -210,7 +213,7 @@ struct k_itimer {
> } alarm;
> } it;
> struct rcu_head rcu;
> -};
> +} ____cacheline_aligned_in_smp;
>
--Nysal
Powered by blists - more mailing lists