forked from mirrors/linux
		
	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. Commit195daf665a("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 byb3738d2932("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>
This commit is contained in:
		
							parent
							
								
									7cf7d424c3
								
							
						
					
					
						commit
						ab992dc38f
					
				
					 1 changed files with 15 additions and 5 deletions
				
			
		| 
						 | 
					@ -41,6 +41,8 @@
 | 
				
			||||||
#define NMI_WATCHDOG_ENABLED      (1 << NMI_WATCHDOG_ENABLED_BIT)
 | 
					#define NMI_WATCHDOG_ENABLED      (1 << NMI_WATCHDOG_ENABLED_BIT)
 | 
				
			||||||
#define SOFT_WATCHDOG_ENABLED     (1 << SOFT_WATCHDOG_ENABLED_BIT)
 | 
					#define SOFT_WATCHDOG_ENABLED     (1 << SOFT_WATCHDOG_ENABLED_BIT)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static DEFINE_MUTEX(watchdog_proc_mutex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_HARDLOCKUP_DETECTOR
 | 
					#ifdef CONFIG_HARDLOCKUP_DETECTOR
 | 
				
			||||||
static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED;
 | 
					static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED;
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					@ -608,26 +610,36 @@ void watchdog_nmi_enable_all(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int cpu;
 | 
						int cpu;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!watchdog_user_enabled)
 | 
						mutex_lock(&watchdog_proc_mutex);
 | 
				
			||||||
		return;
 | 
					
 | 
				
			||||||
 | 
						if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED))
 | 
				
			||||||
 | 
							goto unlock;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	get_online_cpus();
 | 
						get_online_cpus();
 | 
				
			||||||
	for_each_online_cpu(cpu)
 | 
						for_each_online_cpu(cpu)
 | 
				
			||||||
		watchdog_nmi_enable(cpu);
 | 
							watchdog_nmi_enable(cpu);
 | 
				
			||||||
	put_online_cpus();
 | 
						put_online_cpus();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					unlock:
 | 
				
			||||||
 | 
						mutex_lock(&watchdog_proc_mutex);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void watchdog_nmi_disable_all(void)
 | 
					void watchdog_nmi_disable_all(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int cpu;
 | 
						int cpu;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						mutex_lock(&watchdog_proc_mutex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!watchdog_running)
 | 
						if (!watchdog_running)
 | 
				
			||||||
		return;
 | 
							goto unlock;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	get_online_cpus();
 | 
						get_online_cpus();
 | 
				
			||||||
	for_each_online_cpu(cpu)
 | 
						for_each_online_cpu(cpu)
 | 
				
			||||||
		watchdog_nmi_disable(cpu);
 | 
							watchdog_nmi_disable(cpu);
 | 
				
			||||||
	put_online_cpus();
 | 
						put_online_cpus();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					unlock:
 | 
				
			||||||
 | 
						mutex_unlock(&watchdog_proc_mutex);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
 | 
					static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
 | 
				
			||||||
| 
						 | 
					@ -744,8 +756,6 @@ static int proc_watchdog_update(void)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static DEFINE_MUTEX(watchdog_proc_mutex);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * common function for watchdog, nmi_watchdog and soft_watchdog parameter
 | 
					 * common function for watchdog, nmi_watchdog and soft_watchdog parameter
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue