On 06/23, Peter Zijlstra wrote: > > On Tue, Jun 23, 2015 at 12:57:39AM +0200, Oleg Nesterov wrote: > > > + > > > + lock_map_acquire_read(&cpu_hotplug.rwsem.rw_sem.dep_map); > > > + _percpu_down_read(&cpu_hotplug.rwsem); > > > } > > > > Confused... Why do we need _percpu_down_read()? Can't get_online_cpus() > > just use percpu_down_read() ? > > > > Yes, percpu_down_read() is not recursive, like the normal down_read(). > > But this does not matter because we rely on ->cpuhp_ref anyway? > > While we will not call the actual lock, lockdep will still get confused > by the inconsistent locking order observed. > > Change it and boot, you'll find lockdep output pretty quickly.
Hmm. and I simply can't understand why... > > > > --- a/kernel/fork.c > > > +++ b/kernel/fork.c > > > @@ -1410,6 +1410,8 @@ static struct task_struct *copy_process( > > > p->sequential_io_avg = 0; > > > #endif > > > > > > + cpu_hotplug_init_task(p); > > > > This is probably unnecessary, copy_process() should not be called under > > get_online_cpus(). > > Probably true, in which case we could still use the callback to insert a > WARN_ON_ONCE(p->cpuhp_ref) :-) Yes, agreed. And, perhaps, WARN_ON_ONCE(in_irq) in try_get_online_cpus() makes sense... percpu_down_read_trylock() from irq is fine, but try_get_online_cpus() can come right after get/put_online_cpus() updates ->cpuhp_ref. And I forgot to say, > void get_online_cpus(void) > { > might_sleep(); > - if (cpu_hotplug.active_writer == current) > + > + /* read in write recursion */ > + if (cpu_hotplug.writer == current) > + return; ... > void put_online_cpus(void) > { > - int refcount; > - > - if (cpu_hotplug.active_writer == current) > + if (cpu_hotplug.writer == current) > return; We do not need to check cpu_hotplug.writer in get/put_online_cpus(). cpu_hotplug_begin/end can just inc/dec current->cpuhp_ref. Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/