Commit feeaf5512947 ("x86: Move sysctls into arch/x86")
recently moved the sysctl handling of panic_on_unrecovered_nmi and
panic_on_io_nmi to x86-specific code. These variables no longer need to
be declared in the generic header file.
Relocate the variable definitions and declarations closer to where they
are used. This makes all the NMI panic options consistent and easier to
track.
Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
---
arch/x86/include/asm/nmi.h | 2 ++
arch/x86/kernel/dumpstack.c | 2 --
arch/x86/kernel/nmi.c | 3 +++
include/linux/panic.h | 2 --
4 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
index 9cf96cce02fc..f85aea7bf7f1 100644
--- a/arch/x86/include/asm/nmi.h
+++ b/arch/x86/include/asm/nmi.h
@@ -17,6 +17,8 @@ extern void release_evntsel_nmi(unsigned int);
#endif /* CONFIG_X86_LOCAL_APIC */
extern int unknown_nmi_panic;
+extern int panic_on_unrecovered_nmi;
+extern int panic_on_io_nmi;
#define NMI_FLAG_FIRST 1
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 91639d1e4ec2..4abc9153e8a4 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -23,8 +23,6 @@
#include <asm/stacktrace.h>
#include <asm/unwind.h>
-int panic_on_unrecovered_nmi;
-int panic_on_io_nmi;
static int die_counter;
static struct pt_regs exec_summary_regs;
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 9a95d00f1423..671d846ed620 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -91,6 +91,9 @@ static DEFINE_PER_CPU(struct nmi_stats, nmi_stats);
static int ignore_nmis __read_mostly;
int unknown_nmi_panic;
+int panic_on_unrecovered_nmi;
+int panic_on_io_nmi;
+
/*
* Prevent NMI reason port (0x61) being accessed simultaneously, can
* only be used in NMI handler.
diff --git a/include/linux/panic.h b/include/linux/panic.h
index 54d90b6c5f47..b0ec89a9a966 100644
--- a/include/linux/panic.h
+++ b/include/linux/panic.h
@@ -20,8 +20,6 @@ extern bool panic_triggering_all_cpu_backtrace;
extern int panic_timeout;
extern unsigned long panic_print;
extern int panic_on_oops;
-extern int panic_on_unrecovered_nmi;
-extern int panic_on_io_nmi;
extern int panic_on_warn;
extern unsigned long panic_on_taint;
--
2.43.0
On Thu, 2025-03-27 at 23:46 +0000, Mehta, Sohil wrote:
> Commit feeaf5512947 ("x86: Move sysctls into arch/x86")
AFAICT the commit hash is wrong. It should be c305a4e98378.
> recently moved the sysctl handling of panic_on_unrecovered_nmi and
> panic_on_io_nmi to x86-specific code. These variables no longer need to
> be declared in the generic header file.
>
> Relocate the variable definitions and declarations closer to where they
> are used. This makes all the NMI panic options consistent and easier to
> track.
>
> Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
Reviewed-by: Kai Huang <kai.huang@intel.com>
On 3/31/2025 3:43 PM, Huang, Kai wrote:
> On Thu, 2025-03-27 at 23:46 +0000, Mehta, Sohil wrote:
>> Commit feeaf5512947 ("x86: Move sysctls into arch/x86")
>
> AFAICT the commit hash is wrong. It should be c305a4e98378.
>
Yes, sorry about that. I ended up referencing a pre-merge duplicate
commit in my repo.
Thankfully, Ingo fixed it when he applied the patch:
https://web.git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=x86/nmi&id=1a5b15f6b4d18507dc3b2958ca01877cfc8808fd
>> recently moved the sysctl handling of panic_on_unrecovered_nmi and
>> panic_on_io_nmi to x86-specific code. These variables no longer need to
>> be declared in the generic header file.
>>
>> Relocate the variable definitions and declarations closer to where they
>> are used. This makes all the NMI panic options consistent and easier to
>> track.
>>
>> Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
>
> Reviewed-by: Kai Huang <kai.huang@intel.com>
>
On Mon, 2025-03-31 at 15:50 -0700, Mehta, Sohil wrote:
> On 3/31/2025 3:43 PM, Huang, Kai wrote:
> > On Thu, 2025-03-27 at 23:46 +0000, Mehta, Sohil wrote:
> > > Commit feeaf5512947 ("x86: Move sysctls into arch/x86")
> >
> > AFAICT the commit hash is wrong. It should be c305a4e98378.
> >
>
> Yes, sorry about that. I ended up referencing a pre-merge duplicate
> commit in my repo.
>
> Thankfully, Ingo fixed it when he applied the patch:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=x86/nmi&id=1a5b15f6b4d18507dc3b2958ca01877cfc8808fd
>
>
Ah I didn't know this series was merged. I think I'll stop looking at it. :-)
On 3/31/2025 4:05 PM, Huang, Kai wrote:
> On Mon, 2025-03-31 at 15:50 -0700, Mehta, Sohil wrote:
>> On 3/31/2025 3:43 PM, Huang, Kai wrote:
>>> On Thu, 2025-03-27 at 23:46 +0000, Mehta, Sohil wrote:
>>>> Commit feeaf5512947 ("x86: Move sysctls into arch/x86")
>>>
>>> AFAICT the commit hash is wrong. It should be c305a4e98378.
>>>
>>
>> Yes, sorry about that. I ended up referencing a pre-merge duplicate
>> commit in my repo.
>>
>> Thankfully, Ingo fixed it when he applied the patch:
>> https://web.git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=x86/nmi&id=1a5b15f6b4d18507dc3b2958ca01877cfc8808fd
>>
>>
>
> Ah I didn't know this series was merged. I think I'll stop looking at it. :-)
Your review comments have been useful. Please continue reviewing if you
can. You found an issue in patch 1 that both of us missed.
Also, I am not sure if the series is truly merged. I haven't seen the
tip tree tip-bot emails yet. Maybe Ingo can answer this better.
Sohil
On Mon, 2025-03-31 at 16:20 -0700, Mehta, Sohil wrote:
> On 3/31/2025 4:05 PM, Huang, Kai wrote:
> > On Mon, 2025-03-31 at 15:50 -0700, Mehta, Sohil wrote:
> > > On 3/31/2025 3:43 PM, Huang, Kai wrote:
> > > > On Thu, 2025-03-27 at 23:46 +0000, Mehta, Sohil wrote:
> > > > > Commit feeaf5512947 ("x86: Move sysctls into arch/x86")
> > > >
> > > > AFAICT the commit hash is wrong. It should be c305a4e98378.
> > > >
> > >
> > > Yes, sorry about that. I ended up referencing a pre-merge duplicate
> > > commit in my repo.
> > >
> > > Thankfully, Ingo fixed it when he applied the patch:
> > > https://web.git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=x86/nmi&id=1a5b15f6b4d18507dc3b2958ca01877cfc8808fd
> > >
> > >
> >
> > Ah I didn't know this series was merged. I think I'll stop looking at it. :-)
>
> Your review comments have been useful. Please continue reviewing if you
> can. You found an issue in patch 1 that both of us missed.
>
I just did. I didn't find anything apart from one thing that I _think_ it might
be helpful to mention another commit in the changelog of patch 5 "x86/nmi: Fix
comment in unknown NMI handling".
Thanks.
On 3/31/2025 6:06 PM, Huang, Kai wrote: >>> Ah I didn't know this series was merged. I think I'll stop looking at it. :-) >> >> Your review comments have been useful. Please continue reviewing if you >> can. You found an issue in patch 1 that both of us missed. >> > > I just did. I didn't find anything apart from one thing that I _think_ it might > be helpful to mention another commit in the changelog of patch 5 "x86/nmi: Fix > comment in unknown NMI handling". > Kai, I feel the additional commit is indirectly implied. I am inclined to leave the changelog as-is unless you feel strongly about it. Thank you for the reviews. Really appreciate it! Ingo, there are 2 main changes from the patches in tip:x86/nmi. 1) As pointed out by Kai, there is a minor oversight in patch 1 on my part. The header files aren't strictly ordered. There needs to be a single line change to keep them alphabetically ordered. 2) As discussed in patch 7, the title for split-off patch is incorrect. If you prefer, I can generate a new series based on the patches you have in tip to save you the extra effort again. Or I can generate a single additional patch on top if you want. OTOH, feel free to make the changes yourself and include my signoffs.
On Mon, 2025-03-31 at 22:46 -0700, Sohil Mehta wrote: > On 3/31/2025 6:06 PM, Huang, Kai wrote: > > > > > Ah I didn't know this series was merged. I think I'll stop looking at it. :-) > > > > > > Your review comments have been useful. Please continue reviewing if you > > > can. You found an issue in patch 1 that both of us missed. > > > > > > > I just did. I didn't find anything apart from one thing that I _think_ it might > > be helpful to mention another commit in the changelog of patch 5 "x86/nmi: Fix > > comment in unknown NMI handling". > > > > Kai, I feel the additional commit is indirectly implied. I am inclined > to leave the changelog as-is unless you feel strongly about it. Sure np to me.
The following commit has been merged into the x86/nmi branch of tip:
Commit-ID: 78a0323506f01e8017a5826cd7e91951c13184fa
Gitweb: https://git.kernel.org/tip/78a0323506f01e8017a5826cd7e91951c13184fa
Author: Sohil Mehta <sohil.mehta@intel.com>
AuthorDate: Thu, 27 Mar 2025 23:46:22
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 01 Apr 2025 22:25:56 +02:00
x86/nmi: Consolidate NMI panic variables
Commit:
c305a4e98378 ("x86: Move sysctls into arch/x86")
recently moved the sysctl handling of panic_on_unrecovered_nmi and
panic_on_io_nmi to x86-specific code. These variables no longer need to
be declared in the generic header file.
Relocate the variable definitions and declarations closer to where they
are used. This makes all the NMI panic options consistent and easier to
track.
[ mingo: Fixed up the SHA1 of the commit reference. ]
Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Kai Huang <kai.huang@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
Cc: Joel Granados <joel.granados@kernel.org>
Link: https://lore.kernel.org/r/20250327234629.3953536-3-sohil.mehta@intel.com
---
arch/x86/include/asm/nmi.h | 2 ++
arch/x86/kernel/dumpstack.c | 2 --
arch/x86/kernel/nmi.c | 3 +++
include/linux/panic.h | 2 --
4 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
index 9cf96cc..f85aea7 100644
--- a/arch/x86/include/asm/nmi.h
+++ b/arch/x86/include/asm/nmi.h
@@ -17,6 +17,8 @@ extern void release_evntsel_nmi(unsigned int);
#endif /* CONFIG_X86_LOCAL_APIC */
extern int unknown_nmi_panic;
+extern int panic_on_unrecovered_nmi;
+extern int panic_on_io_nmi;
#define NMI_FLAG_FIRST 1
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index c6fefd4..71ee201 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -23,8 +23,6 @@
#include <asm/stacktrace.h>
#include <asm/unwind.h>
-int panic_on_unrecovered_nmi;
-int panic_on_io_nmi;
static int die_counter;
static struct pt_regs exec_summary_regs;
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 9a95d00..671d846 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -91,6 +91,9 @@ static DEFINE_PER_CPU(struct nmi_stats, nmi_stats);
static int ignore_nmis __read_mostly;
int unknown_nmi_panic;
+int panic_on_unrecovered_nmi;
+int panic_on_io_nmi;
+
/*
* Prevent NMI reason port (0x61) being accessed simultaneously, can
* only be used in NMI handler.
diff --git a/include/linux/panic.h b/include/linux/panic.h
index 2494d51..4adc657 100644
--- a/include/linux/panic.h
+++ b/include/linux/panic.h
@@ -20,8 +20,6 @@ extern bool panic_triggering_all_cpu_backtrace;
extern int panic_timeout;
extern unsigned long panic_print;
extern int panic_on_oops;
-extern int panic_on_unrecovered_nmi;
-extern int panic_on_io_nmi;
extern int panic_on_warn;
extern unsigned long panic_on_taint;
© 2016 - 2025 Red Hat, Inc.