Re: [PATCH] sched/clock: Avoid false sharing for sched_clock_irqtime
From: K Prateek Nayak
Date: Mon Jan 12 2026 - 23:27:07 EST
Hello Wangyang,
On 1/13/2026 8:36 AM, Wangyang Guo wrote:
> Read-mostly sched_clock_irqtime may share the same cacheline with
> frequently updated nohz struct. Make it as cache aligned to avoid
> false sharing issue.
nit.
Since you mention this is a "Read-mostly" data ...
[..snip..]
> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> index 7097de2c8cda..34d15972f5fb 100644
> --- a/kernel/sched/cputime.c
> +++ b/kernel/sched/cputime.c
> @@ -25,7 +25,7 @@
> */
> DEFINE_PER_CPU(struct irqtime, cpu_irqtime);
>
> -int sched_clock_irqtime;
> +int sched_clock_irqtime __cacheline_aligned;
Have you tried annotating it with "__ro_after_init" or "__read_mostly"?
That should also ensure "sched_clock_irqtime" doesn't have false-sharing
with the nohz struct without using an entire cacheline worth of space.
--
Thanks and Regards,
Prateek