diff options
author | Peter Zijlstra <peterz@infradead.org> | 2015-05-18 05:31:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-05-18 13:08:29 -0400 |
commit | ab992dc38f9ae40b3ab996d68449692d464c98cf (patch) | |
tree | 04e22f06ab841142cb90d7394834ff6add928455 /kernel | |
parent | 7cf7d424c309457b21318b05963ff3fd723d5bcd (diff) |
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 195daf665a62 ("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
b3738d293233 ("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 <mhocko@suse.cz>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/watchdog.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 2316f50b07a4..506edcc500c4 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c | |||
@@ -41,6 +41,8 @@ | |||
41 | #define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT) | 41 | #define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT) |
42 | #define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT) | 42 | #define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT) |
43 | 43 | ||
44 | static DEFINE_MUTEX(watchdog_proc_mutex); | ||
45 | |||
44 | #ifdef CONFIG_HARDLOCKUP_DETECTOR | 46 | #ifdef CONFIG_HARDLOCKUP_DETECTOR |
45 | static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED; | 47 | static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED; |
46 | #else | 48 | #else |
@@ -608,26 +610,36 @@ void watchdog_nmi_enable_all(void) | |||
608 | { | 610 | { |
609 | int cpu; | 611 | int cpu; |
610 | 612 | ||
611 | if (!watchdog_user_enabled) | 613 | mutex_lock(&watchdog_proc_mutex); |
612 | return; | 614 | |
615 | if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED)) | ||
616 | goto unlock; | ||
613 | 617 | ||
614 | get_online_cpus(); | 618 | get_online_cpus(); |
615 | for_each_online_cpu(cpu) | 619 | for_each_online_cpu(cpu) |
616 | watchdog_nmi_enable(cpu); | 620 | watchdog_nmi_enable(cpu); |
617 | put_online_cpus(); | 621 | put_online_cpus(); |
622 | |||
623 | unlock: | ||
624 | mutex_lock(&watchdog_proc_mutex); | ||
618 | } | 625 | } |
619 | 626 | ||
620 | void watchdog_nmi_disable_all(void) | 627 | void watchdog_nmi_disable_all(void) |
621 | { | 628 | { |
622 | int cpu; | 629 | int cpu; |
623 | 630 | ||
631 | mutex_lock(&watchdog_proc_mutex); | ||
632 | |||
624 | if (!watchdog_running) | 633 | if (!watchdog_running) |
625 | return; | 634 | goto unlock; |
626 | 635 | ||
627 | get_online_cpus(); | 636 | get_online_cpus(); |
628 | for_each_online_cpu(cpu) | 637 | for_each_online_cpu(cpu) |
629 | watchdog_nmi_disable(cpu); | 638 | watchdog_nmi_disable(cpu); |
630 | put_online_cpus(); | 639 | put_online_cpus(); |
640 | |||
641 | unlock: | ||
642 | mutex_unlock(&watchdog_proc_mutex); | ||
631 | } | 643 | } |
632 | #else | 644 | #else |
633 | static int watchdog_nmi_enable(unsigned int cpu) { return 0; } | 645 | static int watchdog_nmi_enable(unsigned int cpu) { return 0; } |
@@ -744,8 +756,6 @@ static int proc_watchdog_update(void) | |||
744 | 756 | ||
745 | } | 757 | } |
746 | 758 | ||
747 | static DEFINE_MUTEX(watchdog_proc_mutex); | ||
748 | |||
749 | /* | 759 | /* |
750 | * common function for watchdog, nmi_watchdog and soft_watchdog parameter | 760 | * common function for watchdog, nmi_watchdog and soft_watchdog parameter |
751 | * | 761 | * |