All of lore.kernel.org
 help / color / mirror / Atom feed
From: Babu Moger <babu.moger@oracle.com>
To: Don Zickus <dzickus@redhat.com>
Cc: mingo@kernel.org, akpm@linux-foundation.org, ak@linux.intel.com,
	jkosina@suse.cz, baiyaowei@cmss.chinamobile.com,
	atomlin@redhat.com, uobergfe@redhat.com, tj@kernel.org,
	hidehiro.kawai.ez@hitachi.com, johunt@akamai.com,
	davem@davemloft.net, sparclinux@vger.kernel.org,
	linux-kernel@vger.kernel.org, sam@ravnborg.org
Subject: Re: [PATCH v2 1/2] watchdog: Introduce arch_watchdog_nmi_enable and arch_watchdog_nmi_disable
Date: Mon, 17 Oct 2016 21:46:52 -0500	[thread overview]
Message-ID: <12e7c12f-3862-ab52-7d5d-ba55764c6a79@oracle.com> (raw)
In-Reply-To: <20161017173157.GK98438@redhat.com>

Don,

On 10/17/2016 12:31 PM, Don Zickus wrote:
> On Thu, Oct 13, 2016 at 01:38:01PM -0700, Babu Moger wrote:
>> Currently we do not have a way to enable/disable arch specific
>> watchdog handlers if it was implemented by any of the architectures.
>>
>> This patch introduces new functions arch_watchdog_nmi_enable and
>> arch_watchdog_nmi_disable which can be used to enable/disable architecture
>> specific NMI watchdog handlers. These functions are defined as weak as
>> architectures can override their definitions to enable/disable nmi
>> watchdog behaviour.
> Hi Babu,
>
> This patch tested fine on my x86 box and I am ok with the changes.
>
> I do have one small cosmetic request below for a failure path.  Other than
> that I will give my ack.
Yes. I am testing these changes. If everything goes as expected, I will 
post  v3 version
tomorrow. Thanks Babu

