Re: [RFC PATCH] trace: prevent preemption in perf_ftrace_function_call()

From: Steven Rostedt
Date: Thu Sep 23 2021 - 23:26:45 EST


On Fri, 24 Sep 2021 10:08:10 +0800
王贇 <yun.wang@xxxxxxxxxxxxxxxxx> wrote:

> I found the rcu tree implementation of rcu_is_watching() will check
> this_cpu_ptr(&rcu_data.dynticks), and after that enable the preemption.
>
> If preemption happened after that and before we disable here, there are
> still possibility that the CPU changed and make the dynticks checking
> invalid, isn't it?

If it can be scheduled, then RCU is definitely watching ;-)

The rcu_is_watching() is a safe guard for places that are in between
context switches. Not task context switches, but transitioning between
kernel and user space, or going into or out of idle, or transitioning
in and out of an interrupt. There are small critical sections that RCU
is not watching, and we are actually working on making those locations
disable instrumentation (like tracing), where rcu_is_watching() will no
longer be needed.

-- Steve