]> Gentwo Git Trees - linux/.git/commitdiff
arm64: support cpuidle-haltpoll
authorAnkur Arora <ankur.a.arora@oracle.com>
Wed, 25 Sep 2024 23:24:25 +0000 (16:24 -0700)
committerChristoph Lameter <cl@gentwo.org>
Wed, 9 Oct 2024 02:06:43 +0000 (19:06 -0700)
Add architectural support for the cpuidle-haltpoll driver by defining
arch_haltpoll_*(). Also define ARCH_CPUIDLE_HALTPOLL to allow
cpuidle-haltpoll to be selected.

Haltpoll uses poll_idle() to do the actual polling. This in turn
uses smp_cond_load*() to wait until there's a specific store to
a cacheline.
In the edge case -- no stores to the cacheline and no interrupt --
the event-stream provides the terminating condition ensuring we
don't wait forever. But because the event-stream runs at a fixed
frequency (configured at 10kHz) haltpoll might spend more time in
the polling stage than specified by cpuidle_poll_time().

This would only happen in the last iteration, since overshooting the
poll_limit means the governor will move out of the polling stage.

Tested-by: Haris Okanovic <harisokn@amazon.com>
Tested-by: Misono Tomohiro <misono.tomohiro@fujitsu.com>
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
Reviewed-by: Haris Okanovic <harisokn@amazon.com>
arch/arm64/Kconfig
arch/arm64/include/asm/cpuidle_haltpoll.h [new file with mode: 0644]

index 43762c68e357a56e23facaf0af92081d5360c64e..bd00647f601304237a9098d5fc3239cddc9eb941 100644 (file)
@@ -2428,6 +2428,12 @@ config ARCH_HIBERNATION_HEADER
 config ARCH_SUSPEND_POSSIBLE
        def_bool y
 
+config ARCH_CPUIDLE_HALTPOLL
+       bool "Enable selection of the cpuidle-haltpoll driver"
+       help
+         cpuidle-haltpoll allows for adaptive polling based on
+         current load before entering the idle state.
+
 endmenu # "Power management options"
 
 menu "CPU Power Management"
diff --git a/arch/arm64/include/asm/cpuidle_haltpoll.h b/arch/arm64/include/asm/cpuidle_haltpoll.h
new file mode 100644 (file)
index 0000000..91f0be7
--- /dev/null
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _ARCH_HALTPOLL_H
+#define _ARCH_HALTPOLL_H
+
+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)
+{
+       /*
+        * Enabling haltpoll requires two things:
+        *
+        * - Event stream support to provide a terminating condition to the
+        *   WFE in the poll loop.
+        *
+        * - KVM support for arch_haltpoll_enable(), arch_haltpoll_disable().
+        *
+        * Given that the second is missing, only allow force loading for
+        * haltpoll.
+        */
+       return force;
+}
+#endif