Skip to content

Commit

Permalink
cpuidle: haltpoll: allow force loading on hosts without the REALTIME …
Browse files Browse the repository at this point in the history
…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 <maciej.szmigiero@oracle.com>
Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Maciej S. Szmigiero authored and Rafael J. Wysocki committed Mar 14, 2020
1 parent 317e5ec commit dd52551
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/cpuidle/cpuidle-haltpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include <linux/kvm_para.h>
#include <linux/cpuidle_haltpoll.h>

static bool force __read_mostly;
module_param(force, bool, 0444);
MODULE_PARM_DESC(force, "Load unconditionally");

static struct cpuidle_device __percpu *haltpoll_cpuidle_devices;
static enum cpuhp_state haltpoll_hp_state;

Expand Down Expand Up @@ -90,6 +94,11 @@ static void haltpoll_uninit(void)
haltpoll_cpuidle_devices = NULL;
}

static bool haltpool_want(void)
{
return kvm_para_has_hint(KVM_HINTS_REALTIME) || force;
}

static int __init haltpoll_init(void)
{
int ret;
Expand All @@ -101,8 +110,7 @@ static int __init haltpoll_init(void)

cpuidle_poll_state_init(drv);

if (!kvm_para_available() ||
!kvm_para_has_hint(KVM_HINTS_REALTIME))
if (!kvm_para_available() || !haltpool_want())
return -ENODEV;

ret = cpuidle_register_driver(drv);
Expand Down

0 comments on commit dd52551

Please sign in to comment.