All of lore.kernel.org
 help / color / mirror / Atom feed
* [Race condition] Race condition at cpuidle_enter_s2idle & __cfi_slowpath_diag
@ 2022-08-11  7:54 ` Kuyo Chang
  0 siblings, 0 replies; 2+ messages in thread
From: Kuyo Chang @ 2022-08-11  7:54 UTC (permalink / raw)
  To: Sami Tolvanen, Kees Cook, Nathan Chancellor, Nick Desaulniers,
	Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Daniel Bristot de Oliveira, Paul E. McKenney, Josh Triplett,
	Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Joel Fernandes,
	rcu, Rafael J. Wysocki, Daniel Lezcano
  Cc: kuyo.chang, linux-pm, linux-kernel, wsd_upstream,
	linux-arm-kernel, linux-mediatek, rcu, llvm

Hi Sami,

During doing s2idle(Suspend-To-Idle) flow, I found a task will put into
runqueue by __cfi_slowpath_diag.
The code trace about fail case as below:

call_cpuidle_s2idle
->if (current_clr_polling_and_test()) //check resched flag
	return -EBUSY;
->cpuidle_enter_s2idle
->enter_s2idle_proper
->target_state->enter_s2idle(dev, drv, index);

Meanwhile the log shows the __cfi_slowpath_diag function will wake up a
task to CPU, below is the backtrace
__cfi_slowpath_diag
find_check_fn
rcu_irq_enter
rcu_nmi_enter
rcu_cleanup_after_idle
invoke_rcu_core
raise_softirq(RCU_SOFTIRQ)
raise_softirq_irqoff
    if (!in_interrupt() && should_wake_ksoftirqd())
        wakeup_softirqd();
//wake up flow
wake_up_process
try_to_wake_up
ttwu_queue
ttwu_do_activate
ttwu_do_wakeup
check_preempt_curr
resched_curr
set_tsk_need_resched(curr);
 

So It will violate the initial check at call_cpuidle_s2idle(Now it
exists a task at rq  and need reched, so it should not enter
cpuidle_enter_s2idle )
if (current_clr_polling_and_test())
	return -EBUSY;

I look the racing may be related to the following patch

57cd6d1 cfi: Fix __cfi_slowpath_diag RCU usage with cpuidle
https://android.googlesource.com/kernel/common/+/57cd6d1

Do you have any suggestion for this issue?
Thank you.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-11  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-11  7:54 [Race condition] Race condition at cpuidle_enter_s2idle & __cfi_slowpath_diag Kuyo Chang
2022-08-11  7:54 ` Kuyo Chang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.