Re: [PATCH] Enable haltpoll for arm64

From: Peter Zijlstra
Date: Wed Aug 09 2023 - 09:49:28 EST


On Wed, Aug 09, 2023 at 02:39:34PM +0300, Mihai Carabas wrote:

> Joao Martins (7):
> cpuidle-haltpoll: Make boot_option_idle_override check X86 specific
> x86: Move ARCH_HAS_CPU_RELAX to arch
> x86/kvm: Move haltpoll_want() to be arch defined
> governors/haltpoll: Drop kvm_para_available() check
> arm64: Select ARCH_HAS_CPU_RELAX
> arm64: Define TIF_POLLING_NRFLAG
> cpuidle-haltpoll: ARM64 support

You have far too many SOB's on some or all of these patches.

Using poll_state as is on arm64 seems sub-optimal, would not something
like the below make sense?

---
diff --git a/drivers/cpuidle/poll_state.c b/drivers/cpuidle/poll_state.c
index 9b6d90a72601..9ab40198b042 100644
--- a/drivers/cpuidle/poll_state.c
+++ b/drivers/cpuidle/poll_state.c
@@ -27,7 +27,11 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev,
limit = cpuidle_poll_time(drv, dev);

while (!need_resched()) {
- cpu_relax();
+
+ smp_cond_load_relaxed(current_thread_info()->flags,
+ (VAL & TIF_NEED_RESCHED) ||
+ (loop_count++ >= POLL_IDLE_RELAX_COUNT));
+
if (loop_count++ < POLL_IDLE_RELAX_COUNT)
continue;