From: Peter Hurley <peter@hurleysoftware.com>
To: Tejun Heo <tj@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Peter Hurley <peter@hurleysoftware.com>,
Stefan Richter <stefanr@s5r6.in-berlin.de>,
<stable@vger.kernel.org>
Subject: [PATCH] workqueue: Document exceptions to work item non-reentrancy guarantee
Date: Sat, 15 Feb 2014 14:38:39 -0500 [thread overview]
Message-ID: <1392493119-9277-1-git-send-email-peter@hurleysoftware.com> (raw)
Since commit a2c1c57be8d9fd5b716113c8991d3d702eeacf77,
workqueue: consider work function when searching for busy work items
work items whose work functions are re-assigned are no longer guaranteed
non-reentrancy with the previously assigned work function. For example,
PREPARE_WORK(&work, funcA)
schedule_work(&work)
.
< funcA starts >
.
PREPARE_WORK(&work, funcB)
schedule_work(&work)
funcA() may run concurrently with funcB().
The work item non-reentrancy guarantee is a crucial design guarantee
which, if violated, may not have obvious consequences. For example,
the entire firewire subsystem expects the as-documented per-work item
non-reentrancy guarantee, which was the behavior prior to the above
commit, not the per-work function + per-work item behavior since.
Document the known exceptions to this guarantee.
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
Documentation/workqueue.txt | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/Documentation/workqueue.txt b/Documentation/workqueue.txt
index f81a65b..5b49491 100644
--- a/Documentation/workqueue.txt
+++ b/Documentation/workqueue.txt
@@ -223,9 +223,17 @@ resources, scheduled and executed.
This flag is meaningless for unbound wq.
-Note that the flag WQ_NON_REENTRANT no longer exists as all workqueues
-are now non-reentrant - any work item is guaranteed to be executed by
-at most one worker system-wide at any given time.
+Note that the flag WQ_NON_REENTRANT no longer exists.
+Generally, workqueues are non-reentrant -- a work item will be executed
+by at most one worker system-wide at any given time. However, this
+non-reentrancy guarantee does not extend to work items whose function
+is re-assigned (for example, via PREPARE_WORK/PREPARE_DELAYED_WORK)
+and re-queued for execution; the newly scheduled work may run concurrently
+with the previous work item function.
+
+Note that WQ_UNBOUND workqueues, such as system_unbound_wq, have no
+non-reentrancy guarantees as these workqueues do not provide concurrency
+management.
@max_active:
--
1.8.1.2
next reply other threads:[~2014-02-15 19:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-15 19:38 Peter Hurley [this message]
2014-02-18 1:43 ` [PATCH] workqueue: Document exceptions to work item non-reentrancy guarantee Ben Hutchings
2014-02-18 2:29 ` Peter Hurley
2014-02-18 15:30 ` Tejun Heo
2014-02-18 16:31 ` Peter Hurley
2014-02-18 16:37 ` 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=1392493119-9277-1-git-send-email-peter@hurleysoftware.com \
--to=peter@hurleysoftware.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=stefanr@s5r6.in-berlin.de \
--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