Re: [PATCH v2] intel_idle: avoid tracing MSR writes while idling

From: Rafael J. Wysocki
Date: Thu Aug 25 2022 - 07:44:14 EST


On Thu, Aug 25, 2022 at 1:42 AM Peter Shier <pshier@xxxxxxxxxx> wrote:
>
> With commit bf5835bcdb963 ("intel_idle: Disable IBRS during long idle"),
> enabling wrmsr trace with CONFIG_LOCKDEP causes "suspicious
> rcu_dereference_check() usage" warning because do_trace_write_msr does not
> use trace_write_msr_rcuidle.
>
> Change intel_idle_ibrs to use native_wrmsr to avoid tracing
>
> Sample warning:
> ============================
> WARNING: suspicious RCU usage
> 6.0.0-dbg-DEV #7 Tainted: G S O
> -----------------------------
> arch/x86/include/asm/msr-trace.h:48 suspicious rcu_dereference_check() usage!
>
> other info that might help us debug this:
>
> rcu_scheduler_active = 2, debug_locks = 1
> RCU used illegally from extended quiescent state!
> no locks held by swapper/59/0.
>
> stack backtrace:
> CPU: 59 PID: 0 Comm: swapper/59 Tainted: G S O 6.0.0-dbg-DEV #7
> Call Trace:
> dump_stack_lvl
> dump_stack
> lockdep_rcu_suspicious
> trace_write_msr
> do_trace_write_msr
> intel_idle_ibrs
> cpuidle_enter_state
> cpuidle_enter
> do_idle
> cpu_startup_entry
> start_secondary
> secondary_startup_64_no_verify
>
> Tested on skylake using:
> echo "msr:write_msr" >/sys/kernel/debug/tracing/set_event
> with and without patch.
>
> Signed-off-by: Peter Shier <pshier@xxxxxxxxxx>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>

> ---
>
> v2:
> - changed to avoid tracing
>
> v1: https://lore.kernel.org/all/20220823234353.937002-1-pshier@xxxxxxxxxx/
>
> drivers/idle/intel_idle.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
> index 3e101719689a..df129c73786f 100644
> --- a/drivers/idle/intel_idle.c
> +++ b/drivers/idle/intel_idle.c
> @@ -187,12 +187,12 @@ static __cpuidle int intel_idle_ibrs(struct cpuidle_device *dev,
> int ret;
>
> if (smt_active)
> - wrmsrl(MSR_IA32_SPEC_CTRL, 0);
> + native_wrmsr(MSR_IA32_SPEC_CTRL, 0);
>
> ret = __intel_idle(dev, drv, index);
>
> if (smt_active)
> - wrmsrl(MSR_IA32_SPEC_CTRL, spec_ctrl);
> + native_wrmsr(MSR_IA32_SPEC_CTRL, spec_ctrl);
>
> return ret;
> }
> --