From: Johannes Berg <johannes@sipsolutions.net>
To: Guenter Roeck <linux@roeck-us.net>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>, Tejun Heo <tj@kernel.org>,
Hillf Danton <hdanton@sina.com>,
LKML <linux-kernel@vger.kernel.org>,
Heyi Guo <guoheyi@linux.alibaba.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH v3] workqueue: don't skip lockdep work dependency in cancel_work_sync()
Date: Wed, 13 Sep 2023 20:11:39 +0200 [thread overview]
Message-ID: <515a7435bd83ecc8a9d63306d4bc076c762f22bf.camel@sipsolutions.net> (raw)
In-Reply-To: <a50218b6-fc42-7f12-155a-5e01fc8dd1a0@roeck-us.net>
On Wed, 2023-09-13 at 08:59 -0700, Guenter Roeck wrote:
>
> So you are saying that anything running in a workqueue must not
> acquire rtnl_lock because cancel_[delayed_]work_sync() may be called
> under rtnl_lock.
No no, sorry if I wasn't clear. I mean this particular function / work
struct cannot acquire the RTNL because the cancel _for it_ is called
under RTNL.
It used to be that this was also tied to the entire workqueue, but this
is no longer true due to the way workqueues work these days.
> FWIW, it would be nice if the lockdep code would generate some other
> message in this situation. Complaining about a deadlock involving a
> lock that doesn't exist if lock debugging isn't enabled is not really
> helpful and, yes, may result in reporters to falsely assume that this
> lock is responsible for the potential deadlock.
Well, I don't know of any way to tell lockdep that, but I guess ideas
welcome? I mean, I'm not even sure what else it would tell you, other
than that you have a deadlock?
I mean, OK, I guess it's fair - it says "acquire lock" when it says
[ 9.810406] ip/357 is trying to acquire lock:
[ 9.810501] 83af6c40 ((work_completion)(&(&dev->state_queue)->work)){+.+.}-{0:0}, at: __flush_work+0x40/0x550
and it's not really a lock, but I'm not even sure how to phrase it
better? Note the scenario may be more complex than here.
I mean, perhaps we could add an optional message somehow and it could
say
"ip/357 is waiting for the work:"
but then we'd also have to update the scenario message to something like
[ 9.813938] CPU0 CPU1
[ 9.813999] ---- ----
[ 9.814062] lock(rtnl_mutex);
[ 9.814139] run((work_completion)(&(&dev->state_queue)->work));
[ 9.814258] lock(rtnl_mutex);
[ 9.814354] wait((work_completion)(&(&dev->state_queue)->work));
which is really hard to do because how should lockdep know that the two
ways of "acquiring the lock" are actually different, and which one is
which? I'm not even convinced it could really do that.
In any case, I'd rather have a bug report from this than not, even if
it's not trivial to read.
... and here I thought we went through all of this 15+ years ago when I
added it in commit 4e6045f13478 ("workqueue: debug flushing deadlocks
with lockdep"), at which time the situation was actually worse because
you had to not only pay attention to the work struct, but also the
entire workqueue - which is today only true for ordered workqueues... Oh
well :)
johannes
prev parent reply other threads:[~2023-09-13 18:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <21b9c1ac-64b7-7f4b-1e62-bf2f021fffcd@I-love.SAKURA.ne.jp>
[not found] ` <YuK78Jiy12BJG/Tp@slm.duckdns.org>
[not found] ` <0ad532b2-df5f-331a-ae7f-21460fc62fe2@I-love.SAKURA.ne.jp>
[not found] ` <97cbf8a9-d5e1-376f-6a49-3474871ea6b4@I-love.SAKURA.ne.jp>
[not found] ` <afa1ac2c-a023-a91e-e596-60931b38247e@I-love.SAKURA.ne.jp>
[not found] ` <7d034f7b-af42-4dbc-0887-60f4bdb3dcca@I-love.SAKURA.ne.jp>
[not found] ` <0a85696a-b0b9-0f4a-7c00-cd89edc9304c@I-love.SAKURA.ne.jp>
[not found] ` <77d47eed-6a22-7e81-59de-4d45852ca4de@I-love.SAKURA.ne.jp>
[not found] ` <e0717628-e436-4091-8b2e-2f4dcb646ec8@roeck-us.net>
2023-09-13 14:41 ` [PATCH v3] workqueue: don't skip lockdep work dependency in cancel_work_sync() Johannes Berg
2023-09-13 15:59 ` Guenter Roeck
2023-09-13 17:25 ` Florian Fainelli
2023-09-13 17:45 ` Guenter Roeck
2023-09-13 18:30 ` Johannes Berg
2023-09-13 18:11 ` Johannes Berg [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=515a7435bd83ecc8a9d63306d4bc076c762f22bf.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=guoheyi@linux.alibaba.com \
--cc=hdanton@sina.com \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=netdev@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--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