Re: [RFC PATCH 01/12] locking/lockdep: Rework lockdep_set_novalidate_class()

From: Waiman Long
Date: Sat Nov 10 2018 - 19:27:06 EST


On 11/10/2018 09:14 AM, Peter Zijlstra wrote:
> On Thu, Nov 08, 2018 at 03:34:17PM -0500, Waiman Long wrote:
>> The current lockdep_set_novalidate_class() implementation is like
>> a hack. It assigns a special class key for that lock and calls
>> lockdep_init_map() twice.
> Ideally it would go away.. it is not thing that should be used.

Yes, I agree. Right now, lockdep_set_novalidate_class() is used in

drivers/base/core.c:ÂÂÂ lockdep_set_novalidate_class(&dev->mutex);
drivers/md/bcache/btree.c:ÂÂÂÂÂ lockdep_set_novalidate_class(&b->lock);
drivers/md/bcache/btree.c:ÂÂÂÂÂ
lockdep_set_novalidate_class(&b->write_lock);

Do you know the history behind making them novalidate?

>
>> This patch changes the implementation to make it more general so that
>> it can be used by other special lock class types. A new "type" field
>> is added to both the lockdep_map and lock_class structures.
>>
>> The new field can now be used to designate a lock and a class object
>> as novalidate. The lockdep_set_novalidate_class() call, however, should
>> be called before lock initialization which calls lockdep_init_map().
> I don't really feel like this is something that should be made easier or
> better.

I am not saying that this patch make lockdep_set_novalidate_class()
easier to use. It is that terminal locks will share similar code path
and so I rework it so that they can checked together in one test instead
of 2 separate tests.

>> @@ -102,6 +100,8 @@ struct lock_class {
>> int name_version;
>> const char *name;
>>
>> + unsigned int flags;
>> +
>> #ifdef CONFIG_LOCK_STAT
>> unsigned long contention_point[LOCKSTAT_POINTS];
>> unsigned long contending_point[LOCKSTAT_POINTS];
> Esp. not at the cost of growing the data structures.
>
>

I did reduce the size by 16 bytes for 64-bit architecture in my previous
lockdep patch. Now I claw back 8 bytes for this new functionality.

Cheers,
Longman