Skip to contentSkip to conversation

RCU: various patches

PATCH In review Dipankar Sarma 4 participants 18 messages Sep 23, 2006 – Sep 28, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RCU: various patches

This patchset consists of various merge candidates that would do well to have some testing in -mm. This patchset breaks out RCU implementation from its APIs to allow multiple implementations, gives RCU its own softirq and finally lines up preemptible RCU from -rt tree as a configurable RCU implementation for mainline. Published earlier and re-diffed against -mm.

They have been tested lightly using combinations of rcutorture, dbench, kernbench and ltp (both CONFIG_CLASSIC_RCU=y and CONFIG_RCU_PREEMPT=y) on x86 and ppc64.

Thanks
Dipankar

#1 lore raw

Re: [-mm PATCH 1/4] RCU: split classic rcu

This patch re-organizes the RCU code to enable multiple implementations of RCU. Users of RCU continues to include rcupdate.h and the RCU interfaces remain the same. This is in preparation for subsequently merging the preepmtpible RCU implementation.

---

 include/linux/rcuclassic.h |  149 +++++++++++
 include/linux/rcupdate.h   |  153 +++---------
 kernel/Makefile            |    2 
 kernel/rcuclassic.c        |  558 ++++++++++++++++++++++++++++++++++++++++++++
 kernel/rcupdate.c          |  562 ++-------------------------------------------
 5 files changed, 783 insertions(+), 641 deletions(-)
include/linux/rcuclassic.h new file +149 -0
diff -puN /dev/null include/linux/rcuclassic.h
@@ -0,0 +1,149 @@
+/*
+ * Read-Copy Update mechanism for mutual exclusion (classic version)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) IBM Corporation, 2001
+ *
+ * Author: Dipankar Sarma <[email protected]>
+ * 
+ * Based on the original work by Paul McKenney <[email protected]>
+ * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen.
+ * Papers:
+ * http://www.rdrop.com/users/paulmck/paper/rclockpdcsproof.pdf
+ * http://lse.sourceforge.net/locking/rclock_OLS.2001.05.01c.sc.pdf (OLS2001)
+ *
+ * For detailed explanation of Read-Copy Update mechanism see -
+ * 		http://lse.sourceforge.net/locking/rcupdate.html
+ *
+ */
+
+#ifndef __LINUX_RCUCLASSIC_H
+#define __LINUX_RCUCLASSIC_H
+
+#ifdef __KERNEL__
+
+#include <linux/cache.h>
+#include <linux/spinlock.h>
+#include <linux/threads.h>
+#include <linux/percpu.h>
+#include <linux/cpumask.h>
+#include <linux/seqlock.h>
+
+
+/* Global control variables for rcupdate callback mechanism. */
+struct rcu_ctrlblk {
+	long	cur;		/* Current batch number.                      */
+	long	completed;	/* Number of the last completed batch         */
+	int	next_pending;	/* Is the next batch already waiting?         */
+
+	spinlock_t	lock	____cacheline_internodealigned_in_smp;
+	cpumask_t	cpumask; /* CPUs that need to switch in order    */
+	                         /* for current batch to proceed.        */
+} ____cacheline_internodealigned_in_smp;
+
+/* Is batch a before batch b ? */
+static inline int rcu_batch_before(long a, long b)
+{
+        return (a - b) < 0;
+}
+
+/* Is batch a after batch b ? */
+static inline int rcu_batch_after(long a, long b)
+{
+        return (a - b) > 0;
+}
+
+/*
+ * Per-CPU data for Read-Copy UPdate.
+ * nxtlist - new callbacks are added here
+ * curlist - current batch for which quiescent cycle started if any
+ */
+struct rcu_data {
+	/* 1) quiescent state handling : */
+	long		quiescbatch;     /* Batch # for grace period */
+	int		passed_quiesc;	 /* User-mode/idle loop etc. */
+	int		qs_pending;	 /* core waits for quiesc state */
+
+	/* 2) batch handling */
+	long  	       	batch;           /* Batch # for current RCU batch */
+	struct rcu_head *nxtlist;
+	struct rcu_head **nxttail;
+	long            qlen; 	 	 /* # of queued callbacks */
+	struct rcu_head *curlist;
+	struct rcu_head **curtail;
+	struct rcu_head *donelist;
+	struct rcu_head **donetail;
+	long		blimit;		 /* Upper limit on a processed batch */
+	int cpu;
+#ifdef CONFIG_SMP
+	long		last_rs_qlen;	 /* qlen during the last resched */
+#endif
+};
+
+DECLARE_PER_CPU(struct rcu_data, rcu_data);
+DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
+
+/*
+ * Increment the quiescent state counter.
+ * The counter is a bit degenerated: We do not need to know
+ * how many quiescent states passed, just if there was at least
+ * one since the start of the grace period. Thus just a flag.
+ */
+static inline void rcu_qsctr_inc(int cpu)
+{
+	struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
+	rdp->passed_quiesc = 1;
+}
+static inline void rcu_bh_qsctr_inc(int cpu)
+{
+	struct rcu_data *rdp = &per_cpu(rcu_bh_data, cpu);
+	rdp->passed_quiesc = 1;
+}
+
+extern int rcu_pending(int cpu);
+extern int rcu_needs_cpu(int cpu);
+
+#define __rcu_read_lock() \
+	do { \
+		preempt_disable(); \
+		__acquire(RCU); \
+	} while(0)
+#define __rcu_read_unlock() \
+	do { \
+		__release(RCU); \
+		preempt_enable(); \
+	} while(0)
+
+#define __rcu_read_lock_bh() \
+	do { \
+		local_bh_disable(); \
+		__acquire(RCU_BH); \
+	} while(0)
+#define __rcu_read_unlock_bh() \
+	do { \
+		__release(RCU_BH); \
+		local_bh_enable(); \
+	} while(0)
+
+#define __synchronize_sched()	synchronize_rcu()
+
+extern void __rcu_init(void);
+extern void rcu_check_callbacks(int cpu, int user);
+extern void rcu_restart_cpu(int cpu);
+extern long rcu_batches_completed(void);
+
+#endif /* __KERNEL__ */
+#endif /* __LINUX_RCUCLASSIC_H */
include/linux/rcupdate.h renamed from include/linux/rcupdate.h~rcu-split-classic +45 -108

199 lines not on this page · raw message

