Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Peter Zijlstra and committed by
Linus Torvalds
ab992dc3 7cf7d424

+15 -5
+15 -5
kernel/watchdog.c
··· 41 41 #define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT) 42 42 #define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT) 43 43 44 + static DEFINE_MUTEX(watchdog_proc_mutex); 45 + 44 46 #ifdef CONFIG_HARDLOCKUP_DETECTOR 45 47 static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED; 46 48 #else ··· 610 608 { 611 609 int cpu; 612 610 613 - if (!watchdog_user_enabled) 614 - return; 611 + mutex_lock(&watchdog_proc_mutex); 612 + 613 + if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED)) 614 + goto unlock; 615 615 616 616 get_online_cpus(); 617 617 for_each_online_cpu(cpu) 618 618 watchdog_nmi_enable(cpu); 619 619 put_online_cpus(); 620 + 621 + unlock: 622 + mutex_lock(&watchdog_proc_mutex); 620 623 } 621 624 622 625 void watchdog_nmi_disable_all(void) 623 626 { 624 627 int cpu; 625 628 629 + mutex_lock(&watchdog_proc_mutex); 630 + 626 631 if (!watchdog_running) 627 - return; 632 + goto unlock; 628 633 629 634 get_online_cpus(); 630 635 for_each_online_cpu(cpu) 631 636 watchdog_nmi_disable(cpu); 632 637 put_online_cpus(); 638 + 639 + unlock: 640 + mutex_unlock(&watchdog_proc_mutex); 633 641 } 634 642 #else 635 643 static int watchdog_nmi_enable(unsigned int cpu) { return 0; } ··· 755 743 return err; 756 744 757 745 } 758 - 759 - static DEFINE_MUTEX(watchdog_proc_mutex); 760 746 761 747 /* 762 748 * common function for watchdog, nmi_watchdog and soft_watchdog parameter