From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> To: Andrew Morton <akpm@linux-foundation.org> Cc: Petr Mladek <pmladek@suse.com>, Jan Kara <jack@suse.cz>, Tejun Heo <tj@kernel.org>, Calvin Owens <calvinowens@fb.com>, Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@redhat.com>, Peter Zijlstra <peterz@infradead.org>, Andy Lutomirski <luto@kernel.org>, Linus Torvalds <torvalds@linux-foundation.org>, Peter Hurley <peter@hurleysoftware.com>, linux-kernel@vger.kernel.org, Sergey Senozhatsky <sergey.senozhatsky@gmail.com>, Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> Subject: [PATCHv6 0/7] printk: use printk_safe to handle printk() recursive calls Date: Wed, 21 Dec 2016 23:35:58 +0900 [thread overview] Message-ID: <20161221143605.2272-1-sergey.senozhatsky@gmail.com> (raw) Hello, This patch set extends a lock-less NMI per-cpu buffers idea to handle recursive printk() calls. The basic mechanism is pretty much the same -- at the beginning of a deadlock-prone section we switch to lock-less printk callback, and return back to a default printk implementation at the end; the messages are getting flushed to a logbuf buffer from a safer context. Deadlock scenarios that printk_safe can handle: a) printk recursion from logbuf_lock spin_lock section in printk() printk() raw_spin_lock(&logbuf_lock); WARN_ON(1); raw_spin_unlock(&logbuf_lock); b) printk from sem->lock spin_lock section printk() console_trylock() down_trylock() raw_spin_lock_irqsave(&sem->lock, flags); WARN_ON(1); raw_spin_unlock_irqrestore(&sem->lock, flags); c) printk from logbuf_lock spin_lock section in console_unlock() printk() console_unlock() raw_spin_lock(&logbuf_lock); WARN_ON(1); raw_spin_unlock(&logbuf_lock); d) printk from ->pi_lock from semaphore up printk() console_unlock() up() try_to_wake_up() raw_spin_lock_irqsave(&p->pi_lock, flags); WARN_ON(1); raw_spin_unlock_irqrestore(&p->pi_lock, flags); e) printk from console_cont_flush() /*and down the call chain */ printk() console_unlock() call_console_drivers() ... WARN_ON(1); v6: -- re-based -- addressed Petr's review (added comments; moved lost accounting to seq buf) v5: -- some style clean-ups and renamings (Petr) -- use deferred printk when flush nmi/safe messages (Petr) v4: -- addressed Steven's review points -- use printk_safe in console_cont_flush() v3: (review by Petr) -- renamed to printk_safe -- !NMI config build fix -- report lost messages for both printk_sae and printk_nmi -- dropped recursion reporting patch -- etc. v2: -- fix build error on !NMI configs, reported by Fengguang -- reworked the series based on Petr's feedback -- added a new patch to drop zap_locks() Sergey Senozhatsky (7): printk: use vprintk_func in vprintk() printk: rename nmi.c and exported api printk: introduce per-cpu safe_print seq buffer printk: always use deferred printk when flush printk_safe lines printk: report lost messages in printk safe/nmi contexts printk: use printk_safe buffers in printk printk: remove zap_locks() function arch/arm/kernel/smp.c | 4 +- include/linux/hardirq.h | 4 +- include/linux/printk.h | 29 +++-- init/Kconfig | 16 +-- init/main.c | 2 +- kernel/kexec_core.c | 2 +- kernel/panic.c | 4 +- kernel/printk/Makefile | 2 +- kernel/printk/internal.h | 63 +++++----- kernel/printk/printk.c | 116 +++++------------- kernel/printk/{nmi.c => printk_safe.c} | 216 +++++++++++++++++++++++---------- lib/nmi_backtrace.c | 2 +- 12 files changed, 245 insertions(+), 215 deletions(-) rename kernel/printk/{nmi.c => printk_safe.c} (53%) -- 2.11.0
next reply other threads:[~2016-12-21 14:36 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-12-21 14:35 Sergey Senozhatsky [this message] 2016-12-21 14:35 ` [PATCHv6 1/7] printk: use vprintk_func in vprintk() Sergey Senozhatsky 2016-12-21 14:36 ` [PATCHv6 2/7] printk: rename nmi.c and exported api Sergey Senozhatsky 2016-12-21 19:45 ` Linus Torvalds 2016-12-22 1:17 ` Sergey Senozhatsky 2016-12-21 14:36 ` [PATCHv6 3/7] printk: introduce per-cpu safe_print seq buffer Sergey Senozhatsky 2016-12-22 0:53 ` kbuild test robot 2016-12-22 1:18 ` Sergey Senozhatsky 2016-12-22 16:36 ` Petr Mladek 2016-12-21 14:36 ` [PATCHv6 4/7] printk: always use deferred printk when flush printk_safe lines Sergey Senozhatsky 2016-12-21 14:36 ` [PATCHv6 5/7] printk: report lost messages in printk safe/nmi contexts Sergey Senozhatsky 2016-12-23 10:54 ` Petr Mladek 2016-12-23 15:08 ` Sergey Senozhatsky 2016-12-21 14:36 ` [PATCHv6 6/7] printk: use printk_safe buffers in printk Sergey Senozhatsky 2016-12-22 5:31 ` Sergey Senozhatsky 2016-12-22 17:10 ` Petr Mladek 2016-12-23 1:46 ` Sergey Senozhatsky 2016-12-23 9:53 ` Petr Mladek 2016-12-21 14:36 ` [PATCHv6 7/7] printk: remove zap_locks() function Sergey Senozhatsky
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=20161221143605.2272-1-sergey.senozhatsky@gmail.com \ --to=sergey.senozhatsky@gmail.com \ --cc=akpm@linux-foundation.org \ --cc=calvinowens@fb.com \ --cc=jack@suse.cz \ --cc=linux-kernel@vger.kernel.org \ --cc=luto@kernel.org \ --cc=mingo@redhat.com \ --cc=peter@hurleysoftware.com \ --cc=peterz@infradead.org \ --cc=pmladek@suse.com \ --cc=rostedt@goodmis.org \ --cc=sergey.senozhatsky.work@gmail.com \ --cc=tj@kernel.org \ --cc=torvalds@linux-foundation.org \ --subject='Re: [PATCHv6 0/7] printk: use printk_safe to handle printk() recursive calls' \ /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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).