[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 1/2] smp: convert the cpu maps lock into a rw lock
On Wed, Feb 19, 2020 at 02:42:58PM +0100, Jan Beulich wrote: > On 19.02.2020 14:19, Roger Pau Monné wrote: > > On Wed, Feb 19, 2020 at 01:56:02PM +0100, Jan Beulich wrote: > >> On 13.02.2020 12:32, Roger Pau Monne wrote: > >>> void __init register_cpu_notifier(struct notifier_block *nb) > >>> { > >>> - if ( !spin_trylock(&cpu_add_remove_lock) ) > >>> + if ( !write_trylock(&cpu_add_remove_lock) ) > >>> BUG(); /* Should never fail as we are called only during boot. */ > >>> notifier_chain_register(&cpu_chain, nb); > >>> - spin_unlock(&cpu_add_remove_lock); > >>> + write_unlock(&cpu_add_remove_lock); > >>> } > >> > >> So why a write lock here? > > > > notifier_chain_register calls cannot be made in parallel, as they > > modify the underlying notifier list without taking any additional > > locks. > > I.e. the lock is being (ab)used to also protect the notifier list, > which is certainly not its purpose. (The locking seems quite > pointless here anyway considering the __init together with the > nature of the function.) Right, it's quite likely that the lock is pointless, I haven't looked at all the callers to assure this. Anyway, iff the lock can be safely removed that should be done in a different patch, and not this one IMO. This merely switching existing users to use a rw lock. Thanks, Roger. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |