Linux Perf Users
 help / color / mirror / Atom feed
From: Sandipan Das <sandipan.das@amd.com>
To: "Absandze, Luka" <absandze@amazon.de>,
	"sashiko-reviews@lists.linux.dev"
	<sashiko-reviews@lists.linux.dev>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>
Subject: Re: [PATCH] perf/x86/amd: Reject AMD Merge event as a countable event
Date: Thu, 17 Sep 2026 12:14:43 +0530	[thread overview]
Message-ID: <121fe413-6861-4d45-a7d3-f3a3f91952dc@amd.com> (raw)
In-Reply-To: <aqqhR9rZBUx-jscN@dev-dsk-absandze-1c-663c31a8.eu-west-1.amazon.com>

On 16-09-2026 19:32, Absandze, Luka wrote:
> On 2026-09-16 12:51, sashiko-bot@kernel.org wrote:
>> [Severity: High]
>> Does returning a permanent -EINVAL error here cause an opportunistic retry storm
>> in KVM?
>>
>> If a KVM guest programs a Large Increment per Cycle (LIPC) event by writing
>> AMD_MERGE_EVENT to an odd vPMC, KVM intercepts this and attempts to create a
>> raw host perf event.  When this fails with -EINVAL, KVM's reprogram_counter()
>> propagates the error to kvm_pmu_handle_event():
>>
>> arch/x86/kvm/pmu.c:kvm_pmu_handle_event() {
>>     ...
>>                 if (reprogram_counter(pmc))
>>                         set_bit(pmc->idx, pmu->reprogram_pmi);
>>     ...
>> }
>>
>> Because KVM treats all failures as transient and unconditionally re-adds the
>> failing counter to pmu->reprogram_pmi, on every subsequent PMU refresh KVM
>> will repeatedly retry the failed counter.
>>
>> Could this create a permanent retry storm that degrades VM performance and
>> wastes host CPU cycles?
>>
> 
> There ins't any substantial load generated, we short circuit here before
> the expesnive parts. However, a followup in KVM could be beneficial to
> reject this case outright.
> 
> I'll wait for opinions

I think it makes sense for the host layer to reject PMCxFFF altogether. Today,
at least for emulated vPMU, when a KVM guest programs a LIPC event, 3 PMCs are
consumed. This will ensure that the 3rd one, initiated by the guest programming
PMCxFFF, is dropped.

I also agree that a followup in KVM is required.

  reply	other threads:[~2026-09-17  6:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 12:33 [PATCH] perf/x86/amd: Reject AMD Merge event as a countable event Luka Absandze
2026-09-16 12:51 ` sashiko-bot
2026-09-16 14:02   ` Absandze, Luka
2026-09-17  6:44     ` Sandipan Das [this message]
2026-09-16 15:04 ` Borislav Petkov
2026-09-21  5:09 ` Sandipan Das

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=121fe413-6861-4d45-a7d3-f3a3f91952dc@amd.com \
    --to=sandipan.das@amd.com \
    --cc=absandze@amazon.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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