kernel/Makefile renamed from kernel/Makefile~rcu-split-classic +1 -1
diff -puN kernel/Makefile~rcu-split-classic kernel/Makefile
@@ -6,7 +6,7 @@ obj-y     = sched.o fork.o exec_domain.o
 	    exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
 	    signal.o sys.o kmod.o workqueue.o pid.o \
-	    rcupdate.o extable.o params.o posix-timers.o \
+	    rcupdate.o rcuclassic.o extable.o params.o posix-timers.o \
 	    kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
 	    hrtimer.o rwsem.o latency.o nsproxy.o srcu.o
 
kernel/rcuclassic.c new file +558 -0

558 lines not on this page · raw message

kernel/rcupdate.c renamed from kernel/rcupdate.c~rcu-split-classic +30 -532

605 lines not on this page · raw message

_

#6 lore raw

Re: [-mm PATCH 2/4]RCU: softirq for RCU

In reply to Dipankar Sarma

Finally, RCU gets its own softirq. With it being used extensively, the per-cpu tasklet used earlier was just a softirq with overheads. This makes things more efficient.

---

 include/linux/interrupt.h |    3 ++-
 kernel/rcuclassic.c       |   12 +++++-------
 2 files changed, 7 insertions(+), 8 deletions(-)
include/linux/interrupt.h renamed from include/linux/interrupt.h~rcu-softirq +2 -1
diff -puN include/linux/interrupt.h~rcu-softirq include/linux/interrupt.h
@@ -237,7 +237,8 @@ enum
 	NET_TX_SOFTIRQ,
 	NET_RX_SOFTIRQ,
 	BLOCK_SOFTIRQ,
-	TASKLET_SOFTIRQ
+	TASKLET_SOFTIRQ,
+	RCU_SOFTIRQ	/* Preferable RCU should always be the last softirq */
 };
 
 /* softirq mask and active fields moved to irq_cpustat_t in
kernel/rcuclassic.c renamed from kernel/rcuclassic.c~rcu-softirq +5 -7
diff -puN kernel/rcuclassic.c~rcu-softirq kernel/rcuclassic.c
@@ -69,7 +69,6 @@ DEFINE_PER_CPU(struct rcu_data, rcu_data
 DEFINE_PER_CPU(struct rcu_data, rcu_bh_data) = { 0L };
 
 /* Fake initialization required by compiler */
-static DEFINE_PER_CPU(struct tasklet_struct, rcu_tasklet) = {NULL};
 static int blimit = 10;
 static int qhimark = 10000;
 static int qlowmark = 100;
@@ -212,7 +211,7 @@ static void rcu_do_batch(struct rcu_data
 	if (!rdp->donelist)
 		rdp->donetail = &rdp->donelist;
 	else
-		tasklet_schedule(&per_cpu(rcu_tasklet, rdp->cpu));
+		raise_softirq(RCU_SOFTIRQ);
 }
 
 /*
@@ -363,7 +362,6 @@ static void rcu_offline_cpu(int cpu)
 					&per_cpu(rcu_bh_data, cpu));
 	put_cpu_var(rcu_data);
 	put_cpu_var(rcu_bh_data);
-	tasklet_kill_immediate(&per_cpu(rcu_tasklet, cpu), cpu);
 }
 
 #else
@@ -375,7 +373,7 @@ static void rcu_offline_cpu(int cpu)
 #endif
 
 /*
- * This does the RCU processing work from tasklet context. 
+ * This does the RCU processing work from softirq context. 
  */
 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp,
 					struct rcu_data *rdp)
@@ -420,7 +418,7 @@ static void __rcu_process_callbacks(stru
 		rcu_do_batch(rdp);
 }
 
