* [PATCH v2] cpuidle: Deny idle entry when CPU already have IPI interrupt pending
@ 2026-04-03 4:08 Maulik Shah
2026-04-06 15:07 ` Rafael J. Wysocki
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Maulik Shah @ 2026-04-03 4:08 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Christian Loehle, Ulf Hansson
Cc: linux-pm, linux-kernel, linux-arm-msm, Maulik Shah
CPU can get IPI interrupt from another CPU while it is executing
cpuidle_select() or about to execute same. The selection do not account
for pending interrupts and may continue to enter selected idle state only
to exit immediately.
Example trace collected when there is cross CPU IPI.
[000] 154.892148: sched_waking: comm=sugov:4 pid=491 prio=-1 target_cpu=007
[000] 154.892148: ipi_raise: target_mask=00000000,00000080 (Function call interrupts)
[007] 154.892162: cpu_idle: state=2 cpu_id=7
[007] 154.892208: cpu_idle: state=4294967295 cpu_id=7
[007] 154.892211: irq_handler_entry: irq=2 name=IPI
[007] 154.892211: ipi_entry: (Function call interrupts)
[007] 154.892213: sched_wakeup: comm=sugov:4 pid=491 prio=-1 target_cpu=007
[007] 154.892214: ipi_exit: (Function call interrupts)
This impacts performance and the above count increments.
commit ccde6525183c ("smp: Introduce a helper function to check for pending
IPIs") already introduced a helper function to check the pending IPIs and
it is used in pmdomain governor to deny the cluster level idle state when
there is a pending IPI on any of cluster CPUs.
This however does not stop CPU to enter CPU level idle state. Make use of
same at CPUidle to deny the idle entry when there is already IPI pending.
With change observing glmark2 [1] off screen scores improving in the range
of 25% to 30% on Qualcomm lemans-evk board which is arm64 based having two
clusters each with 4 CPUs.
[1] https://github.com/glmark2/glmark2
Signed-off-by: Maulik Shah <maulik.shah@oss.qualcomm.com>
---
Changes in v2:
- Fix cpumask argument of cpus_peek_for_pending_ipi() to take single cpu
- Link to v1: https://lore.kernel.org/r/20260316-cpuidle_ipi-v1-1-d0ff6350f4e2@oss.qualcomm.com
---
drivers/cpuidle/cpuidle.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index c7876e9e024f9076663063ad21cfc69343fdbbe7..c01e57df64ca5af8c28da3d971500b3f38306cdf 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(cpumask_of(dev->cpu)))
+ return -EBUSY;
+
instrumentation_begin();
/*
---
base-commit: b84a0ebe421ca56995ff78b66307667b62b3a900
change-id: 20260316-cpuidle_ipi-4c64036f9a48
Best regards,
--
Maulik Shah <maulik.shah@oss.qualcomm.com>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] cpuidle: Deny idle entry when CPU already have IPI interrupt pending
2026-04-03 4:08 [PATCH v2] cpuidle: Deny idle entry when CPU already have IPI interrupt pending Maulik Shah
@ 2026-04-06 15:07 ` Rafael J. Wysocki
2026-04-13 5:03 ` Maulik Shah (mkshah)
2026-08-18 8:51 ` kernel test robot
2026-08-18 10:30 ` kernel test robot
2 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2026-04-06 15:07 UTC (permalink / raw)
To: Maulik Shah
Cc: Rafael J. Wysocki, Daniel Lezcano, Christian Loehle, Ulf Hansson,
linux-pm, linux-kernel, linux-arm-msm
On Fri, Apr 3, 2026 at 6:08 AM Maulik Shah <maulik.shah@oss.qualcomm.com> wrote:
>
> CPU can get IPI interrupt from another CPU while it is executing
> cpuidle_select() or about to execute same. The selection do not account
> for pending interrupts and may continue to enter selected idle state only
> to exit immediately.
>
> Example trace collected when there is cross CPU IPI.
>
> [000] 154.892148: sched_waking: comm=sugov:4 pid=491 prio=-1 target_cpu=007
> [000] 154.892148: ipi_raise: target_mask=00000000,00000080 (Function call interrupts)
> [007] 154.892162: cpu_idle: state=2 cpu_id=7
> [007] 154.892208: cpu_idle: state=4294967295 cpu_id=7
> [007] 154.892211: irq_handler_entry: irq=2 name=IPI
> [007] 154.892211: ipi_entry: (Function call interrupts)
> [007] 154.892213: sched_wakeup: comm=sugov:4 pid=491 prio=-1 target_cpu=007
> [007] 154.892214: ipi_exit: (Function call interrupts)
>
> This impacts performance and the above count increments.
>
> commit ccde6525183c ("smp: Introduce a helper function to check for pending
> IPIs") already introduced a helper function to check the pending IPIs and
> it is used in pmdomain governor to deny the cluster level idle state when
> there is a pending IPI on any of cluster CPUs.
>
> This however does not stop CPU to enter CPU level idle state. Make use of
> same at CPUidle to deny the idle entry when there is already IPI pending.
>
> With change observing glmark2 [1] off screen scores improving in the range
> of 25% to 30% on Qualcomm lemans-evk board which is arm64 based having two
> clusters each with 4 CPUs.
>
> [1] https://github.com/glmark2/glmark2
>
> Signed-off-by: Maulik Shah <maulik.shah@oss.qualcomm.com>
> ---
> Changes in v2:
> - Fix cpumask argument of cpus_peek_for_pending_ipi() to take single cpu
> - Link to v1: https://lore.kernel.org/r/20260316-cpuidle_ipi-v1-1-d0ff6350f4e2@oss.qualcomm.com
> ---
> drivers/cpuidle/cpuidle.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index c7876e9e024f9076663063ad21cfc69343fdbbe7..c01e57df64ca5af8c28da3d971500b3f38306cdf 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(cpumask_of(dev->cpu)))
> + return -EBUSY;
> +
Why do you want to check it here and not in cpuidle_idle_call(), for example?
In principle, this check may be useful in the default idle path too.
> instrumentation_begin();
>
> /*
>
> ---
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] cpuidle: Deny idle entry when CPU already have IPI interrupt pending
2026-04-06 15:07 ` Rafael J. Wysocki
@ 2026-04-13 5:03 ` Maulik Shah (mkshah)
2026-08-18 16:10 ` Christian Loehle
0 siblings, 1 reply; 6+ messages in thread
From: Maulik Shah (mkshah) @ 2026-04-13 5:03 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Daniel Lezcano, Christian Loehle, Ulf Hansson, linux-pm,
linux-kernel, linux-arm-msm
On 4/6/2026 8:37 PM, Rafael J. Wysocki wrote:
> On Fri, Apr 3, 2026 at 6:08 AM Maulik Shah <maulik.shah@oss.qualcomm.com> wrote:
>>
>> CPU can get IPI interrupt from another CPU while it is executing
>> cpuidle_select() or about to execute same. The selection do not account
>> for pending interrupts and may continue to enter selected idle state only
>> to exit immediately.
>>
>> Example trace collected when there is cross CPU IPI.
>>
>> [000] 154.892148: sched_waking: comm=sugov:4 pid=491 prio=-1 target_cpu=007
>> [000] 154.892148: ipi_raise: target_mask=00000000,00000080 (Function call interrupts)
>> [007] 154.892162: cpu_idle: state=2 cpu_id=7
>> [007] 154.892208: cpu_idle: state=4294967295 cpu_id=7
>> [007] 154.892211: irq_handler_entry: irq=2 name=IPI
>> [007] 154.892211: ipi_entry: (Function call interrupts)
>> [007] 154.892213: sched_wakeup: comm=sugov:4 pid=491 prio=-1 target_cpu=007
>> [007] 154.892214: ipi_exit: (Function call interrupts)
>>
>> This impacts performance and the above count increments.
>>
>> commit ccde6525183c ("smp: Introduce a helper function to check for pending
>> IPIs") already introduced a helper function to check the pending IPIs and
>> it is used in pmdomain governor to deny the cluster level idle state when
>> there is a pending IPI on any of cluster CPUs.
>>
>> This however does not stop CPU to enter CPU level idle state. Make use of
>> same at CPUidle to deny the idle entry when there is already IPI pending.
>>
>> With change observing glmark2 [1] off screen scores improving in the range
>> of 25% to 30% on Qualcomm lemans-evk board which is arm64 based having two
>> clusters each with 4 CPUs.
>>
>> [1] https://github.com/glmark2/glmark2
>>
>> Signed-off-by: Maulik Shah <maulik.shah@oss.qualcomm.com>
>> ---
>> Changes in v2:
>> - Fix cpumask argument of cpus_peek_for_pending_ipi() to take single cpu
>> - Link to v1: https://lore.kernel.org/r/20260316-cpuidle_ipi-v1-1-d0ff6350f4e2@oss.qualcomm.com
>> ---
>> drivers/cpuidle/cpuidle.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
>> index c7876e9e024f9076663063ad21cfc69343fdbbe7..c01e57df64ca5af8c28da3d971500b3f38306cdf 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(cpumask_of(dev->cpu)))
>> + return -EBUSY;
>> +
>
> Why do you want to check it here and not in cpuidle_idle_call(), for example?
It can be moved in cpuidle_idle_call(), just before call_cpuidle() too.
The intention is to check after cpuidle_select() is done.
>
> In principle, this check may be useful in the default idle path too.
Yes, this check may be useful in default_idle_call() too.
Thanks,
Maulik
>
>> instrumentation_begin();
>>
>> /*
>>
>> ---
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] cpuidle: Deny idle entry when CPU already have IPI interrupt pending
2026-04-03 4:08 [PATCH v2] cpuidle: Deny idle entry when CPU already have IPI interrupt pending Maulik Shah
2026-04-06 15:07 ` Rafael J. Wysocki
@ 2026-08-18 8:51 ` kernel test robot
2026-08-18 10:30 ` kernel test robot
2 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-08-18 8:51 UTC (permalink / raw)
To: Maulik Shah, Rafael J. Wysocki, Daniel Lezcano, Christian Loehle,
Ulf Hansson
Cc: oe-kbuild-all, linux-pm, linux-kernel, linux-arm-msm, Maulik Shah
Hi Maulik,
kernel test robot noticed the following build errors:
[auto build test ERROR on b84a0ebe421ca56995ff78b66307667b62b3a900]
url: https://github.com/intel-lab-lkp/linux/commits/Maulik-Shah/cpuidle-Deny-idle-entry-when-CPU-already-have-IPI-interrupt-pending/20260815-180554
base: b84a0ebe421ca56995ff78b66307667b62b3a900
patch link: https://lore.kernel.org/r/20260403-cpuidle_ipi-v2-1-b3e44b032e2c%40oss.qualcomm.com
patch subject: [PATCH v2] cpuidle: Deny idle entry when CPU already have IPI interrupt pending
config: x86_64-randconfig-002-20260818 (https://download.01.org/0day-ci/archive/20260818/202608181649.yR8lLTtW-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260818/202608181649.yR8lLTtW-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202608181649.yR8lLTtW-lkp@intel.com/
All errors (new ones prefixed by >>):
>> vmlinux.o: error: objtool: cpuidle_enter_state+0x81: call to cpus_peek_for_pending_ipi() leaves .noinstr.text section
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] cpuidle: Deny idle entry when CPU already have IPI interrupt pending
2026-04-03 4:08 [PATCH v2] cpuidle: Deny idle entry when CPU already have IPI interrupt pending Maulik Shah
2026-04-06 15:07 ` Rafael J. Wysocki
2026-08-18 8:51 ` kernel test robot
@ 2026-08-18 10:30 ` kernel test robot
2 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-08-18 10:30 UTC (permalink / raw)
To: Maulik Shah, Rafael J. Wysocki, Daniel Lezcano, Christian Loehle,
Ulf Hansson
Cc: llvm, oe-kbuild-all, linux-pm, linux-kernel, linux-arm-msm,
Maulik Shah
Hi Maulik,
kernel test robot noticed the following build warnings:
[auto build test WARNING on b84a0ebe421ca56995ff78b66307667b62b3a900]
url: https://github.com/intel-lab-lkp/linux/commits/Maulik-Shah/cpuidle-Deny-idle-entry-when-CPU-already-have-IPI-interrupt-pending/20260815-180554
base: b84a0ebe421ca56995ff78b66307667b62b3a900
patch link: https://lore.kernel.org/r/20260403-cpuidle_ipi-v2-1-b3e44b032e2c%40oss.qualcomm.com
patch subject: [PATCH v2] cpuidle: Deny idle entry when CPU already have IPI interrupt pending
config: x86_64-randconfig-001-20260818 (https://download.01.org/0day-ci/archive/20260818/202608181850.9yczbIEQ-lkp@intel.com/config)
compiler: clang version 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260818/202608181850.9yczbIEQ-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202608181850.9yczbIEQ-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> vmlinux.o: warning: objtool: cpuidle_enter_state+0x56: call to cpus_peek_for_pending_ipi() leaves .noinstr.text section
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] cpuidle: Deny idle entry when CPU already have IPI interrupt pending
2026-04-13 5:03 ` Maulik Shah (mkshah)
@ 2026-08-18 16:10 ` Christian Loehle
0 siblings, 0 replies; 6+ messages in thread
From: Christian Loehle @ 2026-08-18 16:10 UTC (permalink / raw)
To: Maulik Shah (mkshah), Rafael J. Wysocki
Cc: Daniel Lezcano, Ulf Hansson, linux-pm, linux-kernel,
linux-arm-msm
On 4/13/26 06:03, Maulik Shah (mkshah) wrote:
>
>
> On 4/6/2026 8:37 PM, Rafael J. Wysocki wrote:
>> On Fri, Apr 3, 2026 at 6:08 AM Maulik Shah <maulik.shah@oss.qualcomm.com> wrote:
>>>
>>> CPU can get IPI interrupt from another CPU while it is executing
>>> cpuidle_select() or about to execute same. The selection do not account
>>> for pending interrupts and may continue to enter selected idle state only
>>> to exit immediately.
>>>
>>> Example trace collected when there is cross CPU IPI.
>>>
>>> [000] 154.892148: sched_waking: comm=sugov:4 pid=491 prio=-1 target_cpu=007
>>> [000] 154.892148: ipi_raise: target_mask=00000000,00000080 (Function call interrupts)
>>> [007] 154.892162: cpu_idle: state=2 cpu_id=7
>>> [007] 154.892208: cpu_idle: state=4294967295 cpu_id=7
>>> [007] 154.892211: irq_handler_entry: irq=2 name=IPI
>>> [007] 154.892211: ipi_entry: (Function call interrupts)
>>> [007] 154.892213: sched_wakeup: comm=sugov:4 pid=491 prio=-1 target_cpu=007
>>> [007] 154.892214: ipi_exit: (Function call interrupts)
>>>
>>> This impacts performance and the above count increments.
>>>
>>> commit ccde6525183c ("smp: Introduce a helper function to check for pending
>>> IPIs") already introduced a helper function to check the pending IPIs and
>>> it is used in pmdomain governor to deny the cluster level idle state when
>>> there is a pending IPI on any of cluster CPUs.
>>>
>>> This however does not stop CPU to enter CPU level idle state. Make use of
>>> same at CPUidle to deny the idle entry when there is already IPI pending.
>>>
>>> With change observing glmark2 [1] off screen scores improving in the range
>>> of 25% to 30% on Qualcomm lemans-evk board which is arm64 based having two
>>> clusters each with 4 CPUs.
>>>
>>> [1] https://github.com/glmark2/glmark2
>>>
>>> Signed-off-by: Maulik Shah <maulik.shah@oss.qualcomm.com>
>>> ---
>>> Changes in v2:
>>> - Fix cpumask argument of cpus_peek_for_pending_ipi() to take single cpu
>>> - Link to v1: https://lore.kernel.org/r/20260316-cpuidle_ipi-v1-1-d0ff6350f4e2@oss.qualcomm.com
>>> ---
>>> drivers/cpuidle/cpuidle.c | 3 +++
>>> 1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
>>> index c7876e9e024f9076663063ad21cfc69343fdbbe7..c01e57df64ca5af8c28da3d971500b3f38306cdf 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(cpumask_of(dev->cpu)))
>>> + return -EBUSY;
>>> +
>>
>> Why do you want to check it here and not in cpuidle_idle_call(), for example?
>
> It can be moved in cpuidle_idle_call(), just before call_cpuidle() too.
> The intention is to check after cpuidle_select() is done.
>
What do we do about the cpuidle stats in that case?
I'm thinking primiarly about last_residency_ns and rejected here.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-08-18 16:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-03 4:08 [PATCH v2] cpuidle: Deny idle entry when CPU already have IPI interrupt pending Maulik Shah
2026-04-06 15:07 ` Rafael J. Wysocki
2026-04-13 5:03 ` Maulik Shah (mkshah)
2026-08-18 16:10 ` Christian Loehle
2026-08-18 8:51 ` kernel test robot
2026-08-18 10:30 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox