From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-qg0-f46.google.com ([209.85.192.46]:36782 "EHLO mail-qg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751431AbcCDT1q convert rfc822-to-8bit (ORCPT ); Fri, 4 Mar 2016 14:27:46 -0500 Received: by mail-qg0-f46.google.com with SMTP id u110so51468942qge.3 for ; Fri, 04 Mar 2016 11:27:46 -0800 (PST) From: Michal Nazarewicz To: Hidehiro Kawai , Andrew Morton , Thomas Mingarelli , Wim Van Sebroeck , Corey Minyard Cc: Javi Merino , Michal Hocko , linux-watchdog@vger.kernel.org, "Steven Rostedt \(Red Hat\)" , Rasmus Villemoes , linux-kernel@vger.kernel.org, Michal Hocko , Vitaly Kuznetsov , HATAYAMA Daisuke , Borislav Petkov , Gobinda Charan Maji , Tejun Heo , Nicolas Iooss , openipmi-developer@lists.sourceforge.net, Borislav Petkov , Thomas Gleixner , Guenter Roeck Subject: Re: [v3 PATCH 1/3] panic: Change nmi_panic from macro to function In-Reply-To: <20160303105744.4587.1001.stgit@softrs> References: <20160303105741.4587.49047.stgit@softrs> <20160303105744.4587.1001.stgit@softrs> Date: Fri, 04 Mar 2016 14:27:43 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Sender: linux-watchdog-owner@vger.kernel.org List-Id: linux-watchdog@vger.kernel.org Content-Transfer-Encoding: quoted-printable On Thu, Mar 03 2016, Hidehiro Kawai wrote: > Change nmi_panic() macro to a normal function for the portability. > Also, export it for modules. > > Changes since v2: > - Make nmi_panic receive a single string instead of printf style args > > Signed-off-by: Hidehiro Kawai > Cc: Andrew Morton > Cc: Borislav Petkov > Cc: Michal Nazarewicz Code does what the commit advertises so Acked-by: Michal Nazarewicz > Cc: Michal Hocko > Cc: Rasmus Villemoes > Cc: Nicolas Iooss > Cc: Javi Merino > Cc: Gobinda Charan Maji > Cc: "Steven Rostedt (Red Hat)" > Cc: Thomas Gleixner > Cc: Vitaly Kuznetsov > Cc: HATAYAMA Daisuke > Cc: Tejun Heo > --- > include/linux/kernel.h | 21 +------------------- > kernel/panic.c | 20 ++++++++++++++++++++ > 2 files changed, 21 insertions(+), 20 deletions(-) > > diff --git a/include/linux/kernel.h b/include/linux/kernel.h > index f31638c..cbe7d70 100644 > --- a/include/linux/kernel.h > +++ b/include/linux/kernel.h > @@ -255,7 +255,7 @@ extern long (*panic_blink)(int state); > __printf(1, 2) > void panic(const char *fmt, ...) > __noreturn __cold; > -void nmi_panic_self_stop(struct pt_regs *); > +void nmi_panic(struct pt_regs *regs, const char *msg); > extern void oops_enter(void); > extern void oops_exit(void); > void print_oops_end_marker(void); > @@ -455,25 +455,6 @@ extern atomic_t panic_cpu; > #define PANIC_CPU_INVALID -1 > =20 > /* > - * A variant of panic() called from NMI context. We return if we've al= ready > - * panicked on this CPU. If another CPU already panicked, loop in > - * nmi_panic_self_stop() which can provide architecture dependent code= such > - * as saving register state for crash dump. > - */ > -#define nmi_panic(regs, fmt, ...) \ > -do { \ > - int old_cpu, cpu; \ > - \ > - cpu =3D raw_smp_processor_id(); \ > - old_cpu =3D atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, cpu); \ > - \ > - if (old_cpu =3D=3D PANIC_CPU_INVALID) \ > - panic(fmt, ##__VA_ARGS__); \ > - else if (old_cpu !=3D cpu) \ > - nmi_panic_self_stop(regs); \ > -} while (0) > - > -/* > * Only to be used by arch init code. If the user over-wrote the defau= lt > * CONFIG_PANIC_TIMEOUT, honor it. > */ > diff --git a/kernel/panic.c b/kernel/panic.c > index d96469d..8abfc30 100644 > --- a/kernel/panic.c > +++ b/kernel/panic.c > @@ -72,6 +72,26 @@ void __weak nmi_panic_self_stop(struct pt_regs *regs= ) > =20 > atomic_t panic_cpu =3D ATOMIC_INIT(PANIC_CPU_INVALID); > =20 > +/* > + * A variant of panic() called from NMI context. We return if we've al= ready > + * panicked on this CPU. If another CPU already panicked, loop in > + * nmi_panic_self_stop() which can provide architecture dependent code= such > + * as saving register state for crash dump. > + */ > +void nmi_panic(struct pt_regs *regs, const char *msg) > +{ > + int old_cpu, cpu; > + > + cpu =3D raw_smp_processor_id(); > + old_cpu =3D atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, cpu); > + > + if (old_cpu =3D=3D PANIC_CPU_INVALID) > + panic("%s", msg); > + else if (old_cpu !=3D cpu) > + nmi_panic_self_stop(regs); > +} > +EXPORT_SYMBOL(nmi_panic); > + > /** > * panic - halt the system > * @fmt: The text string to print > > --=20 Best regards =E3=83=9F=E3=83=8F=E3=82=A6 =E2=80=9C=F0=9D=93=B6=F0=9D=93=B2=F0=9D=93=B7= =F0=9D=93=AA86=E2=80=9D =E3=83=8A=E3=82=B6=E3=83=AC=E3=83=B4=E3=82=A4=E3=83= =84 =C2=ABIf at first you don=E2=80=99t succeed, give up skydiving=C2=BB -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog"= in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html