KVM: powerpc: Use generic xfer to guest work function
Status from this message: Applied to powerpc/next.
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest2 patches 1 replyApplied
- v32 patches 0 repliesSuperseded
- v21 patch 1 replySuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 1 patch | 3 replies | Superseded |
Patches in v4 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | KVM: powerpc: Use generic xfer to guest work functionarch/ arch/ arch/ +1 more | +55 | 0 replies | |
| 2/2 | powerpc: enable to run posix cpu timers in task contextarch/ | +1 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.
Cover letter [PATCH v4 0/2] KVM: powerpc: Use generic xfer to guest work function
This series fixes a KVM scheduling bug on Book3S HV where a guest VM under a cpu.max bandwidth limit can run arbitrarily past its quota and then appear frozen for minutes afterwards.
== Problem ==
Since commit 2cd571245b43 ("sched/fair: Add related data structure for task based throttle"), merged in v6.18, CFS bandwidth throttling no longer dequeues a task directly. Instead it queues a task_work item via task_work_add(..., TWA_RESUME), sets TIF_NOTIFY_RESUME, and relies on that work running on the return path to actually dequeue the task.
The powerpc KVM run loops only test TIF_SIGPENDING and TIF_NEED_RESCHED before re-entering the guest; TIF_NOTIFY_RESUME is never checked. For a CPU-bound guest that generates few KVM exits back to userspace, the vCPU thread never returns to user mode, so the deferred throttle task_work never runs. The guest keeps running unchecked while its runtime_remaining goes increasingly negative, and once it finally does exit to userspace it is legitimately throttled for minutes while the accrued debt is repaid at the bandwidth-timer replenishment rate.
The generic xfer-to-guest-mode infrastructure (commit 935ace2fb5cc, "entry: Provide infrastructure for work before transitioning to guest mode") exists precisely to handle this kind of work before each guest entry. A full trace-backed root-cause analysis was posted with v1 [2].
== Fix ==
Opt powerpc KVM into VIRT_XFER_TO_GUEST_WORK and use the generic xfer_to_guest_mode helpers to check for and handle pending guest-mode work (reschedule, signals, and TIF_NOTIFY_RESUME task_work such as the deferred CFS throttle) on every guest re-entry:
- Book3S HV: both run loops — kvmhv_run_single_vcpu() for POWER9+ and kvmppc_run_vcpu() for pre-POWER9.
- Book3S PR and BookE: the common kvmppc_prepare_to_enter(), which likewise only checked need_resched()/signal_pending().
== Changes from v3 ==
- BookE: add local_irq_disable() before hard_irq_disable() on the emulated MTMSR[WE] path so lockdep's irq-tracing state is resynced, fixing a lockdep_assert_irqs_disabled() splat in the following xfer_to_guest_mode_prepare(). (Reported by Sashiko AI review)
== Changes from v2 ==
- Add xfer_to_guest_mode_prepare() check for pending rcuog wakeup before entering guest
- While at it patch all exit points for kvmhv_run_single_vcpu() via done label matching the corresponding trace_kvmppc_run_vcpu_enter() with trace_kvmppc_run_vcpu_exit() tracepoint. (Reported by Sashiko AI review)
- Include posix cpu timer enablement patch by Shrikanth as part of this series
== Changes from v1 ==
- Extend the fix beyond Book3S HV to the shared powerpc KVM entry path:
also convert the common kvmppc_prepare_to_enter() used by Book3S PR and BookE. (Shrikanth Hegde)
- Move "select VIRT_XFER_TO_GUEST_WORK" from KVM_BOOK3S_64_HV up to the common "config KVM" so every powerpc KVM variant gets the infrastructure.
- Drop the redundant signal_pending() recheck and its sigpend label in kvmhv_run_single_vcpu(); xfer_to_guest_mode_work_pending() is a superset of it.
- Preserve the E500 CONFIG_KVM_EXIT_TIMING histogram on the signal path via an explicit kvmppc_set_exit_type(SIGNAL_EXITS).
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Shrikanth Hegde (1):
powerpc: enable to run posix cpu timers in task context
Vishal Chourasia (1):
KVM: powerpc: Use generic xfer to guest work function
arch/powerpc/Kconfig | 1 + arch/powerpc/kvm/Kconfig | 1 + arch/powerpc/kvm/book3s_hv.c | 39 +++++++++++++++++++++++------------- arch/powerpc/kvm/booke.c | 1 + arch/powerpc/kvm/powerpc.c | 37 +++++++++++++++++++++++++--------- 5 files changed, 56 insertions(+), 23 deletions(-)
Signature · 1 line
2.54.0