summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorYu Peng <pengyu@kylinos.cn>2026-07-07 20:58:13 +0800
committerThomas Gleixner <tglx@kernel.org>2026-07-07 23:26:58 +0200
commit1d28a67d496f482933b0ba5d8577835bdbe601ca (patch)
treea38a3212e2a886877e951c6a0e6b3094fe242b44 /kernel
parent06aba58e58492d2b8eae059274caed29025ea96e (diff)
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 <pengyu@kylinos.cn> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Link: https://patch.msgid.link/20260707125813.2182532-1-pengyu@kylinos.cn Closes: https://syzkaller.appspot.com/bug?extid=8f0e958900a14d08a51d
Diffstat (limited to 'kernel')
-rw-r--r--kernel/time/timer_list.c17
1 files 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");
}