Re: [PATCH RFC tip/core/rcu 05/11] rcu: add comment saying whyDEBUG_OBJECTS_RCU_HEAD depends on PREEMPT.

From: Steven Rostedt
Date: Wed Feb 23 2011 - 09:11:49 EST


On Wed, 2011-02-23 at 08:59 -0500, Mathieu Desnoyers wrote:
> * Steven Rostedt (rostedt@xxxxxxxxxxx) wrote:
> > On Tue, 2011-02-22 at 17:39 -0800, Paul E. McKenney wrote:
> > > The build will break if you change the Kconfig to allow
> > > DEBUG_OBJECTS_RCU_HEAD and !PREEMPT, so document the reasoning
> > > near where the breakage would occur.
> > >
> > > Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
> > > ---
> > > kernel/rcupdate.c | 5 +++++
> > > 1 files changed, 5 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
> > > index afd21d1..f3240e9 100644
> > > --- a/kernel/rcupdate.c
> > > +++ b/kernel/rcupdate.c
> > > @@ -214,6 +214,11 @@ static int rcuhead_fixup_free(void *addr, enum debug_obj_state state)
> > > * Ensure that queued callbacks are all executed.
> > > * If we detect that we are nested in a RCU read-side critical
> > > * section, we should simply fail, otherwise we would deadlock.
> > > + * Note that the machinery to reliably determine whether
> > > + * or not we are in an RCU read-side critical section
> > > + * exists only in the preemptible RCU implementations
> > > + * (TINY_PREEMPT_RCU and TREE_PREEMPT_RCU), which is why
> > > + * DEBUG_OBJECTS_RCU_HEAD is disallowed if !PREEMPT.
> > > */
> >
> > Shouldn't this comment also be in the kconfig where
> > DEBUG_OBJECTS_RCU_HEAD is defined?
>
> hrm, but this is a "rcuhead_fixup_init" : it does not need to always

Looks like it was in rcuhead_fixup_free to me.

> succeed. It's just that when it is safe to recover from an error
> situation, it does it. We could do:
>
> #ifdef CONFIG_PREEMPT
> /*
> * Ensure that queued callbacks are all executed.
> * If we detect that we are nested in a RCU read-side
> * critical
> * section, we should simply fail, otherwise we would
> * deadlock.
> */
> if (rcu_preempt_depth() != 0 || preempt_count() != 0 ||
> irqs_disabled()) {
> WARN_ON(1);
> return 0;
> }
> rcu_barrier();
> rcu_barrier_sched();
> rcu_barrier_bh();
> debug_object_init(head, &rcuhead_debug_descr);
> return 1;
> #else
> return 0;
> #endif
>
> instead, no ?

The point is that this entire block of code is wrapped in #ifdef
CONFIG_DEBUG_OBJECTS_RCU_HEAD, and that config depends on PREEMPT. Thus
you will never have a case where #ifdef CONFIG_PREEMPT is false.

-- Steve


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/