Re: [RFC PATCH 4/5] RCU: Add TASK_RCU_OFFSET

From: Paul E. McKenney
Date: Tue Apr 05 2011 - 17:55:06 EST


On Fri, Apr 01, 2011 at 01:35:49PM +0200, Peter Zijlstra wrote:
> On Fri, 2011-04-01 at 09:57 +0800, Lai Jiangshan wrote:
> >
> > We are trying to use inlined read_read_[un]lock(), it is required that sched.h
> > needs include rcupdate.h which causes many recursive including. Splitting rcupdate.h
> > only does not help.
>
> You're not making any kind of sense there.
>
> linux-2.6# cat kernel/sched_tmp.c
>
> #include <linux/sched.h>
>
> linux-2.6# make kernel/sched_tmp.i
> linux-2.6# awk '/^#/ { t=$0 } /rcu_read_lock/ { print t " " $0 }' kernel/sched_tmp.i
> # 60 "/usr/src/linux-2.6/include/linux/rcupdate.h" static inline void __rcu_read_lock_bh(void)
> # 60 "/usr/src/linux-2.6/include/linux/rcupdate.h" extern void __rcu_read_lock(void);
> # 258 "/usr/src/linux-2.6/include/linux/rcupdate.h" static inline int rcu_read_lock_held(void)
> # 258 "/usr/src/linux-2.6/include/linux/rcupdate.h" static inline int rcu_read_lock_bh_held(void)
> # 258 "/usr/src/linux-2.6/include/linux/rcupdate.h" static inline int rcu_read_lock_sched_held(void)
> # 559 "/usr/src/linux-2.6/include/linux/rcupdate.h" static inline void rcu_read_lock(void)
> # 559 "/usr/src/linux-2.6/include/linux/rcupdate.h" __rcu_read_lock();
> # 600 "/usr/src/linux-2.6/include/linux/rcupdate.h" static inline void rcu_read_lock_bh(void)
> # 600 "/usr/src/linux-2.6/include/linux/rcupdate.h" __rcu_read_lock_bh();
> # 627 "/usr/src/linux-2.6/include/linux/rcupdate.h" static inline void rcu_read_lock_sched(void)
> # 627 "/usr/src/linux-2.6/include/linux/rcupdate.h" static inline __attribute__((no_instrument_function)) void rcu_read_lock_sched_notrace(void)
> # 70 "/usr/src/linux-2.6/include/linux/srcu.h" int __srcu_read_lock(struct srcu_struct *sp) ;
> # 103 "/usr/src/linux-2.6/include/linux/srcu.h" static inline int srcu_read_lock_held(struct srcu_struct *sp)
> # 149 "/usr/src/linux-2.6/include/linux/srcu.h" static inline int srcu_read_lock(struct srcu_struct *sp)
> # 149 "/usr/src/linux-2.6/include/linux/srcu.h" int retval = __srcu_read_lock(sp);
> # 1227 "/usr/src/linux-2.6/include/linux/sched.h" int rcu_read_lock_nesting;
> # 1786 "/usr/src/linux-2.6/include/linux/sched.h" p->rcu_read_lock_nesting = 0;
>
> There isn't a single rcu_read_lock() user in the include chain of
> sched.h, therefore its possible to split rcupdate.h such that one part
> includes the bits needed for sched.h and another part that includes
> sched.h and provides rcu_read_lock().

Yep, you can easily split struct rcu_head out into its own header file,
and then include that into sched.h in place of rcupdate.h without trouble
(at least in the few builds I tried).

The trouble comes when you take the next step and include sched.h
into include/linux/rcutree.h, which would be needed to allow
TREE_PREEMPT_RCU's rcu_read_lock() and rcu_read_unlock() to be
inlined. This pulls sched.h into files that it was not already
included into, and we do get build failures (the first of which
requires changes local to RCU, FWIW).

Of course, it would be good to straighten this out.

Thanx, Paul
--
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/