lkml.org 
[lkml]   [2013]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] rcu: Is it safe to enter an RCU read-side critical section?
On Fri, Sep 06, 2013 at 10:21:28AM -0700, Eric Dumazet wrote:
> On Fri, 2013-09-06 at 08:18 -0700, Paul E. McKenney wrote:
>
> > int rcu_is_cpu_idle(void)
> > {
> > int ret;
> >
> > preempt_disable();
> > ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
> > preempt_enable();
> > return ret;
> > }
>
> Paul I find this very confusing.
>
> If caller doesn't have preemption disabled, what could be the meaning of
> this rcu_is_cpu_idle() call ?
>
> Its result is meaningless if suddenly thread is preempted, so what is
> the point ?
>
> Sorry if this is obvious to you.

It is a completely fair question. In fact, this might well now be
pointing to a bug given NO_HZ_FULL.

The assumption is that if you don't have preemption disabled, you had
better be running on a CPU that RCU is paying attention to. The rationale
involves preemptible RCU.

Suppose that you just did rcu_read_lock() on a CPU that RCU is paying
attention to. All is well, and rcu_is_cpu_idle() will return false, as
expected. Suppose now that it is possible to be preempted and suddenly
find yourself running on a CPU that RCU is not paying attention to.
This would have the effect of making your RCU read-side critical section
be ignored. Therefore, it had better not be possible to be preempted
from a CPU to which RCU is paying attention to a CPU that RCU is ignoring.

So if rcu_is_cpu_idle() returns false, you had better be guaranteed
that whatever CPU you are running on (which might well be a different
one than the rcu_is_cpu_idle() was running on) is being watched by RCU.

So, Frederic, does this still work with NO_HZ_FULL? If not, I believe
we have a bigger problem than the preempt_disable() in rcu_is_cpu_idle()!

Thanx, Paul



\
 
 \ /
  Last update: 2013-09-06 20:01    [W:0.160 / U:1.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site