Re: [RFC][PATCH 09/13] hotplug: Replace hotplug lock with percpu-rwsem

2015-06-24 Thread Peter Zijlstra
On Wed, Jun 24, 2015 at 05:12:12PM +0200, Oleg Nesterov wrote: > On 06/24, Peter Zijlstra wrote: > > I'm confused.. why isn't the read-in-read recursion good enough? > > Because the code above can actually deadlock if 2 CPU's do this at > the same time? Hmm yes.. this makes the hotplug locking w

Re: [RFC][PATCH 09/13] hotplug: Replace hotplug lock with percpu-rwsem

2015-06-24 Thread Oleg Nesterov
On 06/24, Peter Zijlstra wrote: > > On Wed, Jun 24, 2015 at 03:50:49PM +0200, Oleg Nesterov wrote: > > On 06/23, Peter Zijlstra wrote: > > > If in one callchain we do: > > > > > > get_online_cpus(); > > > lock(A); > > > > > > in another we do: > > > > > > lock(A); > > > get_online_cpus(); >

Re: [RFC][PATCH 09/13] hotplug: Replace hotplug lock with percpu-rwsem

2015-06-24 Thread Peter Zijlstra
On Wed, Jun 24, 2015 at 03:50:49PM +0200, Oleg Nesterov wrote: > On 06/23, Peter Zijlstra wrote: > > If in one callchain we do: > > > > get_online_cpus(); > > lock(A); > > > > in another we do: > > > > lock(A); > > get_online_cpus(); > > > > lockdep will complain about the inverted

Re: [RFC][PATCH 09/13] hotplug: Replace hotplug lock with percpu-rwsem

2015-06-24 Thread Oleg Nesterov
On 06/23, Peter Zijlstra wrote: > > On Tue, Jun 23, 2015 at 07:01:22PM +0200, Oleg Nesterov wrote: > > 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); > >

Re: [RFC][PATCH 09/13] hotplug: Replace hotplug lock with percpu-rwsem

2015-06-23 Thread Peter Zijlstra
On Tue, Jun 23, 2015 at 07:01:22PM +0200, Oleg Nesterov wrote: > 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.

Re: [RFC][PATCH 09/13] hotplug: Replace hotplug lock with percpu-rwsem

2015-06-23 Thread Oleg Nesterov
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_onli

Re: [RFC][PATCH 09/13] hotplug: Replace hotplug lock with percpu-rwsem

2015-06-23 Thread Peter Zijlstra
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() ? >

Re: [RFC][PATCH 09/13] hotplug: Replace hotplug lock with percpu-rwsem

2015-06-22 Thread Oleg Nesterov
On 06/22, Peter Zijlstra wrote: > > The cpu hotplug lock is a rwsem with read-in-write and read-in-read > recursion. Implement it as such. And this patch fixes the problem afaics. Currently cpu_hotplug_begin() can livelock because it doesn't stop the new readers. With this patch this is no longer

[RFC][PATCH 09/13] hotplug: Replace hotplug lock with percpu-rwsem

2015-06-22 Thread Peter Zijlstra
The cpu hotplug lock is a rwsem with read-in-write and read-in-read recursion. Implement it as such. Signed-off-by: Peter Zijlstra (Intel) --- include/linux/cpu.h |6 + include/linux/percpu-rwsem.h | 10 ++- include/linux/sched.h|4 + init/main.c |