Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-12 Thread Paul E. McKenney
On Sun, Nov 11, 2012 at 04:45:09PM +0100, Oleg Nesterov wrote: > On 11/09, Paul E. McKenney wrote: > > > > On Fri, Nov 09, 2012 at 07:10:48PM +0100, Oleg Nesterov wrote: > > > > > > static bool xxx(brw) > > > { > > > down_write(>rw_sem); > > > > down_write_trylock() > > >

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-12 Thread Paul E. McKenney
On Sun, Nov 11, 2012 at 04:45:09PM +0100, Oleg Nesterov wrote: On 11/09, Paul E. McKenney wrote: On Fri, Nov 09, 2012 at 07:10:48PM +0100, Oleg Nesterov wrote: static bool xxx(brw) { down_write(brw-rw_sem); down_write_trylock() As you noted in

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-11 Thread Oleg Nesterov
On 11/09, Paul E. McKenney wrote: > > On Fri, Nov 09, 2012 at 07:10:48PM +0100, Oleg Nesterov wrote: > > > > static bool xxx(brw) > > { > > down_write(>rw_sem); > > down_write_trylock() > > As you noted in your later email. Presumably you return false if > the

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-11 Thread Oleg Nesterov
On 11/09, Paul E. McKenney wrote: On Fri, Nov 09, 2012 at 07:10:48PM +0100, Oleg Nesterov wrote: static bool xxx(brw) { down_write(brw-rw_sem); down_write_trylock() As you noted in your later email. Presumably you return false if the attempt to

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Paul E. McKenney
On Fri, Nov 09, 2012 at 07:10:48PM +0100, Oleg Nesterov wrote: > On 11/09, Paul E. McKenney wrote: > > > > On Fri, Nov 09, 2012 at 04:46:56PM +0100, Oleg Nesterov wrote: > > > Contrary, I am going to try to add some complications later, so that > > > it can have more users. In particular, I think

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Oleg Nesterov
On 11/09, Oleg Nesterov wrote: > > static bool xxx(brw) > { > down_write(>rw_sem); > if (!atomic_read(>slow_read_ctr)) > return true; I meant, try_to_down_write(). Otherwise this can obviously deadlock. Oleg. -- To unsubscribe from

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Oleg Nesterov
On 11/09, Paul E. McKenney wrote: > > On Fri, Nov 09, 2012 at 04:46:56PM +0100, Oleg Nesterov wrote: > > Contrary, I am going to try to add some complications later, so that > > it can have more users. In particular, I think it can replace > > get_online_cpus/cpu_hotplug_begin, just we need > >

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Paul E. McKenney
On Fri, Nov 09, 2012 at 04:46:56PM +0100, Oleg Nesterov wrote: > On 11/08, Andrew Morton wrote: > > > > On Thu, 8 Nov 2012 14:48:49 +0100 > > Oleg Nesterov wrote: > > > > > > > > include/linux/percpu-rwsem.h | 83 + > > > lib/Makefile |2 +- > > >

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Paul E. McKenney
On Fri, Nov 09, 2012 at 05:35:38PM +0100, Oleg Nesterov wrote: > On 11/08, Paul E. McKenney wrote: > > > > On Thu, Nov 08, 2012 at 04:41:36PM -0800, Paul E. McKenney wrote: > > > On Thu, Nov 08, 2012 at 06:41:10PM -0500, Mikulas Patocka wrote: > > > > > > > > On Thu, 8 Nov 2012, Paul E. McKenney

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Oleg Nesterov
On 11/08, Paul E. McKenney wrote: > > On Thu, Nov 08, 2012 at 04:41:36PM -0800, Paul E. McKenney wrote: > > On Thu, Nov 08, 2012 at 06:41:10PM -0500, Mikulas Patocka wrote: > > > > > > On Thu, 8 Nov 2012, Paul E. McKenney wrote: > > > > > > > On Thu, Nov 08, 2012 at 12:07:00PM -0800, Andrew Morton

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Oleg Nesterov
On 11/08, Andrew Morton wrote: > > On Thu, 8 Nov 2012 14:48:49 +0100 > Oleg Nesterov wrote: > > > > > include/linux/percpu-rwsem.h | 83 + > > lib/Makefile |2 +- > > lib/percpu-rwsem.c | 123 > >

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Mikulas Patocka
On Thu, 8 Nov 2012, Andrew Morton wrote: > On Thu, 8 Nov 2012 14:48:49 +0100 > Oleg Nesterov wrote: > > > Currently the writer does msleep() plus synchronize_sched() 3 times > > to acquire/release the semaphore, and during this time the readers > > are blocked completely. Even if the "write"

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Mikulas Patocka
On Thu, 8 Nov 2012, Andrew Morton wrote: On Thu, 8 Nov 2012 14:48:49 +0100 Oleg Nesterov o...@redhat.com wrote: Currently the writer does msleep() plus synchronize_sched() 3 times to acquire/release the semaphore, and during this time the readers are blocked completely. Even if the

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Oleg Nesterov
On 11/08, Andrew Morton wrote: On Thu, 8 Nov 2012 14:48:49 +0100 Oleg Nesterov o...@redhat.com wrote: include/linux/percpu-rwsem.h | 83 + lib/Makefile |2 +- lib/percpu-rwsem.c | 123

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Oleg Nesterov
On 11/08, Paul E. McKenney wrote: On Thu, Nov 08, 2012 at 04:41:36PM -0800, Paul E. McKenney wrote: On Thu, Nov 08, 2012 at 06:41:10PM -0500, Mikulas Patocka wrote: On Thu, 8 Nov 2012, Paul E. McKenney wrote: On Thu, Nov 08, 2012 at 12:07:00PM -0800, Andrew Morton wrote: On

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Paul E. McKenney
On Fri, Nov 09, 2012 at 05:35:38PM +0100, Oleg Nesterov wrote: On 11/08, Paul E. McKenney wrote: On Thu, Nov 08, 2012 at 04:41:36PM -0800, Paul E. McKenney wrote: On Thu, Nov 08, 2012 at 06:41:10PM -0500, Mikulas Patocka wrote: On Thu, 8 Nov 2012, Paul E. McKenney wrote:

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Paul E. McKenney
On Fri, Nov 09, 2012 at 04:46:56PM +0100, Oleg Nesterov wrote: On 11/08, Andrew Morton wrote: On Thu, 8 Nov 2012 14:48:49 +0100 Oleg Nesterov o...@redhat.com wrote: include/linux/percpu-rwsem.h | 83 + lib/Makefile |2 +-

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Oleg Nesterov
On 11/09, Paul E. McKenney wrote: On Fri, Nov 09, 2012 at 04:46:56PM +0100, Oleg Nesterov wrote: Contrary, I am going to try to add some complications later, so that it can have more users. In particular, I think it can replace get_online_cpus/cpu_hotplug_begin, just we need

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Oleg Nesterov
On 11/09, Oleg Nesterov wrote: static bool xxx(brw) { down_write(brw-rw_sem); if (!atomic_read(brw-slow_read_ctr)) return true; I meant, try_to_down_write(). Otherwise this can obviously deadlock. Oleg. -- To unsubscribe from

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-09 Thread Paul E. McKenney
On Fri, Nov 09, 2012 at 07:10:48PM +0100, Oleg Nesterov wrote: On 11/09, Paul E. McKenney wrote: On Fri, Nov 09, 2012 at 04:46:56PM +0100, Oleg Nesterov wrote: Contrary, I am going to try to add some complications later, so that it can have more users. In particular, I think it can

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-08 Thread Paul E. McKenney
On Thu, Nov 08, 2012 at 04:41:36PM -0800, Paul E. McKenney wrote: > On Thu, Nov 08, 2012 at 06:41:10PM -0500, Mikulas Patocka wrote: > > > > > > On Thu, 8 Nov 2012, Paul E. McKenney wrote: > > > > > On Thu, Nov 08, 2012 at 12:07:00PM -0800, Andrew Morton wrote: > > > > On Thu, 8 Nov 2012

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-08 Thread Paul E. McKenney
On Thu, Nov 08, 2012 at 06:41:10PM -0500, Mikulas Patocka wrote: > > > On Thu, 8 Nov 2012, Paul E. McKenney wrote: > > > On Thu, Nov 08, 2012 at 12:07:00PM -0800, Andrew Morton wrote: > > > On Thu, 8 Nov 2012 14:48:49 +0100 > > > Oleg Nesterov wrote: > > > > > > > Currently the writer does

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-08 Thread Mikulas Patocka
On Thu, 8 Nov 2012, Paul E. McKenney wrote: > On Thu, Nov 08, 2012 at 12:07:00PM -0800, Andrew Morton wrote: > > On Thu, 8 Nov 2012 14:48:49 +0100 > > Oleg Nesterov wrote: > > > > > Currently the writer does msleep() plus synchronize_sched() 3 times > > > to acquire/release the semaphore, and

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-08 Thread Paul E. McKenney
On Thu, Nov 08, 2012 at 12:07:00PM -0800, Andrew Morton wrote: > On Thu, 8 Nov 2012 14:48:49 +0100 > Oleg Nesterov wrote: > > > Currently the writer does msleep() plus synchronize_sched() 3 times > > to acquire/release the semaphore, and during this time the readers > > are blocked completely.

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-08 Thread Andrew Morton
On Thu, 8 Nov 2012 14:48:49 +0100 Oleg Nesterov wrote: > Currently the writer does msleep() plus synchronize_sched() 3 times > to acquire/release the semaphore, and during this time the readers > are blocked completely. Even if the "write" section was not actually > started or if it was already

[PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-08 Thread Oleg Nesterov
Currently the writer does msleep() plus synchronize_sched() 3 times to acquire/release the semaphore, and during this time the readers are blocked completely. Even if the "write" section was not actually started or if it was already finished. With this patch down_write/up_write does

[PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-08 Thread Oleg Nesterov
Currently the writer does msleep() plus synchronize_sched() 3 times to acquire/release the semaphore, and during this time the readers are blocked completely. Even if the write section was not actually started or if it was already finished. With this patch down_write/up_write does

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-08 Thread Andrew Morton
On Thu, 8 Nov 2012 14:48:49 +0100 Oleg Nesterov o...@redhat.com wrote: Currently the writer does msleep() plus synchronize_sched() 3 times to acquire/release the semaphore, and during this time the readers are blocked completely. Even if the write section was not actually started or if it was

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-08 Thread Paul E. McKenney
On Thu, Nov 08, 2012 at 12:07:00PM -0800, Andrew Morton wrote: On Thu, 8 Nov 2012 14:48:49 +0100 Oleg Nesterov o...@redhat.com wrote: Currently the writer does msleep() plus synchronize_sched() 3 times to acquire/release the semaphore, and during this time the readers are blocked

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-08 Thread Mikulas Patocka
On Thu, 8 Nov 2012, Paul E. McKenney wrote: On Thu, Nov 08, 2012 at 12:07:00PM -0800, Andrew Morton wrote: On Thu, 8 Nov 2012 14:48:49 +0100 Oleg Nesterov o...@redhat.com wrote: Currently the writer does msleep() plus synchronize_sched() 3 times to acquire/release the semaphore,

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-08 Thread Paul E. McKenney
On Thu, Nov 08, 2012 at 06:41:10PM -0500, Mikulas Patocka wrote: On Thu, 8 Nov 2012, Paul E. McKenney wrote: On Thu, Nov 08, 2012 at 12:07:00PM -0800, Andrew Morton wrote: On Thu, 8 Nov 2012 14:48:49 +0100 Oleg Nesterov o...@redhat.com wrote: Currently the writer does

Re: [PATCH RESEND v2 1/1] percpu_rw_semaphore: reimplement to not block the readers unnecessarily

2012-11-08 Thread Paul E. McKenney
On Thu, Nov 08, 2012 at 04:41:36PM -0800, Paul E. McKenney wrote: On Thu, Nov 08, 2012 at 06:41:10PM -0500, Mikulas Patocka wrote: On Thu, 8 Nov 2012, Paul E. McKenney wrote: On Thu, Nov 08, 2012 at 12:07:00PM -0800, Andrew Morton wrote: On Thu, 8 Nov 2012 14:48:49 +0100