From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: "Liu, Chuansheng" <chuansheng.liu@intel.com>
Cc: "'linux-kernel@vger.kernel.org' (linux-kernel@vger.kernel.org)"
<linux-kernel@vger.kernel.org>, "kay@vrfy.org" <kay@vrfy.org>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"mingo@elte.hu" <mingo@elte.hu>
Subject: Re: [PATCH] printk: fixing the deadlock when calling printk in nmi handle
Date: Wed, 04 Jul 2012 15:22:49 +0200 [thread overview]
Message-ID: <1341408169.2507.111.camel@laptop> (raw)
In-Reply-To: <27240C0AC20F114CBF8149A2696CBE4A10C7F6@SHSMSX101.ccr.corp.intel.com>
On Wed, 2012-07-04 at 13:00 +0000, Liu, Chuansheng wrote:
> From: liu chuansheng <chuansheng.liu@intel.com>
> Subject: [PATCH] printk: fixing the deadlock when calling printk in nmi handle
>
> Current printk implementation can not fully support that
> calling it in nmi handler for SMP arch.
>
> There is typical case in nmi handler function arch_trigger_all_cpu_backtrace_handler().
>
> In my platform, there are 2 CPUs, when function arch_trigger_all_cpu_backtrace()
> is called, 2 CPUs will recevied the nmi interrupts, and the
> arch_trigger_all_cpu_backtrace_handler() will called on 2 CPUs:
>
> case1:
> CPU0 CPU1
> calling arch_trigger_all_cpu_backtrace() calling printk, and has obtain the logbuf_lock
> nmi interrupt received nmi interrupt received
> call arch_trigger_all_cpu_backtrace_handler() call arch_trigger_all_cpu_backtrace_handler()
> Obtain arch_spin_lock(&lock); Waiting for arch_spin_lock(&lock);
> Continue to call printk()
> CPU0 will be blocked by logbuf_lock CPU1 is blocked by arch_spin_lock(&lock)
>
> The deadlock will be happening.
>
> case2:
> CPU0 CPU1:(run dmesg command)
> calling arch_trigger_all_cpu_backtrace() calling do_syslog
> Obtaining the logbuf_lock
> nmi interrupt received nmi interrupt received
> ....
> The dealock will happen also somtimes.
>
> I just write a simple interface to run the arch_trigger_all_cpu_backtrace_handler() every 5s,
> it will trigger dead lock many times.
>
> The solution is when printk is called in nmi handler, we will use trylock instead of lock.
> And in nmi handler, do the call the console write function because normal console write function
> include many spin locks also. This fix can confirm the traces in nmi handler can be output successfully
> almost.
>
> Signed-off-by: liu chuansheng <chuansheng.liu@intel.com>
Yuck.. and no. This makes sane things like early 8250 serial console
less reliable.
next prev parent reply other threads:[~2012-07-04 13:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-04 13:00 [PATCH] printk: fixing the deadlock when calling printk in nmi handle Liu, Chuansheng
2012-07-04 13:22 ` Peter Zijlstra [this message]
2012-07-04 13:30 ` Liu, Chuansheng
2012-07-04 13:39 ` Peter Zijlstra
2012-07-04 14:09 ` Peter Zijlstra
2012-07-04 14:12 ` Peter Zijlstra
2012-07-04 14:18 ` Liu, Chuansheng
2012-07-04 14:46 ` Liu, Chuansheng
2012-07-04 14:50 ` Peter Zijlstra
2012-07-04 14:52 ` Peter Zijlstra
2012-07-04 15:06 ` Liu, Chuansheng
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=1341408169.2507.111.camel@laptop \
--to=a.p.zijlstra@chello.nl \
--cc=chuansheng.liu@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=kay@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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