Re: [PATCH v3] sched/clock: Avoid false sharing for sched_clock_irqtime

From: Guo, Wangyang

Date: Sun Jan 25 2026 - 21:25:55 EST


On 1/24/2026 12:48 AM, K Prateek Nayak wrote:
Hello Vincent,

On 1/23/2026 9:28 PM, Vincent Guittot wrote:
If TSC / any potentially unstable clock is marked unstable before
sched_clock_init_late(), we never flip __sched_clock_stable.

On x86 side, since we already start using TSC for native_sched_clock()
super early, we have defensive measures (and a __use_tsc static key on
the x86 side too) to switch the sched clock back to jiffies if we
realise TSC was unstable before we hit sched_clock_init_late().

This is necessary since post the sched_clock_init(),
"sched_clock_running" is true and the local clocks will always uses
sched_clock_noinstr() and it must be switch to jiffies on the x86 side
since arch defines it.

sched_clock_init_late() is always called so can't we check if
irqtime_enabled and clock is unstable then we disable irqtime
accounting

That can be done, yes.

Wangyang, can you also consolidate the irqtime disable bits (TSC and
generic) to trigger at sched_clock_init_late() if the clock was found
unstable and in __sched_clock_work()?

Both context can directly do a static_branch_disable() without
needing an extra delayed work.

Thanks for the advise, v4 sent out, please help to review:
https://lore.kernel.org/all/20260126021401.1490163-1-wangyang.guo@xxxxxxxxx/

BR
Wangyang