>
> Cheers,
> Don
>
>> Signed-off-by: Babu Moger <babu.moger@oracle.com>
>> ---
>>   kernel/watchdog.c |   65 +++++++++++++++++++++++++++++++++++-----------------
>>   1 files changed, 44 insertions(+), 21 deletions(-)
>>
>> diff --git a/kernel/watchdog.c b/kernel/watchdog.c
>> index 9acb29f..d1e84e6 100644
>> --- a/kernel/watchdog.c
>> +++ b/kernel/watchdog.c
>> @@ -46,7 +46,7 @@
>>   
>>   static DEFINE_MUTEX(watchdog_proc_mutex);
>>   
>> -#ifdef CONFIG_HARDLOCKUP_DETECTOR
>> +#if defined(CONFIG_HARDLOCKUP_DETECTOR) || defined(CONFIG_HAVE_NMI_WATCHDOG)
>>   static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED;
>>   #else
>>   static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED;
>> @@ -585,15 +585,11 @@ static void watchdog(unsigned int cpu)
>>    */
>>   static unsigned long cpu0_err;
>>   
>> -static int watchdog_nmi_enable(unsigned int cpu)
>> +static int arch_watchdog_nmi_enable(unsigned int cpu)
>>   {
>>   	struct perf_event_attr *wd_attr;
>>   	struct perf_event *event = per_cpu(watchdog_ev, cpu);
>>   
>> -	/* nothing to do if the hard lockup detector is disabled */
>> -	if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED))
>> -		goto out;
>> -
>>   	/* is it already setup and enabled? */
>>   	if (event && event->state > PERF_EVENT_STATE_OFF)
>>   		goto out;
>> @@ -619,18 +615,6 @@ static int watchdog_nmi_enable(unsigned int cpu)
>>   		goto out_save;
>>   	}
>>   
>> -	/*
>> -	 * Disable the hard lockup detector if _any_ CPU fails to set up
>> -	 * set up the hardware perf event. The watchdog() function checks
>> -	 * the NMI_WATCHDOG_ENABLED bit periodically.
>> -	 *
>> -	 * The barriers are for syncing up watchdog_enabled across all the
>> -	 * cpus, as clear_bit() does not use barriers.
>> -	 */
>> -	smp_mb__before_atomic();
>> -	clear_bit(NMI_WATCHDOG_ENABLED_BIT, &watchdog_enabled);
>> -	smp_mb__after_atomic();
>> -
>>   	/* skip displaying the same error again */
>>   	if (cpu > 0 && (PTR_ERR(event) == cpu0_err))
>>   		return PTR_ERR(event);
> In the arch_watchdog_nmi_enable code is a pr_info on failure
>
> 	pr_info("Shutting down hard lockup detector on all cpus\n");
>
> that should be moved to below..
>
>
>> @@ -658,7 +642,7 @@ out:
>>   	return 0;
>>   }
>>   
>> -static void watchdog_nmi_disable(unsigned int cpu)
>> +static void arch_watchdog_nmi_disable(unsigned int cpu)
>>   {
>>   	struct perf_event *event = per_cpu(watchdog_ev, cpu);
>>   
>> @@ -676,8 +660,13 @@ static void watchdog_nmi_disable(unsigned int cpu)
>>   }
>>   
>>   #else
>> -static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
>> -static void watchdog_nmi_disable(unsigned int cpu) { return; }
>> +/*
>> + * These two functions are mostly architecture specific
>> + * defining them as weak here.
>> + */
>> +int __weak arch_watchdog_nmi_enable(unsigned int cpu) { return 0; }
>> +void __weak arch_watchdog_nmi_disable(unsigned int cpu) { return; }
>> +
>>   #endif /* CONFIG_HARDLOCKUP_DETECTOR */
>>   
>>   static struct smp_hotplug_thread watchdog_threads = {
>> @@ -781,6 +770,40 @@ void lockup_detector_resume(void)
>>   	put_online_cpus();
>>   }
>>   
>> +void watchdog_nmi_disable(unsigned int cpu)
>> +{
>> +	arch_watchdog_nmi_disable(cpu);
>> +}
>> +
>> +int watchdog_nmi_enable(unsigned int cpu)
>> +{
>> +	int err;
>> +
>> +	/* nothing to do if the hard lockup detector is disabled */
>> +	if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED))
>> +		return 0;
>> +
>> +	err = arch_watchdog_nmi_enable(cpu);
>> +
>> +	if (err) {
>> +		/*
>> +		 * Disable the hard lockup detector if _any_ CPU fails to set up
>> +		 * set up the hardware perf event. The watchdog() function checks
>> +		 * the NMI_WATCHDOG_ENABLED bit periodically.
>> +		 *
>> +		 * The barriers are for syncing up watchdog_enabled across all the
>> +		 * cpus, as clear_bit() does not use barriers.
>> +		 */
>> +		smp_mb__before_atomic();
>> +		clear_bit(NMI_WATCHDOG_ENABLED_BIT, &watchdog_enabled);
>> +		smp_mb__after_atomic();
> moved to here:
>
> 		pr_info("Shutting down hard lockup detector on all cpus\n");
>
>
> This lets the failure message be displayed on all arches instead of just
> x86.  Though I guess sparc does not call theirs 'hard lockup detector'.
> Hmm...
>
>
>> +
>> +		return err;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>>   static int update_watchdog_all_cpus(void)
>>   {
>>   	int ret;
>> -- 
>> 1.7.1
>>

WARNING: multiple messages have this Message-ID (diff)
From: Babu Moger <babu.moger@oracle.com>
To: Don Zickus <dzickus@redhat.com>
Cc: mingo@kernel.org, akpm@linux-foundation.org, ak@linux.intel.com,
	jkosina@suse.cz, baiyaowei@cmss.chinamobile.com,
	atomlin@redhat.com, uobergfe@redhat.com, tj@kernel.org,
	hidehiro.kawai.ez@hitachi.com, johunt@akamai.com,
	davem@davemloft.net, sparclinux@vger.kernel.org,
	linux-kernel@vger.kernel.org, sam@ravnborg.org
Subject: Re: [PATCH v2 1/2] watchdog: Introduce arch_watchdog_nmi_enable and arch_watchdog_nmi_disable
Date: Tue, 18 Oct 2016 02:46:52 +0000	[thread overview]
Message-ID: <12e7c12f-3862-ab52-7d5d-ba55764c6a79@oracle.com> (raw)
In-Reply-To: <20161017173157.GK98438@redhat.com>

Don,

On 10/17/2016 12:31 PM, Don Zickus wrote:
> On Thu, Oct 13, 2016 at 01:38:01PM -0700, Babu Moger wrote:
>> Currently we do not have a way to enable/disable arch specific
>> watchdog handlers if it was implemented by any of the architectures.
>>
>> This patch introduces new functions arch_watchdog_nmi_enable and
>> arch_watchdog_nmi_disable which can be used to enable/disable architecture
>> specific NMI watchdog handlers. These functions are defined as weak as
>> architectures can override their definitions to enable/disable nmi
>> watchdog behaviour.
> Hi Babu,
>
> This patch tested fine on my x86 box and I am ok with the changes.
>
> I do have one small cosmetic request below for a failure path.  Other than
> that I will give my ack.
Yes. I am testing these changes. If everything goes as expected, I will 
post  v3 version
tomorrow. Thanks Babu

>
> Cheers,
> Don
>
>> Signed-off-by: Babu Moger <babu.moger@oracle.com>
>> ---
>>   kernel/watchdog.c |   65 +++++++++++++++++++++++++++++++++++-----------------
>>   1 files changed, 44 insertions(+), 21 deletions(-)
>>
>> diff --git a/kernel/watchdog.c b/kernel/watchdog.c
>> index 9acb29f..d1e84e6 100644
>> --- a/kernel/watchdog.c
>> +++ b/kernel/watchdog.c
>> @@ -46,7 +46,7 @@
>>   
>>   static DEFINE_MUTEX(watchdog_proc_mutex);
>>   
>> -#ifdef CONFIG_HARDLOCKUP_DETECTOR
>> +#if defined(CONFIG_HARDLOCKUP_DETECTOR) || defined(CONFIG_HAVE_NMI_WATCHDOG)
>>   static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED|NMI_WATCHDOG_ENABLED;
>>   #else
>>   static unsigned long __read_mostly watchdog_enabled = SOFT_WATCHDOG_ENABLED;
>> @@ -585,15 +585,11 @@ static void watchdog(unsigned int cpu)
>>    */
>>   static unsigned long cpu0_err;
>>   
>> -static int watchdog_nmi_enable(unsigned int cpu)
>> +static int arch_watchdog_nmi_enable(unsigned int cpu)
>>   {
>>   	struct perf_event_attr *wd_attr;
>>   	struct perf_event *event = per_cpu(watchdog_ev, cpu);
>>   
>> -	/* nothing to do if the hard lockup detector is disabled */
>> -	if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED))
>> -		goto out;
>> -
>>   	/* is it already setup and enabled? */
>>   	if (event && event->state > PERF_EVENT_STATE_OFF)
>>   		goto out;
>> @@ -619,18 +615,6 @@ static int watchdog_nmi_enable(unsigned int cpu)
>>   		goto out_save;
>>   	}
>>   
>> -	/*
>> -	 * Disable the hard lockup detector if _any_ CPU fails to set up
>> -	 * set up the hardware perf event. The watchdog() function checks
>> -	 * the NMI_WATCHDOG_ENABLED bit periodically.
>> -	 *
>> -	 * The barriers are for syncing up watchdog_enabled across all the
>> -	 * cpus, as clear_bit() does not use barriers.
>> -	 */
>> -	smp_mb__before_atomic();
>> -	clear_bit(NMI_WATCHDOG_ENABLED_BIT, &watchdog_enabled);
>> -	smp_mb__after_atomic();
>> -
>>   	/* skip displaying the same error again */
>>   	if (cpu > 0 && (PTR_ERR(event) = cpu0_err))
>>   		return PTR_ERR(event);
> In the arch_watchdog_nmi_enable code is a pr_info on failure
>
> 	pr_info("Shutting down hard lockup detector on all cpus\n");
>
> that should be moved to below..
>
>
>> @@ -658,7 +642,7 @@ out:
>>   	return 0;
>>   }
>>   
>> -static void watchdog_nmi_disable(unsigned int cpu)
>> +static void arch_watchdog_nmi_disable(unsigned int cpu)
>>   {
>>   	struct perf_event *event = per_cpu(watchdog_ev, cpu);
>>   
>> @@ -676,8 +660,13 @@ static void watchdog_nmi_disable(unsigned int cpu)
>>   }
>>   
>>   #else
>> -static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
>> -static void watchdog_nmi_disable(unsigned int cpu) { return; }
>> +/*
>> + * These two functions are mostly architecture specific
>> + * defining them as weak here.
>> + */
>> +int __weak arch_watchdog_nmi_enable(unsigned int cpu) { return 0; }
>> +void __weak arch_watchdog_nmi_disable(unsigned int cpu) { return; }
>> +
>>   #endif /* CONFIG_HARDLOCKUP_DETECTOR */
>>   
>>   static struct smp_hotplug_thread watchdog_threads = {
>> @@ -781,6 +770,40 @@ void lockup_detector_resume(void)
>>   	put_online_cpus();
>>   }
>>   
>> +void watchdog_nmi_disable(unsigned int cpu)
>> +{
>> +	arch_watchdog_nmi_disable(cpu);
>> +}
>> +
>> +int watchdog_nmi_enable(unsigned int cpu)
>> +{
>> +	int err;
>> +
>> +	/* nothing to do if the hard lockup detector is disabled */
>> +	if (!(watchdog_enabled & NMI_WATCHDOG_ENABLED))
>> +		return 0;
>> +
>> +	err = arch_watchdog_nmi_enable(cpu);
>> +
>> +	if (err) {
>> +		/*
>> +		 * Disable the hard lockup detector if _any_ CPU fails to set up
>> +		 * set up the hardware perf event. The watchdog() function checks
>> +		 * the NMI_WATCHDOG_ENABLED bit periodically.
>> +		 *
>> +		 * The barriers are for syncing up watchdog_enabled across all the
>> +		 * cpus, as clear_bit() does not use barriers.
>> +		 */
>> +		smp_mb__before_atomic();
>> +		clear_bit(NMI_WATCHDOG_ENABLED_BIT, &watchdog_enabled);
>> +		smp_mb__after_atomic();
> moved to here:
>
> 		pr_info("Shutting down hard lockup detector on all cpus\n");
>
>
> This lets the failure message be displayed on all arches instead of just
> x86.  Though I guess sparc does not call theirs 'hard lockup detector'.
> Hmm...
>
>
>> +
>> +		return err;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>>   static int update_watchdog_all_cpus(void)
>>   {
>>   	int ret;
>> -- 
>> 1.7.1
>>


  reply	other threads:[~2016-10-18  2:48 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-13 20:38 [PATCH v2 0/2] Introduce arch specific nmi enable, disable handlers Babu Moger
2016-10-13 20:38 ` Babu Moger
2016-10-13 20:38 ` [PATCH v2 1/2] watchdog: Introduce arch_watchdog_nmi_enable and arch_watchdog_nmi_disable Babu Moger
2016-10-13 20:38   ` Babu Moger
2016-10-17 17:31   ` Don Zickus
2016-10-17 17:31     ` Don Zickus
2016-10-18  2:46     ` Babu Moger [this message]
2016-10-18  2:46       ` Babu Moger
2016-10-20  0:00   ` Andrew Morton
2016-10-20  0:00     ` Andrew Morton
2016-10-20 16:14     ` Don Zickus
2016-10-20 16:14       ` Don Zickus
2016-10-21  3:25       ` Andrew Morton
2016-10-21  3:25         ` Andrew Morton
2016-10-21 15:11         ` Don Zickus
2016-10-21 15:11           ` Don Zickus
2016-10-21 19:19           ` Andrew Morton
2016-10-21 19:19             ` Andrew Morton
2016-10-21 21:50             ` Babu Moger
2016-10-21 21:50               ` Babu Moger
2016-10-24 15:19               ` Don Zickus
2016-10-24 15:19                 ` Don Zickus
2016-10-25  0:55                 ` Babu Moger
2016-10-25  0:55                   ` Babu Moger
2016-10-13 20:38 ` [PATCH v2 2/2] sparc: Implement " Babu Moger
2016-10-13 20:38   ` Babu Moger
2016-10-17 14:25 ` [PATCH v2 0/2] Introduce arch specific nmi enable, disable handlers Don Zickus
2016-10-17 14:25   ` Don Zickus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=12e7c12f-3862-ab52-7d5d-ba55764c6a79@oracle.com \
    --to=babu.moger@oracle.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=atomlin@redhat.com \
    --cc=baiyaowei@cmss.chinamobile.com \
    --cc=davem@davemloft.net \
    --cc=dzickus@redhat.com \
    --cc=hidehiro.kawai.ez@hitachi.com \
    --cc=jkosina@suse.cz \
    --cc=johunt@akamai.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=sam@ravnborg.org \
    --cc=sparclinux@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=uobergfe@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.