2019-09-03 13:27:01

by Joao Martins

[permalink] [raw]
Subject: [PATCH v2 0/4] cpuidle, haltpoll: governor switching on idle register

Hey,

Presented herewith a series with aims to tie in together the haltpoll
idle driver and governor, without sacrificing previous governor setups.
In addition, there are a few fixes with respect to module loading for
cpuidle-haltpoll.

The series is organized as follows:

Patch 1: Allows idle driver stating a preferred governor that it
wants to use, based on discussion here:

https://lore.kernel.org/kvm/[email protected]/

Patch 2: Decrease rating of governor, and allows previous defaults
to be as before haltpoll, while using @governor to switch to haltpoll
when haltpoll driver is registered;

Patch 3 - 4: Module loading fixes. first is the incorrect error
reporting and second is supportting module unloading.

Thoughts, comments appreciated.

Thanks,
Joao

v2:
* Add missing Fixes tag on patches 3 and 4.

Joao Martins (4):
cpuidle: allow governor switch on cpuidle_register_driver()
cpuidle-haltpoll: set haltpoll as preferred governor
cpuidle-haltpoll: return -ENODEV on modinit failure
cpuidle-haltpoll: do not set an owner to allow modunload

drivers/cpuidle/cpuidle-haltpoll.c | 4 ++--
drivers/cpuidle/cpuidle.h | 1 +
drivers/cpuidle/driver.c | 26 ++++++++++++++++++++++++++
drivers/cpuidle/governor.c | 6 +++---
drivers/cpuidle/governors/haltpoll.c | 2 +-
include/linux/cpuidle.h | 3 +++
6 files changed, 36 insertions(+), 6 deletions(-)

--
2.17.1


2019-09-03 13:27:49

by Joao Martins

[permalink] [raw]
Subject: [PATCH v2 3/4] cpuidle-haltpoll: return -ENODEV on modinit failure

When a user loads cpuidle-haltpoll on a non KVM guest the module will
successfully load, even though idle driver registration didn't take
place.

We should instead return -ENODEV signaling the user that the driver can't
be loaded, like other error paths in haltpoll_init(). An example of such
error paths is when we return -EBUSY when attempting to register an idle
driver when it had one already (e.g. intel_idle loads at boot and then we
attempt to insert module cpuidle-haltpoll).

Fixes: fa86ee90eb11 ("add cpuidle-haltpoll driver")
Signed-off-by: Joao Martins <[email protected]>
---
v2:
* Add missing Fixes tag
---
drivers/cpuidle/cpuidle-haltpoll.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpuidle/cpuidle-haltpoll.c b/drivers/cpuidle/cpuidle-haltpoll.c
index 519e90d125cf..7a0239ef717e 100644
--- a/drivers/cpuidle/cpuidle-haltpoll.c
+++ b/drivers/cpuidle/cpuidle-haltpoll.c
@@ -99,7 +99,7 @@ static int __init haltpoll_init(void)
cpuidle_poll_state_init(drv);

if (!kvm_para_available())
- return 0;
+ return -ENODEV;

ret = cpuidle_register_driver(drv);
if (ret < 0)
--
2.17.1