From: Babu Moger <babu.moger@oracle.com> To: mingo@kernel.org, akpm@linux-foundation.org, ak@linux.intel.com, jkosina@suse.cz, baiyaowei@cmss.chinamobile.com, dzickus@redhat.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 Cc: linux-kernel@vger.kernel.org, sam@ravnborg.org, babu.moger@oracle.com Subject: [PATCH v2 2/2] sparc: Implement arch_watchdog_nmi_enable and arch_watchdog_nmi_disable Date: Thu, 13 Oct 2016 13:38:02 -0700 [thread overview] Message-ID: <1476391082-77928-3-git-send-email-babu.moger@oracle.com> (raw) In-Reply-To: <1476391082-77928-1-git-send-email-babu.moger@oracle.com> Implement functions arch_watchdog_nmi_enable and arch_watchdog_nmi_disable to enable/disable nmi watchdog. Sparc uses arch specific nmi watchdog handler. Currently, we do not have a way to enable/disable nmi watchdog dynamically. With these patches we can enable or disable arch specific nmi watchdogs using proc or sysctl interface. Example commands. To enable: echo 1 > /proc/sys/kernel/nmi_watchdog To disable: echo 0 > /proc/sys/kernel/nmi_watchdog It can also achieved using the sysctl parameter kernel.nmi_watchdog Signed-off-by: Babu Moger <babu.moger@oracle.com> --- arch/sparc/kernel/nmi.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 40 insertions(+), 1 deletions(-) diff --git a/arch/sparc/kernel/nmi.c b/arch/sparc/kernel/nmi.c index a9973bb..d7e2c01 100644 --- a/arch/sparc/kernel/nmi.c +++ b/arch/sparc/kernel/nmi.c @@ -42,7 +42,7 @@ static int panic_on_timeout; */ atomic_t nmi_active = ATOMIC_INIT(0); /* oprofile uses this */ EXPORT_SYMBOL(nmi_active); - +static int nmi_init_done; static unsigned int nmi_hz = HZ; static DEFINE_PER_CPU(short, wd_enabled); static int endflag __initdata; @@ -153,6 +153,8 @@ static void report_broken_nmi(int cpu, int *prev_nmi_count) void stop_nmi_watchdog(void *unused) { + if (!__this_cpu_read(wd_enabled)) + return; pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_disable); __this_cpu_write(wd_enabled, 0); atomic_dec(&nmi_active); @@ -207,6 +209,9 @@ error: void start_nmi_watchdog(void *unused) { + if (__this_cpu_read(wd_enabled)) + return; + __this_cpu_write(wd_enabled, 1); atomic_inc(&nmi_active); @@ -259,6 +264,8 @@ int __init nmi_init(void) } } + nmi_init_done = 1; + return err; } @@ -270,3 +277,35 @@ static int __init setup_nmi_watchdog(char *str) return 0; } __setup("nmi_watchdog=", setup_nmi_watchdog); + +/* + * sparc specific NMI watchdog enable function. + * Enables watchdog if it is not enabled already. + */ +int arch_watchdog_nmi_enable(unsigned int cpu) +{ + if (atomic_read(&nmi_active) == -1) { + pr_info_once("NMI watchdog cannot be enabled\n"); + return -1; + } + + /* + * watchdog thread could start even before nmi_init is called. + * Just Return in that case. Let nmi_init finish the init + * process first. + */ + if (!nmi_init_done) + return 0; + + smp_call_function_single(cpu, start_nmi_watchdog, NULL, 1); + + return 0; +} +/* + * sparc specific NMI watchdog disable function. + * Disables watchdog if it is not disabled already. + */ +void arch_watchdog_nmi_disable(unsigned int cpu) +{ + smp_call_function_single(cpu, stop_nmi_watchdog, NULL, 1); +} -- 1.7.1
WARNING: multiple messages have this Message-ID (diff)
From: Babu Moger <babu.moger@oracle.com> To: mingo@kernel.org, akpm@linux-foundation.org, ak@linux.intel.com, jkosina@suse.cz, baiyaowei@cmss.chinamobile.com, dzickus@redhat.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 Cc: linux-kernel@vger.kernel.org, sam@ravnborg.org, babu.moger@oracle.com Subject: [PATCH v2 2/2] sparc: Implement arch_watchdog_nmi_enable and arch_watchdog_nmi_disable Date: Thu, 13 Oct 2016 20:38:02 +0000 [thread overview] Message-ID: <1476391082-77928-3-git-send-email-babu.moger@oracle.com> (raw) In-Reply-To: <1476391082-77928-1-git-send-email-babu.moger@oracle.com> Implement functions arch_watchdog_nmi_enable and arch_watchdog_nmi_disable to enable/disable nmi watchdog. Sparc uses arch specific nmi watchdog handler. Currently, we do not have a way to enable/disable nmi watchdog dynamically. With these patches we can enable or disable arch specific nmi watchdogs using proc or sysctl interface. Example commands. To enable: echo 1 > /proc/sys/kernel/nmi_watchdog To disable: echo 0 > /proc/sys/kernel/nmi_watchdog It can also achieved using the sysctl parameter kernel.nmi_watchdog Signed-off-by: Babu Moger <babu.moger@oracle.com> --- arch/sparc/kernel/nmi.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 40 insertions(+), 1 deletions(-) diff --git a/arch/sparc/kernel/nmi.c b/arch/sparc/kernel/nmi.c index a9973bb..d7e2c01 100644 --- a/arch/sparc/kernel/nmi.c +++ b/arch/sparc/kernel/nmi.c @@ -42,7 +42,7 @@ static int panic_on_timeout; */ atomic_t nmi_active = ATOMIC_INIT(0); /* oprofile uses this */ EXPORT_SYMBOL(nmi_active); - +static int nmi_init_done; static unsigned int nmi_hz = HZ; static DEFINE_PER_CPU(short, wd_enabled); static int endflag __initdata; @@ -153,6 +153,8 @@ static void report_broken_nmi(int cpu, int *prev_nmi_count) void stop_nmi_watchdog(void *unused) { + if (!__this_cpu_read(wd_enabled)) + return; pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_disable); __this_cpu_write(wd_enabled, 0); atomic_dec(&nmi_active); @@ -207,6 +209,9 @@ error: void start_nmi_watchdog(void *unused) { + if (__this_cpu_read(wd_enabled)) + return; + __this_cpu_write(wd_enabled, 1); atomic_inc(&nmi_active); @@ -259,6 +264,8 @@ int __init nmi_init(void) } } + nmi_init_done = 1; + return err; } @@ -270,3 +277,35 @@ static int __init setup_nmi_watchdog(char *str) return 0; } __setup("nmi_watchdog=", setup_nmi_watchdog); + +/* + * sparc specific NMI watchdog enable function. + * Enables watchdog if it is not enabled already. + */ +int arch_watchdog_nmi_enable(unsigned int cpu) +{ + if (atomic_read(&nmi_active) = -1) { + pr_info_once("NMI watchdog cannot be enabled\n"); + return -1; + } + + /* + * watchdog thread could start even before nmi_init is called. + * Just Return in that case. Let nmi_init finish the init + * process first. + */ + if (!nmi_init_done) + return 0; + + smp_call_function_single(cpu, start_nmi_watchdog, NULL, 1); + + return 0; +} +/* + * sparc specific NMI watchdog disable function. + * Disables watchdog if it is not disabled already. + */ +void arch_watchdog_nmi_disable(unsigned int cpu) +{ + smp_call_function_single(cpu, stop_nmi_watchdog, NULL, 1); +} -- 1.7.1
next prev parent reply other threads:[~2016-10-13 22:24 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 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 ` Babu Moger [this message] 2016-10-13 20:38 ` [PATCH v2 2/2] sparc: Implement " 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=1476391082-77928-3-git-send-email-babu.moger@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: linkBe 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.