Skip to content

Commit dd52551

Browse files
maciejsszmigierorafaeljw
authored andcommitted
cpuidle: haltpoll: allow force loading on hosts without the REALTIME hint
Before commit 1328edc ("cpuidle-haltpoll: Enable kvm guest polling when dedicated physical CPUs are available") the cpuidle-haltpoll driver could also be used in scenarios when the host does not advertise the KVM_HINTS_REALTIME hint. While the behavior introduced by the aforementioned commit makes sense as the default there are cases where the old behavior is desired, for example, when other kernel changes triggered by presence by this hint are unwanted, for some workloads where the latency benefit from polling overweights the loss from idle CPU capacity that otherwise would be available, or just when running under older Qemu versions that lack this hint. Let's provide a typical "force" module parameter that allows restoring the old behavior. Signed-off-by: Maciej S. Szmigiero <[email protected]> Reviewed-by: Marcelo Tosatti <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 317e5ec commit dd52551

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/cpuidle/cpuidle-haltpoll.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#include <linux/kvm_para.h>
1919
#include <linux/cpuidle_haltpoll.h>
2020

21+
static bool force __read_mostly;
22+
module_param(force, bool, 0444);
23+
MODULE_PARM_DESC(force, "Load unconditionally");
24+
2125
static struct cpuidle_device __percpu *haltpoll_cpuidle_devices;
2226
static enum cpuhp_state haltpoll_hp_state;
2327

@@ -90,6 +94,11 @@ static void haltpoll_uninit(void)
9094
haltpoll_cpuidle_devices = NULL;
9195
}
9296

97+
static bool haltpool_want(void)
98+
{
99+
return kvm_para_has_hint(KVM_HINTS_REALTIME) || force;
100+
}
101+
93102
static int __init haltpoll_init(void)
94103
{
95104
int ret;
@@ -101,8 +110,7 @@ static int __init haltpoll_init(void)
101110

102111
cpuidle_poll_state_init(drv);
103112

104-
if (!kvm_para_available() ||
105-
!kvm_para_has_hint(KVM_HINTS_REALTIME))
113+
if (!kvm_para_available() || !haltpool_want())
106114
return -ENODEV;
107115

108116
ret = cpuidle_register_driver(drv);

0 commit comments

Comments
 (0)