From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Dmitriy Vyukov <dvyukov@google.com>,
Steven Rostedt <rostedt@goodmis.org>,
Alexander Potapenko <glider@google.com>,
Fengguang Wu <fengguang.wu@intel.com>,
Josh Poimboeuf <jpoimboe@redhat.com>,
LKML <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Will Deacon <will.deacon@arm.com>
Subject: Re: [PATCH 3/3] lockdep: Use line-buffered printk() for lockdep messages.
Date: Thu, 8 Nov 2018 13:45:10 +0900 [thread overview]
Message-ID: <20181108044510.GC2343@jagdpanzerIV> (raw)
In-Reply-To: <20181107151900.gxmdvx42qeanpoah@pathway.suse.cz>
On (11/07/18 16:19), Petr Mladek wrote:
> > syzbot is sometimes getting mixed output like below due to concurrent
> > printk(). Mitigate such output by using line-buffered printk() API.
> >
> > @@ -2421,18 +2458,20 @@ static void check_chain_key(struct task_struct *curr)
> > print_usage_bug_scenario(struct held_lock *lock)
> > {
> > struct lock_class *class = hlock_class(lock);
> > + struct printk_buffer *buf = get_printk_buffer();
> >
> > printk(" Possible unsafe locking scenario:\n\n");
> > printk(" CPU0\n");
> > printk(" ----\n");
> > - printk(" lock(");
> > - __print_lock_name(class);
> > - printk(KERN_CONT ");\n");
> > + printk_buffered(buf, " lock(");
> > + __print_lock_name(class, buf);
> > + printk_buffered(buf, ");\n");
> > printk(" <Interrupt>\n");
> > - printk(" lock(");
> > - __print_lock_name(class);
> > - printk(KERN_CONT ");\n");
> > + printk_buffered(buf, " lock(");
> > + __print_lock_name(class, buf);
> > + printk_buffered(buf, ");\n");
> > printk("\n *** DEADLOCK ***\n\n");
> > + put_printk_buffer(buf);
> > }
> >
> > static int
>
> I really hope that the maze of pr_cont() calls in lockdep.c is the most
> complicated one that we would meet.
Hmm... Yes, buffered/seq_buf printk looks like a hard-to-use API,
when it comes to real world cases like this.
So... here is a random and wild idea.
We actually already have an easy-to-use buffered printk. And it's per-CPU.
And it makes all printk-s on this CPU to behave like as if they were called
on UP system. And it cures pr_cont(). And it doesn't require anyone to learn
any new printk API names. And it doesn't require any additional maintenance
work. And it doesn't require any printk->buffered_printk conversions. And
it's already in the kernel. And we gave it a name. And it's printk_safe.
a) lockdep reporting path should be atomic. And it's not a hot path,
so local_irq_save/local_irq_restore will not cause a lot of trouble
there probably.
b) We already have some lockdep reports coming via printk_safe.
All those
printk->console_driver->scheduler->lockdep
printk->console_driver->timekeeping->lockdep
etc.
came via printk_safe path. So it's not a complete novelty.
c) printk_safe sections can nest.
d) No premature flushes. Everything looks the way it was supposed to
look.
e) There are no out-of-line printk-s. We keep the actual order of events.
f) We flush it on panic.
g) Low maintenance costs.
So, can we just do the following? /* a sketch */
lockdep.c
printk_safe_enter_irqsave(flags);
lockdep_report();
printk_safe_exit_irqrestore(flags);
-ss
next prev parent reply other threads:[~2018-11-08 4:45 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-02 13:31 [PATCH v6 1/3] printk: Add line-buffered printk() API Tetsuo Handa
2018-11-02 13:31 ` [PATCH 2/3] mm: Use line-buffered printk() for show_free_areas() Tetsuo Handa
2018-11-07 14:07 ` Petr Mladek
2018-11-02 13:31 ` [PATCH 3/3] lockdep: Use line-buffered printk() for lockdep messages Tetsuo Handa
2018-11-02 13:36 ` Peter Zijlstra
2018-11-03 2:00 ` Tetsuo Handa
2018-11-06 8:38 ` Petr Mladek
2018-11-06 9:05 ` Sergey Senozhatsky
2018-11-06 12:57 ` Petr Mladek
2018-11-06 9:56 ` Tetsuo Handa
2018-11-07 15:19 ` Petr Mladek
2018-11-08 4:45 ` Sergey Senozhatsky [this message]
2018-11-08 11:37 ` Tetsuo Handa
2018-11-09 6:12 ` Sergey Senozhatsky
2018-11-09 9:55 ` Tetsuo Handa
2018-11-09 15:43 ` Petr Mladek
2018-11-10 2:42 ` Tetsuo Handa
2018-11-23 12:46 ` Petr Mladek
2018-11-23 13:12 ` Tetsuo Handa
2018-11-23 15:56 ` Steven Rostedt
2018-11-24 0:24 ` Tetsuo Handa
2018-11-26 4:34 ` Sergey Senozhatsky
2018-11-28 13:29 ` David Laight
2018-11-29 10:09 ` Tetsuo Handa
2018-11-30 16:01 ` Petr Mladek
2018-11-10 8:52 ` Tetsuo Handa
2018-11-23 12:52 ` Petr Mladek
2018-11-09 14:08 ` Linus Torvalds
2018-11-09 14:42 ` Steven Rostedt
2018-11-08 11:53 ` Petr Mladek
2018-11-08 12:44 ` Sergey Senozhatsky
2018-11-08 14:21 ` Sergey Senozhatsky
2018-11-09 9:54 ` Tetsuo Handa
2018-11-02 14:40 ` [PATCH v6 1/3] printk: Add line-buffered printk() API Matthew Wilcox
2018-11-03 1:55 ` Tetsuo Handa
2018-11-02 18:12 ` kbuild test robot
2018-11-06 14:35 ` Sergey Senozhatsky
2018-11-07 10:21 ` Petr Mladek
2018-11-07 12:54 ` Tetsuo Handa
2018-11-08 2:21 ` Sergey Senozhatsky
2018-11-08 11:24 ` Petr Mladek
2018-11-08 11:46 ` Tetsuo Handa
2018-11-08 12:30 ` Sergey Senozhatsky
2018-11-09 14:10 ` Petr Mladek
2018-11-12 7:59 ` Sergey Senozhatsky
2018-11-12 10:42 ` Tetsuo Handa
2018-11-17 10:14 ` Tetsuo Handa
2018-11-07 10:52 ` Tetsuo Handa
2018-11-07 11:01 ` David Laight
2018-11-07 12:00 ` Petr Mladek
2018-11-07 11:45 ` Petr Mladek
2018-11-08 2:30 ` Sergey Senozhatsky
2018-11-07 13:41 ` Petr Mladek
2018-11-07 14:06 ` Petr Mladek
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=20181108044510.GC2343@jagdpanzerIV \
--to=sergey.senozhatsky.work@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dvyukov@google.com \
--cc=fengguang.wu@intel.com \
--cc=glider@google.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@redhat.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=torvalds@linux-foundation.org \
--cc=will.deacon@arm.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;
as well as URLs for NNTP newsgroup(s).