public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Qing Z <njumical@gmail.com>
Cc: mingo@kernel.org, ben@decadent.org.uk, markivx@codeaurora.org,
	ak@linux.intel.com, linux-kernel@vger.kernel.org,
	cxie4@marvell.com, binw@marvell.com, wwang27@marvell.com,
	xjian@marvell.com, zhangwm@marvell.com,
	Qing Zhu <qzhu@marvell.com>
Subject: Re: [PATCH] panic: fix incomplete panic log in panic()
Date: Wed, 17 Oct 2012 17:06:54 -0700	[thread overview]
Message-ID: <20121017170654.638e20bf.akpm@linux-foundation.org> (raw)
In-Reply-To: <CAE-am1OY8Tjv6a004-NfhEe1DXTGcFC6ogVAmtVdESW8sZ_R4w@mail.gmail.com>

On Wed, 17 Oct 2012 18:44:32 +0800
Qing Z <njumical@gmail.com> wrote:

>          In ./drivers/video/fbmem.c, codes below cause issues:
> 	
>                             case FBIOPAN_DISPLAY:
> 			...
> 			console_lock();
> 			ret = fb_pan_display(info, &var);
> 			console_unlock();
> 			...
> 			break;
> 
> issue case 1:
> 1. core 0 call console_lock();
> 2. panic;
> ...
> 4. panic process done.
> Result: all panic log won't be printed.
> 
> issue case 2:
> 1. core 0 panic;
> 2. core 1 call console_lock();
> 3. core 0 call smp_send_stop(), core1 stop;
> 4. core 0 panic process done.
> Result: only little top part of panic log will be printed.
> 
> My soluiton according to your suggestions:
> 
> As you said, the first priority is to get oops message reliably
> delivered. I think we needn't care about console_sem when panic, just
> make sure we print the log imediately, so add
> sema_init(&console_sem,1) in bust_spinlocks(0), just like zap_locks()
> do.  It is safer than console_unlock() or up().

hm, I see.

> We can't add sema_init(..) in bust_spinlocks(1) due to issue case2,
> although the condition is rare. About issue case 2: should we avoid
> call console_lock() when panic?

Well, I think we do have infrastructure to support that:

+	if (!oops_in_progress)
		console_lock();

I haven't looked to see how practical that approach would be.


It would be better if we were to do

	if (oops_in_progress)
		console_trylock();
	else
		console_lock();

where console_trylock() would *try* to do a console_lock() but would
bail out if it was unable to immediately take the lock.  This is better
because most of the time, the oopsing CPU *will* lock the console and
will prevent other code from getting into the console code and messing
things up.

A problem with this approach is that it is very hard to test - the
"console_trylock failed" case will be rare.


I think it would be acceptable to just skip over the console_lock() if
oops_in_progress is set.  And if we skipped the console_lock(), we
should also skip the console_unlock().  So something like:

	bool console_unlock_needed = true;

	if (unlikely(oops_in_progress))
		console_unlock_needed = false;
	else
		console_lock();

	...

	if (console_unlock_needed)
		console_unlock();


> If we init console_sem in panic, old text may be flushed too, but
> should be before panic oops message. Also we can fix it by updating
> con_start("con_start = log_end") once panic happen, only log after
> panic will be printed.

  reply	other threads:[~2012-10-18  0:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <BD54883EA7DE8B41A61B7E723561C711139F75D348@sc-vexch3.marvell.com>
2012-10-15 11:38 ` [PATCH] panic: fix incomplete panic log in panic() Qing Z
2012-10-15 22:02   ` Andrew Morton
2012-10-15 22:06     ` Andi Kleen
2012-10-16 14:25     ` Qing Z
2012-10-17 10:44     ` Qing Z
2012-10-18  0:06       ` Andrew Morton [this message]
2012-10-22 14:54         ` Qing Z
2012-10-22 19:51           ` Andrew Morton
2012-10-11  8:03 Qing Zhu
2012-10-11 21:18 ` Andrew Morton

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=20121017170654.638e20bf.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ak@linux.intel.com \
    --cc=ben@decadent.org.uk \
    --cc=binw@marvell.com \
    --cc=cxie4@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markivx@codeaurora.org \
    --cc=mingo@kernel.org \
    --cc=njumical@gmail.com \
    --cc=qzhu@marvell.com \
    --cc=wwang27@marvell.com \
    --cc=xjian@marvell.com \
    --cc=zhangwm@marvell.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox