2019-10-18 05:24:40

by Zhenzhong Duan

[permalink] [raw]
Subject: [PATCH] cpuidle-haltpoll: make haltpoll aware of 'idle=' override

Currenly haltpoll isn't aware of the 'idle=' override, the priority is
'idle=poll' > haltpoll > 'idle=halt'. When 'idle=poll' is used, cpuidle
driver is bypassed but current_driver in sys still shows 'haltpoll'.

When 'idle=halt' is used, haltpoll take precedence and make 'idle=halt'
no effect.

Add a check to not load haltpoll driver if there is 'idle=' and haltpoll
is built in. If haltpoll is built as a module, still give a chance for
admin to use it despite 'idle='.

Signed-off-by: Zhenzhong Duan <[email protected]>
Signed-off-by: Joao Martins <[email protected]>
---
drivers/cpuidle/cpuidle-haltpoll.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/cpuidle/cpuidle-haltpoll.c b/drivers/cpuidle/cpuidle-haltpoll.c
index 932390b..00e9821 100644
--- a/drivers/cpuidle/cpuidle-haltpoll.c
+++ b/drivers/cpuidle/cpuidle-haltpoll.c
@@ -95,6 +95,12 @@ static int __init haltpoll_init(void)
int ret;
struct cpuidle_driver *drv = &haltpoll_driver;

+#if !defined(CONFIG_HALTPOLL_CPUIDLE_MODULE)
+ /* Do not load haltpoll if idle= is passed */
+ if (boot_option_idle_override != IDLE_NO_OVERRIDE)
+ return -ENODEV;
+#endif
+
cpuidle_poll_state_init(drv);

if (!kvm_para_available() ||
--
1.8.3.1


2019-10-18 22:16:04

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] cpuidle-haltpoll: make haltpoll aware of 'idle=' override

On Thu, Oct 17, 2019 at 2:41 AM Zhenzhong Duan
<[email protected]> wrote:
>
> Currenly haltpoll isn't aware of the 'idle=' override, the priority is
> 'idle=poll' > haltpoll > 'idle=halt'. When 'idle=poll' is used, cpuidle
> driver is bypassed but current_driver in sys still shows 'haltpoll'.
>
> When 'idle=halt' is used, haltpoll take precedence and make 'idle=halt'
> no effect.
>
> Add a check to not load haltpoll driver if there is 'idle='

OK

> and haltpoll
> is built in. If haltpoll is built as a module, still give a chance for
> admin to use it despite 'idle='.

Why exactly? Do you have any particular use case in mind?

Otherwise I'd prefer the behavior to be consistent regardless of
whether or not it is a module..

2019-10-18 22:18:40

by Joao Martins

[permalink] [raw]
Subject: Re: [PATCH] cpuidle-haltpoll: make haltpoll aware of 'idle=' override

On 10/17/19 8:20 PM, Rafael J. Wysocki wrote:
> On Thu, Oct 17, 2019 at 2:41 AM Zhenzhong Duan
> <[email protected]> wrote:
>> and haltpoll
>> is built in. If haltpoll is built as a module, still give a chance for
>> admin to use it despite 'idle='.
>
> Why exactly? Do you have any particular use case in mind?
>
There was no concrete use-case in particular; we thought that when building as a
module, that the general usage would be for cpuidle-haltpoll to be inserted (or
removed) at some point in the time. And hence allow it to override boot 'idle='
given that you can always remove the module and go back to 'idle='.

> Otherwise I'd prefer the behavior to be consistent regardless of
> whether or not it is a module..
>
It's best we just remove the conditional and keep it consistent across builtin
and module.

Joao