mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jiayuan Chen" <jiayuan.chen@linux.dev>
To: "Tejun Heo" <tj@kernel.org>
Cc: linux-kernel@vger.kernel.org, mrpre@163.com, mkoutny@suse.com,
	syzbot+01affb1491750534256d@syzkaller.appspotmail.com,
	"Lai Jiangshan" <jiangshanlai@gmail.com>
Subject: Re: [PATCH v1] workqueue: annotate data-races around pwq->stats
Date: Wed, 23 Apr 2025 15:48:14 +0000	[thread overview]
Message-ID: <a89746d8897c81ed6e55c99d8ba71223ef3e318c@linux.dev> (raw)
In-Reply-To: <aAkHrjU22pCSkWif@slm.duckdns.org>

April 23, 2025 at 23:30, "Tejun Heo" <tj@kernel.org> wrote:



> 
> On Wed, Apr 23, 2025 at 08:53:41PM +0800, Jiayuan Chen wrote:
> 
> > 
> > Suppress warning by annotating these accesses using
> > 
> >  READ_ONCE() / WRITE_ONCE().
> > 
> >  
> > 
> >  Reported-by: syzbot+01affb1491750534256d@syzkaller.appspotmail.com
> > 
> >  Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
> > 
> >  ---
> > 
> >  kernel/workqueue.c | 2 +-
> > 
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> >  
> > 
> >  diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> > 
> >  index cf6203282737..d78640b5d188 100644
> > 
> >  --- a/kernel/workqueue.c
> > 
> >  +++ b/kernel/workqueue.c
> > 
> >  @@ -3241,7 +3241,7 @@ __acquires(&pool->lock)
> > 
> >  * point will only record its address.
> > 
> >  */
> > 
> >  trace_workqueue_execute_end(work, worker->current_func);
> > 
> >  - pwq->stats[PWQ_STAT_COMPLETED]++;
> > 
> >  + WRITE_ONCE(pwq->stats[PWQ_STAT_COMPLETED], READ_ONCE(pwq->stats[PWQ_STAT_COMPLETED]) + 1);
> > 
> 
> The function acquires pool->lock down below. Can you move it down inside the
> 
> locked region instead of adding READ/WRITE_ONCE()?
> 
> Thanks.
> 
> -- 
> 
> tejun
>
Thanks, I can do that.
Previously, I thought it was for performance considerations that the
metrics calculation is out of the lock's scope...

      reply	other threads:[~2025-04-23 15:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-23 12:53 Jiayuan Chen
2025-04-23 15:30 ` Tejun Heo
2025-04-23 15:48   ` Jiayuan Chen [this message]

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=a89746d8897c81ed6e55c99d8ba71223ef3e318c@linux.dev \
    --to=jiayuan.chen@linux.dev \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=mrpre@163.com \
    --cc=syzbot+01affb1491750534256d@syzkaller.appspotmail.com \
    --cc=tj@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

all inboxes | Powered by JetHome®