diff mbox series

[4/9] cpuidle-haltpoll: define arch_haltpoll_supported()

Message ID 20240430183730.561960-5-ankur.a.arora@oracle.com (mailing list archive)
State New
Headers show
Series Enable haltpoll for arm64 | expand

Commit Message

Ankur Arora April 30, 2024, 6:37 p.m. UTC
From: Joao Martins <joao.m.martins@oracle.com>

Right now kvm_para_has_hint(KVM_HINTS_REALTIME) is x86 only. In
pursuit of making cpuidle-haltpoll architecture independent, define
arch_haltpoll_supported() which handles the architectural check for
enabling haltpoll.

Move the (kvm_para_available() && kvm_para_has_hint(KVM_HINTS_REALTIME))
check to the x86 specific arch_haltpoll_supported().

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>

---
Changelog:

  - s/arch_haltpoll_want/arch_haltpoll_supported/
  - change the check in haltpoll_want() from:
      (kvm_para_available() && arch_haltpoll_want()) || force;
    to
      arch_haltpoll_supported() || force;

Dropped Rafael's acked-by due to these changes.

---
 arch/x86/include/asm/cpuidle_haltpoll.h |  1 +
 arch/x86/kernel/kvm.c                   | 10 ++++++++++
 drivers/cpuidle/cpuidle-haltpoll.c      |  9 ++-------
 include/linux/cpuidle_haltpoll.h        |  5 +++++
 4 files changed, 18 insertions(+), 7 deletions(-)

Comments

kernel test robot May 1, 2024, 11:48 a.m. UTC | #1
Hi Ankur,

kernel test robot noticed the following build errors:

[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on rafael-pm/bleeding-edge tip/x86/core arm64/for-next/core linus/master v6.9-rc6 next-20240430]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ankur-Arora/cpuidle-rename-ARCH_HAS_CPU_RELAX-to-ARCH_HAS_OPTIMIZED_POLL/20240501-024252
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/20240430183730.561960-5-ankur.a.arora%40oracle.com
patch subject: [PATCH 4/9] cpuidle-haltpoll: define arch_haltpoll_supported()
config: i386-buildonly-randconfig-001-20240501 (https://download.01.org/0day-ci/archive/20240501/202405011942.NBEU9bJO-lkp@intel.com/config)
compiler: clang version 18.1.4 (https://github.com/llvm/llvm-project e6c3289804a67ea0bb6a86fadbe454dd93b8d855)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240501/202405011942.NBEU9bJO-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405011942.NBEU9bJO-lkp@intel.com/

All errors (new ones prefixed by >>):

>> ld.lld: error: undefined symbol: arch_haltpoll_enable
   >>> referenced by cpuidle-haltpoll.c
   >>>               drivers/cpuidle/cpuidle-haltpoll.o:(haltpoll_cpu_online) in archive vmlinux.a
--
>> ld.lld: error: undefined symbol: arch_haltpoll_disable
   >>> referenced by cpuidle-haltpoll.c
   >>>               drivers/cpuidle/cpuidle-haltpoll.o:(haltpoll_cpu_offline) in archive vmlinux.a
--
>> ld.lld: error: undefined symbol: arch_haltpoll_supported
   >>> referenced by cpuidle-haltpoll.c
   >>>               drivers/cpuidle/cpuidle-haltpoll.o:(haltpoll_init) in archive vmlinux.a
diff mbox series

Patch

diff --git a/arch/x86/include/asm/cpuidle_haltpoll.h b/arch/x86/include/asm/cpuidle_haltpoll.h
index c8b39c6716ff..43ce79b88662 100644
--- a/arch/x86/include/asm/cpuidle_haltpoll.h
+++ b/arch/x86/include/asm/cpuidle_haltpoll.h
@@ -4,5 +4,6 @@ 
 
 void arch_haltpoll_enable(unsigned int cpu);
 void arch_haltpoll_disable(unsigned int cpu);
+bool arch_haltpoll_supported(void);
 
 #endif
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 7f0732bc0ccd..e4dcbe9acc07 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -1151,4 +1151,14 @@  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_supported(void)
+{
+	/* Do not load haltpoll if idle= is passed */
+	if (boot_option_idle_override != IDLE_NO_OVERRIDE)
+		return false;
+
+	return kvm_para_available() && kvm_para_has_hint(KVM_HINTS_REALTIME);
+}
+EXPORT_SYMBOL_GPL(arch_haltpoll_supported);
 #endif
diff --git a/drivers/cpuidle/cpuidle-haltpoll.c b/drivers/cpuidle/cpuidle-haltpoll.c
index d8515d5c0853..70f585383171 100644
--- a/drivers/cpuidle/cpuidle-haltpoll.c
+++ b/drivers/cpuidle/cpuidle-haltpoll.c
@@ -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;
@@ -95,7 +94,7 @@  static void haltpoll_uninit(void)
 
 static bool haltpoll_want(void)
 {
-	return kvm_para_has_hint(KVM_HINTS_REALTIME) || force;
+	return arch_haltpoll_supported() || force;
 }
 
 static int __init haltpoll_init(void)
@@ -103,11 +102,7 @@  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 (!haltpoll_want())
 		return -ENODEV;
 
 	cpuidle_poll_state_init(drv);
diff --git a/include/linux/cpuidle_haltpoll.h b/include/linux/cpuidle_haltpoll.h
index d50c1e0411a2..a3caf01d3f0e 100644
--- a/include/linux/cpuidle_haltpoll.h
+++ b/include/linux/cpuidle_haltpoll.h
@@ -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_supported(void)
+{
+	return false;
+}
 #endif
 #endif