Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1430788 > unrolled thread

Re: [PATCH] printk: introduce should_ignore_loglevel()

Started byPetr Mladek <pmladek@suse.com>
First post2016-06-24 18:10 +0200
Last post2016-06-27 15:10 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] printk: introduce should_ignore_loglevel() Petr Mladek <pmladek@suse.com> - 2016-06-24 18:10 +0200
    Re: [PATCH] printk: introduce should_ignore_loglevel() Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-06-25 07:30 +0200
      Re: [PATCH] printk: introduce should_ignore_loglevel() Petr Mladek <pmladek@suse.com> - 2016-06-27 11:30 +0200
        Re: [PATCH] printk: introduce should_ignore_loglevel() Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-06-27 15:10 +0200

#1430788 — Re: [PATCH] printk: introduce should_ignore_loglevel()

FromPetr Mladek <pmladek@suse.com>
Date2016-06-24 18:10 +0200
SubjectRe: [PATCH] printk: introduce should_ignore_loglevel()
Message-ID<rNBQ5-1SP-1@gated-at.bofh.it>
On Fri 2016-06-24 01:33:02, Sergey Senozhatsky wrote:
> The thing here is this deferred `level >= console_loglevel' check. We are
> wasting CPU cycles on sprintfs/memcpy/etc. preparing the messages that we
> will eventually drop.
> 
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> ---
>  kernel/printk/printk.c | 25 +++++++++++++++++++------
>  1 file changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 414a89f..bfb766b 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -987,6 +987,11 @@ module_param(ignore_loglevel, bool, S_IRUGO | S_IWUSR);
>  MODULE_PARM_DESC(ignore_loglevel,
>  		 "ignore loglevel setting (prints all kernel messages to the console)");
>  
> +static bool should_ignore_loglevel(int level)
> +{
> +	return (level >= console_loglevel && !ignore_loglevel);

The patch looks fine. It is nice optimization.

I was just quite confused by the name of this function. A function
called should_ignore_loglevel() should not return false when
ignore_loglevel variable is true.

I would call it ignore_message() or ignore_message_on_console() or so.

Best Regards,
Petr

[toc] | [next] | [standalone]


#1431069

FromSergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Date2016-06-25 07:30 +0200
Message-ID<rNOkh-1qB-1@gated-at.bofh.it>
In reply to#1430788
On (06/24/16 18:05), Petr Mladek wrote:
[..]
> > +static bool should_ignore_loglevel(int level)
> > +{
> > +	return (level >= console_loglevel && !ignore_loglevel);
> 
> The patch looks fine. It is nice optimization.
> 
> I was just quite confused by the name of this function. A function
> called should_ignore_loglevel() should not return false when
> ignore_loglevel variable is true.
> 
> I would call it ignore_message() or ignore_message_on_console() or so.

Hello Petr, you are right.

I was thinking about

s/should_ignore_loglevel/suppress_message/g
or.... s/should_ignore_loglevel/suppress_message_by_level/g
s/should_ignore_loglevel/suppress_message_printing/g

suppress_message_printing() is probably fine.

will it work for you guys?

	-ss

[toc] | [prev] | [next] | [standalone]


#1431858

FromPetr Mladek <pmladek@suse.com>
Date2016-06-27 11:30 +0200
Message-ID<rOB1E-6Kn-19@gated-at.bofh.it>
In reply to#1431069
On Sat 2016-06-25 14:22:37, Sergey Senozhatsky wrote:
> On (06/24/16 18:05), Petr Mladek wrote:
> [..]
> > > +static bool should_ignore_loglevel(int level)
> > > +{
> > > +	return (level >= console_loglevel && !ignore_loglevel);
> > 
> > The patch looks fine. It is nice optimization.
> > 
> > I was just quite confused by the name of this function. A function
> > called should_ignore_loglevel() should not return false when
> > ignore_loglevel variable is true.
> > 
> > I would call it ignore_message() or ignore_message_on_console() or so.
> 
> Hello Petr, you are right.
> 
> I was thinking about
> 
> s/should_ignore_loglevel/suppress_message/g
> or.... s/should_ignore_loglevel/suppress_message_by_level/g
> s/should_ignore_loglevel/suppress_message_printing/g
> 
> suppress_message_printing() is probably fine.

All variants look fine to me. After renaming, feel free to
add:

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr


PS: The ignore_loglevel handling is a bit racy in some situations.
For example, uv_nmi_dump_state() or __handle_sysrq() set another
level, print some messages, and restore the original level. They
do not wait until all the printed messages appear on the console.
Also they do not synchronize against each other.

I am not sure if we have already discussed this. It is not critical
and it works well most of the time. I just want to make sure that
you know about it as you have more plans with the printk/console code.

[toc] | [prev] | [next] | [standalone]


#1432020

FromSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Date2016-06-27 15:10 +0200
Message-ID<rOEsy-DU-35@gated-at.bofh.it>
In reply to#1431858
On (06/27/16 11:26), Petr Mladek wrote:
> On Sat 2016-06-25 14:22:37, Sergey Senozhatsky wrote:
> > On (06/24/16 18:05), Petr Mladek wrote:
> > [..]
> > > > +static bool should_ignore_loglevel(int level)
> > > > +{
> > > > +	return (level >= console_loglevel && !ignore_loglevel);
> > > 
> > > The patch looks fine. It is nice optimization.
> > > 
> > > I was just quite confused by the name of this function. A function
> > > called should_ignore_loglevel() should not return false when
> > > ignore_loglevel variable is true.
> > > 
> > > I would call it ignore_message() or ignore_message_on_console() or so.
> > 
> > Hello Petr, you are right.
> > 
> > I was thinking about
> > 
> > s/should_ignore_loglevel/suppress_message/g
> > or.... s/should_ignore_loglevel/suppress_message_by_level/g
> > s/should_ignore_loglevel/suppress_message_printing/g
> > 
> > suppress_message_printing() is probably fine.
> 
> All variants look fine to me. After renaming, feel free to
> add:
> 
> Reviewed-by: Petr Mladek <pmladek@suse.com>
> 

thanks.

> PS: The ignore_loglevel handling is a bit racy in some situations.
> For example, uv_nmi_dump_state() or __handle_sysrq() set another
> level, print some messages, and restore the original level. They
> do not wait until all the printed messages appear on the console.
> Also they do not synchronize against each other.
>

__handle_sysrq() also assumes that only cpu printk-s, so it does
KERN_CONT printks in SMP mode. and there are billions of places
that do things like this.

as of deferred loglevel check, we probably can add "console_loglevel:3;"
to 'struct printk_log' and `static struct cont', and keep there
console_loglevel actual at the time the was appeneded to the log
buffer. so then suppress_message_printing() will have one extra param

bool suppress_message_printing(int leve, int cons_loglevel)
{
	return (level >= cons_loglevel ...);
}


speaking of KERN_CONT, I've found one regression with async printk,
and I think I now have some idea what's going on there, will post
some-sort-of-a-patch today or tomorrow.


> I am not sure if we have already discussed this. It is not critical
> and it works well most of the time. I just want to make sure that
> you know about it as you have more plans with the printk/console code.

thanks, I'll put in on a list; not sure we discussed this either.

	-ss

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web