RCU and CONFIG_PREEMPT_RT three-quarters-sane patch
Subsystems (3)
RFC PATCH 1/1 RCU and CONFIG_PREEMPT_RT three-quarters-sane patch
Hello!
The attached patch fixes an interrupt-masking problem in the previous round, so gets about 90% pass rate on LTP (up from 60-80% on the earlier patch). So, call it three-quarters sane. :-/
I have added some debug support and an internal-to-RCU torture test, which has the interesting property of being able to make RCU fail without crashing the kernel. And gets failures to happen a -lot- more quickly than LTP, even if LTP were to fail 100% of the time rather than only 10% of the time. I believe I have a lead on at least one additional bug, but thought I should post this intermediate result in the meantime.
Again, this patch might be acceptable to courageous users of the CONFIG_PREEMPT_RT patch who aren't too concerned about SMP performance and scalability. ;-)
The following caveats still apply:
o Still have heavyweight operations in rcu_read_lock() and
rcu_read_unlock(). Will work on removing the atomic_inc() and atomic_dec() first, with the memory barriers later.
o Global callback queues result in poor SMP performance. On
the list to fix. Will likely require handling CPU hotplug (current code is too stupid to need to care about CPU hotplug).
o Grace-period-detection code is probably too aggressive, but will
worry about that later. This will interact with OOM on systems with small memories.
o There is still at least one bug that causes RCU to declare a
grace period completed before it should.
o Applies against V0.7.51-27 of Ingo's patch.
As before, the code (but not the patch) should work in a stock kernel as well as in the CONFIG_PREEMPT_RT environment.
Thoughts?
Thanx, Paul
fs/proc/proc_misc.c | 81 ++++ include/linux/rcupdate.h | 27 + include/linux/sched.h | 3 kernel/Kconfig.preempt | 26 + kernel/rcupdate.c | 767 +++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 847 insertions(+), 57 deletions(-)
fs/proc/proc_misc.c +81 -0
@@ -599,6 +599,78 @@ void create_seq_entry(char *name, mode_t entry->proc_fops = f; } +#ifdef CONFIG_RCU_STATS +int rcu_read_proc (char *page,char **start,off_t off, +int count,int *eof,void *data) +{ +int len; +extern int rcu_read_proc_data (char *page); + + len =rcu_read_proc_data (page); +return proc_calc_metrics (page, start, off, count, eof, len); +} + +int rcu_read_proc_gp (char *page,char **start,off_t off, +int count,int *eof,void *data) +{ +int len; +extern int rcu_read_proc_gp_data (char *page); + + len =rcu_read_proc_gp_data (page); +return proc_calc_metrics (page, start, off, count, eof, len); +} + +int rcu_read_proc_ptrs (char *page,char **start,off_t off, +int count,int *eof,void *data) +{ +int len; +extern int rcu_read_proc_ptrs_data (char *page); + + len =rcu_read_proc_ptrs_data (page); +return proc_calc_metrics (page, start, off, count, eof, len); +} + +int rcu_read_proc_ctrs (char *page,char **start,off_t off, +int count,int *eof,void *data) +{ +int len; +extern int rcu_read_proc_ctrs_data (char *page); + + len =rcu_read_proc_ctrs_data (page); +return proc_calc_metrics (page, start, off, count, eof, len); +} + +int rcu_read_proc_torture_writer (char *page,char **start,off_t off, +int count,int *eof,void *data) +{ +int len; +extern int rcu_read_proc_torture_writer_data (char *page); + + len =rcu_read_proc_torture_writer_data (page); +return proc_calc_metrics (page, start, off, count, eof, len); +} + +int rcu_read_proc_torture_reader (char *page,char **start,off_t off, +int count,int *eof,void *data) +{ +int len; +extern int rcu_read_proc_torture_reader_data (char *page); + + len =rcu_read_proc_torture_reader_data (page); +return proc_calc_metrics (page, start, off, count, eof, len); +} + +int rcu_read_proc_torture_stats (char *page,char **start,off_t off, +int count,int *eof,void *data) +{ +int len; +extern int rcu_read_proc_torture_stats_data (char *page); + + len =rcu_read_proc_torture_stats_data (page); +return proc_calc_metrics (page, start, off, count, eof, len); +} +#endif /* #ifdef CONFIG_RCU_STATS */ +void __init proc_misc_init (void ) {struct proc_dir_entry *entry;
@@ -621,6 +693,15 @@ void __init proc_misc_init(void) {"cmdline", cmdline_read_proc}, {"locks", locks_read_proc}, {"execdomains", execdomains_read_proc}, +#ifdef CONFIG_RCU_STATS + {"rcustats", rcu_read_proc}, + {"rcugp", rcu_read_proc_gp}, + {"rcuptrs", rcu_read_proc_ptrs}, + {"rcuctrs", rcu_read_proc_ctrs}, + {"rcutw", rcu_read_proc_torture_writer}, + {"rcutr", rcu_read_proc_torture_reader}, + {"rcuts", rcu_read_proc_torture_stats}, +#endif /* #ifdef CONFIG_RCU_STATS */ {NULL,} };for (p = simple_ones; p->name; p++)
include/linux/rcupdate.h +25 -2
@@ -59,6 +59,7 @@ struct rcu_head { } while (0) +#ifndef CONFIG_PREEMPT_RCU /* Global control variables for rcupdate callback mechanism. */ struct rcu_ctrlblk {
@@ -209,6 +210,18 @@ static inline int rcu_pending(int cpu)# define rcu_read_unlock preempt_enable#endif +#else /* #ifndef CONFIG_PREEMPT_RCU */ + +#define rcu_qsctr_inc (cpu) +#define rcu_bh_qsctr_inc (cpu) +#define call_rcu_bh (head, rcu) call_rcu(head, rcu) + +extern void rcu_read_lock (void ); +extern void rcu_read_unlock (void ); +extern int rcu_pending (int cpu); + +#endif /* #else #ifndef CONFIG_PREEMPT_RCU */ +/* * So where is rcu_write_lock()? It does not exist, as there is no * way for writers to lock out RCU readers. This is a feature, not
@@ -230,16 +243,22 @@ static inline int rcu_pending(int cpu)* can use just rcu_read_lock(). * */ -//#define rcu_read_lock_bh() local_bh_disable() +#ifndef CONFIG_PREEMPT_RCU +#define rcu_read_lock_bh () local_bh_disable() +#else /* #ifndef CONFIG_PREEMPT_RCU */ #define rcu_read_lock_bh () { rcu_read_lock(); local_bh_disable(); } +#endif /* #else #ifndef CONFIG_PREEMPT_RCU */ /* * 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() local_bh_enable() +#ifndef CONFIG_PREEMPT_RCU +#define rcu_read_unlock_bh () local_bh_enable() +#else /* #ifndef CONFIG_PREEMPT_RCU */ #define rcu_read_unlock_bh () { local_bh_enable(); rcu_read_unlock(); } +#endif /* #else #ifndef CONFIG_PREEMPT_RCU */ /** * rcu_dereference - fetch an RCU-protected pointer in an
@@ -288,7 +307,11 @@ static inline int rcu_pending(int cpu)* synchronize_kernel() API. In contrast, synchronize_rcu() only * guarantees that rcu_read_lock() sections will have completed. */ +#ifndef CONFIG_PREEMPT_RCU #define synchronize_sched () synchronize_rcu() +#else /* #ifndef CONFIG_PREEMPT_RCU */ +extern void synchronize_sched (void ); +#endif /* #else #ifndef CONFIG_PREEMPT_RCU */ extern void rcu_init (void );extern void rcu_check_callbacks (int cpu,int user);
include/linux/sched.h +2 -1
@@ -917,7 +917,8 @@ struct task_struct {#endif #ifdef CONFIG_PREEMPT_RCU int rcu_read_lock_nesting; -struct rcu_data *rcu_data; +atomic_t *rcu_flipctr1; +atomic_t *rcu_flipctr2;#endif };
kernel/Kconfig.preempt +25 -1
@@ -127,10 +127,34 @@ config PREEMPT_RCU 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 increase memory utilization. + 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. +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. + +config RCU_TORTURE_TEST + bool "/proc torture tests for RCU" + depends on RCU_STATS + default y + help + This option provides /proc files that run torture tests on + the preemptible realtime RCU implementation. + + Say Y here if you want to be able to run RCU torture tests. + Say N if you are unsure. + config SPINLOCK_BKL bool "Old-Style Big Kernel Lock" depends on (PREEMPT || SMP) && !PREEMPT_RT
kernel/rcupdate.c +714 -53
806 lines not on this page · raw message