rcu: Make non-preemptive schedule be Tasks RCU quiescent state
Currently, a call to schedule() acts as a Tasks RCU quiescent state only if a context switch actually takes place. However, just the call to schedule() guarantees that the calling task has moved off of whatever tracing trampoline that it might have been one previously. This commit therefore plumbs schedule()'s "preempt" parameter into rcu_note_context_switch(), which then records the Tasks RCU quiescent state, but only if this call to schedule() was -not- due to a preemption. To avoid adding overhead to the common-case context-switch path, this commit hides the rcu_note_context_switch() check under an existing non-common-case check. Suggested-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
This commit is contained in:
parent
0497b489b8
commit
bcbfdd01dc
|
@ -363,15 +363,20 @@ static inline void rcu_init_nohz(void)
|
|||
#ifdef CONFIG_TASKS_RCU
|
||||
#define TASKS_RCU(x) x
|
||||
extern struct srcu_struct tasks_rcu_exit_srcu;
|
||||
#define rcu_note_voluntary_context_switch(t) \
|
||||
#define rcu_note_voluntary_context_switch_lite(t) \
|
||||
do { \
|
||||
rcu_all_qs(); \
|
||||
if (READ_ONCE((t)->rcu_tasks_holdout)) \
|
||||
WRITE_ONCE((t)->rcu_tasks_holdout, false); \
|
||||
} while (0)
|
||||
#define rcu_note_voluntary_context_switch(t) \
|
||||
do { \
|
||||
rcu_all_qs(); \
|
||||
rcu_note_voluntary_context_switch_lite(t); \
|
||||
} while (0)
|
||||
#else /* #ifdef CONFIG_TASKS_RCU */
|
||||
#define TASKS_RCU(x) do { } while (0)
|
||||
#define rcu_note_voluntary_context_switch(t) rcu_all_qs()
|
||||
#define rcu_note_voluntary_context_switch_lite(t) do { } while (0)
|
||||
#define rcu_note_voluntary_context_switch(t) rcu_all_qs()
|
||||
#endif /* #else #ifdef CONFIG_TASKS_RCU */
|
||||
|
||||
/**
|
||||
|
|
|
@ -92,10 +92,11 @@ static inline void kfree_call_rcu(struct rcu_head *head,
|
|||
call_rcu(head, func);
|
||||
}
|
||||
|
||||
static inline void rcu_note_context_switch(void)
|
||||
{
|
||||
rcu_sched_qs();
|
||||
}
|
||||
#define rcu_note_context_switch(preempt) \
|
||||
do { \
|
||||
rcu_sched_qs(); \
|
||||
rcu_note_voluntary_context_switch_lite(current); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Take advantage of the fact that there is only one CPU, which
|
||||
|
@ -242,6 +243,10 @@ static inline bool rcu_is_watching(void)
|
|||
|
||||
#endif /* #else defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) */
|
||||
|
||||
static inline void rcu_request_urgent_qs_task(struct task_struct *t)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void rcu_all_qs(void)
|
||||
{
|
||||
barrier(); /* Avoid RCU read-side critical sections leaking across. */
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#ifndef __LINUX_RCUTREE_H
|
||||
#define __LINUX_RCUTREE_H
|
||||
|
||||
void rcu_note_context_switch(void);
|
||||
void rcu_note_context_switch(bool preempt);
|
||||
int rcu_needs_cpu(u64 basem, u64 *nextevt);
|
||||
void rcu_cpu_stall_reset(void);
|
||||
|
||||
|
@ -41,7 +41,7 @@ void rcu_cpu_stall_reset(void);
|
|||
*/
|
||||
static inline void rcu_virt_note_context_switch(int cpu)
|
||||
{
|
||||
rcu_note_context_switch();
|
||||
rcu_note_context_switch(false);
|
||||
}
|
||||
|
||||
void synchronize_rcu_bh(void);
|
||||
|
@ -108,6 +108,7 @@ void rcu_scheduler_starting(void);
|
|||
extern int rcu_scheduler_active __read_mostly;
|
||||
|
||||
bool rcu_is_watching(void);
|
||||
void rcu_request_urgent_qs_task(struct task_struct *t);
|
||||
|
||||
void rcu_all_qs(void);
|
||||
|
||||
|
|
|
@ -458,7 +458,7 @@ static void rcu_momentary_dyntick_idle(void)
|
|||
* and requires special handling for preemptible RCU.
|
||||
* The caller must have disabled interrupts.
|
||||
*/
|
||||
void rcu_note_context_switch(void)
|
||||
void rcu_note_context_switch(bool preempt)
|
||||
{
|
||||
barrier(); /* Avoid RCU read-side critical sections leaking down. */
|
||||
trace_rcu_utilization(TPS("Start context switch"));
|
||||
|
@ -471,6 +471,8 @@ void rcu_note_context_switch(void)
|
|||
if (unlikely(raw_cpu_read(rcu_dynticks.rcu_need_heavy_qs)))
|
||||
rcu_momentary_dyntick_idle();
|
||||
this_cpu_inc(rcu_dynticks.rcu_qs_ctr);
|
||||
if (!preempt)
|
||||
rcu_note_voluntary_context_switch_lite(current);
|
||||
out:
|
||||
trace_rcu_utilization(TPS("End context switch"));
|
||||
barrier(); /* Avoid RCU read-side critical sections leaking up. */
|
||||
|
@ -1149,6 +1151,24 @@ bool notrace rcu_is_watching(void)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(rcu_is_watching);
|
||||
|
||||
/*
|
||||
* If a holdout task is actually running, request an urgent quiescent
|
||||
* state from its CPU. This is unsynchronized, so migrations can cause
|
||||
* the request to go to the wrong CPU. Which is OK, all that will happen
|
||||
* is that the CPU's next context switch will be a bit slower and next
|
||||
* time around this task will generate another request.
|
||||
*/
|
||||
void rcu_request_urgent_qs_task(struct task_struct *t)
|
||||
{
|
||||
int cpu;
|
||||
|
||||
barrier();
|
||||
cpu = task_cpu(t);
|
||||
if (!task_curr(t))
|
||||
return; /* This task is not running on that CPU. */
|
||||
smp_store_release(per_cpu_ptr(&rcu_dynticks.rcu_urgent_qs, cpu), true);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_PROVE_RCU) && defined(CONFIG_HOTPLUG_CPU)
|
||||
|
||||
/*
|
||||
|
|
|
@ -665,6 +665,7 @@ static void check_holdout_task(struct task_struct *t,
|
|||
put_task_struct(t);
|
||||
return;
|
||||
}
|
||||
rcu_request_urgent_qs_task(t);
|
||||
if (!needreport)
|
||||
return;
|
||||
if (*firstreport) {
|
||||
|
|
|
@ -3378,7 +3378,7 @@ static void __sched notrace __schedule(bool preempt)
|
|||
hrtick_clear(rq);
|
||||
|
||||
local_irq_disable();
|
||||
rcu_note_context_switch();
|
||||
rcu_note_context_switch(preempt);
|
||||
|
||||
/*
|
||||
* Make sure that signal_pending_state()->signal_pending() below
|
||||
|
|
Loading…
Reference in New Issue