cpuidle-haltpoll: make haltpoll aware of 'idle=' override
diff mbox series

Message ID 1571272750-29798-1-git-send-email-zhenzhong.duan@oracle.com
State Superseded, archived
Headers show
Series
  • cpuidle-haltpoll: make haltpoll aware of 'idle=' override
Related show

Commit Message

Zhenzhong Duan Oct. 17, 2019, 12:39 a.m. UTC
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 <zhenzhong.duan@oracle.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
---
 drivers/cpuidle/cpuidle-haltpoll.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Rafael J. Wysocki Oct. 17, 2019, 7:20 p.m. UTC | #1
On Thu, Oct 17, 2019 at 2:41 AM Zhenzhong Duan
<zhenzhong.duan@oracle.com> 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..
Joao Martins Oct. 17, 2019, 8:15 p.m. UTC | #2
On 10/17/19 8:20 PM, Rafael J. Wysocki wrote:
> On Thu, Oct 17, 2019 at 2:41 AM Zhenzhong Duan
> <zhenzhong.duan@oracle.com> 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

Patch
diff mbox series

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() ||