[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <109c3cc0-2c13-7452-4548-d0155c1aba10@gmail.com>
Date: Sat, 11 Feb 2023 18:06:28 -0500
From: Kent Overstreet <kent.overstreet@...il.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>,
Alan Stern <stern@...land.harvard.edu>,
Coly Li <colyli@...e.de>, kent.overstreet@...ux.dev
Cc: Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
syzkaller <syzkaller@...glegroups.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Boqun Feng <boqun.feng@...il.com>,
LKML <linux-kernel@...r.kernel.org>,
USB list <linux-usb@...r.kernel.org>,
Hillf Danton <hdanton@...a.com>
Subject: Re: [PATCH RFC] drivers/core: Replace lockdep_set_novalidate_class()
with unique class keys
On 2/11/23 16:51, Linus Torvalds wrote:
> On Sat, Feb 11, 2023 at 1:41 PM Alan Stern <stern@...land.harvard.edu> wrote:
>>
>> @@ -2941,7 +2944,10 @@ void device_initialize(struct device *de
>> kobject_init(&dev->kobj, &device_ktype);
>> INIT_LIST_HEAD(&dev->dma_pools);
>> mutex_init(&dev->mutex);
>> - lockdep_set_novalidate_class(&dev->mutex);
>> + if (!lockdep_static_obj(dev)) {
>> + lockdep_register_key(&dev->mutex_key);
>> + lockdep_set_class(&dev->mutex, &dev->mutex_key);
>> + }
>> spin_lock_init(&dev->devres_lock);
>> INIT_LIST_HEAD(&dev->devres_head);
>> device_pm_init(dev);
>
> So I think this is the right thing to do, but I note that while that
> lockdep_set_novalidate_class() was "documented" to only be for
> 'dev->mutex' by scripts/checkpatch.pl, that horrific thing is also
> used by md/bcache/btree.c for the mca_bucket_alloc().
>
> Can we *please* get rid of it there too (it was added by the initial
> code, and never had any explicit excuse for it), possibly by using the
> same model.
>
> And then we could get rid of lockdep_set_novalidate_class() entirely.
> That would be a good thing.
Yeah, what bcache really needs (and presumably dev->mutex as well) is
just to disable lockdep checking for self-deadlock of that lock type,
since it's got its own deadlock avoidance and the subclass thing isn't
good enough.
I've got a patch that should do what we want, replying from my other
account with it.
Powered by blists - more mailing lists