From: Tejun Heo <tj@kernel.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5] workqueue: Wrap flush_workqueue() using a macro
Date: Tue, 7 Jun 2022 07:08:42 -1000 [thread overview]
Message-ID: <Yp+GGhQ8ZpbPgeQQ@slm.duckdns.org> (raw)
In-Reply-To: <f8c281cd-6ce7-818d-8c43-6024a7b3b481@I-love.SAKURA.ne.jp>
On Wed, Jun 01, 2022 at 04:32:47PM +0900, Tetsuo Handa wrote:
> Since flush operation synchronously waits for completion, flushing
> system-wide WQs (e.g. system_wq) might introduce possibility of deadlock
> due to unexpected locking dependency. Tejun Heo commented at [1] that it
> makes no sense at all to call flush_workqueue() on the shared WQs as the
> caller has no idea what it's gonna end up waiting for.
>
> Although there is flush_scheduled_work() which flushes system_wq WQ with
> "Think twice before calling this function! It's very easy to get into
> trouble if you don't take great care." warning message, syzbot found a
> circular locking dependency caused by flushing system_wq WQ [2].
>
> Therefore, let's change the direction to that developers had better use
> their local WQs if flush_scheduled_work()/flush_workqueue(system_*_wq) is
> inevitable.
>
> Steps for converting system-wide WQs into local WQs are explained at [3],
> and a conversion to stop flushing system-wide WQs is in progress. Now we
> want some mechanism for preventing developers who are not aware of this
> conversion from again start flushing system-wide WQs.
>
> Since I found that WARN_ON() is complete but awkward approach for teaching
> developers about this problem, let's use __compiletime_warning() for
> incomplete but handy approach. For completeness, we will also insert
> WARN_ON() into __flush_workqueue() after all in-tree users stopped calling
> flush_scheduled_work().
>
> Link: https://lore.kernel.org/all/YgnQGZWT%2Fn3VAITX@slm.duckdns.org/ [1]
> Link: https://syzkaller.appspot.com/bug?extid=bde0f89deacca7c765b8 [2]
> Link: https://lkml.kernel.org/r/49925af7-78a8-a3dd-bce6-cfc02e1a9236@I-love.SAKURA.ne.jp [3]
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Applied to wq/for-5.19-fixes.
Thanks.
--
tejun
prev parent reply other threads:[~2022-06-07 17:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-01 7:32 Tetsuo Handa
2022-06-06 6:10 ` Tetsuo Handa
2022-06-07 17:08 ` Tejun Heo [this message]
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=Yp+GGhQ8ZpbPgeQQ@slm.duckdns.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
/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
all inboxes | Powered by JetHome®