All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Nazarewicz <mina86@mina86.com>
To: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Mingarelli <thomas.mingarelli@hpe.com>,
	Wim Van Sebroeck <wim@iguana.be>, Corey Minyard <minyard@acm.org>
Cc: Javi Merino <javi.merino@arm.com>, Michal Hocko <mhocko@suse.com>,
	linux-watchdog@vger.kernel.org,
	"Steven Rostedt \(Red Hat\)" <rostedt@goodmis.org>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-kernel@vger.kernel.org, Michal Hocko <mhocko@kernel.org>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>,
	Borislav Petkov <bp@alien8.de>,
	Gobinda Charan Maji <gobinda.cemk07@gmail.com>,
	Tejun Heo <tj@kernel.org>,
	Nicolas Iooss <nicolas.iooss_linux@m4x.org>,
	openipmi-developer@lists.sourceforge.net,
	Borislav Petkov <bp@suse.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Guenter Roeck <linux@roeck-us.net>
Subject: Re: [v3 PATCH 1/3] panic: Change nmi_panic from macro to function
Date: Fri, 04 Mar 2016 14:27:43 -0500	[thread overview]
Message-ID: <xa1tr3fq82mo.fsf@mina86.com> (raw)
In-Reply-To: <20160303105744.4587.1001.stgit@softrs>

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 <hidehiro.kawai.ez@hitachi.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Michal Nazarewicz <mina86@mina86.com>

Code does what the commit advertises so

Acked-by: Michal Nazarewicz <mina86@mina86.com>

> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Cc: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
> Cc: Javi Merino <javi.merino@arm.com>
> Cc: Gobinda Charan Maji <gobinda.cemk07@gmail.com>
> Cc: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
> Cc: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
> Cc: Tejun Heo <tj@kernel.org>
> ---
>  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
>  
>  /*
> - * A variant of panic() called from NMI context. We return if we've already
> - * 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 = raw_smp_processor_id();					\
> -	old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, cpu);	\
> -									\
> -	if (old_cpu == PANIC_CPU_INVALID)				\
> -		panic(fmt, ##__VA_ARGS__);				\
> -	else if (old_cpu != cpu)					\
> -		nmi_panic_self_stop(regs);				\
> -} while (0)
> -
> -/*
>   * Only to be used by arch init code. If the user over-wrote the default
>   * 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)
>  
>  atomic_t panic_cpu = ATOMIC_INIT(PANIC_CPU_INVALID);
>  
> +/*
> + * A variant of panic() called from NMI context. We return if we've already
> + * 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 = raw_smp_processor_id();
> +	old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, cpu);
> +
> +	if (old_cpu == PANIC_CPU_INVALID)
> +		panic("%s", msg);
> +	else if (old_cpu != cpu)
> +		nmi_panic_self_stop(regs);
> +}
> +EXPORT_SYMBOL(nmi_panic);
> +
>  /**
>   *	panic - halt the system
>   *	@fmt: The text string to print
>
>

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
--
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

WARNING: multiple messages have this Message-ID (diff)
From: Michal Nazarewicz <mina86@mina86.com>
To: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Mingarelli <thomas.mingarelli@hpe.com>,
	Wim Van Sebroeck <wim@iguana.be>, Corey Minyard <minyard@acm.org>
Cc: Javi Merino <javi.merino@arm.com>, Michal Hocko <mhocko@suse.com>,
	linux-watchdog@vger.kernel.org,
	"Steven Rostedt \(Red Hat\)" <rostedt@goodmis.org>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-kernel@vger.kernel.org, Michal Hocko <mhocko@kernel.org>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>,
	Borislav Petkov <bp@alien8.de>,
	Gobinda Charan Maji <gobinda.cemk07@gmail.com>,
	Tejun Heo <tj@kernel.org>,
	Nicolas Iooss <nicolas.iooss_linux@m4x.org>,
	openipmi-developer@lists.sourceforge.net,
	Borislav Petkov <bp@suse.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Guenter Roeck <linux@roeck-us.net>
Subject: Re: [v3 PATCH 1/3] panic: Change nmi_panic from macro to function
Date: Fri, 04 Mar 2016 14:27:43 -0500	[thread overview]
Message-ID: <xa1tr3fq82mo.fsf@mina86.com> (raw)
In-Reply-To: <20160303105744.4587.1001.stgit@softrs>

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 <hidehiro.kawai.ez@hitachi.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Michal Nazarewicz <mina86@mina86.com>

Code does what the commit advertises so

Acked-by: Michal Nazarewicz <mina86@mina86.com>

> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Cc: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
> Cc: Javi Merino <javi.merino@arm.com>
> Cc: Gobinda Charan Maji <gobinda.cemk07@gmail.com>
> Cc: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
> Cc: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
> Cc: Tejun Heo <tj@kernel.org>
> ---
>  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
>  
>  /*
> - * A variant of panic() called from NMI context. We return if we've already
> - * 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 = raw_smp_processor_id();					\
> -	old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, cpu);	\
> -									\
> -	if (old_cpu == PANIC_CPU_INVALID)				\
> -		panic(fmt, ##__VA_ARGS__);				\
> -	else if (old_cpu != cpu)					\
> -		nmi_panic_self_stop(regs);				\
> -} while (0)
> -
> -/*
>   * Only to be used by arch init code. If the user over-wrote the default
>   * 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)
>  
>  atomic_t panic_cpu = ATOMIC_INIT(PANIC_CPU_INVALID);
>  
> +/*
> + * A variant of panic() called from NMI context. We return if we've already
> + * 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 = raw_smp_processor_id();
> +	old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, cpu);
> +
> +	if (old_cpu == PANIC_CPU_INVALID)
> +		panic("%s", msg);
> +	else if (old_cpu != cpu)
> +		nmi_panic_self_stop(regs);
> +}
> +EXPORT_SYMBOL(nmi_panic);
> +
>  /**
>   *	panic - halt the system
>   *	@fmt: The text string to print
>
>

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»

  parent reply	other threads:[~2016-03-04 19:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-03 10:57 [v3 PATCH 0/3] Use nmi_panic() in panic on NMI case Hidehiro Kawai
2016-03-03 10:57 ` [v3 PATCH 1/3] panic: Change nmi_panic from macro to function Hidehiro Kawai
2016-03-03 13:14   ` Borislav Petkov
2016-03-07 10:53     ` 河合英宏 / KAWAI,HIDEHIRO
2016-03-07 11:13       ` Borislav Petkov
2016-03-07 11:13         ` Borislav Petkov
2016-03-04 17:49   ` Michal Hocko
2016-03-04 19:27   ` Michal Nazarewicz [this message]
2016-03-04 19:27     ` Michal Nazarewicz
2016-03-03 10:57 ` [v3 PATCH 2/3] ipmi/watchdog: Use nmi_panic() when kernel panics in NMI handler Hidehiro Kawai
2016-03-03 10:57 ` [v3 PATCH 3/3] hpwdt: " Hidehiro Kawai
2016-03-03 12:17   ` Guenter Roeck
2016-03-07 11:07   ` [Openipmi-developer] " 河合英宏 / KAWAI,HIDEHIRO

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=xa1tr3fq82mo.fsf@mina86.com \
    --to=mina86@mina86.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=d.hatayama@jp.fujitsu.com \
    --cc=gobinda.cemk07@gmail.com \
    --cc=hidehiro.kawai.ez@hitachi.com \
    --cc=javi.merino@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=linux@roeck-us.net \
    --cc=mhocko@kernel.org \
    --cc=mhocko@suse.com \
    --cc=minyard@acm.org \
    --cc=nicolas.iooss_linux@m4x.org \
    --cc=openipmi-developer@lists.sourceforge.net \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=thomas.mingarelli@hpe.com \
    --cc=tj@kernel.org \
    --cc=vkuznets@redhat.com \
    --cc=wim@iguana.be \
    /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.