linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Petr Mladek <pmladek@suse.com>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	linux-kernel@vger.kernel.org, Dmitry Safonov <dima@arista.com>,
	Michal Hocko <mhocko@suse.com>,
	Yafang Shao <laoar.shao@gmail.com>
Subject: Re: [PATCH] printk: Add loglevel for "do not print to consoles".
Date: Fri, 24 Apr 2020 11:42:25 -0400	[thread overview]
Message-ID: <20200424114225.5a3bab7e@gandalf.local.home> (raw)
In-Reply-To: <7ec0b0a3-39ae-0f1c-b8c2-e1e9e60f1223@i-love.sakura.ne.jp>

On Sat, 25 Apr 2020 00:28:53 +0900
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> wrote:

> On 2020/04/24 23:31, Steven Rostedt wrote:
> > On Fri, 24 Apr 2020 23:00:01 +0900
> > Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> wrote:
> >   
> >> Since KERN_NO_CONSOLES is for -ENOMEM situations (GFP_KERNEL allocation which
> >> can sleep needs to invoke the OOM killer, or GFP_ATOMIC allocation which cannot
> >> sleep has failed), we can't create buffer on demand. For process context, it
> >> would be possible to create buffer upon fork() time. But for atomic context,
> >> it is so difficult to create buffer on demand. We could allocate shared buffer
> >> like logbuf but it means that we have to replicate what printk() is doing (too
> >> much code), for when atomic memory allocation happens resembles when printk()
> >> is called. Borrowing printk()'s logbuf is simpler.  
> > 
> > I would have a buffer allocated for this at start up.  
> 
> Allocating global buffer itself is simple (except that it might waste a lot of
> memory). Difficult part is how to use the buffer.

I agree with Michal that this really should be a user setting (something on
the command line or sysctl - allocation at the time of decision).

> 
> > 
> > What exactly would you be "replicating" in printk?  
> 
> Making it possible to store into global buffer from almost any context (not only
> process context but also softirq/hardirq/NMI context (well, is memory allocation
>  from NMI context not permitted? I don't know... but future KERN_NO_CONSOLES
> users might want to call from NMI context)), notify userspace program of data
> readiness, and manage the buffer.

printk() was not safe in NMI context up until very recently.

You can also use the tracing ring buffer for this, as it has been safe in
all these contexts for a very long time. And that ring buffer is something
that you can use outside of tracing (oprofile uses it).


> 
> KERN_NO_CONSOLES does not need to call call_console_drivers(). But basically
> things what printk() is doing.
> 
> >                                                    The point of printk is
> > to print to a console, not to be a generic ring buffer. This change is
> > breaking printk's most useful feature.  
> 
> For those who analyze log files (instead of console output), the point of
> printk() is to save kernel messages into log files (via userspace syslog
> daemon).
> 
> By the way, I think
> 
>   printk(KERN_NO_CONSOLES "hello\n")
> 
> is almost same with doing
> 
>   saved_loglevel = console_loglevel;
>   console_loglevel = CONSOLE_LOGLEVEL_SILENT;
>   printk("hello\n");
>   console_loglevel = saved_loglevel;
> 
> used by vkdb_printf().

And both shouldn't be done within the kernel. The "CONSOLE_LOGLEVEL_SILENT"
if for user decided policy, not the kernel making that policy for the user.

-- Steve

  reply	other threads:[~2020-04-24 15:42 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24  2:42 [PATCH] printk: Add loglevel for "do not print to consoles" Tetsuo Handa
2020-04-24 13:28 ` Steven Rostedt
2020-04-24 14:00   ` Tetsuo Handa
2020-04-24 14:31     ` Steven Rostedt
2020-04-24 15:28       ` Tetsuo Handa
2020-04-24 15:42         ` Steven Rostedt [this message]
2020-04-24 15:52           ` Dmitry Safonov
2020-04-24 16:10           ` Tetsuo Handa
2020-04-24 16:21             ` Steven Rostedt
2020-04-24 16:34               ` Tetsuo Handa
2020-04-25  0:46 ` Sergey Senozhatsky
2020-04-25  1:07   ` Tetsuo Handa
2020-04-27  6:21     ` Sergey Senozhatsky
2020-04-28 11:33       ` Tetsuo Handa
2020-04-28 12:18         ` Michal Hocko
2020-04-28 13:11           ` Tetsuo Handa
2020-04-28 15:45             ` Michal Hocko
2020-04-28 16:23               ` Tetsuo Handa
2020-04-29 14:21                 ` Michal Hocko
2020-04-29 16:35                   ` Tetsuo Handa
2020-05-13  6:26                     ` Sergey Senozhatsky
2020-05-13  7:58                       ` Tetsuo Handa
2020-05-13 10:04                         ` Petr Mladek
2020-05-13 10:49                           ` Michal Hocko
2020-05-13 11:24                             ` Tetsuo Handa
2020-05-13 12:19                               ` Petr Mladek
2020-05-13 12:59                                 ` Tetsuo Handa
2020-05-14  8:00                                   ` Petr Mladek
2020-05-14 11:23                                     ` Tetsuo Handa
2020-05-14 16:26                                       ` Petr Mladek
2020-05-14 23:24                                         ` Tetsuo Handa
2020-05-13 11:03                           ` Tetsuo Handa
2020-05-13 12:34                             ` Petr Mladek
2020-05-13 13:46                             ` Steven Rostedt
2020-05-13 14:03                               ` Tetsuo Handa
2020-05-13 13:55                             ` Steven Rostedt
2020-05-13 15:20                               ` Tetsuo Handa
2020-05-06  9:45         ` Tetsuo Handa
2020-05-06 15:26           ` Joe Perches
2020-05-07  0:50             ` Tetsuo Handa
2020-05-07  1:02               ` Joe Perches
2020-05-07  5:13                 ` Tetsuo Handa
2020-05-07  5:30                   ` Joe Perches
2020-05-07  5:39                     ` Tetsuo Handa

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=20200424114225.5a3bab7e@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=dima@arista.com \
    --cc=laoar.shao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhocko@suse.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=pmladek@suse.com \
    --cc=sergey.senozhatsky@gmail.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).