mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Konstantin Khorenko <khorenko@virtuozzo.com>,
	Jim Mattson <jmattson@google.com>
Subject: [PATCH 00/10] KVM: x86/pmu: Optimize triggering of emulated events
Date: Thu,  9 Nov 2023 18:28:47 -0800	[thread overview]
Message-ID: <20231110022857.1273836-1-seanjc@google.com> (raw)

Optimize code used by, or which impacts, kvm_pmu_trigger_event() to try
and make a dent in the overhead of emulating PMU events in software, which
is quite noticeable due to it kicking in anytime the guest has a vPMU and
KVM is skipping an instruction.

Note, Jim has a proposal/idea[*] (that I supported) to make
kvm_pmu_trigger_event() even more performant.  I opted not to do that as
it's a bit more invasive, and I started chewing on this not so much because
I care _that_ much about performance, but because it irritates me that the
PMU code makes things way harder than they need to be.

Note #2, this applies on top of my other two PMU series:

  https://lore.kernel.org/all/20231103230541.352265-1-seanjc@google.com
  https://lore.kernel.org/all/20231110021306.1269082-1-seanjc@google.com

Those series fix actual functional issues, i.e. I'll definitely apply them
first (there's definitely no rush on this one).

[*] https://lore.kernel.org/all/CALMp9eQGqqo66fQGwFJMc3y+9XdUrL7ageE8kvoAOV6NJGfJpw@mail.gmail.com

Sean Christopherson (10):
  KVM: x86/pmu: Zero out PMU metadata on AMD if PMU is disabled
  KVM: x86/pmu: Add common define to capture fixed counters offset
  KVM: x86/pmu: Move pmc_idx => pmc translation helper to common code
  KVM: x86/pmu: Snapshot and clear reprogramming bitmap before
    reprogramming
  KVM: x86/pmu: Add macros to iterate over all PMCs given a bitmap
  KVM: x86/pmu: Process only enabled PMCs when emulating events in
    software
  KVM: x86/pmu: Snapshot event selectors that KVM emulates in software
  KVM: x86/pmu: Expand the comment about what bits are check emulating
    events
  KVM: x86/pmu: Check eventsel first when emulating (branch) insns
    retired
  KVM: x86/pmu: Avoid CPL lookup if PMC enabline for USER and KERNEL is
    the same

 arch/x86/include/asm/kvm-x86-pmu-ops.h |   1 -
 arch/x86/include/asm/kvm_host.h        |   1 +
 arch/x86/kvm/pmu.c                     | 143 +++++++++++++++----------
 arch/x86/kvm/pmu.h                     |  52 ++++++++-
 arch/x86/kvm/svm/pmu.c                 |   7 +-
 arch/x86/kvm/vmx/nested.c              |   2 +-
 arch/x86/kvm/vmx/pmu_intel.c           |  44 ++------
 arch/x86/kvm/x86.c                     |   6 +-
 8 files changed, 154 insertions(+), 102 deletions(-)


base-commit: ef1883475d4a24d8eaebb84175ed46206a688103
-- 
2.42.0.869.gea05f2083d-goog


             reply	other threads:[~2023-11-10  2:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-10  2:28 Sean Christopherson [this message]
2023-11-10  2:28 ` [PATCH 01/10] KVM: x86/pmu: Zero out PMU metadata on AMD if PMU is disabled Sean Christopherson
2023-11-10  2:28 ` [PATCH 02/10] KVM: x86/pmu: Add common define to capture fixed counters offset Sean Christopherson
2023-11-10  2:28 ` [PATCH 03/10] KVM: x86/pmu: Move pmc_idx => pmc translation helper to common code Sean Christopherson
2023-11-10  2:28 ` [PATCH 04/10] KVM: x86/pmu: Snapshot and clear reprogramming bitmap before reprogramming Sean Christopherson
2023-11-10  2:28 ` [PATCH 05/10] KVM: x86/pmu: Add macros to iterate over all PMCs given a bitmap Sean Christopherson
2023-11-10  2:28 ` [PATCH 06/10] KVM: x86/pmu: Process only enabled PMCs when emulating events in software Sean Christopherson
2023-11-10  2:28 ` [PATCH 07/10] KVM: x86/pmu: Snapshot event selectors that KVM emulates " Sean Christopherson
2023-11-10  2:28 ` [PATCH 08/10] KVM: x86/pmu: Expand the comment about what bits are check emulating events Sean Christopherson
2023-11-10  2:28 ` [PATCH 09/10] KVM: x86/pmu: Check eventsel first when emulating (branch) insns retired Sean Christopherson
2023-11-10  2:28 ` [PATCH 10/10] KVM: x86/pmu: Avoid CPL lookup if PMC enabline for USER and KERNEL is the same Sean Christopherson
2023-11-10  6:37 ` [PATCH 00/10] KVM: x86/pmu: Optimize triggering of emulated events Dongli Zhang
2023-11-10 14:56   ` Sean Christopherson
2023-11-16 16:37     ` Konstantin Khorenko
2024-02-03  0:11 ` Sean Christopherson

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=20231110022857.1273836-1-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=jmattson@google.com \
    --cc=khorenko@virtuozzo.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.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

all inboxes | Powered by JetHome®