From: Hillf Danton <hdanton@sina.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-mm@kvack.org, USB list <linux-usb@vger.kernel.org>
Subject: Re: Converting dev->mutex into dev->spinlock ?
Date: Sun, 5 Feb 2023 08:21:56 +0800 [thread overview]
Message-ID: <20230205002156.1071-1-hdanton@sina.com> (raw)
In-Reply-To: <Y958hOvtqq7Uiu0G@rowland.harvard.edu>
On Sat, 4 Feb 2023 10:40:52 -0500 Alan Stern <stern@rowland.harvard.edu>
> On Sun, Feb 05, 2023 at 12:30:07AM +0900, Tetsuo Handa wrote:
> > On 2023/02/05 0:12, Alan Stern wrote:
> > >> it would solve many deadlocks in driver code if you can update
> > >
> > > What deadlocks? If there are so many deadlocks floating around in
> > > driver code, why haven't we heard about them before now?
> >
> > Since dev->mutex is hidden from lockdep checks, nobody can see lockdep warnings.
> > syzbot is reporting real deadlocks without lockdep warnings, for the fundamental
> > problem you mentioned in https://lkml.kernel.org/r/Pine.LNX.4.44L0.0804171117450.18040-100000@iolanthe.rowland.org
> > is remaining. I'm suggesting you that now is time to address this fundamental problem.
>
> Maybe so. But the place to address it is inside lockdep, not in the
> driver core.
>
> > >> (by e.g. replacing dev->mutex with dev->spinlock and dev->atomic_flags).
> > >> But I'm not familiar enough to propose such change...
> > >
> > > Such a change cannot be made. Consider this: Driver callbacks often
> > > need to sleep. But when a thread holds a spinlock, it is not allowed to
> > > sleep. Therefore driver callbacks must not be invoked while a spinlock
> > > is held.
> >
> > What I'm suggesting is "Do not call driver callbacks with dev->mutex held,
> > by rewriting driver core code".
>
> That cannot be done. The only possible solution is to teach lockdep how
> to handle recursive locking structures.
It works in dcache - see the slow path in dentry_kill() for instance.
Hillf
next parent reply other threads:[~2023-02-05 0:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <28a82f50-39d5-a45f-7c7a-57a66cec0741@I-love.SAKURA.ne.jp>
[not found] ` <Y951z0Au9MlP1GxX@rowland.harvard.edu>
[not found] ` <e89ad942-cab6-fad1-1cc2-98885d829ea7@I-love.SAKURA.ne.jp>
[not found] ` <Y958hOvtqq7Uiu0G@rowland.harvard.edu>
2023-02-05 0:21 ` Hillf Danton [this message]
[not found] ` <Y95h7Vop9t5Li0HD@kroah.com>
[not found] ` <a236ab6b-d38c-3974-d4cb-5e92d0877abc@I-love.SAKURA.ne.jp>
[not found] ` <Y957GSFVAQz8v3Xo@rowland.harvard.edu>
[not found] ` <cf56ebc3-187a-6ee4-26bc-2d180272b5cf@I-love.SAKURA.ne.jp>
[not found] ` <Y96HiYcreb8jZIHi@rowland.harvard.edu>
[not found] ` <917e1e3b-094f-e594-c1a2-8b97fb5195fd@I-love.SAKURA.ne.jp>
[not found] ` <Y965qEg0Re2QoQ7Q@rowland.harvard.edu>
[not found] ` <c7fb01a9-3e12-77ed-5c4c-db7deb64dc73@I-love.SAKURA.ne.jp>
[not found] ` <Y9/dTp/hQ5btWTEH@rowland.harvard.edu>
2023-02-06 2:56 ` Hillf Danton
2023-02-06 4:44 ` Matthew Wilcox
2023-02-06 5:17 ` Greg Kroah-Hartman
2023-02-06 6:43 ` Hillf Danton
2023-02-06 6:48 ` Greg Kroah-Hartman
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=20230205002156.1071-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-usb@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=rafael@kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=torvalds@linux-foundation.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