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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJhGHyC4Qj7t=Emd65556r_g0fUbf9LWEA-1OKuwaDFTz8O50g@mail.gmail.com>
Date: Tue, 26 Dec 2023 17:12:55 +0800
From: Lai Jiangshan <jiangshanlai@...il.com>
To: Tejun Heo <tj@...nel.org>
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 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.


> +
> +       if (obtained)
> +               pwq->nr_active++;
> +       return obtained;
> +}
> +

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