On Thu, 2018-11-29 at 13:04 +0100, Peter Zijlstra wrote: > On Wed, Nov 28, 2018 at 03:43:23PM -0800, Bart Van Assche wrote: > > A shortcoming of the current lockdep implementation is that it requires > > lock keys to be allocated statically. That forces certain lock objects > > to share lock keys. Since lock dependency analysis groups lock objects > > per key sharing lock keys can cause false positive lockdep reports. > > Make it possible to avoid such false positive reports by allowing lock > > keys to be allocated dynamically. Require that dynamically allocated > > lock keys are registered before use by calling lockdep_register_key(). > > Complain about attempts to register the same lock key pointer twice > > without calling lockdep_unregister_key() between successive > > registration calls. > > struct lock_class_key { > > + struct hlist_node hash_entry; > > struct lockdep_subclass_key subkeys[MAX_LOCKDEP_SUBCLASSES]; > > }; > > That hash_entry is purely for that double-register warning, right? I > wonder if we can do that differently; by always doing > register_lock_class(), and checking that state.
Hi Peter, The hash_entry serves two purposes. One purpose is to verify whether the lockdep_register_key() and lockdep_unregister_key() functions are used correctly. A second purpose is to avoid that lockdep_init_map() complains when encountering a dynamically allocated key. I'm not sure how always doing register_lock_class() would help? Thanks, Bart.