linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpuidle-haltpoll: allow force loading on hosts without the REALTIME hint
@ 2020-02-21 17:43 Maciej S. Szmigiero
  2020-02-24 20:10 ` Maciej S. Szmigiero
  2020-02-28 17:10 ` Maciej S. Szmigiero
  0 siblings, 2 replies; 8+ messages in thread
From: Maciej S. Szmigiero @ 2020-02-21 17:43 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano
  Cc: Joao Martins, Boris Ostrovsky, linux-pm, linux-kernel

From: "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>

Before commit 1328edca4a14 ("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>
---
 drivers/cpuidle/cpuidle-haltpoll.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/cpuidle/cpuidle-haltpoll.c b/drivers/cpuidle/cpuidle-haltpoll.c
index b0ce9bc78113..07e5b36076bb 100644
--- a/drivers/cpuidle/cpuidle-haltpoll.c
+++ b/drivers/cpuidle/cpuidle-haltpoll.c
@@ -18,6 +18,11 @@
 #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 even if the host does not provide the REALTIME hint");
+
 static struct cpuidle_device __percpu *haltpoll_cpuidle_devices;
 static enum cpuhp_state haltpoll_hp_state;
 
@@ -90,6 +95,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;
@@ -102,7 +112,7 @@ static int __init haltpoll_init(void)
 	cpuidle_poll_state_init(drv);
 
 	if (!kvm_para_available() ||
-		!kvm_para_has_hint(KVM_HINTS_REALTIME))
+	    !haltpool_want())
 		return -ENODEV;
 
 	ret = cpuidle_register_driver(drv);

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-03-11 21:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-21 17:43 [PATCH] cpuidle-haltpoll: allow force loading on hosts without the REALTIME hint Maciej S. Szmigiero
2020-02-24 20:10 ` Maciej S. Szmigiero
2020-03-06  9:56   ` Marcelo Tosatti
2020-03-06 20:11     ` Maciej S. Szmigiero
2020-02-28 17:10 ` Maciej S. Szmigiero
2020-03-04 10:31   ` Rafael J. Wysocki
2020-03-10 13:50     ` Marcelo Tosatti
2020-03-11 21:30       ` Maciej S. Szmigiero

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).