From: Vishal Chourasia <vishalc@linux.ibm.com>
To: maddy@linux.ibm.com
Cc: peterz@infradead.org, frederic@kernel.org, npiggin@gmail.com,
mpe@ellerman.id.au, chleroy@kernel.org, sshegde@linux.ibm.com,
amachhiw@linux.ibm.com, vaibhav@linux.ibm.com,
harshpb@linux.ibm.com, gautam@linux.ibm.com,
linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org,
Vishal Chourasia <vishalc@linux.ibm.com>
Subject: [PATCH v4 0/2] KVM: powerpc: Use generic xfer to guest work function
Date: Thu, 9 Jul 2026 14:51:38 +0530 [thread overview]
Message-ID: <20260709092140.1753715-2-vishalc@linux.ibm.com> (raw)
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/20250421102837.78515-2-sshegde@linux.ibm.com/
[2] https://lore.kernel.org/all/20260626105449.2897924-2-vishalc@linux.ibm.com/
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(-)
--
2.54.0
next reply other threads:[~2026-07-09 9:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 9:21 Vishal Chourasia [this message]
2026-07-09 9:21 ` [PATCH v4 1/2] KVM: powerpc: Use generic xfer to guest work function Vishal Chourasia
2026-07-09 9:21 ` [PATCH v4 2/2] powerpc: enable to run posix cpu timers in task context Vishal Chourasia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260709092140.1753715-2-vishalc@linux.ibm.com \
--to=vishalc@linux.ibm.com \
--cc=amachhiw@linux.ibm.com \
--cc=chleroy@kernel.org \
--cc=frederic@kernel.org \
--cc=gautam@linux.ibm.com \
--cc=harshpb@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=peterz@infradead.org \
--cc=sshegde@linux.ibm.com \
--cc=vaibhav@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox