Re: [PATCH v14 12/15] cpuidle/poll_state: Wait for need-resched via tif_need_resched_relaxed_wait()

[email protected]
Newsgroups org.kernel.vger.linux-arch,org.infradead.lists.linux-arm-kernel,org.kernel.vger.bpf,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm
Message-ID <4281974d1859d47c58f0e44ff33d654eaa98eee84be65d2ae72e22b5e24b4b04@mail.kernel.org>
>     cpuidle/poll_state: Wait for need-resched via tif_need_resched_relaxed_wait()
>
>     The inner loop in poll_idle() polls over the thread_info flags,
>     waiting to see if the thread has TIF_NEED_RESCHED set. The loop
>     exits once the condition is met, or if the poll time limit has
>     been exceeded.
>
>     To minimize the number of instructions executed in each iteration,
>     the time check is rate-limited. In addition, each loop iteration
>     executes cpu_relax() which on certain platforms provides a hint to
>     the pipeline that the loop busy-waits, allowing the processor to
>     reduce power consumption.
>
>     Switch over to tif_need_resched_relaxed_wait() instead, since that
>     provides exactly that.
>
>     However, since we want to minimize power consumption in idle, building
>     of cpuidle/poll_state.c continues to depend on CONFIG_ARCH_HAS_CPU_RELAX
>     as that serves as an indicator that the platform supports an optimized
>     version of tif_need_resched_relaxed_wait() (via
>     smp_cond_load_acquire_timeout()).

This isn't a bug, but the changelog names smp_cond_load_acquire_timeout() as
the backing primitive, while the code path looks like it uses the relaxed
variant:

include/linux/sched/idle.h:tif_need_resched_relaxed_wait() {
    return tif_bitset_relaxed_wait(TIF_NEED_RESCHED, timeout_ns);
}

include/linux/sched/idle.h:tif_bitset_relaxed_wait() {
    flags = smp_cond_load_relaxed_timeout(&current_thread_info()->flags,
                                          (VAL & BIT(tif)),
                                          local_clock_noinstr(),
                                          timeout_ns);
    ...
}

Should this reference smp_cond_load_relaxed_timeout() instead?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/29315652884
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.