2017-09-12 19:50:00

by Thomas Gleixner

[permalink] [raw]
Subject: [patch V2 25/29] lockup_detector: Implement init time detection of perf

Use the init time detection of the perf NMI watchdog to determine whether
the perf NMI watchdog is functional. If not disable it permanentely. It
won't come back magically at runtime.

Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Don Zickus <[email protected]>
Cc: Chris Metcalf <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Sebastian Siewior <[email protected]>
Cc: Nicholas Piggin <[email protected]>
Cc: Ulrich Obergfell <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Andrew Morton <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]

---
kernel/watchdog.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -44,6 +44,7 @@ int __read_mostly watchdog_user_enabled
int __read_mostly nmi_watchdog_user_enabled = NMI_WATCHDOG_DEFAULT;
int __read_mostly soft_watchdog_user_enabled = 1;
int __read_mostly watchdog_thresh = 10;
+int __read_mostly nmi_watchdog_available;

struct cpumask watchdog_allowed_mask __read_mostly;
static bool softlockup_threads_initialized __read_mostly;
@@ -114,6 +115,12 @@ void __weak watchdog_nmi_disable(unsigne
hardlockup_detector_perf_disable();
}

+/* Return 0, if a NMI watchdog is available. Error code otherwise */
+int __weak __init void watchdog_nmi_probe(void)
+{
+ return hardlockup_detector_perf_init();
+}
+
/**
* watchdog_nmi_reconfigure - Optional function to reconfigure NMI watchdogs
* @run: If false stop the watchdogs on all enabled CPUs
@@ -145,7 +152,7 @@ static void lockup_detector_update_enabl
watchdog_enabled = 0;
if (!watchdog_user_enabled)
return;
- if (nmi_watchdog_user_enabled)
+ if (nmi_watchdog_available && nmi_watchdog_user_enabled)
watchdog_enabled |= NMI_WATCHDOG_ENABLED;
if (soft_watchdog_user_enabled)
watchdog_enabled |= SOFT_WATCHDOG_ENABLED;
@@ -692,6 +699,8 @@ int proc_watchdog(struct ctl_table *tabl
int proc_nmi_watchdog(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
+ if (!nmi_watchdog_available && write)
+ return -ENOTSUPP;
return proc_watchdog_common(NMI_WATCHDOG_ENABLED,
table, write, buffer, lenp, ppos);
}
@@ -764,5 +773,7 @@ void __init lockup_detector_init(void)
cpumask_copy(&watchdog_cpumask, cpu_possible_mask);
#endif

+ if (!watchdog_nmi_probe())
+ nmi_watchdog_available = true;
softlockup_init_threads();
}



2017-09-13 18:02:44

by Don Zickus

[permalink] [raw]
Subject: Re: [patch V2 25/29] lockup_detector: Implement init time detection of perf

On Tue, Sep 12, 2017 at 09:37:19PM +0200, Thomas Gleixner wrote:
> Use the init time detection of the perf NMI watchdog to determine whether
> the perf NMI watchdog is functional. If not disable it permanentely. It
> won't come back magically at runtime.
>
> Signed-off-by: Thomas Gleixner <[email protected]>
> Cc: Don Zickus <[email protected]>
> Cc: Chris Metcalf <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Sebastian Siewior <[email protected]>
> Cc: Nicholas Piggin <[email protected]>
> Cc: Ulrich Obergfell <[email protected]>
> Cc: Borislav Petkov <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Link: http://lkml.kernel.org/r/[email protected]
>
> ---
> kernel/watchdog.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> --- a/kernel/watchdog.c
> +++ b/kernel/watchdog.c
> @@ -44,6 +44,7 @@ int __read_mostly watchdog_user_enabled
> int __read_mostly nmi_watchdog_user_enabled = NMI_WATCHDOG_DEFAULT;
> int __read_mostly soft_watchdog_user_enabled = 1;
> int __read_mostly watchdog_thresh = 10;
> +int __read_mostly nmi_watchdog_available;
>
> struct cpumask watchdog_allowed_mask __read_mostly;
> static bool softlockup_threads_initialized __read_mostly;
> @@ -114,6 +115,12 @@ void __weak watchdog_nmi_disable(unsigne
> hardlockup_detector_perf_disable();
> }
>
> +/* Return 0, if a NMI watchdog is available. Error code otherwise */
> +int __weak __init void watchdog_nmi_probe(void)

^^^ compile error, can't have 'int' and 'void'. Removing 'void' fixes it.

Cheers,
Don

