mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marcos Paulo de Souza <mpdesouza@suse.com>
To: John Ogness <john.ogness@linutronix.de>, Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Sergey Senozhatsky	 <senozhatsky@chromium.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Jiri Slaby <jirislaby@kernel.org>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH 1/2] printk: Introduce LOUD_CON flag
Date: Wed, 23 Oct 2024 17:36:04 -0300	[thread overview]
Message-ID: <533f6a578d8489c1107ba83ce1e49b6e2d5c84ce.camel@suse.com> (raw)
In-Reply-To: <8434kpfsvr.fsf@jogness.linutronix.de>

On Mon, 2024-10-21 at 16:17 +0206, John Ogness wrote:
> On 2024-10-21, Petr Mladek <pmladek@suse.com> wrote:
> > > That will not work because migrate_enable() can only be called
> > > from
> > > can_sleep context. Instead, the migrate_disable()/enable() should
> > > be at
> > > the few (one?) call sites where
> > > printk_loud_console_enter()/exit() is
> > > used from task context.
> > 
> > Hmm, if I get it correctly, we could not use migrate_disable() in
> > __handle_sysrq() because it can be called also in atomic context,
> 
> I am talking about callers of __handle_sysrq() and/or their callers.
> 
> For example write_sysrq_trigger() could do:
> 
> 	migrate_disable();
> 	__handle_sysrq(c, false);
> 	migrate_enable();
> 
> Or a new wrapper could be introduced for this purpose:
> 
> static inline void wrapper handle_sysrq_task(u8 key, bool check_mask)
> {
> 	migrate_disable();
> 	__handle_sysrq(key, check_mask);
> 	migrate_enable();
> }
> 
> A quick grep shows about 25 call sites to check.
> 
> > I do not see any easy way how to distinguish whether it was called
> > in
> > an atomic context or not.
> 
> There is no clean way to do that. If this information is needed, it
> must
> be tracked by the call chain.
> 
> > So, I see three possibilities:
> > 
> >   1. Explicitly call preempt_disable() in __handle_sysrq().
> > 
> >      It would be just around the the single line or the help. But
> > still,
> >      I do not like it much.
> 
> Not acceptable for PREEMPT_RT since sysrq is exposed to external
> inputs.
> 
> >   2. Avoid the per-CPU variable. Force adding the
> > LOUD_CON/FORCE_CON
> >      flag using a global variable, e.g. printk_force_console.
> > 
> >      The problem is that it might affect also messages printed by
> >      other CPUs. And there might be many.
> > 
> >      Well, console_loglevel is a global variable. The original code
> >      had a similar problem.
> 
> If disabling migration is not an option for you, this would be my
> second
> choice. I assume tagging too many messages is better than not tagging
> enough. And, as you say, this is effectively what the current code is
> trying to do.

Thanks for your input John. I talked with Petr and he suggested to
follow this option. I'll prepare the changes and send them after
reviewing them with Petr.

Thanks,
  Marcos

> 
> >   3. Add the LOUD_CON/FLUSH_CON flag via a parameter. For example,
> >      by a special LOGLEVEL_FORCE_CON, similar to LOGLEVEL_SCHED.
> > 
> >      I might work well for __handle_sysrq() which calls the
> > affected
> >      printk() directly.
> > 
> >      But it won't work, for example, for kdb_show_stack(). It wants
> >      to show messages printed by a nested functions.
> 
> Right, this has limited usefulness and might miss the important
> things,
> which tend to be within helper functions.
> 
> John


  reply	other threads:[~2024-10-23 20:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-16 17:03 [PATCH 0/2] printk: Add loud_console printk flag to not suppress sysrq header msgs Marcos Paulo de Souza
2024-10-16 17:03 ` [PATCH 1/2] printk: Introduce LOUD_CON flag Marcos Paulo de Souza
2024-10-16 18:11   ` John Ogness
2024-10-17 10:24     ` Petr Mladek
2024-10-18  7:14       ` John Ogness
2024-10-21 13:33         ` Petr Mladek
2024-10-21 14:11           ` John Ogness
2024-10-23 20:36             ` Marcos Paulo de Souza [this message]
2024-10-24  8:34               ` Petr Mladek
2024-10-18 12:11     ` Marcos Paulo de Souza
2024-10-19  1:28   ` kernel test robot
2024-10-16 17:03 ` [PATCH 2/2] tty: sysrq: Use printk_loud_console context on __handle_sysrq Marcos Paulo de Souza
2024-10-18  3:43   ` kernel test robot
2024-10-18  4:36   ` kernel test robot

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=533f6a578d8489c1107ba83ce1e49b6e2d5c84ce.camel@suse.com \
    --to=mpdesouza@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    /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

all inboxes | Powered by JetHome®