lkml.org 
[lkml]   [2013]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] rcu: Create rcu_sync infrastructure
On 10/04, Peter Zijlstra wrote:
>
> On Fri, Oct 04, 2013 at 01:15:13PM +0200, Oleg Nesterov wrote:
> > > What's exclusive to mean? One writer at a time?
> >
> > Yes,
>
> I'm not entirely sure what the advantage is of having that logic in this
> primitive. Shouldn't that be something the user of this rcu_sync stuff
> does (or not) depending on its needs.

Yes, the user can do the locking itself. But I think this option can help.
If nothing else it can help to avoid another mutex/whatever and unnecessary
wakeup/scheule's, even if this is minor.

And. rcu_sync_enter() should be "bool", it should return "need_sync". IOW,
rcu_sync_enter() == T means that this thread has done the FAST -> SLOW
transition, this is particularly useful in "exclusive" mode.

Consider percpu_down_write(). It takes rw_sem for writing (and this blocks
the readers) before clear_fast_ctr(), but we only need to do this this
after sync_sched(), so it could do

if (rcu_sync_enter(&brw->rcu_sync))
atomic_add(clear_fast_ctr(brw), &brw->slow_read_ctr);
else
; /* the above was already done */

/* exclude readers */
down_write(&brw->rw_sem);

and now ->rw_sem is only needed to serialize readers/writer.

Sure, this all is minor (and we will probably copy the "pending writer"
logic from cpu_hotplug_begin/get_online_cpus).

But we can get this feature almost for free, so I think it makes sense.

Oleg.



\
 
 \ /
  Last update: 2013-10-04 14:41    [W:1.851 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site