Skip to content

Commit 65d798f

Browse files
paulmckfweisbec
authored andcommitted
rcu: Kick adaptive-ticks CPUs that are holding up RCU grace periods
Adaptive-ticks CPUs inform RCU when they enter kernel mode, but they do not necessarily turn the scheduler-clock tick back on. This state of affairs could result in RCU waiting on an adaptive-ticks CPU running for an extended period in kernel mode. Such a CPU will never run the RCU state machine, and could therefore indefinitely extend the RCU state machine, sooner or later resulting in an OOM condition. This patch, inspired by an earlier patch by Frederic Weisbecker, therefore causes RCU's force-quiescent-state processing to check for this condition and to send an IPI to CPUs that remain in that state for too long. "Too long" currently means about three jiffies by default, which is quite some time for a CPU to remain in the kernel without blocking. The rcu_tree.jiffies_till_first_fqs and rcutree.jiffies_till_next_fqs sysfs variables may be used to tune "too long" if needed. Reported-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Chris Metcalf <cmetcalf@tilera.com> Cc: Christoph Lameter <cl@linux.com> Cc: Geoff Levand <geoff@infradead.org> Cc: Gilad Ben Yossef <gilad@benyossef.com> Cc: Hakan Akkan <hakanakkan@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Kevin Hilman <khilman@linaro.org> Cc: Li Zhong <zhong@linux.vnet.ibm.com> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de>
1 parent fae30dd commit 65d798f

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎kernel/rcutree.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,16 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
794794
rdp->offline_fqs++;
795795
return 1;
796796
}
797+
798+
/*
799+
* There is a possibility that a CPU in adaptive-ticks state
800+
* might run in the kernel with the scheduling-clock tick disabled
801+
* for an extended time period. Invoke rcu_kick_nohz_cpu() to
802+
* force the CPU to restart the scheduling-clock tick in this
803+
* CPU is in this state.
804+
*/
805+
rcu_kick_nohz_cpu(rdp->cpu);
806+
797807
return 0;
798808
}
799809

‎kernel/rcutree.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ static void rcu_boot_init_nocb_percpu_data(struct rcu_data *rdp);
539539
static void rcu_spawn_nocb_kthreads(struct rcu_state *rsp);
540540
static void init_nocb_callback_list(struct rcu_data *rdp);
541541
static void __init rcu_init_nocb(void);
542+
static void rcu_kick_nohz_cpu(int cpu);
542543

543544
#endif /* #ifndef RCU_TREE_NONCORE */
544545

‎kernel/rcutree_plugin.h‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/gfp.h>
2929
#include <linux/oom.h>
3030
#include <linux/smpboot.h>
31+
#include <linux/tick.h>
3132

3233
#define RCU_KTHREAD_PRIO 1
3334

@@ -2502,3 +2503,20 @@ static void __init rcu_init_nocb(void)
25022503
}
25032504

25042505
#endif /* #else #ifdef CONFIG_RCU_NOCB_CPU */
2506+
2507+
/*
2508+
* An adaptive-ticks CPU can potentially execute in kernel mode for an
2509+
* arbitrarily long period of time with the scheduling-clock tick turned
2510+
* off. RCU will be paying attention to this CPU because it is in the
2511+
* kernel, but the CPU cannot be guaranteed to be executing the RCU state
2512+
* machine because the scheduling-clock tick has been disabled. Therefore,
2513+
* if an adaptive-ticks CPU is failing to respond to the current grace
2514+
* period and has not be idle from an RCU perspective, kick it.
2515+
*/
2516+
static void rcu_kick_nohz_cpu(int cpu)
2517+
{
2518+
#ifdef CONFIG_NO_HZ_FULL
2519+
if (tick_nohz_full_cpu(cpu))
2520+
smp_send_reschedule(cpu);
2521+
#endif /* #ifdef CONFIG_NO_HZ_FULL */
2522+
}

0 commit comments

Comments
 (0)