Re: [PATCH] rcu: make PREEMPT_RCU to be a decoration of TREE_RCU

From: Paul E. McKenney
Date: Tue Oct 15 2019 - 06:48:40 EST


On Tue, Oct 15, 2019 at 11:01:00AM +0800, Lai Jiangshan wrote:
> On 2019/10/15 10:45 äå, Lai Jiangshan wrote:
> > On 2019/10/15 10:00 äå, Paul E. McKenney wrote:
> > > On Tue, Oct 15, 2019 at 09:50:21AM +0800, Lai Jiangshan wrote:
> > > > On Tue, Oct 15, 2019 at 9:46 AM Paul E. McKenney
> > > > <paulmck@xxxxxxxxxx> wrote:
> > > > >
> > > > > On Mon, Oct 14, 2019 at 02:48:32PM -0400, Joel Fernandes wrote:
> > > > > > On Sun, Oct 13, 2019 at 12:59:57PM +0000, Lai Jiangshan wrote:
> > > > > > > Currently PREEMPT_RCU and TREE_RCU are "contrary" configs
> > > > > > > when they can't be both on. But PREEMPT_RCU is actually a kind
> > > > > > > of TREE_RCU in the implementation. It seams to be appropriate
> > > > > > > to make PREEMPT_RCU to be a decorative option of TREE_RCU.
> > > > > > >
> > > > > >
> > > > > > Looks like a nice simplification and so far I could not
> > > > > > poke any holes in the
> > > > > > code...
> > > > > >
> > > > > > I am in support of this patch for further review and testing. Thanks!
> > > > > >
> > > > > > Reviewed-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx>
> > > > >
> > > > > Thank you both!
> > > > >
> > > > > Lai, what is this patch against? It does not want to apply
> > > > > to the current
> > > > > -rcu "dev" branch.
> > > >
> > > > Oh, sorry
> > > >
> > > > I wrongly made the change base on upstream.
> > > > I will rebase later.
> > >
> > > Very good, looking forward to this updated version.
> > >
> > > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ Thanx, Paul
> >
> >
> > In my box, the patch can be applied to the -rcu "dev" well.
>
> Oh, I first applied it by "git cherry-pick" not "git am".
> It did have conflicts when using "git am". Updated patch
> was sent, sorry for the nosing.

No problem, and that is why I asked you where it applied. I do sometimes
"git am" to wherever you put it, then "git cherrypick" to move it to where
it belongs. But much better when you rebase it as you have done!

Thanx, Paul