> +{
> + return hardlockup_detector_perf_init();
> +}
> +
> /**
> * watchdog_nmi_reconfigure - Optional function to reconfigure NMI watchdogs
> * @run: If false stop the watchdogs on all enabled CPUs
> @@ -145,7 +152,7 @@ static void lockup_detector_update_enabl
> watchdog_enabled = 0;
> if (!watchdog_user_enabled)
> return;
> - if (nmi_watchdog_user_enabled)
> + if (nmi_watchdog_available && nmi_watchdog_user_enabled)
> watchdog_enabled |= NMI_WATCHDOG_ENABLED;
> if (soft_watchdog_user_enabled)
> watchdog_enabled |= SOFT_WATCHDOG_ENABLED;
> @@ -692,6 +699,8 @@ int proc_watchdog(struct ctl_table *tabl
> int proc_nmi_watchdog(struct ctl_table *table, int write,
> void __user *buffer, size_t *lenp, loff_t *ppos)
> {
> + if (!nmi_watchdog_available && write)
> + return -ENOTSUPP;
> return proc_watchdog_common(NMI_WATCHDOG_ENABLED,
> table, write, buffer, lenp, ppos);
> }
> @@ -764,5 +773,7 @@ void __init lockup_detector_init(void)
> cpumask_copy(&watchdog_cpumask, cpu_possible_mask);
> #endif
>
> + if (!watchdog_nmi_probe())
> + nmi_watchdog_available = true;
> softlockup_init_threads();
> }
>
>

2017-09-13 18:05:26

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [patch V2 25/29] lockup_detector: Implement init time detection of perf

On Wed, 13 Sep 2017, Don Zickus wrote:
> > +/* Return 0, if a NMI watchdog is available. Error code otherwise */
> > +int __weak __init void watchdog_nmi_probe(void)
>
> ^^^ compile error, can't have 'int' and 'void'. Removing 'void' fixes it.

Yes, I know. I feel stupid because I'm 100% sure that I compiled it ....

2017-09-14 05:27:20

by Ingo Molnar

[permalink] [raw]
Subject: Re: [patch V2 25/29] lockup_detector: Implement init time detection of perf


* Thomas Gleixner <[email protected]> wrote:

> On Wed, 13 Sep 2017, Don Zickus wrote:
> > > +/* Return 0, if a NMI watchdog is available. Error code otherwise */
> > > +int __weak __init void watchdog_nmi_probe(void)
> >
> > ^^^ compile error, can't have 'int' and 'void'. Removing 'void' fixes it.
>
> Yes, I know. I feel stupid because I'm 100% sure that I compiled it ....

So there a Kconfig dependency on that - defconfig won't show it, which might be
why you didn't see it?

Thanks,

Ingo

Subject: [tip:core/urgent] watchdog/hardlockup/perf: Implement init time detection of perf

Commit-ID: a994a3147e4c0c9c50a46e6cace7586254975e20
Gitweb: http://git.kernel.org/tip/a994a3147e4c0c9c50a46e6cace7586254975e20
Author: Thomas Gleixner <[email protected]>
AuthorDate: Tue, 12 Sep 2017 21:37:19 +0200
Committer: Ingo Molnar <[email protected]>
CommitDate: Thu, 14 Sep 2017 11:41:08 +0200

watchdog/hardlockup/perf: Implement init time detection of perf

Use the init time detection of the perf NMI watchdog to determine whether
the perf NMI watchdog is functional. If not disable it permanentely. It
won't come back magically at runtime.

Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Don Zickus <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Chris Metcalf <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Nicholas Piggin <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Sebastian Siewior <[email protected]>
Cc: Ulrich Obergfell <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
kernel/watchdog.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 8488631..fd8a998 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -44,6 +44,7 @@ int __read_mostly watchdog_user_enabled = 1;
int __read_mostly nmi_watchdog_user_enabled = NMI_WATCHDOG_DEFAULT;
int __read_mostly soft_watchdog_user_enabled = 1;
int __read_mostly watchdog_thresh = 10;
+int __read_mostly nmi_watchdog_available;

struct cpumask watchdog_allowed_mask __read_mostly;
static bool softlockup_threads_initialized __read_mostly;
@@ -114,6 +115,12 @@ void __weak watchdog_nmi_disable(unsigned int cpu)
hardlockup_detector_perf_disable();
}

+/* Return 0, if a NMI watchdog is available. Error code otherwise */
+int __weak __init watchdog_nmi_probe(void)
+{
+ return hardlockup_detector_perf_init();
+}
+
/**
* watchdog_nmi_reconfigure - Optional function to reconfigure NMI watchdogs
* @run: If false stop the watchdogs on all enabled CPUs
@@ -145,7 +152,7 @@ static void lockup_detector_update_enable(void)
watchdog_enabled = 0;
if (!watchdog_user_enabled)
return;
- if (nmi_watchdog_user_enabled)
+ if (nmi_watchdog_available && nmi_watchdog_user_enabled)
watchdog_enabled |= NMI_WATCHDOG_ENABLED;
if (soft_watchdog_user_enabled)
watchdog_enabled |= SOFT_WATCHDOG_ENABLED;
@@ -692,6 +699,8 @@ int proc_watchdog(struct ctl_table *table, int write,
int proc_nmi_watchdog(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
+ if (!nmi_watchdog_available && write)
+ return -ENOTSUPP;
return proc_watchdog_common(NMI_WATCHDOG_ENABLED,
table, write, buffer, lenp, ppos);
}
@@ -764,5 +773,7 @@ void __init lockup_detector_init(void)
cpumask_copy(&watchdog_cpumask, cpu_possible_mask);
#endif

+ if (!watchdog_nmi_probe())
+ nmi_watchdog_available = true;
softlockup_init_threads();
}