All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephane Eranian <eranian@google.com>
To: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: like.xu.linux@gmail.com, jmattson@google.com,
	santosh.shukla@amd.com, pbonzini@redhat.com, seanjc@google.com,
	wanpengli@tencent.com, vkuznets@redhat.com, joro@8bytes.org,
	peterz@infradead.org, mingo@redhat.com,
	alexander.shishkin@linux.intel.com, tglx@linutronix.de,
	bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com,
	kvm@vger.kernel.org, x86@kernel.org,
	linux-perf-users@vger.kernel.org, ananth.narayan@amd.com,
	kim.phillips@amd.com
Subject: Re: [PATCH] perf/amd: Implement errata #1292 workaround for F19h M00-0Fh
Date: Tue, 1 Feb 2022 22:16:36 -0800	[thread overview]
Message-ID: <CABPqkBQXvkqArcrXKVweWCobcaQZBRV6t3AhFuW8X28MBRkqBg@mail.gmail.com> (raw)
In-Reply-To: <4662f1dd-d7dc-ea19-82dc-f81e8f3dcf1a@amd.com>

On Tue, Feb 1, 2022 at 10:03 PM Ravi Bangoria <ravi.bangoria@amd.com> wrote:
>
> Hi Stephane,
>
> On 02-Feb-22 10:57 AM, Stephane Eranian wrote:
> > On Tue, Feb 1, 2022 at 8:29 PM Ravi Bangoria <ravi.bangoria@amd.com> wrote:
> >>
> >> Perf counter may overcount for a list of Retire Based Events. Implement
> >> workaround for Zen3 Family 19 Model 00-0F processors as suggested in
> >> Revision Guide[1]:
> >>
> >>   To count the non-FP affected PMC events correctly:
> >>     o Use Core::X86::Msr::PERF_CTL2 to count the events, and
> >>     o Program Core::X86::Msr::PERF_CTL2[43] to 1b, and
> >>     o Program Core::X86::Msr::PERF_CTL2[20] to 0b.
> >>
> >> Above workaround suggests to clear PERF_CTL2[20], but that will disable
> >> sampling mode. Given the fact that, there is already a skew between
> >> actual counter overflow vs PMI hit, we are anyway not getting accurate
> >> count for sampling events. Also, using PMC2 with both bit43 and bit20
> >> set can result in additional issues. Hence Linux implementation of
> >> workaround uses non-PMC2 counter for sampling events.
> >>
> > Something is missing from your description here. If you are not
> > clearing bit[20] and
> > not setting bit[43], then how does running on CTL2 by itself improve
> > the count. Is that
> > enough to make the counter count correctly?
>
> Yes. For counting retire based events, we need PMC2[43] set and
> PMC2[20] clear so that it will not overcount.
>
Ok, I get that part now. You are forcing the bits in the
get_constraint() function.

> >
> > For sampling events, your patch makes CTL2 not available. That seems
> > to contradict the
> > workaround. Are you doing this to free CTL2 for counting mode events
> > instead? If you are
> > not using CTL2, then you are not correcting the count. Are you saying
> > this is okay in sampling mode
> > because of the skid, anyway?
>
> Correct. The constraint I am placing is to count retire events on
> PMC2 and sample retire events on other counters.
>
Why do you need to permanently exclude CTL2 for retired events given
you are forcing the bits
in the get_constraints() for counting events config only, i.e., as
opposed to in CTL2 itself.
If the sampling retired events are unconstrained, they can use any
counters. If a counting retired
event is added, it has a "stronger" constraints and will be scheduled
before the unconstrained events,
yield the same behavior you wanted, except on demand which is preferable.

> Thanks,
> Ravi

  reply	other threads:[~2022-02-02  6:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17  5:57 [PATCH] KVM: x86/pmu: Clear reserved bit PERF_CTL2[43] for AMD erratum 1292 Like Xu
2022-02-02  4:28 ` [PATCH] perf/amd: Implement errata #1292 workaround for F19h M00-0Fh Ravi Bangoria
2022-02-02  5:27   ` Stephane Eranian
2022-02-02  6:02     ` Ravi Bangoria
2022-02-02  6:16       ` Stephane Eranian [this message]
2022-02-02  6:32         ` Ravi Bangoria
2022-02-02 10:51           ` [PATCH v2] perf/amd: Implement erratum " Ravi Bangoria
2022-02-02 14:36             ` Peter Zijlstra
2022-02-02 15:32               ` Ravi Bangoria
2022-02-03  9:58                 ` [PATCH v3] " Ravi Bangoria
2022-02-09 12:51                   ` Peter Zijlstra
2022-02-10  4:05                     ` Ravi Bangoria
2022-02-10  8:46                       ` Peter Zijlstra
2022-02-03  4:09             ` [PATCH v2] " Jim Mattson
2022-02-03  5:18               ` Ravi Bangoria
2022-02-03 17:55                 ` Jim Mattson
2022-02-04  9:32                   ` Ravi Bangoria
2022-02-04 13:01                     ` Jim Mattson
2022-02-09 10:18                       ` Like Xu
2022-02-09 21:40                         ` Jim Mattson
2022-02-10  4:06                           ` Ravi Bangoria
2022-02-10 13:56                             ` Like Xu

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=CABPqkBQXvkqArcrXKVweWCobcaQZBRV6t3AhFuW8X28MBRkqBg@mail.gmail.com \
    --to=eranian@google.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=ananth.narayan@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kim.phillips@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=like.xu.linux@gmail.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@amd.com \
    --cc=santosh.shukla@amd.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.