]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
printk: lock/unlock console only for new logbuf entries
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Tue, 2 Oct 2018 02:38:35 +0000 (11:38 +0900)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:21:14 +0000 (14:21 -0300)
commit65d3e3c4f24555131b61862bb8fe677d6a028558
treece37b13453f28c12afaa7ce8d813d612fe5c5fa7
parentf29508fcce42702e94c74a4dbbd5c0d35dbfbd0f
printk: lock/unlock console only for new logbuf entries

BugLink: https://bugs.launchpad.net/bugs/1854975
[ Upstream commit 3ac37a93fa9217e576bebfd4ba3e80edaaeb2289 ]

Prior to commit 5c2992ee7fd8a29 ("printk: remove console flushing special
cases for partial buffered lines") we would do console_cont_flush()
for each pr_cont() to print cont fragments, so console_unlock() would
actually print data:

pr_cont();
 console_lock();
 console_unlock()
  console_cont_flush(); // print cont fragment
...
pr_cont();
 console_lock();
 console_unlock()
  console_cont_flush(); // print cont fragment

We don't do console_cont_flush() anymore, so when we do pr_cont()
console_unlock() does nothing (unless we flushed the cont buffer):

pr_cont();
 console_lock();
 console_unlock();      // noop
...
pr_cont();
 console_lock();
 console_unlock();      // noop
...
pr_cont();
  cont_flush();
    console_lock();
    console_unlock();   // print data

We also wakeup klogd purposelessly for pr_cont() output - un-flushed
cont buffer is not stored in log_buf; there is nothing to pull.

Thus we can console_lock()/console_unlock()/wake_up_klogd() only when
we know that we log_store()-ed a message and there is something to
print to the consoles/syslog.

Link: http://lkml.kernel.org/r/20181002023836.4487-3-sergey.senozhatsky@gmail.com
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Tejun Heo <tj@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
kernel/printk/printk.c