lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 27 Dec 2023 05:06:48 +0900
From: Tejun Heo <tj@...nel.org>
To: Lai Jiangshan <jiangshanlai@...il.com>
Cc: linux-kernel@...r.kernel.org, Naohiro.Aota@....com,
	kernel-team@...a.com
Subject: Re: [PATCH 04/10] workqueue: Move nr_active handling into helpers

On Tue, Dec 26, 2023 at 05:12:55PM +0800, Lai Jiangshan wrote:
> On Wed, Dec 20, 2023 at 3:25 PM Tejun Heo <tj@...nel.org> wrote:
> 
> > +static bool pwq_tryinc_nr_active(struct pool_workqueue *pwq)
> >  {
> > -       struct work_struct *work = list_first_entry(&pwq->inactive_works,
> > -                                                   struct work_struct, entry);
> > +       struct workqueue_struct *wq = pwq->wq;
> > +       struct worker_pool *pool = pwq->pool;
> > +       bool obtained;
> >
> > -       pwq_activate_work(pwq, work);
> > +       lockdep_assert_held(&pool->lock);
> > +
> > +       obtained = pwq->nr_active < wq->max_active;
> 
> It is better to use READ_ONCE(wq->max_active) here in case
> the compiler issues code to calculate "obtained" multi-time.
> 
> Theoretically, READ_ONCE(wq->max_active) is recommended
> from the patch1 in pwq_dec_nr_in_flight() and __queue_work()
> since there is no wq->mutex for them.

Yeah, good point. Lemme add WRITE/READ_ONCE() around max_active accesses.

Thanks.

-- 
tejun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