All of lore.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: holzheu@linux.vnet.ibm.com
Cc: kexec@lists.infradead.org, heiko.carstens@de.ibm.com,
	linux-kernel@vger.kernel.org, schwidefsky@de.ibm.com,
	"Américo Wang" <xiyou.wangcong@gmail.com>,
	akpm@linux-foundation.org, "Vivek Goyal" <vgoyal@redhat.com>
Subject: Re: kdump: crash_kexec()-smp_send_stop() race in panic
Date: Tue, 25 Oct 2011 05:04:57 -0700	[thread overview]
Message-ID: <m17h3tcm52.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <1319532245.3056.5.camel@br98xy6r> (Michael Holzheu's message of "Tue, 25 Oct 2011 10:44:05 +0200")

Michael Holzheu <holzheu@linux.vnet.ibm.com> writes:

> Hello Eric,
>
> On Mon, 2011-10-24 at 10:07 -0700, Eric W. Biederman wrote:
>
> [snip]
>
>> So my second thought is to introduce another atomic variable
>> panic_in_progress, visible only in panic.  The cpu that sets
>> increments panic_in_progress can call smp_send_stop.  The rest of
>> the cpus can just go into a busy wait.  That should stop nasty
>> fights about who is going to come out of smp_send_stop first.
>
> So this is a spinlock, no? What about the following patch:
Do we want both panic printks?

We really only need the mutual exclusion starting just before
smp_send_stop so that is where I would be inclined to put it.

But yeah something like the below should work.

Eric


> ---
>  kernel/panic.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -59,6 +59,7 @@ EXPORT_SYMBOL(panic_blink);
>   */
>  NORET_TYPE void panic(const char * fmt, ...)
>  {
> +	static DEFINE_SPINLOCK(panic_lock);
>  	static char buf[1024];
>  	va_list args;
>  	long i, i_next = 0;
> @@ -68,8 +69,12 @@ NORET_TYPE void panic(const char * fmt,
>  	 * It's possible to come here directly from a panic-assertion and
>  	 * not have preempt disabled. Some functions called from here want
>  	 * preempt to be disabled. No point enabling it later though...
> +	 *
> +	 * Only one CPU is allowed to execute the panic code. For multiple
> +	 * parallel invocations of panic all other CPUs will wait on the
> +	 * panic_lock. They are stopped afterwards by smp_send_stop().
>  	 */
> -	preempt_disable();
> +	spin_lock(&panic_lock);
>  
>  	console_verbose();
>  	bust_spinlocks(1);

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

WARNING: multiple messages have this Message-ID (diff)
From: ebiederm@xmission.com (Eric W. Biederman)
To: holzheu@linux.vnet.ibm.com
Cc: "Américo Wang" <xiyou.wangcong@gmail.com>,
	"Vivek Goyal" <vgoyal@redhat.com>,
	akpm@linux-foundation.org, schwidefsky@de.ibm.com,
	heiko.carstens@de.ibm.com, kexec@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: kdump: crash_kexec()-smp_send_stop() race in panic
Date: Tue, 25 Oct 2011 05:04:57 -0700	[thread overview]
Message-ID: <m17h3tcm52.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <1319532245.3056.5.camel@br98xy6r> (Michael Holzheu's message of "Tue, 25 Oct 2011 10:44:05 +0200")

Michael Holzheu <holzheu@linux.vnet.ibm.com> writes:

> Hello Eric,
>
> On Mon, 2011-10-24 at 10:07 -0700, Eric W. Biederman wrote:
>
> [snip]
>
>> So my second thought is to introduce another atomic variable
>> panic_in_progress, visible only in panic.  The cpu that sets
>> increments panic_in_progress can call smp_send_stop.  The rest of
>> the cpus can just go into a busy wait.  That should stop nasty
>> fights about who is going to come out of smp_send_stop first.
>
> So this is a spinlock, no? What about the following patch:
Do we want both panic printks?

We really only need the mutual exclusion starting just before
smp_send_stop so that is where I would be inclined to put it.

But yeah something like the below should work.

Eric


> ---
>  kernel/panic.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -59,6 +59,7 @@ EXPORT_SYMBOL(panic_blink);
>   */
>  NORET_TYPE void panic(const char * fmt, ...)
>  {
> +	static DEFINE_SPINLOCK(panic_lock);
>  	static char buf[1024];
>  	va_list args;
>  	long i, i_next = 0;
> @@ -68,8 +69,12 @@ NORET_TYPE void panic(const char * fmt,
>  	 * It's possible to come here directly from a panic-assertion and
>  	 * not have preempt disabled. Some functions called from here want
>  	 * preempt to be disabled. No point enabling it later though...
> +	 *
> +	 * Only one CPU is allowed to execute the panic code. For multiple
> +	 * parallel invocations of panic all other CPUs will wait on the
> +	 * panic_lock. They are stopped afterwards by smp_send_stop().
>  	 */
> -	preempt_disable();
> +	spin_lock(&panic_lock);
>  
>  	console_verbose();
>  	bust_spinlocks(1);

  reply	other threads:[~2011-10-25 12:04 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-24 14:55 kdump: crash_kexec()-smp_send_stop() race in panic Michael Holzheu
2011-10-24 14:55 ` Michael Holzheu
2011-10-24 15:14 ` Eric W. Biederman
2011-10-24 15:14   ` Eric W. Biederman
2011-10-24 15:23   ` Américo Wang
2011-10-24 15:23     ` Américo Wang
2011-10-24 17:07     ` Eric W. Biederman
2011-10-24 17:07       ` Eric W. Biederman
2011-10-24 17:33       ` Vivek Goyal
2011-10-24 17:33         ` Vivek Goyal
2011-10-24 22:24         ` Seiji Aguchi
2011-10-24 22:24           ` Seiji Aguchi
2011-10-25  8:33           ` Michael Holzheu
2011-10-25  8:33             ` Michael Holzheu
2011-10-25  8:44       ` Michael Holzheu
2011-10-25  8:44         ` Michael Holzheu
2011-10-25 12:04         ` Eric W. Biederman [this message]
2011-10-25 12:04           ` Eric W. Biederman
2011-10-25 14:54           ` Vivek Goyal
2011-10-25 14:54             ` Vivek Goyal
2011-10-25 14:58           ` Michael Holzheu
2011-10-25 14:58             ` Michael Holzheu
2011-10-25 15:08             ` Vivek Goyal
2011-10-25 15:08               ` Vivek Goyal
2011-10-25 15:28               ` Michael Holzheu
2011-10-25 15:28                 ` Michael Holzheu
2011-10-25 15:28               ` Don Zickus
2011-10-25 15:28                 ` 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=m17h3tcm52.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=akpm@linux-foundation.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=holzheu@linux.vnet.ibm.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=vgoyal@redhat.com \
    --cc=xiyou.wangcong@gmail.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: 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.