From: Tejun Heo <tj@kernel.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Bart Van Assche <bvanassche@acm.org>,
jgg@ziepe.ca, linux-kernel@vger.kernel.org,
Lai Jiangshan <jiangshanlai@gmail.com>,
Haakon Bugge <haakon.bugge@oracle.com>
Subject: Re: [PATCH v2] workqueue: Warn flush attempt using system-wide workqueues
Date: Tue, 22 Feb 2022 08:36:16 -1000 [thread overview]
Message-ID: <YhUtIHtH2IAOWrEp@slm.duckdns.org> (raw)
In-Reply-To: <2f887679-c783-bf18-a2aa-aa9a709bfb38@I-love.SAKURA.ne.jp>
On Thu, Feb 17, 2022 at 08:22:30PM +0900, Tetsuo Handa wrote:
> @@ -335,6 +335,18 @@ enum {
> */
> WQ_POWER_EFFICIENT = 1 << 7,
>
> + /*
> + * Since flush operation synchronously waits for completion, flushing
> + * system-wide workqueues (e.g. system_wq) or a work on a system-wide
> + * workqueue might introduce possibility of deadlock due to unexpected
> + * locking dependency.
> + *
> + * This flag emits warning if flush operation is attempted. Don't set
> + * this flag on user-defined workqueues, for destroy_workqueue() will
> + * involve flush operation.
> + */
> + WQ_WARN_FLUSH_ATTEMPT = 1 << 8,
Maybe just __WQ_NO_FLUSH?
> __WQ_DRAINING = 1 << 16, /* internal: workqueue is draining */
> __WQ_ORDERED = 1 << 17, /* internal: workqueue is ordered */
> __WQ_LEGACY = 1 << 18, /* internal: create*_workqueue() */
...
> +static void warn_flush_attempt(struct workqueue_struct *wq)
> +{
> + static DEFINE_RATELIMIT_STATE(flush_warn_rs, 600 * HZ, 1);
> +
> +
> + /* Use ratelimit for now in order not to flood warning messages. */
> + ratelimit_set_flags(&flush_warn_rs, RATELIMIT_MSG_ON_RELEASE);
> + if (!__ratelimit(&flush_warn_rs))
> + return;
If you're worried about spamming console while conversion is in progress, we
can just print the immediate (and maybe one more) caller with %pf and
__builtin_return_address() so that it only prints out one line.
Thanks.
--
tejun
next prev parent reply other threads:[~2022-02-22 18:36 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-10 19:27 [syzbot] possible deadlock in worker_thread syzbot
2022-02-11 18:59 ` Bart Van Assche
2022-02-12 5:31 ` Tetsuo Handa
2022-02-12 16:37 ` Bart Van Assche
2022-02-12 17:14 ` Tetsuo Handa
2022-02-13 15:33 ` Leon Romanovsky
2022-02-13 23:06 ` Bart Van Assche
2022-02-14 1:08 ` Tetsuo Handa
2022-02-14 3:44 ` Tejun Heo
2022-02-14 13:36 ` Tetsuo Handa
2022-02-14 17:34 ` Tejun Heo
2022-02-15 10:26 ` Tetsuo Handa
2022-02-15 10:43 ` Haakon Bugge
2022-02-15 12:48 ` Tetsuo Handa
2022-02-15 17:05 ` Bart Van Assche
2022-02-15 22:05 ` Tetsuo Handa
2022-02-22 18:26 ` Tejun Heo
2022-02-17 11:22 ` [PATCH v2] workqueue: Warn flush attempt using system-wide workqueues Tetsuo Handa
2022-02-22 18:36 ` Tejun Heo [this message]
[not found] ` <CGME20220223212048eucas1p1fab5e35ff398eff57808a8f1125dd15f@eucas1p1.samsung.com>
2022-02-23 21:20 ` Marek Szyprowski
2022-02-23 21:35 ` Tejun Heo
2022-02-23 22:06 ` Tetsuo Handa
2022-02-17 12:27 ` [syzbot] possible deadlock in worker_thread Fabio M. De Francesco
2022-02-22 18:30 ` 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=YhUtIHtH2IAOWrEp@slm.duckdns.org \
--to=tj@kernel.org \
--cc=bvanassche@acm.org \
--cc=haakon.bugge@oracle.com \
--cc=jgg@ziepe.ca \
--cc=jiangshanlai@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).