RCU changes for v4.9
Subsystems (5)
Linus,
Please pull the latest core-rcu-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core-rcu-for-linus
# HEAD: 2d8fbcd13ea1d0be3a7ea5f20c3a5b44b592e79c Merge branch 'for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu into core/rcu
The main changes in this cycle were:
- Expedited grace-period changes, most notably avoiding having user threads drive expedited grace periods, using a workqueue instead.
- Miscellaneous fixes, including a performance fix for lists that was sent with the lists modifications.
- CPU hotplug updates, most notably providing exact CPU-online tracking for RCU. This will in turn allow removal of the checks supporting RCU's prior heuristic that was based on the assumption that CPUs would take no longer than one jiffy to come online.
- Torture-test updates.
- Documentation updates.
Thanks,
Ingo
------------------>
Chris Wilson (1):
list: Expand list_first_entry_or_null()
Ding Tianhong (1):
rcu: Fix soft lockup for rcu_nocb_kthread
Jisheng Zhang (1):
rcu: Use rcu_gp_kthread_wake() to wake up grace period kthreads
Paul E. McKenney (12):
documentation: Record reason for rcu_head two-byte alignment
rcu: Consolidate expedited grace period machinery
rcu: Drive expedited grace periods from workqueue
rcu: Stop disabling expedited RCU CPU stall warnings
rcu: Make expedited RCU CPU stall warnings respond to controls
rcu: Exclude RCU-offline CPUs from expedited grace periods
rcu: Use RCU's online-CPU state for expedited IPI retry
sched: Make wake_up_nohz_cpu() handle CPUs going offline
rcu: Avoid redundant quiescent-state chasing
rcu: Provide exact CPU-online tracking for RCU
torture: Convert torture_shutdown() to hrtimer
torture: Add task state to writer-task stall printk()s
Paul Gortmaker (1):
rcu: Don't use modular infrastructure in non-modular code
Sebastian Andrzej Siewior (2):
cpu/hotplug: Get rid of CPU_STARTING reference
rcutorture: Convert to hotplug state machine
SeongJae Park (4):
rcutorture: Remove outdated config option description
rcutorture: Print out barrier error as document says
rcuperf: Consistently insert space between flag and message
torture: TOROUT_STRING(): Insert a space between flag and message
.../RCU/Design/Requirements/Requirements.html | 22 ++++ Documentation/RCU/torture.txt | 15 --- include/linux/list.h | 7 +- include/linux/rcupdate.h | 1 + include/linux/torture.h | 2 +- kernel/cpu.c | 1 + kernel/rcu/rcuperf.c | 7 +- kernel/rcu/rcutorture.c | 62 ++++------- kernel/rcu/tree.c | 44 ++++++-- kernel/rcu/tree.h | 1 + kernel/rcu/tree_exp.h | 124 +++++++++++++-------- kernel/rcu/tree_plugin.h | 1 + kernel/rcu/tree_trace.c | 7 +- kernel/rcu/update.c | 3 +- kernel/sched/core.c | 7 ++ kernel/torture.c | 27 +++-- 16 files changed, 193 insertions(+), 138 deletions(-)
Documentation/RCU/Design/Requirements/Requirements.html +22 -0
@@ -2493,6 +2493,28 @@ or some future “lazy” variant of <tt>call_rcu()</tt> that might one day be created for energy-efficiency purposes. +<p> +That said, there are limits. +RCU requires that the <tt>rcu_head</tt> structure be aligned to a +two-byte boundary, and passing a misaligned <tt>rcu_head</tt> +structure to one of the <tt>call_rcu()</tt> family of functions +will result in a splat. +It is therefore necessary to exercise caution when packing +structures containing fields of type <tt>rcu_head</tt>. +Why not a four-byte or even eight-byte alignment requirement? +Because the m68k architecture provides only two-byte alignment, +and thus acts as alignment's least common denominator. + +<p> +The reason for reserving the bottom bit of pointers to +<tt>rcu_head</tt> structures is to leave the door open to +“lazy” callbacks whose invocations can safely be deferred. +Deferring invocation could potentially have energy-efficiency +benefits, but only if the rate of non-lazy callbacks decreases +significantly for some important workload. +In the meantime, reserving the bottom bit keeps this option open +in case it one day becomes useful. + <h3><a name="Performance, Scalability, Response Time, and Reliability"> Performance, Scalability, Response Time, and Reliability</a></h3>
Documentation/RCU/torture.txt +0 -15
@@ -10,21 +10,6 @@ status messages via printk(), which can be examined via the dmesg command (perhaps grepping for "torture"). The test is started when the module is loaded, and stops when the module is unloaded. -CONFIG_RCU_TORTURE_TEST_RUNNABLE - -It is also possible to specify CONFIG_RCU_TORTURE_TEST=y, which will -result in the tests being loaded into the base kernel. In this case, -the CONFIG_RCU_TORTURE_TEST_RUNNABLE config option is used to specify -whether the RCU torture tests are to be started immediately during -boot or whether the /proc/sys/kernel/rcutorture_runnable file is used -to enable them. This /proc file can be used to repeatedly pause and -restart the tests, regardless of the initial state specified by the -CONFIG_RCU_TORTURE_TEST_RUNNABLE config option. - -You will normally -not- want to start the RCU torture tests during boot -(and thus the default is CONFIG_RCU_TORTURE_TEST_RUNNABLE=n), but doing -this can sometimes be useful in finding boot-time bugs. - MODULE PARAMETERS
include/linux/list.h +5 -2
@@ -381,8 +381,11 @@ static inline void list_splice_tail_init(struct list_head *list,* * Note that if the list is empty, it returns NULL. */ -#define list_first_entry_or_null (ptr, type, member) \ - (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL) +#define list_first_entry_or_null (ptr, type, member) ({ \ + struct list_head *head__ = (ptr); \ + struct list_head *pos__ = READ_ONCE(head__->next); \ + pos__ != head__ ? list_entry(pos__, type, member) : NULL; \ +})/** * list_next_entry - get the next element in list
include/linux/rcupdate.h +1 -0
@@ -334,6 +334,7 @@ void rcu_sched_qs(void);void rcu_bh_qs (void );void rcu_check_callbacks (int user);void rcu_report_dead (unsigned int cpu); +void rcu_cpu_starting (unsigned int cpu);#ifndef CONFIG_TINY_RCU void rcu_end_inkernel_boot (void );
include/linux/torture.h +1 -1
@@ -43,7 +43,7 @@#define TORTURE_FLAG "-torture:"#define TOROUT_STRING (s) \ - pr_alert("%s" TORTURE_FLAG s "\n", torture_type) + pr_alert("%s" TORTURE_FLAG " %s\n", torture_type, s)#define VERBOSE_TOROUT_STRING (s) \ do { if (verbose) pr_alert("%s" TORTURE_FLAG " %s\n", torture_type, s); } while (0)#define VERBOSE_TOROUT_ERRSTRING (s) \
kernel/cpu.c +1 -0
@@ -889,6 +889,7 @@ void notify_cpu_starting(unsigned int cpu)struct cpuhp_cpu_state *st =per_cpu_ptr (&cpuhp_state, cpu);enum cpuhp_state target =min ((int )st->target,CPUHP_AP_ONLINE ); +rcu_cpu_starting (cpu);/* Enables RCU usage on this CPU. */ while (st->state < target) {struct cpuhp_step *step;
kernel/rcu/rcuperf.c +3 -4
@@ -52,7 +52,7 @@ MODULE_AUTHOR("Paul E. McKenney <[email protected]>");#define PERF_FLAG "-perf:"#define PERFOUT_STRING (s) \ - pr_alert("%s" PERF_FLAG s "\n", perf_type) + pr_alert("%s" PERF_FLAG " %s\n", perf_type, s)#define VERBOSE_PERFOUT_STRING (s) \ do { if (verbose) pr_alert("%s" PERF_FLAG " %s\n", perf_type, s); } while (0)#define VERBOSE_PERFOUT_ERRSTRING (s) \
@@ -400,9 +400,8 @@ rcu_perf_writer(void *arg) sp.sched_priority =0 ;sched_setscheduler_nocheck (current,SCHED_NORMAL , &sp); -pr_alert ("%s" PERF_FLAG -"rcu_perf_writer %ld has %d measurements\n" , - perf_type, me,MIN_MEAS ); +pr_alert ("%s%s rcu_perf_writer %ld has %d measurements\n" , + perf_type,PERF_FLAG , me,MIN_MEAS );if (atomic_inc_return (&n_rcu_perf_writer_finished) >= nrealwriters) {schedule_timeout_interruptible (10 );
kernel/rcu/rcutorture.c +21 -41
119 lines not on this page · raw message
kernel/rcu/tree.c +35 -9
100 lines not on this page · raw message
kernel/rcu/tree.h +1 -0
@@ -400,6 +400,7 @@ struct rcu_data {#ifdef CONFIG_RCU_FAST_NO_HZ struct rcu_head oom_head;#endif /* #ifdef CONFIG_RCU_FAST_NO_HZ */ +atomic_long_t exp_workdone0;/* # done by workqueue. */ atomic_long_t exp_workdone1;/* # done by others #1. */ atomic_long_t exp_workdone2;/* # done by others #2. */ atomic_long_t exp_workdone3;/* # done by others #3. */
kernel/rcu/tree_exp.h +77 -47
178 lines not on this page · raw message
kernel/rcu/tree_plugin.h +1 -0
@@ -2173,6 +2173,7 @@ static int rcu_nocb_kthread(void *arg) cl++; c++;local_bh_enable (); +cond_resched_rcu_qs (); list = next; }trace_rcu_batch_end (rdp->rsp->name, c, !!list,0 ,0 ,1 );
kernel/rcu/tree_trace.c +4 -3
@@ -185,16 +185,17 @@ static int show_rcuexp(struct seq_file *m, void *v)int cpu;struct rcu_state *rsp = (struct rcu_state *)m->private;struct rcu_data *rdp; -unsigned long s1 =0 , s2 =0 , s3 =0 ; +unsigned long s0 =0 , s1 =0 , s2 =0 , s3 =0 ;for_each_possible_cpu (cpu) { rdp =per_cpu_ptr (rsp->rda, cpu); + s0 +=atomic_long_read (&rdp->exp_workdone0); s1 +=atomic_long_read (&rdp->exp_workdone1); s2 +=atomic_long_read (&rdp->exp_workdone2); s3 +=atomic_long_read (&rdp->exp_workdone3); } -seq_printf (m,"s=%lu wd1=%lu wd2=%lu wd3=%lu n=%lu enq=%d sc=%lu\n" , - rsp->expedited_sequence, s1, s2, s3, +seq_printf (m,"s=%lu wd0=%lu wd1=%lu wd2=%lu wd3=%lu n=%lu enq=%d sc=%lu\n" , + rsp->expedited_sequence, s0, s1, s2, s3,atomic_long_read (&rsp->expedited_normal),atomic_read (&rsp->expedited_need_qs), rsp->expedited_sequence /2 );
kernel/rcu/update.c +1 -2
@@ -46,7 +46,7 @@#include <linux/export.h> #include <linux/hardirq.h> #include <linux/delay.h> -#include <linux/module.h> +#include <linux/moduleparam.h> #include <linux/kthread.h> #include <linux/tick.h>
@@ -54,7 +54,6 @@#include "rcu.h" -MODULE_ALIAS ("rcupdate" );#ifdef MODULE_PARAM_PREFIX #undef MODULE_PARAM_PREFIX#endif
kernel/sched/core.c +7 -0
@@ -581,6 +581,8 @@ static bool wake_up_full_nohz_cpu(int cpu)* If needed we can still optimize that later with an * empty IRQ. */ +if (cpu_is_offline (cpu)) +return true;/* Don't try to wake offline CPUs. */ if (tick_nohz_full_cpu (cpu)) {if (cpu !=smp_processor_id () ||tick_nohz_tick_stopped ())
@@ -591,6 +593,11 @@ static bool wake_up_full_nohz_cpu(int cpu)return false; } +/* +* Wake up the specified CPU. If the CPU is going offline, it is the +* caller's responsibility to deal with the lost wakeup, for example, +* by hooking into the CPU_DEAD notifier like timers and hrtimers do. +*/ void wake_up_nohz_cpu (int cpu) {if (!wake_up_full_nohz_cpu (cpu))
kernel/torture.c +13 -14
@@ -43,6 +43,7 @@#include <linux/stat.h> #include <linux/slab.h> #include <linux/trace_clock.h> +#include <linux/ktime.h> #include <asm/byteorder.h> #include <linux/torture.h>
@@ -446,9 +447,8 @@ EXPORT_SYMBOL_GPL(torture_shuffle_cleanup);* Variables for auto-shutdown. This allows "lights out" torture runs * to be fully scripted. */ -static int shutdown_secs;/* desired test duration in seconds. */ static struct task_struct *shutdown_task; -static unsigned long shutdown_time;/* jiffies to system shutdown. */ +static ktime_t shutdown_time;/* time to system shutdown. */ static void (*torture_shutdown_hook)(void );/*
@@ -471,20 +471,20 @@ EXPORT_SYMBOL_GPL(torture_shutdown_absorb);*/ static int torture_shutdown (void *arg) { -long delta; -unsigned long jiffies_snap; +ktime_t ktime_snap;VERBOSE_TOROUT_STRING ("torture_shutdown task started" ); - jiffies_snap = jiffies; -while (ULONG_CMP_LT (jiffies_snap, shutdown_time) && + ktime_snap =ktime_get (); +while (ktime_before (ktime_snap, shutdown_time) && !torture_must_stop ()) { - delta = shutdown_time - jiffies_snap;if (verbose)pr_alert ("%s" TORTURE_FLAG -"torture_shutdown task: %lu jiffies remaining\n" , - torture_type, delta); -schedule_timeout_interruptible (delta); - jiffies_snap = jiffies; +"torture_shutdown task: %llu ms remaining\n" , + torture_type, +ktime_ms_delta (shutdown_time, ktime_snap)); +set_current_state (TASK_INTERRUPTIBLE ); +schedule_hrtimeout (&shutdown_time,HRTIMER_MODE_ABS ); + ktime_snap =ktime_get (); }if (torture_must_stop ()) {torture_kthread_stopping ("torture_shutdown" );
@@ -511,10 +511,9 @@ int torture_shutdown_init(int ssecs, void (*cleanup)(void)) {int ret =0 ; - shutdown_secs = ssecs; torture_shutdown_hook = cleanup; -if (shutdown_secs >0 ) { - shutdown_time = jiffies + shutdown_secs *HZ ; +if (ssecs >0 ) { + shutdown_time =ktime_add (ktime_get (),ktime_set (ssecs,0 )); ret =torture_create_kthread (torture_shutdown,NULL , shutdown_task); }