[PATCH] timer_list: Annotate print_cpu() diagnostic reads
From: Yu Peng
Date: Tue Jul 07 2026 - 09:03:51 EST
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@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=8f0e958900a14d08a51d
Signed-off-by: Yu Peng <pengyu@xxxxxxxxxx>
---
kernel/time/timer_list.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index 514802def1e0..0e05a03db723 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -118,12 +118,13 @@ 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 DIAG_READ(x) data_race(READ_ONCE(x)) /* Diagnostic read. */
#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 +140,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 +167,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");
}
--
2.43.0