> thanks
> Lai
>
>
> > And there is nothing strange after boot.
> >
> > Have I just made a mistake a again? In my box, the HEAD
> > of -rcu "dev" is 9725023b ("torture: Handle jitter for CPUs that cannot
> > be offlined")
> >
> > Thanks
> > Lai
> >
> > >
> > > > thanks
> > > > Lai
> > > >
> > > > >
> > > > > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ Thanx, Paul
> > > > >
> > > > > > thanks,
> > > > > >
> > > > > > Â - Joel
> > > > > >
> > > > > >
> > > > > > > Signed-off-by: Lai Jiangshan <jiangshanlai@xxxxxxxxx>
> > > > > > > Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>
> > > > > > > ---
> > > > > > > Â include/linux/rcupdate.hÂÂ |Â 4 ++--
> > > > > > > Â include/trace/events/rcu.h |Â 4 ++--
> > > > > > > Â kernel/rcu/KconfigÂÂÂÂÂÂÂÂ | 13 +++++++------
> > > > > > > Â kernel/rcu/MakefileÂÂÂÂÂÂÂ |Â 1 -
> > > > > > > Â kernel/rcu/rcu.hÂÂÂÂÂÂÂÂÂÂ |Â 2 +-
> > > > > > > Â kernel/rcu/update.cÂÂÂÂÂÂÂ |Â 2 +-
> > > > > > > Â kernel/sysctl.cÂÂÂÂÂÂÂÂÂÂÂ |Â 2 +-
> > > > > > > Â 7 files changed, 14 insertions(+), 14 deletions(-)
> > > > > > >
> > > > > > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> > > > > > > index 75a2eded7aa2..1eee9f6c27f9 100644
> > > > > > > --- a/include/linux/rcupdate.h
> > > > > > > +++ b/include/linux/rcupdate.h
> > > > > > > @@ -167,7 +167,7 @@ do { \
> > > > > > > ÂÂ * TREE_RCU and rcu_barrier_() primitives in TINY_RCU.
> > > > > > > ÂÂ */
> > > > > > >
> > > > > > > -#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
> > > > > > > +#if defined(CONFIG_TREE_RCU)
> > > > > > > Â #include <linux/rcutree.h>
> > > > > > > Â #elif defined(CONFIG_TINY_RCU)
> > > > > > > Â #include <linux/rcutiny.h>
> > > > > > > @@ -583,7 +583,7 @@ do {
> > > > > > > \
> > > > > > > ÂÂ * read-side critical section that would block in
> > > > > > > a !PREEMPT kernel.
> > > > > > > ÂÂ * But if you want the full story, read on!
> > > > > > > ÂÂ *
> > > > > > > - * In non-preemptible RCU implementations (TREE_RCU and TINY_RCU),
> > > > > > > + * In non-preemptible RCU implementations (pure
> > > > > > > TREE_RCU and TINY_RCU),
> > > > > > > ÂÂ * it is illegal to block while in an RCU
> > > > > > > read-side critical section.
> > > > > > > ÂÂ * In preemptible RCU implementations
> > > > > > > (PREEMPT_RCU) in CONFIG_PREEMPTION
> > > > > > > ÂÂ * kernel builds, RCU read-side critical sections may be preempted,
> > > > > > > diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h
> > > > > > > index 694bd040cf51..1ce15c5be4c8 100644
> > > > > > > --- a/include/trace/events/rcu.h
> > > > > > > +++ b/include/trace/events/rcu.h
> > > > > > > @@ -41,7 +41,7 @@ TRACE_EVENT(rcu_utilization,
> > > > > > > ÂÂÂÂ TP_printk("%s", __entry->s)
> > > > > > > Â );
> > > > > > >
> > > > > > > -#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
> > > > > > > +#if defined(CONFIG_TREE_RCU)
> > > > > > >
> > > > > > > Â /*
> > > > > > >  * Tracepoint for grace-period events. Takes a
> > > > > > > string identifying the
> > > > > > > @@ -425,7 +425,7 @@ TRACE_EVENT_RCU(rcu_fqs,
> > > > > > > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ __entry->cpu, __entry->qsevent)
> > > > > > > Â );
> > > > > > >
> > > > > > > -#endif /* #if defined(CONFIG_TREE_RCU) ||
> > > > > > > defined(CONFIG_PREEMPT_RCU) */
> > > > > > > +#endif /* #if defined(CONFIG_TREE_RCU) */
> > > > > > >
> > > > > > > Â /*
> > > > > > > ÂÂ * Tracepoint for dyntick-idle entry/exit events.Â
> > > > > > > These take a string
> > > > > > > diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig
> > > > > > > index 7644eda17d62..0303934e6ef0 100644
> > > > > > > --- a/kernel/rcu/Kconfig
> > > > > > > +++ b/kernel/rcu/Kconfig
> > > > > > > @@ -7,7 +7,7 @@ menu "RCU Subsystem"
> > > > > > >
> > > > > > > Â config TREE_RCU
> > > > > > > ÂÂÂÂ bool
> > > > > > > -ÂÂ default y if !PREEMPTION && SMP
> > > > > > > +ÂÂ default y if SMP
> > > > > > > ÂÂÂÂ help
> > > > > > > ÂÂÂÂÂÂ This option selects the RCU implementation that is
> > > > > > > ÂÂÂÂÂÂ designed for very large SMP system with hundreds or
> > > > > > > @@ -17,6 +17,7 @@ config TREE_RCU
> > > > > > > Â config PREEMPT_RCU
> > > > > > > ÂÂÂÂ bool
> > > > > > > ÂÂÂÂ default y if PREEMPTION
> > > > > > > +ÂÂ select TREE_RCU
> > > > > > > ÂÂÂÂ help
> > > > > > > ÂÂÂÂÂÂ This option selects the RCU implementation that is
> > > > > > > ÂÂÂÂÂÂ designed for very large SMP systems with hundreds or
> > > > > > > @@ -78,7 +79,7 @@ config TASKS_RCU
> > > > > > > ÂÂÂÂÂÂ user-mode execution as quiescent states.
> > > > > > >
> > > > > > > Â config RCU_STALL_COMMON
> > > > > > > -ÂÂ def_bool ( TREE_RCU || PREEMPT_RCU )
> > > > > > > +ÂÂ def_bool TREE_RCU
> > > > > > > ÂÂÂÂ help
> > > > > > > ÂÂÂÂÂÂ This option enables RCU CPU stall code that is common between
> > > > > > >  the TINY and TREE variants of RCU. The purpose is to allow
> > > > > > > @@ -86,13 +87,13 @@ config RCU_STALL_COMMON
> > > > > > > ÂÂÂÂÂÂ making these warnings mandatory for the tree variants.
> > > > > > >
> > > > > > > Â config RCU_NEED_SEGCBLIST
> > > > > > > -ÂÂ def_bool ( TREE_RCU || PREEMPT_RCU || TREE_SRCU )
> > > > > > > +ÂÂ def_bool ( TREE_RCU || TREE_SRCU )
> > > > > > >
> > > > > > > Â config RCU_FANOUT
> > > > > > > ÂÂÂÂ int "Tree-based hierarchical RCU fanout value"
> > > > > > > ÂÂÂÂ range 2 64 if 64BIT
> > > > > > > ÂÂÂÂ range 2 32 if !64BIT
> > > > > > > -ÂÂ depends on (TREE_RCU || PREEMPT_RCU) && RCU_EXPERT
> > > > > > > +ÂÂ depends on TREE_RCU && RCU_EXPERT
> > > > > > > ÂÂÂÂ default 64 if 64BIT
> > > > > > > ÂÂÂÂ default 32 if !64BIT
> > > > > > > ÂÂÂÂ help
> > > > > > > @@ -112,7 +113,7 @@ config RCU_FANOUT_LEAF
> > > > > > > ÂÂÂÂ int "Tree-based hierarchical RCU leaf-level fanout value"
> > > > > > > ÂÂÂÂ range 2 64 if 64BIT
> > > > > > > ÂÂÂÂ range 2 32 if !64BIT
> > > > > > > -ÂÂ depends on (TREE_RCU || PREEMPT_RCU) && RCU_EXPERT
> > > > > > > +ÂÂ depends on TREE_RCU && RCU_EXPERT
> > > > > > > ÂÂÂÂ default 16
> > > > > > > ÂÂÂÂ help
> > > > > > > ÂÂÂÂÂÂ This option controls the leaf-level fanout of hierarchical
> > > > > > > @@ -187,7 +188,7 @@ config RCU_BOOST_DELAY
> > > > > > >
> > > > > > > Â config RCU_NOCB_CPU
> > > > > > > ÂÂÂÂ bool "Offload RCU callback processing from boot-selected CPUs"
> > > > > > > -ÂÂ depends on TREE_RCU || PREEMPT_RCU
> > > > > > > +ÂÂ depends on TREE_RCU
> > > > > > > ÂÂÂÂ depends on RCU_EXPERT || NO_HZ_FULL
> > > > > > > ÂÂÂÂ default n
> > > > > > > ÂÂÂÂ help
> > > > > > > diff --git a/kernel/rcu/Makefile b/kernel/rcu/Makefile
> > > > > > > index 020e8b6a644b..82d5fba48b2f 100644
> > > > > > > --- a/kernel/rcu/Makefile
> > > > > > > +++ b/kernel/rcu/Makefile
> > > > > > > @@ -9,6 +9,5 @@ obj-$(CONFIG_TINY_SRCU) += srcutiny.o
> > > > > > > Â obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
> > > > > > > Â obj-$(CONFIG_RCU_PERF_TEST) += rcuperf.o
> > > > > > > Â obj-$(CONFIG_TREE_RCU) += tree.o
> > > > > > > -obj-$(CONFIG_PREEMPT_RCU) += tree.o
> > > > > > > Â obj-$(CONFIG_TINY_RCU) += tiny.o
> > > > > > > Â obj-$(CONFIG_RCU_NEED_SEGCBLIST) += rcu_segcblist.o
> > > > > > > diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
> > > > > > > index 8fd4f82c9b3d..4149ba76824f 100644
> > > > > > > --- a/kernel/rcu/rcu.h
> > > > > > > +++ b/kernel/rcu/rcu.h
> > > > > > > @@ -452,7 +452,7 @@ enum rcutorture_type {
> > > > > > > ÂÂÂÂ INVALID_RCU_FLAVOR
> > > > > > > Â };
> > > > > > >
> > > > > > > -#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
> > > > > > > +#if defined(CONFIG_TREE_RCU)
> > > > > > > Â void rcutorture_get_gp_data(enum rcutorture_type
> > > > > > > test_type, int *flags,
> > > > > > > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ unsigned long *gp_seq);
> > > > > > > Â void rcutorture_record_progress(unsigned long vernum);
> > > > > > > diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
> > > > > > > index 1861103662db..34a7452b25fd 100644
> > > > > > > --- a/kernel/rcu/update.c
> > > > > > > +++ b/kernel/rcu/update.c
> > > > > > > @@ -435,7 +435,7 @@ struct debug_obj_descr rcuhead_debug_descr = {
> > > > > > > Â EXPORT_SYMBOL_GPL(rcuhead_debug_descr);
> > > > > > > Â #endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
> > > > > > >
> > > > > > > -#if defined(CONFIG_TREE_RCU) ||
> > > > > > > defined(CONFIG_PREEMPT_RCU) ||
> > > > > > > defined(CONFIG_RCU_TRACE)
> > > > > > > +#if defined(CONFIG_TREE_RCU) || defined(CONFIG_RCU_TRACE)
> > > > > > > Â void do_trace_rcu_torture_read(const char
> > > > > > > *rcutorturename, struct rcu_head *rhp,
> > > > > > > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ unsigned long secs,
> > > > > > > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ unsigned long c_old, unsigned long c)
> > > > > > > diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> > > > > > > index 00fcea236eba..2ace158a4d72 100644
> > > > > > > --- a/kernel/sysctl.c
> > > > > > > +++ b/kernel/sysctl.c
> > > > > > > @@ -1268,7 +1268,7 @@ static struct ctl_table kern_table[] = {
> > > > > > > ÂÂÂÂÂÂÂÂÂÂÂÂ .proc_handlerÂÂ = proc_do_static_key,
> > > > > > > ÂÂÂÂ },
> > > > > > > Â #endif
> > > > > > > -#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
> > > > > > > +#if defined(CONFIG_TREE_RCU)
> > > > > > > ÂÂÂÂ {
> > > > > > > ÂÂÂÂÂÂÂÂÂÂÂÂ .procnameÂÂÂÂÂÂ = "panic_on_rcu_stall",
> > > > > > > ÂÂÂÂÂÂÂÂÂÂÂÂ .dataÂÂÂÂÂÂÂÂÂÂ = &sysctl_panic_on_rcu_stall,
> > > > > > > --
> > > > > > > 2.20.1
> > > > > > >