]> Gentwo Git Trees - linux/.git/commitdiff
cpuidle-haltpoll: define arch_haltpoll_want()
authorJoao Martins <joao.m.martins@oracle.com>
Wed, 25 Sep 2024 23:24:18 +0000 (16:24 -0700)
committerChristoph Lameter <cl@gentwo.org>
Wed, 9 Oct 2024 02:06:42 +0000 (19:06 -0700)
While initializing haltpoll we check if KVM supports the
realtime hint and if idle is overridden at boot.

Both of these checks are x86 specific. So, in pursuit of
making cpuidle-haltpoll architecture independent, move these
checks out of common code.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
Acked-by: Will Deacon <will@kernel.org>
Tested-by: Misono Tomohiro <misono.tomohiro@fujitsu.com>
arch/x86/include/asm/cpuidle_haltpoll.h
arch/x86/kernel/kvm.c
drivers/cpuidle/cpuidle-haltpoll.c
include/linux/cpuidle_haltpoll.h

index c8b39c6716ff1798ab3e1391722e9b4f99aab2aa..8a0a12769c2e5976dd3acad8c09d392cf669df18 100644 (file)
@@ -4,5 +4,6 @@
 
 void arch_haltpoll_enable(unsigned int cpu);
 void arch_haltpoll_disable(unsigned int cpu);
+bool arch_haltpoll_want(bool force);
 
 #endif
index 263f8aed4e2cf8b84575d21e4b4358b2924915b5..63710cb1aa6324986a35965c6351df2056b51116 100644 (file)
@@ -1151,4 +1151,17 @@ void arch_haltpoll_disable(unsigned int cpu)
        smp_call_function_single(cpu, kvm_enable_host_haltpoll, NULL, 1);
 }
 EXPORT_SYMBOL_GPL(arch_haltpoll_disable);
+
+bool arch_haltpoll_want(bool force)
+{
+       /* Do not load haltpoll if idle= is passed */
+       if (boot_option_idle_override != IDLE_NO_OVERRIDE)
+               return false;
+
+       if (!kvm_para_available())
+               return false;
+
+       return kvm_para_has_hint(KVM_HINTS_REALTIME) || force;
+}
+EXPORT_SYMBOL_GPL(arch_haltpoll_want);
 #endif
index bcd03e893a0a22332dfb6d3f6343ce0dad19d109..e532aa2bf6080011c2f0d5e9f7c4834c7871081b 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/cpuidle.h>
 #include <linux/module.h>
 #include <linux/sched/idle.h>
-#include <linux/kvm_para.h>
 #include <linux/cpuidle_haltpoll.h>
 
 static bool force __read_mostly;
@@ -93,21 +92,12 @@ static void haltpoll_uninit(void)
        haltpoll_cpuidle_devices = NULL;
 }
 
-static bool haltpoll_want(void)
-{
-       return kvm_para_has_hint(KVM_HINTS_REALTIME) || force;
-}
-
 static int __init haltpoll_init(void)
 {
        int ret;
        struct cpuidle_driver *drv = &haltpoll_driver;
 
-       /* Do not load haltpoll if idle= is passed */
-       if (boot_option_idle_override != IDLE_NO_OVERRIDE)
-               return -ENODEV;
-
-       if (!kvm_para_available() || !haltpoll_want())
+       if (!arch_haltpoll_want(force))
                return -ENODEV;
 
        cpuidle_poll_state_init(drv);
index d50c1e0411a2dda2376ff01e34f01075ebe7a245..68eb7a757120bcaf89a8861a9ec0559bfc625bf6 100644 (file)
@@ -12,5 +12,10 @@ static inline void arch_haltpoll_enable(unsigned int cpu)
 static inline void arch_haltpoll_disable(unsigned int cpu)
 {
 }
+
+static inline bool arch_haltpoll_want(bool force)
+{
+       return false;
+}
 #endif
 #endif