Re: [PATCH v4 6/9] sched/core: Check for rcu_read_lock_any_held() in idle_get_state()

From: K Prateek Nayak

Date: Thu Mar 12 2026 - 06:12:32 EST


Hello Peter,

On 3/12/2026 3:16 PM, Peter Zijlstra wrote:
>> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
>> index 953d89d71804..c4fc7726f82a 100644
>> --- a/kernel/sched/sched.h
>> +++ b/kernel/sched/sched.h
>> @@ -2853,7 +2853,7 @@ static inline void idle_set_state(struct rq *rq,
>>
>> static inline struct cpuidle_state *idle_get_state(struct rq *rq)
>> {
>> - WARN_ON_ONCE(!rcu_read_lock_held());
>> + WARN_ON_ONCE(!rcu_read_lock_any_held());
>
> Should we perhaps make that:
>
> lockdep_assert(rcu_read_lock_any_held());
>
> ?

That makes sense! I was under the impression this was behind
CONFIG_DEBUG_LOCK_ALLOC but looks like this still checks for
!preemptible() on !CONFIG_DEBUG_LOCK_ALLOC which does add a
bit of overhead.

I'll modify it to lockdep_assert() in the next version.

--
Thanks and Regards,
Prateek