linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux-next: manual merge of the akpm-current tree with the tile tree
@ 2015-04-07 11:09 Stephen Rothwell
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Rothwell @ 2015-04-07 11:09 UTC (permalink / raw)
  To: Andrew Morton, Chris Metcalf
  Cc: linux-next, linux-kernel, Ulrich Obergfell, Don Zickus

[-- Attachment #1: Type: text/plain, Size: 1635 bytes --]

Hi Andrew,

Today's linux-next merge of the akpm-current tree got a conflict in
kernel/sysctl.c between commit e164ade07b21 ("watchdog: add
watchdog_exclude sysctl to assist nohz") from the tile tree and commit
866d62a433cc ("watchdog: enable the new user interface of the watchdog
mechanism") from the akpm-current tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

diff --cc kernel/sysctl.c
index 431601ad393a,076473547fe5..000000000000
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@@ -861,13 -858,28 +859,35 @@@ static struct ctl_table kern_table[] = 
  		.extra2		= &sixty,
  	},
  	{
 +		.procname	= "watchdog_exclude",
 +		.data		= &watchdog_exclude_mask_bits,
 +		.maxlen		= NR_CPUS,
 +		.mode		= 0644,
 +		.proc_handler	= proc_dowatchdog_exclude,
 +	},
 +	{
+ 		.procname       = "nmi_watchdog",
+ 		.data           = &nmi_watchdog_enabled,
+ 		.maxlen         = sizeof (int),
+ 		.mode           = 0644,
+ 		.proc_handler   = proc_nmi_watchdog,
+ 		.extra1		= &zero,
+ #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
+ 		.extra2		= &one,
+ #else
+ 		.extra2		= &zero,
+ #endif
+ 	},
+ 	{
+ 		.procname       = "soft_watchdog",
+ 		.data           = &soft_watchdog_enabled,
+ 		.maxlen         = sizeof (int),
+ 		.mode           = 0644,
+ 		.proc_handler   = proc_soft_watchdog,
+ 		.extra1		= &zero,
+ 		.extra2		= &one,
+ 	},
+ 	{
  		.procname	= "softlockup_panic",
  		.data		= &softlockup_panic,
  		.maxlen		= sizeof(int),

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* linux-next: manual merge of the akpm-current tree with the tile tree
@ 2016-04-29  6:08 Stephen Rothwell
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Rothwell @ 2016-04-29  6:08 UTC (permalink / raw)
  To: Andrew Morton, Chris Metcalf; +Cc: linux-next, linux-kernel, Jiri Slaby

Hi Andrew,

Today's linux-next merge of the akpm-current tree got a conflict in:

  arch/tile/Kconfig

between commit:

  4ef00aa30a3f ("tile: sort the "select" lines in the TILE/TILEGX configs")

from the tile tree and commits:

  628b7a1e7049 ("exit_thread: remove empty bodies")
  803ae84888bb ("printk/nmi: generic solution for safe printk in NMI")

from the akpm-current tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/tile/Kconfig
index c3bbb295bc4a,76989b878f3c..000000000000
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@@ -18,21 -35,17 +18,23 @@@ config TIL
  	select GENERIC_STRNCPY_FROM_USER
  	select GENERIC_STRNLEN_USER
  	select HAVE_ARCH_SECCOMP_FILTER
 -
 -# FIXME: investigate whether we need/want these options.
 -#	select HAVE_IOREMAP_PROT
 -#	select HAVE_OPTPROBES
 -#	select HAVE_REGS_AND_STACK_ACCESS_API
 -#	select HAVE_HW_BREAKPOINT
 -#	select PERF_EVENTS
 -#	select HAVE_USER_RETURN_NOTIFIER
 -#	config NO_BOOTMEM
 -#	config ARCH_SUPPORTS_DEBUG_PAGEALLOC
 -#	config HUGETLB_PAGE_SIZE_VARIABLE
 +	select HAVE_ARCH_TRACEHOOK
 +	select HAVE_CONTEXT_TRACKING
 +	select HAVE_DEBUG_BUGVERBOSE
 +	select HAVE_DEBUG_KMEMLEAK
 +	select HAVE_DEBUG_STACKOVERFLOW
 +	select HAVE_DMA_API_DEBUG
++	select HAVE_EXIT_THREAD
 +	select HAVE_KVM if !TILEGX
++	select HAVE_NMI if USE_PMC
 +	select HAVE_PERF_EVENTS
 +	select HAVE_SYSCALL_TRACEPOINTS
 +	select MODULES_USE_ELF_RELA
 +	select SYSCTL_EXCEPTION_TRACE
 +	select SYS_HYPERVISOR
 +	select USER_STACKTRACE_SUPPORT
 +	select USE_PMC if PERF_EVENTS
 +	select VIRT_TO_BUS
  
  config MMU
  	def_bool y

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: linux-next: manual merge of the akpm-current tree with the tile tree
  2015-04-07 11:21 Stephen Rothwell
  2015-04-07 11:27 ` Stephen Rothwell
  2015-04-07 13:00 ` Ulrich Obergfell
@ 2015-04-07 17:51 ` Chris Metcalf
  2 siblings, 0 replies; 8+ messages in thread
From: Chris Metcalf @ 2015-04-07 17:51 UTC (permalink / raw)
  To: Stephen Rothwell, Andrew Morton
  Cc: linux-next, linux-kernel, Ulrich Obergfell, Don Zickus

On 04/07/2015 07:21 AM, Stephen Rothwell wrote:
> Hi Andrew,
>
> Today's linux-next merge of the akpm-current tree got a conflict in
> kernel/watchdog.c between commit e164ade07b21 ("watchdog: add
> watchdog_exclude sysctl to assist nohz") from the tile tree and commits
> e0afaab242da ("watchdog: introduce separate handlers for parameters
> in /proc/sys/kernel"), 866d62a433cc ("watchdog: enable the new user
> interface of the watchdog mechanism") and 09d1b2261fcc ("watchdog:
> clean up some function names and arguments") from the akpm-current tree.
>
> I fixed it up (see below, but it may need more work) and can carry the
> fix as necessary (no action is required).

Thanks for the fixups.

I have removed the patch from the tile tree after rebasing it to the tip of
linux-next so as to properly handle the just-updated refactoring
in watchdog.c by Uli.

It probably makes most sense if Andrew can pick it up once
it has baked a bit longer on LKML and he can send it to you
that way.

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: linux-next: manual merge of the akpm-current tree with the tile tree
  2015-04-07 11:21 Stephen Rothwell
  2015-04-07 11:27 ` Stephen Rothwell
@ 2015-04-07 13:00 ` Ulrich Obergfell
  2015-04-07 17:51 ` Chris Metcalf
  2 siblings, 0 replies; 8+ messages in thread
From: Ulrich Obergfell @ 2015-04-07 13:00 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Andrew Morton, Chris Metcalf, linux-next, linux-kernel, Don Zickus


Stephen,

the if-statement in proc_dowatchdog_exclude() does not look correct to me.
Please see my comments in https://lkml.org/lkml/2015/4/5/119 for details.
Chris posted v5 of his patch in https://lkml.org/lkml/2015/4/6/255.

Regards,

Uli


----- Original Message -----
From: "Stephen Rothwell" <sfr@canb.auug.org.au>
To: "Andrew Morton" <akpm@linux-foundation.org>, "Chris Metcalf" <cmetcalf@ezchip.com>
Cc: linux-next@vger.kernel.org, linux-kernel@vger.kernel.org, "Ulrich Obergfell" <uobergfe@redhat.com>, "Don Zickus" <dzickus@redhat.com>
Sent: Tuesday, April 7, 2015 1:21:53 PM
Subject: linux-next: manual merge of the akpm-current tree with the tile tree

Hi Andrew,

Today's linux-next merge of the akpm-current tree got a conflict in
kernel/watchdog.c between commit e164ade07b21 ("watchdog: add
watchdog_exclude sysctl to assist nohz") from the tile tree and commits
e0afaab242da ("watchdog: introduce separate handlers for parameters
in /proc/sys/kernel"), 866d62a433cc ("watchdog: enable the new user
interface of the watchdog mechanism") and 09d1b2261fcc ("watchdog:
clean up some function names and arguments") from the akpm-current tree.

I fixed it up (see below, but it may need more work) and can carry the
fix as necessary (no action is required).

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

diff --cc kernel/watchdog.c
index 083bd9007b3e,f2be11ab7e08..000000000000
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@@ -656,90 -693,160 +696,191 @@@ static void watchdog_disable_all_cpus(v
  	}
  }
  
 +static DEFINE_MUTEX(watchdog_proc_mutex);
 +
  /*
-  * proc handler for /proc/sys/kernel/nmi_watchdog,watchdog_thresh
+  * Update the run state of the lockup detectors.
   */
+ static int proc_watchdog_update(void)
+ {
+ 	int err = 0;
+ 
+ 	/*
+ 	 * Watchdog threads won't be started if they are already active.
+ 	 * The 'watchdog_running' variable in watchdog_*_all_cpus() takes
+ 	 * care of this. If those threads are already active, the sample
+ 	 * period will be updated and the lockup detectors will be enabled
+ 	 * or disabled 'on the fly'.
+ 	 */
+ 	if (watchdog_enabled && watchdog_thresh)
+ 		err = watchdog_enable_all_cpus();
+ 	else
+ 		watchdog_disable_all_cpus();
+ 
+ 	return err;
+ 
+ }
+ 
+ static DEFINE_MUTEX(watchdog_proc_mutex);
  
- int proc_dowatchdog(struct ctl_table *table, int write,
- 		    void __user *buffer, size_t *lenp, loff_t *ppos)
+ /*
+  * common function for watchdog, nmi_watchdog and soft_watchdog parameter
+  *
+  * caller             | table->data points to | 'which' contains the flag(s)
+  * -------------------|-----------------------|-----------------------------
+  * proc_watchdog      | watchdog_user_enabled | NMI_WATCHDOG_ENABLED or'ed
+  *                    |                       | with SOFT_WATCHDOG_ENABLED
+  * -------------------|-----------------------|-----------------------------
+  * proc_nmi_watchdog  | nmi_watchdog_enabled  | NMI_WATCHDOG_ENABLED
+  * -------------------|-----------------------|-----------------------------
+  * proc_soft_watchdog | soft_watchdog_enabled | SOFT_WATCHDOG_ENABLED
+  */
+ static int proc_watchdog_common(int which, struct ctl_table *table, int write,
+ 				void __user *buffer, size_t *lenp, loff_t *ppos)
  {
- 	int err, old_thresh, old_enabled;
- 	bool old_hardlockup;
+ 	int err, old, new;
+ 	int *watchdog_param = (int *)table->data;
  
  	mutex_lock(&watchdog_proc_mutex);
- 	old_thresh = ACCESS_ONCE(watchdog_thresh);
- 	old_enabled = ACCESS_ONCE(watchdog_user_enabled);
- 	old_hardlockup = watchdog_hardlockup_detector_is_enabled();
  
- 	err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
- 	if (err || !write)
- 		goto out;
- 
- 	set_sample_period();
  	/*
- 	 * Watchdog threads shouldn't be enabled if they are
- 	 * disabled. The 'watchdog_running' variable check in
- 	 * watchdog_*_all_cpus() function takes care of this.
+ 	 * If the parameter is being read return the state of the corresponding
+ 	 * bit(s) in 'watchdog_enabled', else update 'watchdog_enabled' and the
+ 	 * run state of the lockup detectors.
  	 */
- 	if (watchdog_user_enabled && watchdog_thresh) {
+ 	if (!write) {
+ 		*watchdog_param = (watchdog_enabled & which) != 0;
+ 		err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+ 	} else {
+ 		err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+ 		if (err)
+ 			goto out;
+ 
  		/*
- 		 * Prevent a change in watchdog_thresh accidentally overriding
- 		 * the enablement of the hardlockup detector.
+ 		 * There is a race window between fetching the current value
+ 		 * from 'watchdog_enabled' and storing the new value. During
+ 		 * this race window, watchdog_nmi_enable() can sneak in and
+ 		 * clear the NMI_WATCHDOG_ENABLED bit in 'watchdog_enabled'.
+ 		 * The 'cmpxchg' detects this race and the loop retries.
  		 */
- 		if (watchdog_user_enabled != old_enabled)
- 			watchdog_enable_hardlockup_detector(true);
- 		err = watchdog_enable_all_cpus(old_thresh != watchdog_thresh);
- 	} else
- 		watchdog_disable_all_cpus();
+ 		do {
+ 			old = watchdog_enabled;
+ 			/*
+ 			 * If the parameter value is not zero set the
+ 			 * corresponding bit(s), else clear it(them).
+ 			 */
+ 			if (*watchdog_param)
+ 				new = old | which;
+ 			else
+ 				new = old & ~which;
+ 		} while (cmpxchg(&watchdog_enabled, old, new) != old);
  
- 	/* Restore old values on failure */
- 	if (err) {
- 		watchdog_thresh = old_thresh;
- 		watchdog_user_enabled = old_enabled;
- 		watchdog_enable_hardlockup_detector(old_hardlockup);
+ 		/*
+ 		 * Update the run state of the lockup detectors.
+ 		 * Restore 'watchdog_enabled' on failure.
+ 		 */
+ 		err = proc_watchdog_update();
+ 		if (err)
+ 			watchdog_enabled = old;
  	}
  out:
  	mutex_unlock(&watchdog_proc_mutex);
  	return err;
  }
  
 +int proc_dowatchdog_exclude(struct ctl_table *table, int write,
 +			    void __user *buffer, size_t *lenp, loff_t *ppos)
 +{
 +	int err;
 +
 +	mutex_lock(&watchdog_proc_mutex);
 +	err = proc_do_large_bitmap(table, write, buffer, lenp, ppos);
 +	if (!err && write && watchdog_user_enabled) {
 +		watchdog_disable_all_cpus();
- 		watchdog_enable_all_cpus(false);
++		watchdog_enable_all_cpus();
 +	}
 +	mutex_unlock(&watchdog_proc_mutex);
 +	return err;
 +}
 +
+ /*
+  * /proc/sys/kernel/watchdog
+  */
+ int proc_watchdog(struct ctl_table *table, int write,
+ 		  void __user *buffer, size_t *lenp, loff_t *ppos)
+ {
+ 	return proc_watchdog_common(NMI_WATCHDOG_ENABLED|SOFT_WATCHDOG_ENABLED,
+ 				    table, write, buffer, lenp, ppos);
+ }
+ 
+ /*
+  * /proc/sys/kernel/nmi_watchdog
+  */
+ int proc_nmi_watchdog(struct ctl_table *table, int write,
+ 		      void __user *buffer, size_t *lenp, loff_t *ppos)
+ {
+ 	return proc_watchdog_common(NMI_WATCHDOG_ENABLED,
+ 				    table, write, buffer, lenp, ppos);
+ }
+ 
+ /*
+  * /proc/sys/kernel/soft_watchdog
+  */
+ int proc_soft_watchdog(struct ctl_table *table, int write,
+ 			void __user *buffer, size_t *lenp, loff_t *ppos)
+ {
+ 	return proc_watchdog_common(SOFT_WATCHDOG_ENABLED,
+ 				    table, write, buffer, lenp, ppos);
+ }
+ 
+ /*
+  * /proc/sys/kernel/watchdog_thresh
+  */
+ int proc_watchdog_thresh(struct ctl_table *table, int write,
+ 			 void __user *buffer, size_t *lenp, loff_t *ppos)
+ {
+ 	int err, old;
+ 
+ 	mutex_lock(&watchdog_proc_mutex);
+ 
+ 	old = ACCESS_ONCE(watchdog_thresh);
+ 	err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+ 
+ 	if (err || !write)
+ 		goto out;
+ 
+ 	/*
+ 	 * Update the sample period.
+ 	 * Restore 'watchdog_thresh' on failure.
+ 	 */
+ 	set_sample_period();
+ 	err = proc_watchdog_update();
+ 	if (err)
+ 		watchdog_thresh = old;
+ out:
+ 	mutex_unlock(&watchdog_proc_mutex);
+ 	return err;
+ }
  #endif /* CONFIG_SYSCTL */
  
  void __init lockup_detector_init(void)
  {
  	set_sample_period();
  
 +	alloc_bootmem_cpumask_var(&watchdog_exclude_mask);
 +	watchdog_threads.exclude_mask = watchdog_exclude_mask;
 +
 +#ifdef CONFIG_NO_HZ_FULL
 +	if (!cpumask_empty(tick_nohz_full_mask))
 +		pr_info("Disabling watchdog on nohz_full cores by default\n");
 +	cpumask_copy(watchdog_exclude_mask, tick_nohz_full_mask);
 +#else
 +	cpumask_clear(watchdog_exclude_mask);
 +#endif
 +
 +	/* The sysctl API requires a variable holding a pointer to the mask. */
 +	watchdog_exclude_mask_bits = cpumask_bits(watchdog_exclude_mask);
 +
- 	if (watchdog_user_enabled)
- 		watchdog_enable_all_cpus(false);
+ 	if (watchdog_enabled)
+ 		watchdog_enable_all_cpus();
  }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: linux-next: manual merge of the akpm-current tree with the tile tree
  2015-04-07 11:21 Stephen Rothwell
@ 2015-04-07 11:27 ` Stephen Rothwell
  2015-04-07 13:00 ` Ulrich Obergfell
  2015-04-07 17:51 ` Chris Metcalf
  2 siblings, 0 replies; 8+ messages in thread
From: Stephen Rothwell @ 2015-04-07 11:27 UTC (permalink / raw)
  To: Andrew Morton, Chris Metcalf
  Cc: linux-next, linux-kernel, Ulrich Obergfell, Don Zickus

[-- Attachment #1: Type: text/plain, Size: 1572 bytes --]

Hi all,

On Tue, 7 Apr 2015 21:21:53 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Today's linux-next merge of the akpm-current tree got a conflict in
> kernel/watchdog.c between commit e164ade07b21 ("watchdog: add
> watchdog_exclude sysctl to assist nohz") from the tile tree and commits
> e0afaab242da ("watchdog: introduce separate handlers for parameters
> in /proc/sys/kernel"), 866d62a433cc ("watchdog: enable the new user
> interface of the watchdog mechanism") and 09d1b2261fcc ("watchdog:
> clean up some function names and arguments") from the akpm-current tree.
> 
> I fixed it up (see below, but it may need more work) and can carry the
> fix as necessary (no action is required).
> 
> diff --cc kernel/watchdog.c
> index 083bd9007b3e,f2be11ab7e08..000000000000
> --- a/kernel/watchdog.c
> +++ b/kernel/watchdog.c

It also needed this:

From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Tue, 7 Apr 2015 21:24:56 +1000
Subject: [PATCH] watchdog: fix up for bad merge

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
 kernel/watchdog.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index c5c87d1af41b..95ad9d6cb761 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -721,8 +721,6 @@ static int proc_watchdog_update(void)
 
 }
 
-static DEFINE_MUTEX(watchdog_proc_mutex);
-
 /*
  * common function for watchdog, nmi_watchdog and soft_watchdog parameter
  *
-- 
2.1.4

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* linux-next: manual merge of the akpm-current tree with the tile tree
@ 2015-04-07 11:21 Stephen Rothwell
  2015-04-07 11:27 ` Stephen Rothwell
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Stephen Rothwell @ 2015-04-07 11:21 UTC (permalink / raw)
  To: Andrew Morton, Chris Metcalf
  Cc: linux-next, linux-kernel, Ulrich Obergfell, Don Zickus

[-- Attachment #1: Type: text/plain, Size: 8062 bytes --]

Hi Andrew,

Today's linux-next merge of the akpm-current tree got a conflict in
kernel/watchdog.c between commit e164ade07b21 ("watchdog: add
watchdog_exclude sysctl to assist nohz") from the tile tree and commits
e0afaab242da ("watchdog: introduce separate handlers for parameters
in /proc/sys/kernel"), 866d62a433cc ("watchdog: enable the new user
interface of the watchdog mechanism") and 09d1b2261fcc ("watchdog:
clean up some function names and arguments") from the akpm-current tree.

I fixed it up (see below, but it may need more work) and can carry the
fix as necessary (no action is required).

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

diff --cc kernel/watchdog.c
index 083bd9007b3e,f2be11ab7e08..000000000000
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@@ -656,90 -693,160 +696,191 @@@ static void watchdog_disable_all_cpus(v
  	}
  }
  
 +static DEFINE_MUTEX(watchdog_proc_mutex);
 +
  /*
-  * proc handler for /proc/sys/kernel/nmi_watchdog,watchdog_thresh
+  * Update the run state of the lockup detectors.
   */
+ static int proc_watchdog_update(void)
+ {
+ 	int err = 0;
+ 
+ 	/*
+ 	 * Watchdog threads won't be started if they are already active.
+ 	 * The 'watchdog_running' variable in watchdog_*_all_cpus() takes
+ 	 * care of this. If those threads are already active, the sample
+ 	 * period will be updated and the lockup detectors will be enabled
+ 	 * or disabled 'on the fly'.
+ 	 */
+ 	if (watchdog_enabled && watchdog_thresh)
+ 		err = watchdog_enable_all_cpus();
+ 	else
+ 		watchdog_disable_all_cpus();
+ 
+ 	return err;
+ 
+ }
+ 
+ static DEFINE_MUTEX(watchdog_proc_mutex);
  
- int proc_dowatchdog(struct ctl_table *table, int write,
- 		    void __user *buffer, size_t *lenp, loff_t *ppos)
+ /*
+  * common function for watchdog, nmi_watchdog and soft_watchdog parameter
+  *
+  * caller             | table->data points to | 'which' contains the flag(s)
+  * -------------------|-----------------------|-----------------------------
+  * proc_watchdog      | watchdog_user_enabled | NMI_WATCHDOG_ENABLED or'ed
+  *                    |                       | with SOFT_WATCHDOG_ENABLED
+  * -------------------|-----------------------|-----------------------------
+  * proc_nmi_watchdog  | nmi_watchdog_enabled  | NMI_WATCHDOG_ENABLED
+  * -------------------|-----------------------|-----------------------------
+  * proc_soft_watchdog | soft_watchdog_enabled | SOFT_WATCHDOG_ENABLED
+  */
+ static int proc_watchdog_common(int which, struct ctl_table *table, int write,
+ 				void __user *buffer, size_t *lenp, loff_t *ppos)
  {
- 	int err, old_thresh, old_enabled;
- 	bool old_hardlockup;
+ 	int err, old, new;
+ 	int *watchdog_param = (int *)table->data;
  
  	mutex_lock(&watchdog_proc_mutex);
- 	old_thresh = ACCESS_ONCE(watchdog_thresh);
- 	old_enabled = ACCESS_ONCE(watchdog_user_enabled);
- 	old_hardlockup = watchdog_hardlockup_detector_is_enabled();
  
- 	err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
- 	if (err || !write)
- 		goto out;
- 
- 	set_sample_period();
  	/*
- 	 * Watchdog threads shouldn't be enabled if they are
- 	 * disabled. The 'watchdog_running' variable check in
- 	 * watchdog_*_all_cpus() function takes care of this.
+ 	 * If the parameter is being read return the state of the corresponding
+ 	 * bit(s) in 'watchdog_enabled', else update 'watchdog_enabled' and the
+ 	 * run state of the lockup detectors.
  	 */
- 	if (watchdog_user_enabled && watchdog_thresh) {
+ 	if (!write) {
+ 		*watchdog_param = (watchdog_enabled & which) != 0;
+ 		err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+ 	} else {
+ 		err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+ 		if (err)
+ 			goto out;
+ 
  		/*
- 		 * Prevent a change in watchdog_thresh accidentally overriding
- 		 * the enablement of the hardlockup detector.
+ 		 * There is a race window between fetching the current value
+ 		 * from 'watchdog_enabled' and storing the new value. During
+ 		 * this race window, watchdog_nmi_enable() can sneak in and
+ 		 * clear the NMI_WATCHDOG_ENABLED bit in 'watchdog_enabled'.
+ 		 * The 'cmpxchg' detects this race and the loop retries.
  		 */
- 		if (watchdog_user_enabled != old_enabled)
- 			watchdog_enable_hardlockup_detector(true);
- 		err = watchdog_enable_all_cpus(old_thresh != watchdog_thresh);
- 	} else
- 		watchdog_disable_all_cpus();
+ 		do {
+ 			old = watchdog_enabled;
+ 			/*
+ 			 * If the parameter value is not zero set the
+ 			 * corresponding bit(s), else clear it(them).
+ 			 */
+ 			if (*watchdog_param)
+ 				new = old | which;
+ 			else
+ 				new = old & ~which;
+ 		} while (cmpxchg(&watchdog_enabled, old, new) != old);
  
- 	/* Restore old values on failure */
- 	if (err) {
- 		watchdog_thresh = old_thresh;
- 		watchdog_user_enabled = old_enabled;
- 		watchdog_enable_hardlockup_detector(old_hardlockup);
+ 		/*
+ 		 * Update the run state of the lockup detectors.
+ 		 * Restore 'watchdog_enabled' on failure.
+ 		 */
+ 		err = proc_watchdog_update();
+ 		if (err)
+ 			watchdog_enabled = old;
  	}
  out:
  	mutex_unlock(&watchdog_proc_mutex);
  	return err;
  }
  
 +int proc_dowatchdog_exclude(struct ctl_table *table, int write,
 +			    void __user *buffer, size_t *lenp, loff_t *ppos)
 +{
 +	int err;
 +
 +	mutex_lock(&watchdog_proc_mutex);
 +	err = proc_do_large_bitmap(table, write, buffer, lenp, ppos);
 +	if (!err && write && watchdog_user_enabled) {
 +		watchdog_disable_all_cpus();
- 		watchdog_enable_all_cpus(false);
++		watchdog_enable_all_cpus();
 +	}
 +	mutex_unlock(&watchdog_proc_mutex);
 +	return err;
 +}
 +
+ /*
+  * /proc/sys/kernel/watchdog
+  */
+ int proc_watchdog(struct ctl_table *table, int write,
+ 		  void __user *buffer, size_t *lenp, loff_t *ppos)
+ {
+ 	return proc_watchdog_common(NMI_WATCHDOG_ENABLED|SOFT_WATCHDOG_ENABLED,
+ 				    table, write, buffer, lenp, ppos);
+ }
+ 
+ /*
+  * /proc/sys/kernel/nmi_watchdog
+  */
+ int proc_nmi_watchdog(struct ctl_table *table, int write,
+ 		      void __user *buffer, size_t *lenp, loff_t *ppos)
+ {
+ 	return proc_watchdog_common(NMI_WATCHDOG_ENABLED,
+ 				    table, write, buffer, lenp, ppos);
+ }
+ 
+ /*
+  * /proc/sys/kernel/soft_watchdog
+  */
+ int proc_soft_watchdog(struct ctl_table *table, int write,
+ 			void __user *buffer, size_t *lenp, loff_t *ppos)
+ {
+ 	return proc_watchdog_common(SOFT_WATCHDOG_ENABLED,
+ 				    table, write, buffer, lenp, ppos);
+ }
+ 
+ /*
+  * /proc/sys/kernel/watchdog_thresh
+  */
+ int proc_watchdog_thresh(struct ctl_table *table, int write,
+ 			 void __user *buffer, size_t *lenp, loff_t *ppos)
+ {
+ 	int err, old;
+ 
+ 	mutex_lock(&watchdog_proc_mutex);
+ 
+ 	old = ACCESS_ONCE(watchdog_thresh);
+ 	err = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+ 
+ 	if (err || !write)
+ 		goto out;
+ 
+ 	/*
+ 	 * Update the sample period.
+ 	 * Restore 'watchdog_thresh' on failure.
+ 	 */
+ 	set_sample_period();
+ 	err = proc_watchdog_update();
+ 	if (err)
+ 		watchdog_thresh = old;
+ out:
+ 	mutex_unlock(&watchdog_proc_mutex);
+ 	return err;
+ }
  #endif /* CONFIG_SYSCTL */
  
  void __init lockup_detector_init(void)
  {
  	set_sample_period();
  
 +	alloc_bootmem_cpumask_var(&watchdog_exclude_mask);
 +	watchdog_threads.exclude_mask = watchdog_exclude_mask;
 +
 +#ifdef CONFIG_NO_HZ_FULL
 +	if (!cpumask_empty(tick_nohz_full_mask))
 +		pr_info("Disabling watchdog on nohz_full cores by default\n");
 +	cpumask_copy(watchdog_exclude_mask, tick_nohz_full_mask);
 +#else
 +	cpumask_clear(watchdog_exclude_mask);
 +#endif
 +
 +	/* The sysctl API requires a variable holding a pointer to the mask. */
 +	watchdog_exclude_mask_bits = cpumask_bits(watchdog_exclude_mask);
 +
- 	if (watchdog_user_enabled)
- 		watchdog_enable_all_cpus(false);
+ 	if (watchdog_enabled)
+ 		watchdog_enable_all_cpus();
  }

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* linux-next: manual merge of the akpm-current tree with the tile tree
@ 2015-04-07 11:05 Stephen Rothwell
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Rothwell @ 2015-04-07 11:05 UTC (permalink / raw)
  To: Andrew Morton, Chris Metcalf
  Cc: linux-next, linux-kernel, Ulrich Obergfell, Don Zickus

[-- Attachment #1: Type: text/plain, Size: 1773 bytes --]

Hi Andrew,

Today's linux-next merge of the akpm-current tree got a conflict in
include/linux/nmi.h between commit e164ade07b21 ("watchdog: add
watchdog_exclude sysctl to assist nohz") from the tile tree and commit
866d62a433cc ("watchdog: enable the new user interface of the watchdog
mechanism") from the akpm-current tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

diff --cc include/linux/nmi.h
index 1703829c5812,3d46fb4708e0..000000000000
--- a/include/linux/nmi.h
+++ b/include/linux/nmi.h
@@@ -68,15 -63,20 +63,23 @@@ static inline bool trigger_allbutself_c
  #ifdef CONFIG_LOCKUP_DETECTOR
  int hw_nmi_is_cpu_stuck(struct pt_regs *);
  u64 hw_nmi_get_sample_period(int watchdog_thresh);
+ extern int nmi_watchdog_enabled;
+ extern int soft_watchdog_enabled;
  extern int watchdog_user_enabled;
  extern int watchdog_thresh;
 +extern unsigned long *watchdog_exclude_mask_bits;
  extern int sysctl_softlockup_all_cpu_backtrace;
  struct ctl_table;
- extern int proc_dowatchdog(struct ctl_table *, int ,
- 			   void __user *, size_t *, loff_t *);
+ extern int proc_watchdog(struct ctl_table *, int ,
+ 			 void __user *, size_t *, loff_t *);
+ extern int proc_nmi_watchdog(struct ctl_table *, int ,
+ 			     void __user *, size_t *, loff_t *);
+ extern int proc_soft_watchdog(struct ctl_table *, int ,
+ 			      void __user *, size_t *, loff_t *);
+ extern int proc_watchdog_thresh(struct ctl_table *, int ,
+ 				void __user *, size_t *, loff_t *);
 +extern int proc_dowatchdog_exclude(struct ctl_table *, int,
 +				   void __user *, size_t *, loff_t *);
  #endif
  
  #ifdef CONFIG_HAVE_ACPI_APEI_NMI

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* linux-next: manual merge of the akpm-current tree with the tile tree
@ 2015-04-07 11:00 Stephen Rothwell
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Rothwell @ 2015-04-07 11:00 UTC (permalink / raw)
  To: Andrew Morton, Chris Metcalf; +Cc: linux-next, linux-kernel, Don Zickus

[-- Attachment #1: Type: text/plain, Size: 1983 bytes --]

Hi Andrew,

Today's linux-next merge of the akpm-current tree got a conflict in
Documentation/sysctl/kernel.txt between commit e164ade07b21 ("watchdog:
add watchdog_exclude sysctl to assist nohz") from the tile tree and
commit 25909f748a50 ("watchdog: update documentation for kernel params
and sysctl") from the akpm-current tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au

diff --cc Documentation/sysctl/kernel.txt
index aad9f9ba347c,c831001c45f1..000000000000
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@@ -858,15 -904,25 +904,34 @@@ example.  If a system hangs up, try pre
  
  ==============================================================
  
+ watchdog:
+ 
+ This parameter can be used to disable or enable the soft lockup detector
+ _and_ the NMI watchdog (i.e. the hard lockup detector) at the same time.
+ 
+    0 - disable both lockup detectors
+    1 - enable both lockup detectors
+ 
+ The soft lockup detector and the NMI watchdog can also be disabled or
+ enabled individually, using the soft_watchdog and nmi_watchdog parameters.
+ If the watchdog parameter is read, for example by executing
+ 
+    cat /proc/sys/kernel/watchdog
+ 
+ the output of this command (0 or 1) shows the logical OR of soft_watchdog
+ and nmi_watchdog.
+ 
+ ==============================================================
+ 
 +watchdog_exclude:
 +
 +This value can be used to control on which cpus the watchdog is
 +prohibited from running.  The default exclude mask is empty, but if
 +NO_HZ_FULL is enabled in the kernel config, and cores are specified
 +with the nohz_full= boot argument, those cores are excluded by default.
 +
 +==============================================================
 +
  watchdog_thresh:
  
  This value can be used to control the frequency of hrtimer and NMI

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-04-29  6:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07 11:09 linux-next: manual merge of the akpm-current tree with the tile tree Stephen Rothwell
  -- strict thread matches above, loose matches on Subject: below --
2016-04-29  6:08 Stephen Rothwell
2015-04-07 11:21 Stephen Rothwell
2015-04-07 11:27 ` Stephen Rothwell
2015-04-07 13:00 ` Ulrich Obergfell
2015-04-07 17:51 ` Chris Metcalf
2015-04-07 11:05 Stephen Rothwell
2015-04-07 11:00 Stephen Rothwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).