* [PATCH tip/core/rcu 0/2] NO_HZ_FULL_SYSIDLE updates for v4.1 @ 2015-03-03 17:50 Paul E. McKenney 2015-03-03 17:50 ` [PATCH tip/core/rcu 1/2] rcu: Fixes to NO_HZ_FULL sysidle accounting Paul E. McKenney 0 siblings, 1 reply; 7+ messages in thread From: Paul E. McKenney @ 2015-03-03 17:50 UTC (permalink / raw) To: linux-kernel Cc: mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec, oleg, bobby.prani Hello! This series contains some fixes for NO_HZ_FULL sysidle: 1. Correctly initialize and set isidle variable. 2. Tighten up affinity and sysidle checks. Thanx, Paul ------------------------------------------------------------------------ b/kernel/rcu/tree.c | 8 ++++---- b/kernel/rcu/tree_plugin.h | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH tip/core/rcu 1/2] rcu: Fixes to NO_HZ_FULL sysidle accounting 2015-03-03 17:50 [PATCH tip/core/rcu 0/2] NO_HZ_FULL_SYSIDLE updates for v4.1 Paul E. McKenney @ 2015-03-03 17:50 ` Paul E. McKenney 2015-03-03 17:50 ` [PATCH tip/core/rcu 2/2] rcu: Tighten up affinity and check for sysidle Paul E. McKenney 0 siblings, 1 reply; 7+ messages in thread From: Paul E. McKenney @ 2015-03-03 17:50 UTC (permalink / raw) To: linux-kernel Cc: mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec, oleg, bobby.prani, Paul E. McKenney From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> On second and subsequent passes through quiescent-state forcing, the isidle variable was initialized to false, which would prevent full sysidle state from being reached if a grace period needed more than one round of quiescent-state forcing (which most should not). However, the check for offline CPUs in the quiescent-state forcing main loop had the wrong sense, which could prevent CPUs from ever entering full sysidle state. This commit fixes both of these bugs. Given that sysidle is not yet wired up, this has no effect in old kernels, but might have proven frustrating had anyone attempted to wire it up. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> --- kernel/rcu/tree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 48d640ca1a05..735bd7ee749a 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -1798,7 +1798,7 @@ static int rcu_gp_fqs(struct rcu_state *rsp, int fqs_state_in) fqs_state = RCU_FORCE_QS; } else { /* Handle dyntick-idle and offline CPUs. */ - isidle = false; + isidle = true; force_qs_rnp(rsp, rcu_implicit_dynticks_qs, &isidle, &maxj); } /* Clear flag to prevent immediate re-entry. */ @@ -2596,8 +2596,8 @@ static void force_qs_rnp(struct rcu_state *rsp, bit = 1; for (; cpu <= rnp->grphi; cpu++, bit <<= 1) { if ((rnp->qsmask & bit) != 0) { - if ((rnp->qsmaskinit & bit) != 0) - *isidle = false; + if ((rnp->qsmaskinit & bit) == 0) + *isidle = false; /* Pending hotplug. */ if (f(per_cpu_ptr(rsp->rda, cpu), isidle, maxj)) mask |= bit; } -- 1.8.1.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH tip/core/rcu 2/2] rcu: Tighten up affinity and check for sysidle 2015-03-03 17:50 ` [PATCH tip/core/rcu 1/2] rcu: Fixes to NO_HZ_FULL sysidle accounting Paul E. McKenney @ 2015-03-03 17:50 ` Paul E. McKenney 2015-05-04 22:10 ` Sasha Levin 0 siblings, 1 reply; 7+ messages in thread From: Paul E. McKenney @ 2015-03-03 17:50 UTC (permalink / raw) To: linux-kernel Cc: mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec, oleg, bobby.prani, Paul E. McKenney From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> If the RCU grace-period kthread invoking rcu_sysidle_check_cpu() happens to be running on the tick_do_timer_cpu initially, then rcu_bind_gp_kthread() won't bind it. This kthread might then migrate before invoking rcu_gp_fqs(), which will trigger the WARN_ON_ONCE() in rcu_sysidle_check_cpu(). This commit therefore makes rcu_bind_gp_kthread() do the binding even if the kthread is currently on the same CPU. Because this incurs added overhead, this commit also causes each RCU grace-period kthread to invoke rcu_bind_gp_kthread() once at boot rather than at the beginning of each grace period. And as long as rcu_bind_gp_kthread() is being modified, this commit eliminates its #ifdef. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> --- kernel/rcu/tree.c | 2 +- kernel/rcu/tree_plugin.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 735bd7ee749a..a6972c20eaa5 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -1707,7 +1707,6 @@ static int rcu_gp_init(struct rcu_state *rsp) struct rcu_node *rnp = rcu_get_root(rsp); ACCESS_ONCE(rsp->gp_activity) = jiffies; - rcu_bind_gp_kthread(); raw_spin_lock_irq(&rnp->lock); smp_mb__after_unlock_lock(); if (!ACCESS_ONCE(rsp->gp_flags)) { @@ -1895,6 +1894,7 @@ static int __noreturn rcu_gp_kthread(void *arg) struct rcu_state *rsp = arg; struct rcu_node *rnp = rcu_get_root(rsp); + rcu_bind_gp_kthread(); for (;;) { /* Handle grace-period start. */ diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 0a571e9a0f1d..b46c92824db1 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -2763,7 +2763,8 @@ static void rcu_sysidle_exit(int irq) /* * Check to see if the current CPU is idle. Note that usermode execution - * does not count as idle. The caller must have disabled interrupts. + * does not count as idle. The caller must have disabled interrupts, + * and must be running on tick_do_timer_cpu. */ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle, unsigned long *maxj) @@ -2784,8 +2785,8 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle, if (!*isidle || rdp->rsp != rcu_state_p || cpu_is_offline(rdp->cpu) || rdp->cpu == tick_do_timer_cpu) return; - if (rcu_gp_in_progress(rdp->rsp)) - WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu); + /* Verify affinity of current kthread. */ + WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu); /* Pick up current idle and NMI-nesting counter and check. */ cur = atomic_read(&rdtp->dynticks_idle); @@ -3068,11 +3069,10 @@ static void rcu_bind_gp_kthread(void) return; #ifdef CONFIG_NO_HZ_FULL_SYSIDLE cpu = tick_do_timer_cpu; - if (cpu >= 0 && cpu < nr_cpu_ids && raw_smp_processor_id() != cpu) + if (cpu >= 0 && cpu < nr_cpu_ids) set_cpus_allowed_ptr(current, cpumask_of(cpu)); #else /* #ifdef CONFIG_NO_HZ_FULL_SYSIDLE */ - if (!is_housekeeping_cpu(raw_smp_processor_id())) - housekeeping_affine(current); + housekeeping_affine(current); #endif /* #else #ifdef CONFIG_NO_HZ_FULL_SYSIDLE */ } -- 1.8.1.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH tip/core/rcu 2/2] rcu: Tighten up affinity and check for sysidle 2015-03-03 17:50 ` [PATCH tip/core/rcu 2/2] rcu: Tighten up affinity and check for sysidle Paul E. McKenney @ 2015-05-04 22:10 ` Sasha Levin 2015-05-05 7:27 ` Paul E. McKenney 0 siblings, 1 reply; 7+ messages in thread From: Sasha Levin @ 2015-05-04 22:10 UTC (permalink / raw) To: Paul E. McKenney, linux-kernel Cc: mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec, oleg, bobby.prani On 03/03/2015 12:50 PM, Paul E. McKenney wrote: > From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> > > If the RCU grace-period kthread invoking rcu_sysidle_check_cpu() > happens to be running on the tick_do_timer_cpu initially, > then rcu_bind_gp_kthread() won't bind it. This kthread might > then migrate before invoking rcu_gp_fqs(), which will trigger the > WARN_ON_ONCE() in rcu_sysidle_check_cpu(). This commit therefore makes > rcu_bind_gp_kthread() do the binding even if the kthread is currently > on the same CPU. Because this incurs added overhead, this commit also > causes each RCU grace-period kthread to invoke rcu_bind_gp_kthread() > once at boot rather than at the beginning of each grace period. > And as long as rcu_bind_gp_kthread() is being modified, this commit > eliminates its #ifdef. > > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> > --- > kernel/rcu/tree.c | 2 +- > kernel/rcu/tree_plugin.h | 12 ++++++------ > 2 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 735bd7ee749a..a6972c20eaa5 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -1707,7 +1707,6 @@ static int rcu_gp_init(struct rcu_state *rsp) > struct rcu_node *rnp = rcu_get_root(rsp); > > ACCESS_ONCE(rsp->gp_activity) = jiffies; > - rcu_bind_gp_kthread(); > raw_spin_lock_irq(&rnp->lock); > smp_mb__after_unlock_lock(); > if (!ACCESS_ONCE(rsp->gp_flags)) { > @@ -1895,6 +1894,7 @@ static int __noreturn rcu_gp_kthread(void *arg) > struct rcu_state *rsp = arg; > struct rcu_node *rnp = rcu_get_root(rsp); > > + rcu_bind_gp_kthread(); > for (;;) { > > /* Handle grace-period start. */ > diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h > index 0a571e9a0f1d..b46c92824db1 100644 > --- a/kernel/rcu/tree_plugin.h > +++ b/kernel/rcu/tree_plugin.h > @@ -2763,7 +2763,8 @@ static void rcu_sysidle_exit(int irq) > > /* > * Check to see if the current CPU is idle. Note that usermode execution > - * does not count as idle. The caller must have disabled interrupts. > + * does not count as idle. The caller must have disabled interrupts, > + * and must be running on tick_do_timer_cpu. > */ > static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle, > unsigned long *maxj) > @@ -2784,8 +2785,8 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle, > if (!*isidle || rdp->rsp != rcu_state_p || > cpu_is_offline(rdp->cpu) || rdp->cpu == tick_do_timer_cpu) > return; > - if (rcu_gp_in_progress(rdp->rsp)) > - WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu); > + /* Verify affinity of current kthread. */ > + WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu); Hey Paul, I seem to be hitting this warning: [22408.472078] ------------[ cut here ]------------ [22408.476972] WARNING: CPU: 1 PID: 8 at kernel/rcu/tree_plugin.h:2796 rcu_sysidle_check_cpu+0x374/0x3f0() [22408.481567] Modules linked in: [22408.486054] CPU: 1 PID: 8 Comm: rcu_sched Tainted: G W 4.1.0-rc1-next-20150504+ #3 [22408.490576] Hardware name: Oracle Corporation OVCA X3-2 /ASSY,MOTHERBOARD,1U , BIOS 17021300 06/19/2012 [22408.495117] ffff881ff2db4600 0000000044d8814b ffff881ff2f1fab8 ffffffff830f9926 [22408.499647] 0000000000000000 0000000000000000 ffff881ff2f1fb08 ffffffff8120bed0 [22408.504120] ffff881ff2f1fb88 ffffffff81324ec4 1ffff103fe5e3f65 ffff881ff2f1fd48 [22408.508568] Call Trace: [22408.512953] dump_stack (lib/dump_stack.c:52) [22408.517331] warn_slowpath_common (kernel/panic.c:447) [22408.521637] ? rcu_sysidle_check_cpu (kernel/rcu/tree_plugin.h:2796 (discriminator 53)) [22408.525899] warn_slowpath_null (kernel/panic.c:481) [22408.530105] rcu_sysidle_check_cpu (kernel/rcu/tree_plugin.h:2796 (discriminator 53)) [22408.534287] ? console_conditional_schedule (kernel/time/timer.c:1472) [22408.538413] dyntick_save_progress_counter (kernel/rcu/tree.c:1041) [22408.542486] force_qs_rnp (kernel/rcu/tree.c:2793) [22408.546504] ? wake_up_atomic_t (kernel/sched/wait.c:200) [22408.550461] ? rcu_sysidle_check_cpu (kernel/rcu/tree.c:1039) [22408.554374] rcu_gp_kthread (kernel/rcu/tree.c:1914 include/linux/jump_label.h:125 include/linux/context_tracking_state.h:28 include/linux/tick.h:123 kernel/rcu/tree_plugin.h:2914 kernel/rcu/tree.c:1916 kernel/rcu/tree.c:2075) [22408.558240] ? rcu_oom_notify (kernel/rcu/tree.c:2012) [22408.562044] ? finish_task_switch (include/linux/tick.h:179 kernel/sched/core.c:2248) [22408.565789] ? __schedule (kernel/sched/core.c:2340 kernel/sched/core.c:2798) [22408.569473] ? __wake_up_common (kernel/sched/wait.c:73) [22408.573088] ? prepare_to_wait_event (kernel/sched/wait.c:292) [22408.576665] ? rcu_oom_notify (kernel/rcu/tree.c:2012) [22408.580197] kthread (kernel/kthread.c:207) [22408.583652] ? arch_vtime_task_switch (kernel/sched/cputime.c:753) [22408.587065] ? kthread_create_on_node (kernel/kthread.c:176) [22408.590427] ? kthread_create_on_node (kernel/kthread.c:176) [22408.593713] ret_from_fork (arch/x86/kernel/entry_64.S:640) [22408.596972] ? kthread_create_on_node (kernel/kthread.c:176) Thanks, Sasha ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH tip/core/rcu 2/2] rcu: Tighten up affinity and check for sysidle 2015-05-04 22:10 ` Sasha Levin @ 2015-05-05 7:27 ` Paul E. McKenney 2015-05-05 18:45 ` Paul E. McKenney 0 siblings, 1 reply; 7+ messages in thread From: Paul E. McKenney @ 2015-05-05 7:27 UTC (permalink / raw) To: Sasha Levin Cc: linux-kernel, mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec, oleg, bobby.prani On Mon, May 04, 2015 at 06:10:31PM -0400, Sasha Levin wrote: > On 03/03/2015 12:50 PM, Paul E. McKenney wrote: > > From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> > > > > If the RCU grace-period kthread invoking rcu_sysidle_check_cpu() > > happens to be running on the tick_do_timer_cpu initially, > > then rcu_bind_gp_kthread() won't bind it. This kthread might > > then migrate before invoking rcu_gp_fqs(), which will trigger the > > WARN_ON_ONCE() in rcu_sysidle_check_cpu(). This commit therefore makes > > rcu_bind_gp_kthread() do the binding even if the kthread is currently > > on the same CPU. Because this incurs added overhead, this commit also > > causes each RCU grace-period kthread to invoke rcu_bind_gp_kthread() > > once at boot rather than at the beginning of each grace period. > > And as long as rcu_bind_gp_kthread() is being modified, this commit > > eliminates its #ifdef. > > > > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> > > --- > > kernel/rcu/tree.c | 2 +- > > kernel/rcu/tree_plugin.h | 12 ++++++------ > > 2 files changed, 7 insertions(+), 7 deletions(-) > > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > index 735bd7ee749a..a6972c20eaa5 100644 > > --- a/kernel/rcu/tree.c > > +++ b/kernel/rcu/tree.c > > @@ -1707,7 +1707,6 @@ static int rcu_gp_init(struct rcu_state *rsp) > > struct rcu_node *rnp = rcu_get_root(rsp); > > > > ACCESS_ONCE(rsp->gp_activity) = jiffies; > > - rcu_bind_gp_kthread(); > > raw_spin_lock_irq(&rnp->lock); > > smp_mb__after_unlock_lock(); > > if (!ACCESS_ONCE(rsp->gp_flags)) { > > @@ -1895,6 +1894,7 @@ static int __noreturn rcu_gp_kthread(void *arg) > > struct rcu_state *rsp = arg; > > struct rcu_node *rnp = rcu_get_root(rsp); > > > > + rcu_bind_gp_kthread(); > > for (;;) { > > > > /* Handle grace-period start. */ > > diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h > > index 0a571e9a0f1d..b46c92824db1 100644 > > --- a/kernel/rcu/tree_plugin.h > > +++ b/kernel/rcu/tree_plugin.h > > @@ -2763,7 +2763,8 @@ static void rcu_sysidle_exit(int irq) > > > > /* > > * Check to see if the current CPU is idle. Note that usermode execution > > - * does not count as idle. The caller must have disabled interrupts. > > + * does not count as idle. The caller must have disabled interrupts, > > + * and must be running on tick_do_timer_cpu. > > */ > > static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle, > > unsigned long *maxj) > > @@ -2784,8 +2785,8 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle, > > if (!*isidle || rdp->rsp != rcu_state_p || > > cpu_is_offline(rdp->cpu) || rdp->cpu == tick_do_timer_cpu) > > return; > > - if (rcu_gp_in_progress(rdp->rsp)) > > - WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu); > > + /* Verify affinity of current kthread. */ > > + WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu); > > Hey Paul, > > I seem to be hitting this warning: > > [22408.472078] ------------[ cut here ]------------ > [22408.476972] WARNING: CPU: 1 PID: 8 at kernel/rcu/tree_plugin.h:2796 rcu_sysidle_check_cpu+0x374/0x3f0() > [22408.481567] Modules linked in: > [22408.486054] CPU: 1 PID: 8 Comm: rcu_sched Tainted: G W 4.1.0-rc1-next-20150504+ #3 > [22408.490576] Hardware name: Oracle Corporation OVCA X3-2 /ASSY,MOTHERBOARD,1U , BIOS 17021300 06/19/2012 > [22408.495117] ffff881ff2db4600 0000000044d8814b ffff881ff2f1fab8 ffffffff830f9926 > [22408.499647] 0000000000000000 0000000000000000 ffff881ff2f1fb08 ffffffff8120bed0 > [22408.504120] ffff881ff2f1fb88 ffffffff81324ec4 1ffff103fe5e3f65 ffff881ff2f1fd48 > [22408.508568] Call Trace: > [22408.512953] dump_stack (lib/dump_stack.c:52) > [22408.517331] warn_slowpath_common (kernel/panic.c:447) > [22408.521637] ? rcu_sysidle_check_cpu (kernel/rcu/tree_plugin.h:2796 (discriminator 53)) > [22408.525899] warn_slowpath_null (kernel/panic.c:481) > [22408.530105] rcu_sysidle_check_cpu (kernel/rcu/tree_plugin.h:2796 (discriminator 53)) > [22408.534287] ? console_conditional_schedule (kernel/time/timer.c:1472) > [22408.538413] dyntick_save_progress_counter (kernel/rcu/tree.c:1041) > [22408.542486] force_qs_rnp (kernel/rcu/tree.c:2793) > [22408.546504] ? wake_up_atomic_t (kernel/sched/wait.c:200) > [22408.550461] ? rcu_sysidle_check_cpu (kernel/rcu/tree.c:1039) > [22408.554374] rcu_gp_kthread (kernel/rcu/tree.c:1914 include/linux/jump_label.h:125 include/linux/context_tracking_state.h:28 include/linux/tick.h:123 kernel/rcu/tree_plugin.h:2914 kernel/rcu/tree.c:1916 kernel/rcu/tree.c:2075) > [22408.558240] ? rcu_oom_notify (kernel/rcu/tree.c:2012) > [22408.562044] ? finish_task_switch (include/linux/tick.h:179 kernel/sched/core.c:2248) > [22408.565789] ? __schedule (kernel/sched/core.c:2340 kernel/sched/core.c:2798) > [22408.569473] ? __wake_up_common (kernel/sched/wait.c:73) > [22408.573088] ? prepare_to_wait_event (kernel/sched/wait.c:292) > [22408.576665] ? rcu_oom_notify (kernel/rcu/tree.c:2012) > [22408.580197] kthread (kernel/kthread.c:207) > [22408.583652] ? arch_vtime_task_switch (kernel/sched/cputime.c:753) > [22408.587065] ? kthread_create_on_node (kernel/kthread.c:176) > [22408.590427] ? kthread_create_on_node (kernel/kthread.c:176) > [22408.593713] ret_from_fork (arch/x86/kernel/entry_64.S:640) > [22408.596972] ? kthread_create_on_node (kernel/kthread.c:176) That is certainly not what I wanted to happen! ;-) Looking into it. Thanx, Paul ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH tip/core/rcu 2/2] rcu: Tighten up affinity and check for sysidle 2015-05-05 7:27 ` Paul E. McKenney @ 2015-05-05 18:45 ` Paul E. McKenney 2015-05-06 0:08 ` Sasha Levin 0 siblings, 1 reply; 7+ messages in thread From: Paul E. McKenney @ 2015-05-05 18:45 UTC (permalink / raw) To: Sasha Levin Cc: linux-kernel, mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec, oleg, bobby.prani On Tue, May 05, 2015 at 12:27:21AM -0700, Paul E. McKenney wrote: > On Mon, May 04, 2015 at 06:10:31PM -0400, Sasha Levin wrote: > > On 03/03/2015 12:50 PM, Paul E. McKenney wrote: > > > From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> > > > > > > If the RCU grace-period kthread invoking rcu_sysidle_check_cpu() > > > happens to be running on the tick_do_timer_cpu initially, > > > then rcu_bind_gp_kthread() won't bind it. This kthread might > > > then migrate before invoking rcu_gp_fqs(), which will trigger the > > > WARN_ON_ONCE() in rcu_sysidle_check_cpu(). This commit therefore makes > > > rcu_bind_gp_kthread() do the binding even if the kthread is currently > > > on the same CPU. Because this incurs added overhead, this commit also > > > causes each RCU grace-period kthread to invoke rcu_bind_gp_kthread() > > > once at boot rather than at the beginning of each grace period. > > > And as long as rcu_bind_gp_kthread() is being modified, this commit > > > eliminates its #ifdef. > > > > > > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> > > > --- > > > kernel/rcu/tree.c | 2 +- > > > kernel/rcu/tree_plugin.h | 12 ++++++------ > > > 2 files changed, 7 insertions(+), 7 deletions(-) > > > > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > > index 735bd7ee749a..a6972c20eaa5 100644 > > > --- a/kernel/rcu/tree.c > > > +++ b/kernel/rcu/tree.c > > > @@ -1707,7 +1707,6 @@ static int rcu_gp_init(struct rcu_state *rsp) > > > struct rcu_node *rnp = rcu_get_root(rsp); > > > > > > ACCESS_ONCE(rsp->gp_activity) = jiffies; > > > - rcu_bind_gp_kthread(); > > > raw_spin_lock_irq(&rnp->lock); > > > smp_mb__after_unlock_lock(); > > > if (!ACCESS_ONCE(rsp->gp_flags)) { > > > @@ -1895,6 +1894,7 @@ static int __noreturn rcu_gp_kthread(void *arg) > > > struct rcu_state *rsp = arg; > > > struct rcu_node *rnp = rcu_get_root(rsp); > > > > > > + rcu_bind_gp_kthread(); > > > for (;;) { > > > > > > /* Handle grace-period start. */ > > > diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h > > > index 0a571e9a0f1d..b46c92824db1 100644 > > > --- a/kernel/rcu/tree_plugin.h > > > +++ b/kernel/rcu/tree_plugin.h > > > @@ -2763,7 +2763,8 @@ static void rcu_sysidle_exit(int irq) > > > > > > /* > > > * Check to see if the current CPU is idle. Note that usermode execution > > > - * does not count as idle. The caller must have disabled interrupts. > > > + * does not count as idle. The caller must have disabled interrupts, > > > + * and must be running on tick_do_timer_cpu. > > > */ > > > static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle, > > > unsigned long *maxj) > > > @@ -2784,8 +2785,8 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle, > > > if (!*isidle || rdp->rsp != rcu_state_p || > > > cpu_is_offline(rdp->cpu) || rdp->cpu == tick_do_timer_cpu) > > > return; > > > - if (rcu_gp_in_progress(rdp->rsp)) > > > - WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu); > > > + /* Verify affinity of current kthread. */ > > > + WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu); > > > > Hey Paul, > > > > I seem to be hitting this warning: > > > > [22408.472078] ------------[ cut here ]------------ > > [22408.476972] WARNING: CPU: 1 PID: 8 at kernel/rcu/tree_plugin.h:2796 rcu_sysidle_check_cpu+0x374/0x3f0() > > [22408.481567] Modules linked in: > > [22408.486054] CPU: 1 PID: 8 Comm: rcu_sched Tainted: G W 4.1.0-rc1-next-20150504+ #3 > > [22408.490576] Hardware name: Oracle Corporation OVCA X3-2 /ASSY,MOTHERBOARD,1U , BIOS 17021300 06/19/2012 > > [22408.495117] ffff881ff2db4600 0000000044d8814b ffff881ff2f1fab8 ffffffff830f9926 > > [22408.499647] 0000000000000000 0000000000000000 ffff881ff2f1fb08 ffffffff8120bed0 > > [22408.504120] ffff881ff2f1fb88 ffffffff81324ec4 1ffff103fe5e3f65 ffff881ff2f1fd48 > > [22408.508568] Call Trace: > > [22408.512953] dump_stack (lib/dump_stack.c:52) > > [22408.517331] warn_slowpath_common (kernel/panic.c:447) > > [22408.521637] ? rcu_sysidle_check_cpu (kernel/rcu/tree_plugin.h:2796 (discriminator 53)) > > [22408.525899] warn_slowpath_null (kernel/panic.c:481) > > [22408.530105] rcu_sysidle_check_cpu (kernel/rcu/tree_plugin.h:2796 (discriminator 53)) > > [22408.534287] ? console_conditional_schedule (kernel/time/timer.c:1472) > > [22408.538413] dyntick_save_progress_counter (kernel/rcu/tree.c:1041) > > [22408.542486] force_qs_rnp (kernel/rcu/tree.c:2793) > > [22408.546504] ? wake_up_atomic_t (kernel/sched/wait.c:200) > > [22408.550461] ? rcu_sysidle_check_cpu (kernel/rcu/tree.c:1039) > > [22408.554374] rcu_gp_kthread (kernel/rcu/tree.c:1914 include/linux/jump_label.h:125 include/linux/context_tracking_state.h:28 include/linux/tick.h:123 kernel/rcu/tree_plugin.h:2914 kernel/rcu/tree.c:1916 kernel/rcu/tree.c:2075) > > [22408.558240] ? rcu_oom_notify (kernel/rcu/tree.c:2012) > > [22408.562044] ? finish_task_switch (include/linux/tick.h:179 kernel/sched/core.c:2248) > > [22408.565789] ? __schedule (kernel/sched/core.c:2340 kernel/sched/core.c:2798) > > [22408.569473] ? __wake_up_common (kernel/sched/wait.c:73) > > [22408.573088] ? prepare_to_wait_event (kernel/sched/wait.c:292) > > [22408.576665] ? rcu_oom_notify (kernel/rcu/tree.c:2012) > > [22408.580197] kthread (kernel/kthread.c:207) > > [22408.583652] ? arch_vtime_task_switch (kernel/sched/cputime.c:753) > > [22408.587065] ? kthread_create_on_node (kernel/kthread.c:176) > > [22408.590427] ? kthread_create_on_node (kernel/kthread.c:176) > > [22408.593713] ret_from_fork (arch/x86/kernel/entry_64.S:640) > > [22408.596972] ? kthread_create_on_node (kernel/kthread.c:176) > > That is certainly not what I wanted to happen! ;-) > > Looking into it. Could you please send along your .CONFIG? Thanx, Paul ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH tip/core/rcu 2/2] rcu: Tighten up affinity and check for sysidle 2015-05-05 18:45 ` Paul E. McKenney @ 2015-05-06 0:08 ` Sasha Levin 0 siblings, 0 replies; 7+ messages in thread From: Sasha Levin @ 2015-05-06 0:08 UTC (permalink / raw) To: paulmck Cc: linux-kernel, mingo, laijs, dipankar, akpm, mathieu.desnoyers, josh, tglx, peterz, rostedt, dhowells, edumazet, dvhart, fweisbec, oleg, bobby.prani [-- Attachment #1: Type: text/plain, Size: 5830 bytes --] On 05/05/2015 02:45 PM, Paul E. McKenney wrote: > On Tue, May 05, 2015 at 12:27:21AM -0700, Paul E. McKenney wrote: >> On Mon, May 04, 2015 at 06:10:31PM -0400, Sasha Levin wrote: >>> On 03/03/2015 12:50 PM, Paul E. McKenney wrote: >>>> From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> >>>> >>>> If the RCU grace-period kthread invoking rcu_sysidle_check_cpu() >>>> happens to be running on the tick_do_timer_cpu initially, >>>> then rcu_bind_gp_kthread() won't bind it. This kthread might >>>> then migrate before invoking rcu_gp_fqs(), which will trigger the >>>> WARN_ON_ONCE() in rcu_sysidle_check_cpu(). This commit therefore makes >>>> rcu_bind_gp_kthread() do the binding even if the kthread is currently >>>> on the same CPU. Because this incurs added overhead, this commit also >>>> causes each RCU grace-period kthread to invoke rcu_bind_gp_kthread() >>>> once at boot rather than at the beginning of each grace period. >>>> And as long as rcu_bind_gp_kthread() is being modified, this commit >>>> eliminates its #ifdef. >>>> >>>> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> >>>> --- >>>> kernel/rcu/tree.c | 2 +- >>>> kernel/rcu/tree_plugin.h | 12 ++++++------ >>>> 2 files changed, 7 insertions(+), 7 deletions(-) >>>> >>>> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c >>>> index 735bd7ee749a..a6972c20eaa5 100644 >>>> --- a/kernel/rcu/tree.c >>>> +++ b/kernel/rcu/tree.c >>>> @@ -1707,7 +1707,6 @@ static int rcu_gp_init(struct rcu_state *rsp) >>>> struct rcu_node *rnp = rcu_get_root(rsp); >>>> >>>> ACCESS_ONCE(rsp->gp_activity) = jiffies; >>>> - rcu_bind_gp_kthread(); >>>> raw_spin_lock_irq(&rnp->lock); >>>> smp_mb__after_unlock_lock(); >>>> if (!ACCESS_ONCE(rsp->gp_flags)) { >>>> @@ -1895,6 +1894,7 @@ static int __noreturn rcu_gp_kthread(void *arg) >>>> struct rcu_state *rsp = arg; >>>> struct rcu_node *rnp = rcu_get_root(rsp); >>>> >>>> + rcu_bind_gp_kthread(); >>>> for (;;) { >>>> >>>> /* Handle grace-period start. */ >>>> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h >>>> index 0a571e9a0f1d..b46c92824db1 100644 >>>> --- a/kernel/rcu/tree_plugin.h >>>> +++ b/kernel/rcu/tree_plugin.h >>>> @@ -2763,7 +2763,8 @@ static void rcu_sysidle_exit(int irq) >>>> >>>> /* >>>> * Check to see if the current CPU is idle. Note that usermode execution >>>> - * does not count as idle. The caller must have disabled interrupts. >>>> + * does not count as idle. The caller must have disabled interrupts, >>>> + * and must be running on tick_do_timer_cpu. >>>> */ >>>> static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle, >>>> unsigned long *maxj) >>>> @@ -2784,8 +2785,8 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle, >>>> if (!*isidle || rdp->rsp != rcu_state_p || >>>> cpu_is_offline(rdp->cpu) || rdp->cpu == tick_do_timer_cpu) >>>> return; >>>> - if (rcu_gp_in_progress(rdp->rsp)) >>>> - WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu); >>>> + /* Verify affinity of current kthread. */ >>>> + WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu); >>> >>> Hey Paul, >>> >>> I seem to be hitting this warning: >>> >>> [22408.472078] ------------[ cut here ]------------ >>> [22408.476972] WARNING: CPU: 1 PID: 8 at kernel/rcu/tree_plugin.h:2796 rcu_sysidle_check_cpu+0x374/0x3f0() >>> [22408.481567] Modules linked in: >>> [22408.486054] CPU: 1 PID: 8 Comm: rcu_sched Tainted: G W 4.1.0-rc1-next-20150504+ #3 >>> [22408.490576] Hardware name: Oracle Corporation OVCA X3-2 /ASSY,MOTHERBOARD,1U , BIOS 17021300 06/19/2012 >>> [22408.495117] ffff881ff2db4600 0000000044d8814b ffff881ff2f1fab8 ffffffff830f9926 >>> [22408.499647] 0000000000000000 0000000000000000 ffff881ff2f1fb08 ffffffff8120bed0 >>> [22408.504120] ffff881ff2f1fb88 ffffffff81324ec4 1ffff103fe5e3f65 ffff881ff2f1fd48 >>> [22408.508568] Call Trace: >>> [22408.512953] dump_stack (lib/dump_stack.c:52) >>> [22408.517331] warn_slowpath_common (kernel/panic.c:447) >>> [22408.521637] ? rcu_sysidle_check_cpu (kernel/rcu/tree_plugin.h:2796 (discriminator 53)) >>> [22408.525899] warn_slowpath_null (kernel/panic.c:481) >>> [22408.530105] rcu_sysidle_check_cpu (kernel/rcu/tree_plugin.h:2796 (discriminator 53)) >>> [22408.534287] ? console_conditional_schedule (kernel/time/timer.c:1472) >>> [22408.538413] dyntick_save_progress_counter (kernel/rcu/tree.c:1041) >>> [22408.542486] force_qs_rnp (kernel/rcu/tree.c:2793) >>> [22408.546504] ? wake_up_atomic_t (kernel/sched/wait.c:200) >>> [22408.550461] ? rcu_sysidle_check_cpu (kernel/rcu/tree.c:1039) >>> [22408.554374] rcu_gp_kthread (kernel/rcu/tree.c:1914 include/linux/jump_label.h:125 include/linux/context_tracking_state.h:28 include/linux/tick.h:123 kernel/rcu/tree_plugin.h:2914 kernel/rcu/tree.c:1916 kernel/rcu/tree.c:2075) >>> [22408.558240] ? rcu_oom_notify (kernel/rcu/tree.c:2012) >>> [22408.562044] ? finish_task_switch (include/linux/tick.h:179 kernel/sched/core.c:2248) >>> [22408.565789] ? __schedule (kernel/sched/core.c:2340 kernel/sched/core.c:2798) >>> [22408.569473] ? __wake_up_common (kernel/sched/wait.c:73) >>> [22408.573088] ? prepare_to_wait_event (kernel/sched/wait.c:292) >>> [22408.576665] ? rcu_oom_notify (kernel/rcu/tree.c:2012) >>> [22408.580197] kthread (kernel/kthread.c:207) >>> [22408.583652] ? arch_vtime_task_switch (kernel/sched/cputime.c:753) >>> [22408.587065] ? kthread_create_on_node (kernel/kthread.c:176) >>> [22408.590427] ? kthread_create_on_node (kernel/kthread.c:176) >>> [22408.593713] ret_from_fork (arch/x86/kernel/entry_64.S:640) >>> [22408.596972] ? kthread_create_on_node (kernel/kthread.c:176) >> >> That is certainly not what I wanted to happen! ;-) >> >> Looking into it. > > Could you please send along your .CONFIG? Attached. Thanks, Sasha [-- Attachment #2: config-sasha.gz --] [-- Type: application/gzip, Size: 26740 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-05-06 0:09 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-03-03 17:50 [PATCH tip/core/rcu 0/2] NO_HZ_FULL_SYSIDLE updates for v4.1 Paul E. McKenney 2015-03-03 17:50 ` [PATCH tip/core/rcu 1/2] rcu: Fixes to NO_HZ_FULL sysidle accounting Paul E. McKenney 2015-03-03 17:50 ` [PATCH tip/core/rcu 2/2] rcu: Tighten up affinity and check for sysidle Paul E. McKenney 2015-05-04 22:10 ` Sasha Levin 2015-05-05 7:27 ` Paul E. McKenney 2015-05-05 18:45 ` Paul E. McKenney 2015-05-06 0:08 ` Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox