From: Laurent Vivier <lvivier@redhat.com>
To: Nicholas Piggin <npiggin@gmail.com>, linuxppc-dev@lists.ozlabs.org
Cc: stable@vger.kernel.org
Subject: Re: [PATCH v3] KVM: PPC: Tick accounting should defer vtime accounting 'til after IRQ handling
Date: Thu, 28 Oct 2021 14:39:56 +0200 [thread overview]
Message-ID: <641e823b-ed22-1e3f-6ce5-eeb09e8f947f@redhat.com> (raw)
In-Reply-To: <20211027142150.3711582-1-npiggin@gmail.com>
On 27/10/2021 16:21, Nicholas Piggin wrote:
> From: Laurent Vivier <lvivier@redhat.com>
>
> Commit 112665286d08 ("KVM: PPC: Book3S HV: Context tracking exit guest
> context before enabling irqs") moved guest_exit() into the interrupt
> protected area to avoid wrong context warning (or worse). The problem is
> that tick-based time accounting has not yet been updated at this point
> (because it depends on the timer interrupt firing), so the guest time
> gets incorrectly accounted to system time.
>
> To fix the problem, follow the x86 fix in commit 160457140187 ("Defer
> vtime accounting 'til after IRQ handling"), and allow host IRQs to run
> before accounting the guest exit time.
>
> In the case vtime accounting is enabled, this is not required because TB
> is used directly for accounting.
>
> Before this patch, with CONFIG_TICK_CPU_ACCOUNTING=y in the host and a
> guest running a kernel compile, the 'guest' fields of /proc/stat are
> stuck at zero. With the patch they can be observed increasing roughly as
> expected.
>
> Fixes: e233d54d4d97 ("KVM: booke: use __kvm_guest_exit")
> Fixes: 112665286d08 ("KVM: PPC: Book3S HV: Context tracking exit guest context before enabling irqs")
> Cc: <stable@vger.kernel.org> # 5.12
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> [np: only required for tick accounting, add Book3E fix, tweak changelog]
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> Since v2:
> - I took over the patch with Laurent's blessing.
> - Changed to avoid processing IRQs if we do have vtime accounting
> enabled.
> - Changed so in either case the accounting is called with irqs disabled.
> - Added similar Book3E fix.
> - Rebased on upstream, tested, observed bug and confirmed fix.
>
> arch/powerpc/kvm/book3s_hv.c | 30 ++++++++++++++++++++++++++++--
> arch/powerpc/kvm/booke.c | 16 +++++++++++++++-
> 2 files changed, 43 insertions(+), 3 deletions(-)
>
Tested-by: Laurent Vivier <lvivier@redhat.com>
Checked with mpstat that time is accounted to %guest while a stress-ng test is running in
the guest. Checked there is no warning in the host kernellogs.
Thanks,
Laurent
next prev parent reply other threads:[~2021-10-28 12:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-27 14:21 [PATCH v3] KVM: PPC: Tick accounting should defer vtime accounting 'til after IRQ handling Nicholas Piggin
2021-10-28 12:39 ` Laurent Vivier [this message]
2021-10-28 12:48 ` Laurent Vivier
2021-10-29 0:35 ` Nicholas Piggin
2021-11-02 10:12 ` Michael Ellerman
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=641e823b-ed22-1e3f-6ce5-eeb09e8f947f@redhat.com \
--to=lvivier@redhat.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
--cc=stable@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).