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]
Message-ID: <YW+rxfMof4QcGSrq@boqun-archlinux>
Date:   Wed, 20 Oct 2021 13:40:21 +0800
From:   Boqun Feng <boqun.feng@...il.com>
To:     Tejun Heo <tj@...nel.org>
Cc:     linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
        Lai Jiangshan <jiangshanlai@...il.com>,
        "Paul E . McKenney" <paulmck@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Peter Zijlstra <peterz@...radead.org>,
        Frederic Weisbecker <frederic@...nel.org>,
        Jonathan Corbet <corbet@....net>,
        Matthew Wilcox <willy@...radead.org>
Subject: Re: [PATCH] workqueue: doc: Call out the non-reentrance conditions

On Tue, Oct 19, 2021 at 07:47:56AM -1000, Tejun Heo wrote:
> On Mon, Oct 18, 2021 at 09:31:17AM +0800, Boqun Feng wrote:
> > +Workqueue guarantees that a work item cannot be re-entrant if the following
> > +conditions hold after a work item gets queued:
> > +
> > +        1. The work function hasn't been changed.
> > +        2. No one queues the work item to another workqueue.
> > +        3. The work item hasn't been reinitiated.
> 
> Maybe phrasing it so that the above are the conditions defining a work item
> to be the same instance would be clearer?
> 

Hmm.. that would mean queue_work_on() may change the work item to
another instance? For example:

	struct work_struct w;

	INIT_WORK_ONSTACK(w, some_f);

	queue_work_on(&w, system_wq, 1); // queue a work and create
					 // an instance

	queue_work_on(&w, system_long_wq, 2); // queue the same work
					      // item but it means
					      // changing it to another
					      // instance.

Looks a little counter-intuitive to me, but let me try (combined with
Matthew's suggestion)

<in Guidelines section>

* A work item instance will not be processed by multiple workers at the
  same time, i.e. it's non-reentrant, so requeuing the same instance of
  a work item is safe and not racy.  Operations considered as changing
  the work item to a different instance are: 1) change the work
  function, 2) queue the work item to a different workqueue, or 3)
  reinitiate the work item.  The non-reentrance guarantee doesn't hold
  for different work item instances.

Regards,
Boqun

> Thanks.
> 
> -- 
> tejun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