Re: [PATCH v6] sched/clock: Avoid false sharing for sched_clock_irqtime
From: K Prateek Nayak
Date: Tue Jan 27 2026 - 01:31:04 EST
Hello Wangyang,
On 1/27/2026 10:11 AM, Wangyang Guo wrote:
> --- a/kernel/sched/clock.c
> +++ b/kernel/sched/clock.c
> @@ -173,6 +173,7 @@ notrace static void __sched_clock_work(struct work_struct *work)
> scd->tick_gtod, __gtod_offset,
> scd->tick_raw, __sched_clock_offset);
>
> + disable_sched_clock_irqtime();
We can come here with !irqtime_enabled() but this is a slowpath so I
don't really mind calling disable_sched_clock_irqtime() unconditionally
here. Feel free to include:
Reviewed-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
Tested-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
Tested with a bunch of fake cases of sched_clock going unstable by
hacking the kernel and the irqtime was disabled correctly in both cases
- pre-lateinit and post-lateinit.
> static_branch_disable(&__sched_clock_stable);
> }
>
--
Thanks and Regards,
Prateek