Re: [PATCH v3 2/3] printk: Fix preferred console selection with multiple matches

From: Benjamin Herrenschmidt
Date: Tue Feb 11 2020 - 10:34:09 EST


On Tue, 2020-02-11 at 15:41 +0100, Petr Mladek wrote:
>
> > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> > index 17602d7b7ffc..5cf47a7b880c 100644
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -2674,8 +2679,13 @@ static int try_enable_new_console(struct console *newcon)
> > /*
> > * Some consoles, such as pstore and netconsole, can be enabled even
> > * without matching.
> > + *
> > + * Note: We only do this test on the !user_specified pass so that such
> > + * a statically enabled console that isn't user specified gets a chance
> > + * to have its match() or setup() function called on our second pass
> > + * through this function.
>
> I had some troubles to part the comment. I wonder if the following is
> more clear:
>
> * Accept pre-enabled consoles only when match() and setup()
> * was called.

Yeah the sentence is a bit convoluted, I agree. As for the fix, see
below

> And I would do the same check as in the for cycle:
>
> if (newcon->flags & CON_ENABLED && c->user_specified == user_specified)
> return 0;

Fair enough, this is simpler.

> With the above change:
>
> Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
>
> I could do the change when pushing if you agree and v4 is not needed
> for other reasons.

Of course. I'm travelling this week (which is why I somewhat rushed
sending you the patches last week, hence the glitches you noted), so I
won't have a chance to repost until sometime next week.

>
> PS: JFYI, I am going to look at the 3rd patch tomorrow. I have to go now.

No worries. It's not super important, it's a minor thing I noticed
while testing (when I artifically make my consoles not match to test
the "default" fallback). It's not directly related to the fix in patch
2, but is completely standlaone.

Cheers,
Ben.