mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Song Liu <song@kernel.org>
Cc: linux-kernel@vger.kernel.org, jiangshanlai@gmail.com,
	leitao@debian.org, pmladek@suse.com, kernel-team@meta.com,
	puranjay@kernel.org
Subject: Re: [PATCH] workqueue: Fix false positive stall reports
Date: Sat, 21 Mar 2026 08:27:59 -1000	[thread overview]
Message-ID: <ab7jL_RXpFuijf1M@slm.duckdns.org> (raw)
In-Reply-To: <20260320192332.1726079-1-song@kernel.org>

Hello,

On Fri, Mar 20, 2026 at 12:23:32PM -0700, Song Liu wrote:
> index b77119d71641..5b501ff1223a 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -7701,6 +7701,23 @@ static void wq_watchdog_timer_fn(struct timer_list *unused)
>  
>  		/* did we stall? */
>  		if (time_after(now, ts + thresh)) {
> +			unsigned long irq_flags;
> +
> +			raw_spin_lock_irqsave(&pool->lock, irq_flags);

Can you use guard() instead? I don't think we can just keep the lock in the
block.

> +			/*
> +			 * Recheck last_progress_ts with pool->lock, this
> +			 * eliminates false positive where we report wq
> +			 * stall for newly queued work.
> +			 */

And I think this deserves a bit more explanation. Can you move this comment
outside the block where /* did we stall? */ is and give the scenario where
it can go wrong w/o the locked check?

> +			pool_ts = READ_ONCE(pool->last_progress_ts);

pool->last_progress_ts is write protected by pool lock. No need for
READ_ONCE().

> +			if (time_after(pool_ts, touched))
> +				ts = pool_ts;
> +			else
> +				ts = touched;
> +			raw_spin_unlock_irqrestore(&pool->lock, irq_flags);
> +			if (!time_after(now, ts + thresh))
> +				continue;

Thanks.

-- 
tejun

  reply	other threads:[~2026-03-21 18:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 19:23 Song Liu
2026-03-21 18:27 ` Tejun Heo [this message]
2026-03-23  9:35 ` Breno Leitao

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=ab7jL_RXpFuijf1M@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=jiangshanlai@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=puranjay@kernel.org \
    --cc=song@kernel.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

Powered by JetHome