All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: John Ogness <john.ogness@linutronix.de>,
	linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: Re: [PATCH v2] printk: Use two irq_works instead per-CPU
Date: Wed, 23 Sep 2026 14:16:25 +0200	[thread overview]
Message-ID: <arPDGWWeBEb1b3vW@pathway.suse.cz> (raw)
In-Reply-To: <20260923075512.SBaoMRXt@linutronix.de>

On Wed 2026-09-23 09:55:12, Sebastian Andrzej Siewior wrote:
> On 2026-09-22 19:35:26 [+0200], John Ogness wrote:
> > > @@ -4643,12 +4637,11 @@ static void __wake_up_klogd(int val)
> > >  	 *
> > >  	 * This pairs with devkmsg_read:A and syslog_print:A.
> > >  	 */
> > > -	if (wq_has_sleeper(&log_wait) || /* LMM(__wake_up_klogd:A) */
> > > -	    (val & PRINTK_PENDING_OUTPUT)) {
> > > -		this_cpu_or(printk_pending, val);
> > > -		irq_work_queue(this_cpu_ptr(&wake_up_klogd_work));
> > > -	}
> > > -	preempt_enable();
> > > +	if (wq_has_sleeper(&log_wait)) /* LMM(__wake_up_klogd:A) */
> > > +		irq_work_queue(&pending_wakeup_work);
> > > +
> > > +	if (val & PRINTK_PENDING_OUTPUT)
> > > +		irq_work_queue(&pending_output_work);
> > 
> > The ordering of operations has been reverse queued. Perhaps because
> > irq_work is LIFO (implementation internal detail) and you wanted to
> > preserve the current ordering?

Great catch.

> > Or maybe this ordering was chosen because
> > the code looks nicer. Either way, I think it doesn't matter if the
> > legacy flushing occurs before/after waking the klogd waiter.
> 
> Hmm. I did not give much thinking into the ordering because it shouldn't
> matter. We used to have "unlock" followed by "wakeup" in the irq-work
> callback and this is what we have now given the LIFO ordering.
> Having "wakeup" first might not take effect immediately because the
> scheduler delays it or puts it on the current CPU and then it is delayed
> until after the interrupt ("unlock") is done. So…

Honestly, I am not sure what ordering is better. And it depends on
the internal irq_work implementation now. I would keep the patch
as is.

Best Regards,
Petr

  reply	other threads:[~2026-09-23 12:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 14:34 [PATCH v2] printk: Use two irq_works instead per-CPU Sebastian Andrzej Siewior
2026-09-22  7:08 ` Sebastian Andrzej Siewior
2026-09-22  9:29   ` Petr Mladek
2026-09-22 13:18     ` John Ogness
2026-09-22 10:02 ` Petr Mladek
2026-09-22 10:06   ` Sebastian Andrzej Siewior
2026-09-22 17:35 ` John Ogness
2026-09-23  7:55   ` Sebastian Andrzej Siewior
2026-09-23 12:16     ` Petr Mladek [this message]
2026-09-29 15:11 ` Petr Mladek

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=arPDGWWeBEb1b3vW@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=bigeasy@linutronix.de \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.