Commit dff1672d authored by Paul E. McKenney's avatar Paul E. McKenney Committed by Paul E. McKenney

rcu: Keep invoking callbacks if CPU otherwise idle

The rcu_do_batch() function that invokes callbacks for TREE_RCU and
TREE_PREEMPT_RCU normally throttles callback invocation to avoid degrading
scheduling latency.  However, as long as the CPU would otherwise be idle,
there is no downside to continuing to invoke any callbacks that have passed
through their grace periods.  In fact, processing such callbacks in a
timely manner has the benefit of increasing the probability that the
CPU can enter the power-saving dyntick-idle mode.

Therefore, this commit allows callback invocation to continue beyond the
preset limit as long as the scheduler does not have some other task to
run and as long as context is that of the idle task or the relevant
RCU kthread.
Signed-off-by: default avatarPaul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
parent facc4e15
...@@ -1403,7 +1403,10 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp) ...@@ -1403,7 +1403,10 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
debug_rcu_head_unqueue(list); debug_rcu_head_unqueue(list);
__rcu_reclaim(rsp->name, list); __rcu_reclaim(rsp->name, list);
list = next; list = next;
if (++count >= bl) /* Stop only if limit reached and CPU has something to do. */
if (++count >= bl &&
(need_resched() ||
(!is_idle_task(current) && !rcu_is_callbacks_kthread())))
break; break;
} }
......
...@@ -455,6 +455,7 @@ static void __init __rcu_init_preempt(void); ...@@ -455,6 +455,7 @@ static void __init __rcu_init_preempt(void);
static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags); static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags);
static void rcu_preempt_boost_start_gp(struct rcu_node *rnp); static void rcu_preempt_boost_start_gp(struct rcu_node *rnp);
static void invoke_rcu_callbacks_kthread(void); static void invoke_rcu_callbacks_kthread(void);
static bool rcu_is_callbacks_kthread(void);
#ifdef CONFIG_RCU_BOOST #ifdef CONFIG_RCU_BOOST
static void rcu_preempt_do_callbacks(void); static void rcu_preempt_do_callbacks(void);
static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp,
......
...@@ -1336,6 +1336,15 @@ static void invoke_rcu_callbacks_kthread(void) ...@@ -1336,6 +1336,15 @@ static void invoke_rcu_callbacks_kthread(void)
local_irq_restore(flags); local_irq_restore(flags);
} }
/*
* Is the current CPU running the RCU-callbacks kthread?
* Caller must have preemption disabled.
*/
static bool rcu_is_callbacks_kthread(void)
{
return __get_cpu_var(rcu_cpu_kthread_task) == current;
}
/* /*
* Set the affinity of the boost kthread. The CPU-hotplug locks are * Set the affinity of the boost kthread. The CPU-hotplug locks are
* held, so no one should be messing with the existence of the boost * held, so no one should be messing with the existence of the boost
...@@ -1780,6 +1789,11 @@ static void invoke_rcu_callbacks_kthread(void) ...@@ -1780,6 +1789,11 @@ static void invoke_rcu_callbacks_kthread(void)
WARN_ON_ONCE(1); WARN_ON_ONCE(1);
} }
static bool rcu_is_callbacks_kthread(void)
{
return false;
}
static void rcu_preempt_boost_start_gp(struct rcu_node *rnp) static void rcu_preempt_boost_start_gp(struct rcu_node *rnp)
{ {
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment