From: Boqun Feng <boqun.feng@gmail.com>
To: Tejun Heo <tj@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
Lai Jiangshan <jiangshanlai@gmail.com>,
"Paul E . McKenney" <paulmck@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <frederic@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH] workqueue: doc: Call out the non-reentrance conditions
Date: Wed, 20 Oct 2021 13:40:21 +0800 [thread overview]
Message-ID: <YW+rxfMof4QcGSrq@boqun-archlinux> (raw)
In-Reply-To: <YW8EzNmq/bde5VTa@slm.duckdns.org>
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
next prev parent reply other threads:[~2021-10-20 5:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-18 1:31 [PATCH] workqueue: doc: Call out the non-reentrance conditions Boqun Feng
2021-10-18 2:17 ` Matthew Wilcox
2021-10-18 3:19 ` Boqun Feng
2021-10-18 11:26 ` Matthew Wilcox
2021-10-19 17:47 ` Tejun Heo
2021-10-20 5:40 ` Boqun Feng [this message]
2021-10-20 16:18 ` Tejun Heo
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=YW+rxfMof4QcGSrq@boqun-archlinux \
--to=boqun.feng@gmail.com \
--cc=corbet@lwn.net \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=willy@infradead.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