Skip to content

Commit 528262f

Browse files
qiangzh3paulmckrcu
authored andcommitted
rcu-tasks: Make RCU Tasks Trace check for userspace execution
Userspace execution is a valid quiescent state for RCU Tasks Trace, but the scheduling-clock interrupt does not currently report such quiescent states. Of course, the scheduling-clock interrupt is not strictly speaking userspace execution. However, the only way that this code is not in a quiescent state is if something invoked rcu_read_lock_trace(), and that would be reflected in the ->trc_reader_nesting field in the task_struct structure. Furthermore, this field is checked by rcu_tasks_trace_qs(), which is invoked by rcu_tasks_qs() which is in turn invoked by rcu_note_voluntary_context_switch() in kernels building at least one of the RCU Tasks flavors. It is therefore safe to invoke rcu_tasks_trace_qs() from the rcu_sched_clock_irq(). But rcu_tasks_qs() also invokes rcu_tasks_classic_qs() for RCU Tasks, which lacks the read-side markers provided by RCU Tasks Trace. This raises the possibility that an RCU Tasks grace period could start after the interrupt from userspace execution, but before the call to rcu_sched_clock_irq(). However, it turns out that this is safe because the RCU Tasks grace period waits for an RCU grace period, which will wait for the entire scheduling-clock interrupt handler, including any RCU Tasks read-side critical section that this handler might contain. This commit therefore updates the rcu_sched_clock_irq() function's check for usermode execution and its call to rcu_tasks_classic_qs() to instead check for both usermode execution and interrupt from idle, and to instead call rcu_note_voluntary_context_switch(). This consolidates code and provides more faster RCU Tasks Trace reporting of quiescent states in kernels that do scheduling-clock interrupts for userspace execution. [ paulmck: Consolidate checks into rcu_sched_clock_irq(). ] Signed-off-by: Zqiang <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent d6ad606 commit 528262f

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

kernel/rcu/tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,8 +2341,8 @@ void rcu_sched_clock_irq(int user)
23412341
rcu_flavor_sched_clock_irq(user);
23422342
if (rcu_pending(user))
23432343
invoke_rcu_core();
2344-
if (user)
2345-
rcu_tasks_classic_qs(current, false);
2344+
if (user || rcu_is_cpu_rrupt_from_idle())
2345+
rcu_note_voluntary_context_switch(current);
23462346
lockdep_assert_irqs_disabled();
23472347

23482348
trace_rcu_utilization(TPS("End scheduler-tick"));

kernel/rcu/tree_plugin.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,6 @@ static void rcu_flavor_sched_clock_irq(int user)
718718
struct task_struct *t = current;
719719

720720
lockdep_assert_irqs_disabled();
721-
if (user || rcu_is_cpu_rrupt_from_idle()) {
722-
rcu_note_voluntary_context_switch(current);
723-
}
724721
if (rcu_preempt_depth() > 0 ||
725722
(preempt_count() & (PREEMPT_MASK | SOFTIRQ_MASK))) {
726723
/* No QS, force context switch if deferred. */
@@ -972,7 +969,6 @@ static void rcu_flavor_sched_clock_irq(int user)
972969
* neither access nor modify, at least not while the
973970
* corresponding CPU is online.
974971
*/
975-
976972
rcu_qs();
977973
}
978974
}

0 commit comments

Comments
 (0)