Skip to content

Commit 28168ec

Browse files
diandersakpm00
authored andcommitted
watchdog/hardlockup: move SMP barriers from common code to buddy code
It's been suggested that since the SMP barriers are only potentially useful for the buddy hardlockup detector, not the perf hardlockup detector, that the barriers belong in the buddy code. Let's move them and add clearer comments about why they're needed. Link: https://lkml.kernel.org/r/20230526184139.9.I5ab0a0eeb0bd52fb23f901d298c72fa5c396e22b@changeid Signed-off-by: Douglas Anderson <[email protected]> Suggested-by: Petr Mladek <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Nicholas Piggin <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 7ece48b commit 28168ec

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

kernel/watchdog.c

-6
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ EXPORT_SYMBOL(arch_touch_nmi_watchdog);
109109
void watchdog_hardlockup_touch_cpu(unsigned int cpu)
110110
{
111111
per_cpu(watchdog_hardlockup_touched, cpu) = true;
112-
113-
/* Match with smp_rmb() in watchdog_hardlockup_check() */
114-
smp_wmb();
115112
}
116113

117114
static bool is_hardlockup(unsigned int cpu)
@@ -141,9 +138,6 @@ static void watchdog_hardlockup_kick(void)
141138

142139
void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
143140
{
144-
/* Match with smp_wmb() in watchdog_hardlockup_touch_cpu() */
145-
smp_rmb();
146-
147141
if (per_cpu(watchdog_hardlockup_touched, cpu)) {
148142
per_cpu(watchdog_hardlockup_touched, cpu) = false;
149143
return;

kernel/watchdog_buddy.c

+21
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ void watchdog_hardlockup_enable(unsigned int cpu)
5151
if (next_cpu < nr_cpu_ids)
5252
watchdog_hardlockup_touch_cpu(next_cpu);
5353

54+
/*
55+
* Makes sure that watchdog is touched on this CPU before
56+
* other CPUs could see it in watchdog_cpus. The counter
57+
* part is in watchdog_buddy_check_hardlockup().
58+
*/
59+
smp_wmb();
60+
5461
cpumask_set_cpu(cpu, &watchdog_cpus);
5562
}
5663

@@ -68,6 +75,13 @@ void watchdog_hardlockup_disable(unsigned int cpu)
6875
if (next_cpu < nr_cpu_ids)
6976
watchdog_hardlockup_touch_cpu(next_cpu);
7077

78+
/*
79+
* Makes sure that watchdog is touched on the next CPU before
80+
* this CPU disappear in watchdog_cpus. The counter part is in
81+
* watchdog_buddy_check_hardlockup().
82+
*/
83+
smp_wmb();
84+
7185
cpumask_clear_cpu(cpu, &watchdog_cpus);
7286
}
7387

@@ -88,5 +102,12 @@ void watchdog_buddy_check_hardlockup(int hrtimer_interrupts)
88102
if (next_cpu >= nr_cpu_ids)
89103
return;
90104

105+
/*
106+
* Make sure that the watchdog was touched on next CPU when
107+
* watchdog_next_cpu() returned another one because of
108+
* a change in watchdog_hardlockup_enable()/disable().
109+
*/
110+
smp_rmb();
111+
91112
watchdog_hardlockup_check(next_cpu, NULL);
92113
}

0 commit comments

Comments
 (0)