From 1d28a67d496f482933b0ba5d8577835bdbe601ca Mon Sep 17 00:00:00 2001 From: Yu Peng Date: Tue, 7 Jul 2026 20:58:13 +0800 Subject: [PATCH] timer_list: Annotate print_cpu() diagnostic reads print_cpu() prints hrtimer_cpu_base and tick_sched state without synchronizing with concurrent updates. The output is diagnostic only, so use data_race(READ_ONCE()) for these scalar reads to document the intentional races and avoid KCSAN reports. Reported-by: syzbot+8f0e958900a14d08a51d@syzkaller.appspotmail.com Signed-off-by: Yu Peng Signed-off-by: Thomas Gleixner Link: https://patch.msgid.link/20260707125813.2182532-1-pengyu@kylinos.cn Closes: https://syzkaller.appspot.com/bug?extid=8f0e958900a14d08a51d --- kernel/time/timer_list.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c index 514802def1e0..8823e7dcfce6 100644 --- a/kernel/time/timer_list.c +++ b/kernel/time/timer_list.c @@ -118,12 +118,15 @@ static void print_cpu(struct seq_file *m, int cpu, u64 now) SEQ_printf(m, " clock %d:\n", i); print_base(m, cpu_base->clock_base + i, now); } -#define P(x) \ + +#define DIAG_READ(x) data_race(READ_ONCE(x)) + +#define P(x) \ SEQ_printf(m, " .%-15s: %Lu\n", #x, \ - (unsigned long long)(cpu_base->x)) + (unsigned long long)DIAG_READ(cpu_base->x)) #define P_ns(x) \ SEQ_printf(m, " .%-15s: %Lu nsecs\n", #x, \ - (unsigned long long)(ktime_to_ns(cpu_base->x))) + (unsigned long long)ktime_to_ns(DIAG_READ(cpu_base->x))) #ifdef CONFIG_HIGH_RES_TIMERS P_ns(expires_next); @@ -139,12 +142,12 @@ static void print_cpu(struct seq_file *m, int cpu, u64 now) #ifdef CONFIG_TICK_ONESHOT # define P(x) \ SEQ_printf(m, " .%-15s: %Lu\n", #x, \ - (unsigned long long)(ts->x)) + (unsigned long long)DIAG_READ(ts->x)) # define P_ns(x) \ SEQ_printf(m, " .%-15s: %Lu nsecs\n", #x, \ - (unsigned long long)(ktime_to_ns(ts->x))) + (unsigned long long)ktime_to_ns(DIAG_READ(ts->x))) # define P_flag(x, f) \ - SEQ_printf(m, " .%-15s: %d\n", #x, !!(ts->flags & (f))) + SEQ_printf(m, " .%-15s: %d\n", #x, !!(DIAG_READ(ts->flags) & (f))) { struct tick_sched *ts = tick_get_tick_sched(cpu); @@ -166,6 +169,8 @@ static void print_cpu(struct seq_file *m, int cpu, u64 now) #undef P #undef P_ns +#undef P_flag +#undef DIAG_READ SEQ_printf(m, "\n"); }