Re: [PATCH] cpuidle: Deny idle entry when CPU already have IPI interrupt pending

From: Maulik Shah (mkshah)

Date: Mon Mar 16 2026 - 05:24:23 EST




On 3/16/2026 2:25 PM, Christian Loehle wrote:
> On 3/16/26 07:37, Maulik Shah wrote:
..
..
>>
>> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
>> index c7876e9e024f9076663063ad21cfc69343fdbbe7..c88c0cbf910d6c2c09697e6a3ac78c081868c2ad 100644
>> --- a/drivers/cpuidle/cpuidle.c
>> +++ b/drivers/cpuidle/cpuidle.c
>> @@ -224,6 +224,9 @@ noinstr int cpuidle_enter_state(struct cpuidle_device *dev,
>> bool broadcast = !!(target_state->flags & CPUIDLE_FLAG_TIMER_STOP);
>> ktime_t time_start, time_end;
>>
>> + if (cpus_peek_for_pending_ipi(drv->cpumask))
>> + return -EBUSY;
>> +
>> instrumentation_begin();
..
..
>> Best regards,
>
> So we already do a per-CPU IPI need_resched() check in the idle path.
> Your patch uses drv->cpumask, which will contain all CPUs, preventing idle entry if
> any CPU has an IPI pending?

The IPI interrupt became pending after the need_resched() check,
when the CPUidle governor is selecting a mode, but before the idle entry.

On qualcomm lemans-evk case, drv->cpumask using cpuidle-psci is having only single
CPU but seems other idle drivers may contain all CPUs.

Since intent here was to check the pending IPI on same CPU, this check be replaced
with another need_resched() or using cpus_peek_for_pending_ipi() taking a single
(current) CPU's mask in the argument. I can update this in v2 based on recommendation.

Thanks,
Maulik