-static void rcu_process_callbacks(unsigned long unused)
+static void rcu_process_callbacks(struct softirq_action *unused)
 {
 	__rcu_process_callbacks(&rcu_ctrlblk, &__get_cpu_var(rcu_data));
 	__rcu_process_callbacks(&rcu_bh_ctrlblk, &__get_cpu_var(rcu_bh_data));
@@ -484,7 +482,7 @@ void rcu_check_callbacks(int cpu, int us
 		rcu_bh_qsctr_inc(cpu);
 	} else if (!in_softirq())
 		rcu_bh_qsctr_inc(cpu);
-	tasklet_schedule(&per_cpu(rcu_tasklet, cpu));
+	raise_softirq(RCU_SOFTIRQ);
 }
 
 static void rcu_init_percpu_data(int cpu, struct rcu_ctrlblk *rcp,
@@ -507,7 +505,7 @@ static void __devinit rcu_online_cpu(int
 
 	rcu_init_percpu_data(cpu, &rcu_ctrlblk, rdp);
 	rcu_init_percpu_data(cpu, &rcu_bh_ctrlblk, bh_rdp);
-	tasklet_init(&per_cpu(rcu_tasklet, cpu), rcu_process_callbacks, 0UL);
+	open_softirq(RCU_SOFTIRQ, rcu_process_callbacks, NULL);
 }
 
 static int __cpuinit rcu_cpu_notify(struct notifier_block *self,

_

#7 lore raw

Re: [-mm PATCH 3/4] RCU: preemptible RCU

In reply to Dipankar Sarma

From: Paul McKenney <[email protected]>

This patch implements a new version of RCU which allows its read-side critical sections to be preempted. It uses a set of counter pairs to keep track of the read-side critical sections and flips them when all tasks exit read-side critical section. The details of this implementation can be found in this paper -

http://www.rdrop.com/users/paulmck/RCU/OLSrtRCU.2006.08.11a.pdf

This patch was developed as a part of the -rt kernel development and meant to provide better latencies when read-side critical sections of RCU don't disable preemption. As a consequence of keeping track of RCU readers, the readers have a slight overhead (optimizations in the paper). This implementation co-exists with the "classic" RCU implementations and can be switched to at compiler.

 include/linux/rcupdate.h   |    5 
 include/linux/rcupreempt.h |   66 ++++++
 include/linux/sched.h      |    6 
 kernel/Kconfig.preempt     |   37 +++
 kernel/Makefile            |    4 
 kernel/rcupreempt.c        |  464 +++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 581 insertions(+), 1 deletion(-)
include/linux/rcupdate.h renamed from include/linux/rcupdate.h~rcu-preempt +5 -0
diff -puN include/linux/rcupdate.h~rcu-preempt include/linux/rcupdate.h
@@ -41,7 +41,12 @@
 #include <linux/percpu.h>
 #include <linux/cpumask.h>
 #include <linux/seqlock.h>
+#include <linux/config.h>
+#ifdef CONFIG_CLASSIC_RCU
 #include <linux/rcuclassic.h>
+#else
+#include <linux/rcupreempt.h>
+#endif
 
 /**
  * struct rcu_head - callback structure for use with RCU
include/linux/rcupreempt.h new file +66 -0

66 lines not on this page · raw message

include/linux/sched.h renamed from include/linux/sched.h~rcu-preempt +6 -0
diff -puN include/linux/sched.h~rcu-preempt include/linux/sched.h
@@ -826,6 +826,12 @@ struct task_struct {
 	cpumask_t cpus_allowed;
 	unsigned int time_slice, first_time_slice;
 
+#ifdef CONFIG_PREEMPT_RCU
+        int rcu_read_lock_nesting;
+        atomic_t *rcu_flipctr1;
+        atomic_t *rcu_flipctr2;
+#endif
+
 #if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
 	struct sched_info sched_info;
 #endif
kernel/Kconfig.preempt renamed from kernel/Kconfig.preempt~rcu-preempt +37 -0
diff -puN kernel/Kconfig.preempt~rcu-preempt kernel/Kconfig.preempt
@@ -63,3 +63,40 @@ config PREEMPT_BKL
 	  Say Y here if you are building a kernel for a desktop system.
 	  Say N if you are unsure.
 
+choice
+	prompt "RCU implementation type:"
+	default CLASSIC_RCU
+
+config CLASSIC_RCU
+	bool "Classic RCU"
+	help
+	  This option selects the classic RCU implementation that is
+	  designed for best read-side performance on non-realtime
+	  systems.
+
+	  Say Y if you are unsure.
+
+config PREEMPT_RCU
+	bool "Preemptible RCU"
+	help
+	  This option reduces the latency of the kernel by making certain
+	  RCU sections preemptible. Normally RCU code is non-preemptible, if
+	  this option is selected then read-only RCU sections become
+	  preemptible. This helps latency, but may expose bugs due to
+	  now-naive assumptions about each RCU read-side critical section
+	  remaining on a given CPU through its execution.
+
+	  Say N if you are unsure.
+
+endchoice
+
+config RCU_STATS
+	bool "/proc stats for preemptible RCU read-side critical sections"
+	depends on PREEMPT_RCU
+	default y
+	help
+	  This option provides /proc stats to provide debugging info for
+	  the preemptible realtime RCU implementation.
+
+	  Say Y here if you want to see RCU stats in /proc
+	  Say N if you are unsure.
kernel/Makefile renamed from kernel/Makefile~rcu-preempt +3 -1
diff -puN kernel/Makefile~rcu-preempt kernel/Makefile
@@ -6,7 +6,7 @@ obj-y     = sched.o fork.o exec_domain.o
 	    exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o capability.o ptrace.o timer.o user.o \
 	    signal.o sys.o kmod.o workqueue.o pid.o \
-	    rcupdate.o rcuclassic.o extable.o params.o posix-timers.o \
+	    extable.o params.o posix-timers.o \
 	    kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
 	    hrtimer.o rwsem.o latency.o nsproxy.o srcu.o
 
@@ -47,6 +47,8 @@ obj-$(CONFIG_DETECT_SOFTLOCKUP) += softl
 obj-$(CONFIG_GENERIC_HARDIRQS) += irq/
 obj-$(CONFIG_SECCOMP) += seccomp.o
 obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
+obj-$(CONFIG_CLASSIC_RCU) += rcupdate.o rcuclassic.o
+obj-$(CONFIG_PREEMPT_RCU) += rcupdate.o rcupreempt.o
 obj-$(CONFIG_DEBUG_SYNCHRO_TEST) += synchro-test.o
 obj-$(CONFIG_RELAY) += relay.o
 obj-$(CONFIG_UTS_NS) += utsname.o
kernel/rcupreempt.c new file +464 -0

464 lines not on this page · raw message

_

#8 lore raw

Re: [-mm PATCH 4/4] RCU: preempt rcu trace

In reply to Dipankar Sarma

This patch consolidates the RCU tracing code in the preemptible RCU implementation, moves them to a separate "trace" file and cleans up the #ifdefs. Moving to a separate file will eventually allow dynamic tracing of RCU implementation.

---

 include/linux/rcupreempt_trace.h |   84 ++++++++++++++++++++++++++++
 kernel/Kconfig.preempt           |   11 +--
 kernel/Makefile                  |    1 
 kernel/rcupreempt.c              |  113 ++++++++++++---------------------------
 kernel/rcupreempt_trace.c        |   99 ++++++++++++++++++++++++++++++++++
 5 files changed, 225 insertions(+), 83 deletions(-)
include/linux/rcupreempt_trace.h new file +84 -0
diff -puN /dev/null include/linux/rcupreempt_trace.h
@@ -0,0 +1,84 @@
+/*
+ * Read-Copy Update mechanism for mutual exclusion (RT implementation)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) IBM Corporation, 2006
+ *
+ * Author:  Paul McKenney <[email protected]>
+ * 
+ * Based on the original work by Paul McKenney <[email protected]>
+ * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen.
+ * Papers:
+ * http://www.rdrop.com/users/paulmck/paper/rclockpdcsproof.pdf
+ * http://lse.sourceforge.net/locking/rclock_OLS.2001.05.01c.sc.pdf (OLS2001)
+ *
+ * For detailed explanation of Read-Copy Update mechanism see -
+ * 		http://lse.sourceforge.net/locking/rcupdate.html
+ *
+ */
+
+#ifndef __LINUX_RCUPREEMPT_TRACE_H
+#define __LINUX_RCUPREEMPT_TRACE_H
+
+#ifdef __KERNEL__
+#include <linux/types.h>
+#include <linux/kernel.h>
+
+#include <asm/atomic.h>
+
+/*
+ * PREEMPT_RCU data structures.
+ */
+
+struct rcupreempt_trace {
+	long		next_length;
+	long		next_add;
+	long		wait_length;
+	long		wait_add;
+	long		done_length;
+	long		done_add;
+	long		done_remove;
+	atomic_t	done_invoked;
+	long		rcu_check_callbacks;
+	atomic_t	rcu_try_flip1;
+	long		rcu_try_flip2;
+	long		rcu_try_flip3;
+	atomic_t	rcu_try_flip_e1;
+	long		rcu_try_flip_e2;
+	long		rcu_try_flip_e3;
+};
+
+#ifdef CONFIG_RCU_TRACE
+#define RCU_TRACE(fn, arg) 	fn(arg);
+#else
+#define RCU_TRACE(fn, arg)
+#endif
+
+extern void rcupreempt_trace_move2done(struct rcupreempt_trace *trace);
+extern void rcupreempt_trace_move2wait(struct rcupreempt_trace *trace);
+extern void rcupreempt_trace_try_flip1(struct rcupreempt_trace *trace);
+extern void rcupreempt_trace_try_flip_e1(struct rcupreempt_trace *trace);
+extern void rcupreempt_trace_try_flip_e2(struct rcupreempt_trace *trace);
+extern void rcupreempt_trace_try_flip_e3(struct rcupreempt_trace *trace);
+extern void rcupreempt_trace_try_flip2(struct rcupreempt_trace *trace);
+extern void rcupreempt_trace_try_flip3(struct rcupreempt_trace *trace);
+extern void rcupreempt_trace_check_callbacks(struct rcupreempt_trace *trace);
+extern void rcupreempt_trace_done_remove(struct rcupreempt_trace *trace);
+extern void rcupreempt_trace_invoke(struct rcupreempt_trace *trace);
+extern void rcupreempt_trace_next_add(struct rcupreempt_trace *trace);
+
+#endif /* __KERNEL__ */
+#endif /* __LINUX_RCUPREEMPT_TRACE_H */
kernel/Kconfig.preempt renamed from kernel/Kconfig.preempt~rcu-preempt-trace +5 -6
diff -puN kernel/Kconfig.preempt~rcu-preempt-trace kernel/Kconfig.preempt
@@ -90,13 +90,12 @@ config PREEMPT_RCU
 
 endchoice
 
-config RCU_STATS
-	bool "/proc stats for preemptible RCU read-side critical sections"
-	depends on PREEMPT_RCU
+config RCU_TRACE
+	bool "Enable tracing for RCU - currently stats in /proc"
 	default y
 	help
-	  This option provides /proc stats to provide debugging info for
-	  the preemptible realtime RCU implementation.
+	  This option provides tracing in RCU which presents /proc 
+          stats for debugging RCU implementation.
 
-	  Say Y here if you want to see RCU stats in /proc
+	  Say Y here if you want to enable RCU tracing
 	  Say N if you are unsure.
kernel/Makefile renamed from kernel/Makefile~rcu-preempt-trace +1 -0
diff -puN kernel/Makefile~rcu-preempt-trace kernel/Makefile
@@ -49,6 +49,7 @@ obj-$(CONFIG_SECCOMP) += seccomp.o
 obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
 obj-$(CONFIG_CLASSIC_RCU) += rcupdate.o rcuclassic.o
 obj-$(CONFIG_PREEMPT_RCU) += rcupdate.o rcupreempt.o
+obj-$(CONFIG_RCU_TRACE) += rcupreempt_trace.o
 obj-$(CONFIG_DEBUG_SYNCHRO_TEST) += synchro-test.o
 obj-$(CONFIG_RELAY) += relay.o
 obj-$(CONFIG_UTS_NS) += utsname.o
kernel/rcupreempt.c renamed from kernel/rcupreempt.c~rcu-preempt-trace +36 -77

208 lines not on this page · raw message

kernel/rcupreempt_trace.c new file +99 -0

99 lines not on this page · raw message

_

#9 lore raw
In reply to Dipankar Sarma
Quoted 8 lines · Dipankar Sarma

This patchset consists of various merge candidates that would do well to have some testing in -mm. This patchset breaks out RCU implementation from its APIs to allow multiple implementations, gives RCU its own softirq and finally lines up preemptible RCU from -rt tree as a configurable RCU implementation for mainline. Published earlier and re-diffed against -mm.

Andrew,

I forgot that some of the 2.6.18-rc7-mm1 has a few patches that have been merged. So, I should diff against that so that including these in -mm will be easy. Patches will follow tomorrow.

Thanks
Dipankar

#10 lore raw
Quoted 10 lines · Dipankar Sarma
Quoted 8 lines · Dipankar Sarma

This patchset consists of various merge candidates that would do well to have some testing in -mm. This patchset breaks out RCU implementation from its APIs to allow multiple implementations, gives RCU its own softirq and finally lines up preemptible RCU from -rt tree as a configurable RCU implementation for mainline. Published earlier and re-diffed against -mm.

Quoted 3 lines

I forgot that some of the 2.6.18-rc7-mm1 has a few patches that have been merged. So, I should diff against that so that including these in -mm will be easy. Patches will follow tomorrow.

The latest diffs are here -

http://www.hill9.org/linux/kernel/patches/2.6.18-rc7-mm1/

The series file specifies the order.

Thanks
Dipankar

#11 lore raw
Quoted 15 lines · Dipankar Sarma
Quoted 10 lines · Dipankar Sarma
Quoted 8 lines · Dipankar Sarma

This patchset consists of various merge candidates that would do well to have some testing in -mm. This patchset breaks out RCU implementation from its APIs to allow multiple implementations, gives RCU its own softirq and finally lines up preemptible RCU from -rt tree as a configurable RCU implementation for mainline. Published earlier and re-diffed against -mm.

Quoted 3 lines

I forgot that some of the 2.6.18-rc7-mm1 has a few patches that have been merged. So, I should diff against that so that including these in -mm will be easy. Patches will follow tomorrow.

Quoted 5 lines

The latest diffs are here -

http://www.hill9.org/linux/kernel/patches/2.6.18-rc7-mm1/

The series file specifies the order.

Please ignore this patchset for a moment. I will resend a more complete and more tested patchset against 2.6.18-mm1.

Thanks
Dipankar

#12 lore raw

Re: [-mm PATCH] RCU: debug sleep check

In reply to Dipankar Sarma

This adds an overhead of a function call and local_irq_save/restore in the rcu reader path when CONFIG_DEBUG_SPINLOCK_SLEEP is set. Hopefully that is not much of a concern. Comments are welcome. Applies on top of my earlier patches. The full patchset is at http://www.hill9.org/linux/kernel/patches/2.6.18-mm1/.

Add a debug check for rcu read-side critical section code calling a function that might sleep which is illegal. The check is enabled only if CONFIG_DEBUG_SPINLOCK_SLEEP is set.

---

 include/linux/rcupdate.h |   34 ++++++++++++++++++++++++++++++----
 kernel/rcupdate.c        |   33 +++++++++++++++++++++++++++++++++
 kernel/sched.c           |    2 +-
 3 files changed, 64 insertions(+), 5 deletions(-)
include/linux/rcupdate.h renamed from include/linux/rcupdate.h~rcu-reader-sleep-check +30 -4
diff -puN include/linux/rcupdate.h~rcu-reader-sleep-check include/linux/rcupdate.h
@@ -64,6 +64,16 @@ struct rcu_head {
        (ptr)->next = NULL; (ptr)->func = NULL; \
 } while (0)
 
+#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+extern int rcu_read_in_atomic(void);
+extern void rcu_add_read_count(void);
+extern void rcu_sub_read_count(void);
+#else
+static inline int rcu_read_in_atomic(void) { return 0;}
+static inline void rcu_add_read_count(void) {}
+static inline void rcu_sub_read_count(void) {}
+#endif
+
 /**
  * rcu_read_lock - mark the beginning of an RCU read-side critical section.
  *
@@ -93,14 +103,22 @@ struct rcu_head {
  *
  * It is illegal to block while in an RCU read-side critical section.
  */
-#define rcu_read_lock() __rcu_read_lock()
+#define rcu_read_lock()	\
+	do {	\
+		rcu_add_read_count();	\
+		__rcu_read_lock();	\
+	} while (0)
 
 /**
  * rcu_read_unlock - marks the end of an RCU read-side critical section.
  *
  * See rcu_read_lock() for more information.
  */
-#define rcu_read_unlock() __rcu_read_unlock()
+#define rcu_read_unlock()	\
+	do {	\
+		__rcu_read_unlock();	\
+		rcu_sub_read_count();	\
+	} while (0)
 
 /*
  * So where is rcu_write_lock()?  It does not exist, as there is no
@@ -123,14 +141,22 @@ struct rcu_head {
  * can use just rcu_read_lock().
  *
  */
-#define rcu_read_lock_bh()	__rcu_read_lock_bh()
+#define rcu_read_lock_bh()	\
+	do {	\
+		rcu_add_read_count();	\
+		__rcu_read_lock_bh();	\
+	} while (0)
   
 /**
  * rcu_read_unlock_bh - marks the end of a softirq-only RCU critical section
  *
  * See rcu_read_lock_bh() for more information.
  */
-#define rcu_read_unlock_bh()	__rcu_read_unlock_bh()
+#define rcu_read_unlock_bh()	\
+	do {	\
+		__rcu_read_unlock_bh();	\
+		rcu_sub_read_count();	\
+	} while (0)
   
 /**
  * rcu_dereference - fetch an RCU-protected pointer in an
kernel/rcupdate.c renamed from kernel/rcupdate.c~rcu-reader-sleep-check +33 -0
diff -puN kernel/rcupdate.c~rcu-reader-sleep-check kernel/rcupdate.c
@@ -127,5 +127,38 @@ void __init rcu_init(void)
 	__rcu_init();
 }
 
+#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+DEFINE_PER_CPU(int, rcu_read_count);
+int rcu_read_in_atomic(void)
+{
+	int val;
+	int cpu = get_cpu();
+	val = per_cpu(rcu_read_count, cpu);
+	put_cpu();
+	return val;
+}
+
+void rcu_add_read_count(void)
+{
+	int cpu, flags;
+	local_irq_save(flags);
+	cpu = smp_processor_id();
+	per_cpu(rcu_read_count, cpu)++;
+	local_irq_restore(flags);
+}
+
+void rcu_sub_read_count(void)
+{
+	int cpu, flags;
+	local_irq_save(flags);
+	cpu = smp_processor_id();
+	per_cpu(rcu_read_count, cpu)--;
+	local_irq_restore(flags);
+}
+EXPORT_SYMBOL_GPL(rcu_read_in_atomic);
+EXPORT_SYMBOL_GPL(rcu_add_read_count);
+EXPORT_SYMBOL_GPL(rcu_sub_read_count);
+#endif
+
 EXPORT_SYMBOL_GPL(rcu_barrier);
 EXPORT_SYMBOL_GPL(synchronize_rcu);
kernel/sched.c renamed from kernel/sched.c~rcu-reader-sleep-check +1 -1
diff -puN kernel/sched.c~rcu-reader-sleep-check kernel/sched.c
@@ -6974,7 +6974,7 @@ void __might_sleep(char *file, int line)
 #ifdef in_atomic
 	static unsigned long prev_jiffy;	/* ratelimiting */
 
-	if ((in_atomic() || irqs_disabled()) &&
+	if ((in_atomic() || irqs_disabled() || rcu_read_in_atomic()) &&
 	    system_state == SYSTEM_RUNNING && !oops_in_progress) {
 		if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
 			return;

_

#13 lore raw

Re: [-mm PATCH] RCU: debug sleep check

Quoted 4 lines · On Mon, 25 Sep 2006 00:05:09 +0530 Dipankar Sarma <[email protected]> wrote:

Add a debug check for rcu read-side critical section code calling a function that might sleep which is illegal. The check is enabled only if CONFIG_DEBUG_SPINLOCK_SLEEP is set.

Does this actually change anything? rcu_read_lock is preempt_disable(), and might_sleep() already triggers if called inside preempt_disable().

include/linux/rcupdate.h struct rcu_head { · line 109

Quoted 5 lines
include/linux/rcupdate.h renamed from include/linux/rcupdate.h~rcu-reader-sleep-check +4 -1
-#define rcu_read_lock() __rcu_read_lock()
+#define rcu_read_lock()	\
+	do {	\
+		rcu_add_read_count();	\
+		__rcu_read_lock();	\

I don't have any __rcu_read_lock(). I guess this is against your to-be-resent RCU patches?

Quoted 1 line

+DEFINE_PER_CPU(int, rcu_read_count);

Can have static scope.

#14 lore raw

Re: [-mm PATCH] RCU: debug sleep check

Quoted 10 lines · Andrew Morton
Quoted 4 lines · On Mon, 25 Sep 2006 00:05:09 +0530 Dipankar Sarma <[email protected]> wrote:

Add a debug check for rcu read-side critical section code calling a function that might sleep which is illegal. The check is enabled only if CONFIG_DEBUG_SPINLOCK_SLEEP is set.

Does this actually change anything? rcu_read_lock is preempt_disable(), and might_sleep() already triggers if called inside preempt_disable().

It makes a difference if CONFIG_PREEMPT=n. AFAICS, preempt_disable() is a nop then and rcu needs its own check for sleeping while in read-side critical section. Anyway, I need to fix the rcupreempt part of this check, update patch is included below.

Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +4 -1
-#define rcu_read_lock() __rcu_read_lock()
+#define rcu_read_lock()	\
+	do {	\
+		rcu_add_read_count();	\
+		__rcu_read_lock();	\

I don't have any __rcu_read_lock(). I guess this is against your to-be-resent RCU patches?

Yes, they are up in http://www.hill9.org/linux/kernel/patches/2.6.18-mm1/.
However I am still running some tests.

Quoted 4 lines
Quoted 2 lines

+DEFINE_PER_CPU(int, rcu_read_count);

Can have static scope.

Done.

Thanks
Dipankar

Add a debug check for rcu read-side critical section code calling a function that might sleep which is illegal. The check is enabled only if CONFIG_DEBUG_SPINLOCK_SLEEP is set.

---

 include/linux/rcuclassic.h |   12 ++++++++++++
 include/linux/rcupdate.h   |    6 ++++++
 kernel/rcuclassic.c        |   33 +++++++++++++++++++++++++++++++++
 kernel/rcupreempt.c        |    7 +++++++
 kernel/sched.c             |    2 +-
 5 files changed, 59 insertions(+), 1 deletion(-)
include/linux/rcupdate.h renamed from include/linux/rcupdate.h~rcu-reader-sleep-check +6 -0
diff -puN include/linux/rcupdate.h~rcu-reader-sleep-check include/linux/rcupdate.h
@@ -64,6 +64,12 @@ struct rcu_head {
        (ptr)->next = NULL; (ptr)->func = NULL; \
 } while (0)
 
+#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+extern int rcu_read_in_atomic(void);
+#else
+static inline int rcu_read_in_atomic(void) { return 0;}
+#endif
+
 /**
  * rcu_read_lock - mark the beginning of an RCU read-side critical section.
  *
kernel/sched.c renamed from kernel/sched.c~rcu-reader-sleep-check +1 -1
diff -puN kernel/sched.c~rcu-reader-sleep-check kernel/sched.c
@@ -6974,7 +6974,7 @@ void __might_sleep(char *file, int line)
 #ifdef in_atomic
 	static unsigned long prev_jiffy;	/* ratelimiting */
 
-	if ((in_atomic() || irqs_disabled()) &&
+	if ((in_atomic() || irqs_disabled() || rcu_read_in_atomic()) &&
 	    system_state == SYSTEM_RUNNING && !oops_in_progress) {
 		if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
 			return;
kernel/rcuclassic.c renamed from kernel/rcuclassic.c~rcu-reader-sleep-check +33 -0
diff -puN kernel/rcuclassic.c~rcu-reader-sleep-check kernel/rcuclassic.c
@@ -545,6 +545,39 @@ void __init __rcu_init(void)
 	register_cpu_notifier(&rcu_nb);
 }
 
+#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+static DEFINE_PER_CPU(int, rcu_read_count);
+int rcu_read_in_atomic(void)
+{
+	int val;
+	int cpu = get_cpu();
+	val = per_cpu(rcu_read_count, cpu);
+	put_cpu();
+	return val;
+}
+
+void rcu_add_read_count(void)
+{
+	int cpu, flags;
+	local_irq_save(flags);
+	cpu = smp_processor_id();
+	per_cpu(rcu_read_count, cpu)++;
+	local_irq_restore(flags);
+}
+
+void rcu_sub_read_count(void)
+{
+	int cpu, flags;
+	local_irq_save(flags);
+	cpu = smp_processor_id();
+	per_cpu(rcu_read_count, cpu)--;
+	local_irq_restore(flags);
+}
+EXPORT_SYMBOL_GPL(rcu_read_in_atomic);
+EXPORT_SYMBOL_GPL(rcu_add_read_count);
+EXPORT_SYMBOL_GPL(rcu_sub_read_count);
+#endif
+
 module_param(blimit, int, 0);
 module_param(qhimark, int, 0);
 module_param(qlowmark, int, 0);
include/linux/rcuclassic.h renamed from include/linux/rcuclassic.h~rcu-reader-sleep-check +12 -0
diff -puN include/linux/rcuclassic.h~rcu-reader-sleep-check include/linux/rcuclassic.h
@@ -115,25 +115,37 @@ static inline void rcu_bh_qsctr_inc(int 
 extern int rcu_pending(int cpu);
 extern int rcu_needs_cpu(int cpu);
 
+#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+extern void rcu_add_read_count(void);
+extern void rcu_sub_read_count(void);
+#else
+static inline void rcu_add_read_count(void) {}
+static inline void rcu_sub_read_count(void) {}
+#endif
+
 #define __rcu_read_lock() \
 	do { \
 		preempt_disable(); \
+		rcu_add_read_count(); \
 		__acquire(RCU); \
 	} while(0)
 #define __rcu_read_unlock() \
 	do { \
 		__release(RCU); \
+		rcu_sub_read_count(); \
 		preempt_enable(); \
 	} while(0)
 
 #define __rcu_read_lock_bh() \
 	do { \
 		local_bh_disable(); \
+		rcu_add_read_count(); \
 		__acquire(RCU_BH); \
 	} while(0)
 #define __rcu_read_unlock_bh() \
 	do { \
 		__release(RCU_BH); \
+		rcu_sub_read_count(); \
 		local_bh_enable(); \
 	} while(0)
 
kernel/rcupreempt.c renamed from kernel/rcupreempt.c~rcu-reader-sleep-check +7 -0
diff -puN kernel/rcupreempt.c~rcu-reader-sleep-check kernel/rcupreempt.c
@@ -424,6 +424,13 @@ int rcu_read_proc_ctrs_data(char *page)
 
 #endif /* #ifdef CONFIG_RCU_TRACE */
 
+#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+int rcu_read_in_atomic(void)
+{
+	return current->rcu_read_lock_nesting;
+}
+#endif
+
 EXPORT_SYMBOL_GPL(call_rcu);
 EXPORT_SYMBOL_GPL(rcu_batches_completed);
 EXPORT_SYMBOL_GPL(rcu_batches_completed_bh);

_

#15 lore raw

Re: [-mm PATCH] RCU: debug sleep check

Quoted 9 lines · On Mon, 25 Sep 2006 03:05:08 +0530 Dipankar Sarma <[email protected]> wrote:
Quoted 8 lines · Andrew Morton
Quoted 4 lines · On Mon, 25 Sep 2006 00:05:09 +0530 Dipankar Sarma <[email protected]> wrote:

Add a debug check for rcu read-side critical section code calling a function that might sleep which is illegal. The check is enabled only if CONFIG_DEBUG_SPINLOCK_SLEEP is set.

Quoted 6 lines
Quoted 2 lines

Does this actually change anything? rcu_read_lock is preempt_disable(), and might_sleep() already triggers if called inside preempt_disable().

It makes a difference if CONFIG_PREEMPT=n. AFAICS, preempt_disable() is a nop then and rcu needs its own check for sleeping while in read-side critical section.

Right. I think enough people run with CONFIG_PREEMPT=y to make this change rather unnecessary.

And if there are developers out there who are testing their code without an effective CONFIG_DEBUG_SPINLOCK_SLEEP, then *that* is what we need to fix, no?

#16 lore raw

Re: [-mm PATCH] RCU: debug sleep check

Quoted 8 lines · Andrew Morton
Quoted 5 lines · On Mon, 25 Sep 2006 03:05:08 +0530 Dipankar Sarma <[email protected]> wrote:
Quoted 3 lines · Andrew Morton

Does this actually change anything? rcu_read_lock is preempt_disable(), and might_sleep() already triggers if called inside preempt_disable().

Quoted 6 lines
Quoted 3 lines

It makes a difference if CONFIG_PREEMPT=n. AFAICS, preempt_disable() is a nop then and rcu needs its own check for sleeping while in read-side critical section.

Right. I think enough people run with CONFIG_PREEMPT=y to make this change rather unnecessary.

I would mostly agree except that for the rcupreempt (-rt) implementation we don't use preempt_disable/enable in rcu read-side critical section. So, I have to add a rcu_read_in_atomic() API anyway and there is no harm in adding the same for rcuclassic (current default) so that sleeping-while-rcu-atomic check happens irrespective of CONFIG_PREEMPT. It is included only if CONFIG_DEBUG_SPINLOCK_SLEEP=y.

Quoted 4 lines

And if there are developers out there who are testing their code without an effective CONFIG_DEBUG_SPINLOCK_SLEEP, then *that* is what we need to fix, no?

Yes. With this patch, I am relying on people to test their code with CONFIG_DEBUG_SPINLOCK_SLEEP so that we can catch bad rcu users.

Thanks
Dipankar

#2 lore raw

Re: [-mm PATCH 1/4] RCU: split classic rcu

In reply to Dipankar Sarma
Quoted 5 lines · Dipankar Sarma

This patch re-organizes the RCU code to enable multiple implementations of RCU. Users of RCU continues to include rcupdate.h and the RCU interfaces remain the same. This is in preparation for subsequently merging the preepmtpible RCU implementation.

I still disagree very strongly. In a given tree there should be oneRCU implementation for the traditional interface. We probably want srcu in addition, but not things hiding behind the interface.

#17 lore raw

Re: [-mm PATCH] RCU: debug sleep check

In reply to Dipankar Sarma
Quoted 9 lines · Dipankar Sarma

This adds an overhead of a function call and local_irq_save/restore in the rcu reader path when CONFIG_DEBUG_SPINLOCK_SLEEP is set. Hopefully that is not much of a concern. Comments are welcome. Applies on top of my earlier patches. The full patchset is at http://www.hill9.org/linux/kernel/patches/2.6.18-mm1/.

Add a debug check for rcu read-side critical section code calling a function that might sleep which is illegal. The check is enabled only if CONFIG_DEBUG_SPINLOCK_SLEEP is set.

Useful for non-CONFIG_PREEMPT kernels!

Quoted 135 lines

---

 include/linux/rcupdate.h |   34 ++++++++++++++++++++++++++++++----
 kernel/rcupdate.c        |   33 +++++++++++++++++++++++++++++++++
 kernel/sched.c           |    2 +-
 3 files changed, 64 insertions(+), 5 deletions(-)

diff -puN include/linux/rcupdate.h~rcu-reader-sleep-check include/linux/rcupdate.h

include/linux/rcupdate.h renamed from include/linux/rcupdate.h~rcu-reader-sleep-check +30 -4
@@ -64,6 +64,16 @@ struct rcu_head {
        (ptr)->next = NULL; (ptr)->func = NULL; \
 } while (0)
 
+#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+extern int rcu_read_in_atomic(void);
+extern void rcu_add_read_count(void);
+extern void rcu_sub_read_count(void);
+#else
+static inline int rcu_read_in_atomic(void) { return 0;}
+static inline void rcu_add_read_count(void) {}
+static inline void rcu_sub_read_count(void) {}
+#endif
+
 /**
  * rcu_read_lock - mark the beginning of an RCU read-side critical section.
  *
@@ -93,14 +103,22 @@ struct rcu_head {
  *
  * It is illegal to block while in an RCU read-side critical section.
  */
-#define rcu_read_lock() __rcu_read_lock()
+#define rcu_read_lock()	\
+	do {	\
+		rcu_add_read_count();	\
+		__rcu_read_lock();	\
+	} while (0)
 
 /**
  * rcu_read_unlock - marks the end of an RCU read-side critical section.
  *
  * See rcu_read_lock() for more information.
  */
-#define rcu_read_unlock() __rcu_read_unlock()
+#define rcu_read_unlock()	\
+	do {	\
+		__rcu_read_unlock();	\
+		rcu_sub_read_count();	\
+	} while (0)
 
 /*
  * So where is rcu_write_lock()?  It does not exist, as there is no
@@ -123,14 +141,22 @@ struct rcu_head {
  * can use just rcu_read_lock().
  *
  */
-#define rcu_read_lock_bh()	__rcu_read_lock_bh()
+#define rcu_read_lock_bh()	\
+	do {	\
+		rcu_add_read_count();	\
+		__rcu_read_lock_bh();	\
+	} while (0)
 
 /**
  * rcu_read_unlock_bh - marks the end of a softirq-only RCU critical section
  *
  * See rcu_read_lock_bh() for more information.
  */
-#define rcu_read_unlock_bh()	__rcu_read_unlock_bh()
+#define rcu_read_unlock_bh()	\
+	do {	\
+		__rcu_read_unlock_bh();	\
+		rcu_sub_read_count();	\
+	} while (0)
 
 /**
  * rcu_dereference - fetch an RCU-protected pointer in an

diff -puN kernel/rcupdate.c~rcu-reader-sleep-check kernel/rcupdate.c

kernel/rcupdate.c renamed from kernel/rcupdate.c~rcu-reader-sleep-check +33 -0
@@ -127,5 +127,38 @@ void __init rcu_init(void)
 	__rcu_init();
 }
 
+#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
+DEFINE_PER_CPU(int, rcu_read_count);
+int rcu_read_in_atomic(void)
+{
+	int val;
+	int cpu = get_cpu();
+	val = per_cpu(rcu_read_count, cpu);
+	put_cpu();
+	return val;
+}
+
+void rcu_add_read_count(void)
+{
+	int cpu, flags;
+	local_irq_save(flags);
+	cpu = smp_processor_id();
+	per_cpu(rcu_read_count, cpu)++;
+	local_irq_restore(flags);
+}
+
+void rcu_sub_read_count(void)
+{
+	int cpu, flags;
+	local_irq_save(flags);
+	cpu = smp_processor_id();
+	per_cpu(rcu_read_count, cpu)--;
+	local_irq_restore(flags);
+}
+EXPORT_SYMBOL_GPL(rcu_read_in_atomic);
+EXPORT_SYMBOL_GPL(rcu_add_read_count);
+EXPORT_SYMBOL_GPL(rcu_sub_read_count);
+#endif
+
 EXPORT_SYMBOL_GPL(rcu_barrier);
 EXPORT_SYMBOL_GPL(synchronize_rcu);

diff -puN kernel/sched.c~rcu-reader-sleep-check kernel/sched.c

kernel/sched.c renamed from kernel/sched.c~rcu-reader-sleep-check +1 -1
@@ -6974,7 +6974,7 @@ void __might_sleep(char *file, int line)
 #ifdef in_atomic
 	static unsigned long prev_jiffy;	/* ratelimiting */
 
-	if ((in_atomic() || irqs_disabled()) &&
+	if ((in_atomic() || irqs_disabled() || rcu_read_in_atomic()) &&
 	    system_state == SYSTEM_RUNNING && !oops_in_progress) {
 		if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
 			return;

_

#3 lore raw

Re: [-mm PATCH 1/4] RCU: split classic rcu

In reply to Christoph Hellwig
Quoted 10 lines · Christoph Hellwig
Quoted 5 lines · Dipankar Sarma

This patch re-organizes the RCU code to enable multiple implementations of RCU. Users of RCU continues to include rcupdate.h and the RCU interfaces remain the same. This is in preparation for subsequently merging the preepmtpible RCU implementation.

I still disagree very strongly. In a given tree there should be oneRCU implementation for the traditional interface. We probably want srcu in addition, but not things hiding behind the interface.

Hello, Christoph!

I agree very much with your "oneRCU to defer them all" goal for the traditional interface.

However, the current implementation is extremely well-tested and seems to be quite reliable. Yes, there might still be a rough edge or two in cases where people do call_rcu() in tight loops, but even that is being covered in most cases where "don't do that" doesn't apply (e.g., close(open()) from user space). The Linux implementation of RCU is almost six years old, and first appeared in mainline almost four years ago -- that is some -serious- testing!

We will be switching to a new implementation. I am working to make it as reliable as I know how, but it seems reasonable to have a changeover period that might be measured in years. I -really- don't want to be inflicting even the possibility of RCU implementation bugs on anyone who has not "signed up" for code that has not yet be hammered into total and complete submission! CONFIG_PREEMPT_RT is quite reliable even now, but there is "quite reliable" and then there is "hammered into total and complete submission". ;-)

Also, we need any new implementation of RCU to be in a separate file. I don't want to even think about the number of times that I accidentally changed the wrong version of RCU when working on the -rt implementation before we split it -- the functions have the same name, right? :-/

So maybe we rip the multi-RCU infrastructure out once we have fully (and I mean -fully-) tested the new RCU implementation, taken care of any performance anomalies, and so on. I would be totally OK with that, but believe the split will be needed in the meantime.

Fair enough? Or am I missing something?

Thanx, Paul

#4 lore raw

Re: [-mm PATCH 1/4] RCU: split classic rcu

Quoted 9 lines · Paul E. McKenney

We will be switching to a new implementation. I am working to make it as reliable as I know how, but it seems reasonable to have a changeover period that might be measured in years. I -really- don't want to be inflicting even the possibility of RCU implementation bugs on anyone who has not "signed up" for code that has not yet be hammered into total and complete submission! CONFIG_PREEMPT_RT is quite reliable even now, but there is "quite reliable" and then there is "hammered into total and complete submission". ;-)

Quoted 4 lines

Also, we need any new implementation of RCU to be in a separate file. I don't want to even think about the number of times that I accidentally changed the wrong version of RCU when working on the -rt implementation before we split it -- the functions have the same name, right? :-/

Still there's absolutely no point in putting all this into mainline. Do it in your toy tree (whether it's called -rt or -pk :)) and keep one stable implementation in mainline. That one implementation should be srcu capable rather sooner than later (as soon as you're satisfied with it) because there's lots of interesting use cases for sleeping in RCU read sections. But until then keep the mainline code simple.

#5 lore raw

Re: [-mm PATCH 1/4] RCU: split classic rcu

Quoted 15 lines · Christoph Hellwig
Quoted 9 lines · Paul E. McKenney

We will be switching to a new implementation. I am working to make it as reliable as I know how, but it seems reasonable to have a changeover period that might be measured in years. I -really- don't want to be inflicting even the possibility of RCU implementation bugs on anyone who has not "signed up" for code that has not yet be hammered into total and complete submission! CONFIG_PREEMPT_RT is quite reliable even now, but there is "quite reliable" and then there is "hammered into total and complete submission". ;-)

Quoted 4 lines

Also, we need any new implementation of RCU to be in a separate file. I don't want to even think about the number of times that I accidentally changed the wrong version of RCU when working on the -rt implementation before we split it -- the functions have the same name, right? :-/

Quoted 6 lines

Still there's absolutely no point in putting all this into mainline. Do it in your toy tree (whether it's called -rt or -pk :)) and keep one stable implementation in mainline. That one implementation should be srcu capable rather sooner than later (as soon as you're satisfied with it) because there's lots of interesting use cases for sleeping in RCU read sections. But until then keep the mainline code simple.

Christoph,

The RCU read path is so sensitive that unless a large number of users test the rcupreempt implementation, it will be difficult for us to safely switch over without hurting. We cannot get that test exposure from -rt or -pk :-) Really, the mainline code split is very simple and should be maintainable with an understanding that within a year or so, we can switch over to just one implementation. I am not comfortable with the risk of causing sudden performance problems for some users. By staging it, we can minimize that risk.

Srcu is independent of the underlying RCU mechanism, it works with both the RCU implementations.

Thanks
Dipankar