Skip to content

Commit d3b62ac

Browse files
diandersakpm00
authored andcommitted
watchdog/buddy: cleanup how watchdog_buddy_check_hardlockup() is called
In the patch ("watchdog/hardlockup: detect hard lockups using secondary (buddy) CPUs"), we added a call from the common watchdog.c file into the buddy. That call could be done more cleanly. Specifically: 1. If we move the call into watchdog_hardlockup_kick() then it keeps watchdog_timer_fn() simpler. 2. We don't need to pass an "unsigned long" to the buddy for the timer count. In the patch ("watchdog/hardlockup: add a "cpu" param to watchdog_hardlockup_check()") the count was changed to "atomic_t" which is backed by an int, so we should match types. Link: https://lkml.kernel.org/r/20230526184139.6.I006c7d958a1ea5c4e1e4dc44a25596d9bb5fd3ba@changeid Signed-off-by: Douglas Anderson <dianders@chromium.org> Suggested-by: Petr Mladek <pmladek@suse.com> Reviewed-by: Petr Mladek <pmladek@suse.com> Cc: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: "David S. Miller" <davem@davemloft.net> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 05e7b55 commit d3b62ac

3 files changed

Lines changed: 10 additions & 11 deletions

File tree

include/linux/nmi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ void watchdog_hardlockup_disable(unsigned int cpu);
114114
void lockup_detector_reconfigure(void);
115115

116116
#ifdef CONFIG_HARDLOCKUP_DETECTOR_BUDDY
117-
void watchdog_buddy_check_hardlockup(unsigned long hrtimer_interrupts);
117+
void watchdog_buddy_check_hardlockup(int hrtimer_interrupts);
118118
#else
119-
static inline void watchdog_buddy_check_hardlockup(unsigned long hrtimer_interrupts) {}
119+
static inline void watchdog_buddy_check_hardlockup(int hrtimer_interrupts) {}
120120
#endif
121121

122122
/**

kernel/watchdog.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@ static bool is_hardlockup(unsigned int cpu)
131131
return false;
132132
}
133133

134-
static unsigned long watchdog_hardlockup_kick(void)
134+
static void watchdog_hardlockup_kick(void)
135135
{
136-
return atomic_inc_return(this_cpu_ptr(&hrtimer_interrupts));
136+
int new_interrupts;
137+
138+
new_interrupts = atomic_inc_return(this_cpu_ptr(&hrtimer_interrupts));
139+
watchdog_buddy_check_hardlockup(new_interrupts);
137140
}
138141

139142
void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
@@ -195,7 +198,7 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
195198

196199
#else /* CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER */
197200

198-
static inline unsigned long watchdog_hardlockup_kick(void) { return 0; }
201+
static inline void watchdog_hardlockup_kick(void) { }
199202

200203
#endif /* !CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER */
201204

@@ -449,15 +452,11 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
449452
struct pt_regs *regs = get_irq_regs();
450453
int duration;
451454
int softlockup_all_cpu_backtrace = sysctl_softlockup_all_cpu_backtrace;
452-
unsigned long hrtimer_interrupts;
453455

454456
if (!watchdog_enabled)
455457
return HRTIMER_NORESTART;
456458

457-
hrtimer_interrupts = watchdog_hardlockup_kick();
458-
459-
/* test for hardlockups */
460-
watchdog_buddy_check_hardlockup(hrtimer_interrupts);
459+
watchdog_hardlockup_kick();
461460

462461
/* kick the softlockup detector */
463462
if (completion_done(this_cpu_ptr(&softlockup_completion))) {

kernel/watchdog_buddy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void watchdog_hardlockup_disable(unsigned int cpu)
7272
cpumask_clear_cpu(cpu, &watchdog_cpus);
7373
}
7474

75-
void watchdog_buddy_check_hardlockup(unsigned long hrtimer_interrupts)
75+
void watchdog_buddy_check_hardlockup(int hrtimer_interrupts)
7676
{
7777
unsigned int next_cpu;
7878

0 commit comments

Comments
 (0)