Skip to content

Commit ab992dc

Browse files
Peter Zijlstratorvalds
authored andcommitted
watchdog: Fix merge 'conflict'
Two watchdog changes that came through different trees had a non conflicting conflict, that is, one changed the semantics of a variable but no actual code conflict happened. So the merge appeared fine, but the resulting code did not behave as expected. Commit 195daf6 ("watchdog: enable the new user interface of the watchdog mechanism") changes the semantics of watchdog_user_enabled, which thereafter is only used by the functions introduced by b3738d2 ("watchdog: Add watchdog enable/disable all functions"). There further appears to be a distinct lack of serialization between setting and using watchdog_enabled, so perhaps we should wrap the {en,dis}able_all() things in watchdog_proc_mutex. This patch fixes a s2r failure reported by Michal; which I cannot readily explain. But this does make the code internally consistent again. Reported-and-tested-by: Michal Hocko <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 7cf7d42 commit ab992dc

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

kernel/watchdog.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT)
4242
#define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT)
4343

44+
static DEFINE_MUTEX(watchdog_proc_mutex);
45+
4446
#ifdef CONFIG_HARDLOCKUP_DETECTOR
4547
static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED;
4648
#else
@@ -608,26 +610,36 @@ void watchdog_nmi_enable_all(void)
608610
{
609611
int cpu;
610612

611-
if (!watchdog_user_enabled)
612-
return;
613+
mutex_lock(&watchdog_proc_mutex);
614+
615+
if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED))
616+
goto unlock;
613617

614618
get_online_cpus();
615619
for_each_online_cpu(cpu)
616620
watchdog_nmi_enable(cpu);
617621
put_online_cpus();
622+
623+
unlock:
624+
mutex_lock(&watchdog_proc_mutex);
618625
}
619626

620627
void watchdog_nmi_disable_all(void)
621628
{
622629
int cpu;
623630

631+
mutex_lock(&watchdog_proc_mutex);
632+
624633
if (!watchdog_running)
625-
return;
634+
goto unlock;
626635

627636
get_online_cpus();
628637
for_each_online_cpu(cpu)
629638
watchdog_nmi_disable(cpu);
630639
put_online_cpus();
640+
641+
unlock:
642+
mutex_unlock(&watchdog_proc_mutex);
631643
}
632644
#else
633645
static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
@@ -744,8 +756,6 @@ static int proc_watchdog_update(void)
744756

745757
}
746758

747-
static DEFINE_MUTEX(watchdog_proc_mutex);
748-
749759
/*
750760
* common function for watchdog, nmi_watchdog and soft_watchdog parameter
751761
*

0 commit comments

Comments
 (0)