Re: [PATCH RFC tip/core/rcu] SRCU rewrite

From: Lai Jiangshan
Date: Thu Nov 17 2016 - 13:42:01 EST


On Tue, Nov 15, 2016 at 10:37 PM, Paul E. McKenney
<paulmck@xxxxxxxxxxxxxxxxxx> wrote:
> On Tue, Nov 15, 2016 at 09:44:45AM +0800, Boqun Feng wrote:

>>
>> __srcu_read_lock() used to be called with preemption disabled. I guess
>> the reason was because we have two percpu variables to increase. So with
>> only one percpu right, could we remove the preempt_{dis,en}able() in
>> srcu_read_lock() and use this_cpu_inc() here?
>
> Quite possibly...
>

it will be nicer if it is removed.

The reason for the preemption-disabled was also because we
have to disallow any preemption between the fetching of the idx
and the increasement. so that we have at most NR_CPUS worth
of readers using the old index that haven't incremented the counters.

if we remove the preempt_{dis,en}able(). we must change the
"NR_CPUS" in the comment into ULONG_MAX/4. (I assume
one on-going reader needs at least need 4bytes at the stack). it is still safe.

but we still need to think more if we want to remove the preempt_{dis,en}able().

Thanks
Lai