From: peterz@infradead.org
To: Kim Phillips <kim.phillips@amd.com>
Cc: Borislav Petkov <bp@alien8.de>, Borislav Petkov <bp@suse.de>,
Ingo Molnar <mingo@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Stephane Eranian <eranian@google.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>, Jiri Olsa <jolsa@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Michael Petlan <mpetlan@redhat.com>,
Namhyung Kim <namhyung@kernel.org>,
LKML <linux-kernel@vger.kernel.org>, x86 <x86@kernel.org>,
Stephane Eranian <stephane.eranian@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v2 3/7] arch/x86/amd/ibs: Fix re-arming IBS Fetch
Date: Thu, 10 Sep 2020 10:50:36 +0200 [thread overview]
Message-ID: <20200910085036.GD35926@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200910083223.GY1362448@hirez.programming.kicks-ass.net>
On Thu, Sep 10, 2020 at 10:32:23AM +0200, peterz@infradead.org wrote:
> > @@ -363,7 +363,14 @@ perf_ibs_event_update(struct perf_ibs *perf_ibs, struct perf_event *event,
> > static inline void perf_ibs_enable_event(struct perf_ibs *perf_ibs,
> > struct hw_perf_event *hwc, u64 config)
> > {
> > - wrmsrl(hwc->config_base, hwc->config | config | perf_ibs->enable_mask);
> > + u64 _config = (hwc->config | config) & ~perf_ibs->enable_mask;
> > +
> > + /* On Fam17h, the periodic fetch counter is set when IbsFetchEn is changed from 0 to 1 */
> > + if (perf_ibs == &perf_ibs_fetch && boot_cpu_data.x86 >= 0x16 && boot_cpu_data.x86 <= 0x18)
> > + wrmsrl(hwc->config_base, _config);
> A better option would be to use hwc->flags, you're loading from that
> line already, so it's guaranteed hot and then you only have a single
> branch. Or stick it in perf_ibs near enable_mask, same difference.
I fixed it for you.
---
struct perf_ibs {
struct pmu pmu; /* 0 296 */
/* --- cacheline 4 boundary (256 bytes) was 40 bytes ago --- */
unsigned int msr; /* 296 4 */
/* XXX 4 bytes hole, try to pack */
u64 config_mask; /* 304 8 */
u64 cnt_mask; /* 312 8 */
/* --- cacheline 5 boundary (320 bytes) --- */
u64 enable_mask; /* 320 8 */
u64 valid_mask; /* 328 8 */
u64 max_period; /* 336 8 */
long unsigned int offset_mask[1]; /* 344 8 */
int offset_max; /* 352 4 */
unsigned int fetch_count_reset_broken:1; /* 356: 0 4 */
/* XXX 31 bits hole, try to pack */
struct cpu_perf_ibs * pcpu; /* 360 8 */
struct attribute * * format_attrs; /* 368 8 */
struct attribute_group format_group; /* 376 40 */
/* --- cacheline 6 boundary (384 bytes) was 32 bytes ago --- */
const struct attribute_group * attr_groups[2]; /* 416 16 */
u64 (*get_count)(u64); /* 432 8 */
/* size: 440, cachelines: 7, members: 15 */
/* sum members: 432, holes: 1, sum holes: 4 */
/* sum bitfield members: 1 bits, bit holes: 1, sum bit holes: 31 bits */
/* last cacheline: 56 bytes */
};
--- a/arch/x86/events/amd/ibs.c
+++ b/arch/x86/events/amd/ibs.c
@@ -89,6 +89,7 @@ struct perf_ibs {
u64 max_period;
unsigned long offset_mask[1];
int offset_max;
+ unsigned int fetch_count_reset_broken : 1;
struct cpu_perf_ibs __percpu *pcpu;
struct attribute **format_attrs;
@@ -370,7 +371,13 @@ perf_ibs_event_update(struct perf_ibs *p
static inline void perf_ibs_enable_event(struct perf_ibs *perf_ibs,
struct hw_perf_event *hwc, u64 config)
{
- wrmsrl(hwc->config_base, hwc->config | config | perf_ibs->enable_mask);
+ u64 _config = (hwc->config | config) & ~perf_ibs->enable_mask;
+
+ if (perf_ibs->fetch_count_reset_broken)
+ wrmsrl(hwc->config_base, _config);
+
+ _config |= perf_ibs->enable_mask;
+ wrmsrl(hwc->config_base, _config);
}
/*
@@ -756,6 +763,13 @@ static __init void perf_event_ibs_init(v
{
struct attribute **attr = ibs_op_format_attrs;
+ /*
+ * Some chips fail to reset the fetch count when it is written; instead
+ * they need a 0-1 transition of IbsFetchEn.
+ */
+ if (boot_cpu_data.x86 >= 0x16 && boot_cpu_data.x86 <= 0x18)
+ perf_ibs_fetch.fetch_count_reset_broken = 1;
+
perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch");
if (ibs_caps & IBS_CAPS_OPCNT) {
next prev parent reply other threads:[~2020-09-10 8:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-08 21:47 [PATCH v2 0/7] perf/x86/amd: Miscellaneous updates Kim Phillips
2020-09-08 21:47 ` [PATCH v2 1/7] perf/amd/uncore: Set all slices and threads to restore perf stat -a behaviour Kim Phillips
2020-09-10 16:34 ` Sasha Levin
2020-09-11 7:02 ` [tip: perf/core] " tip-bot2 for Kim Phillips
2020-09-08 21:47 ` [PATCH v2 2/7] perf/x86/amd: Fix sampling Large Increment per Cycle events Kim Phillips
2020-09-08 21:47 ` [PATCH v2 3/7] arch/x86/amd/ibs: Fix re-arming IBS Fetch Kim Phillips
2020-09-10 8:32 ` peterz
2020-09-10 8:50 ` peterz [this message]
2020-09-10 15:58 ` Kim Phillips
2020-09-08 21:47 ` [PATCH v2 4/7] perf/x86/amd/ibs: Don't include randomized bits in get_ibs_op_count() Kim Phillips
2020-09-08 21:47 ` [PATCH v2 5/7] perf/x86/amd/ibs: Fix raw sample data accumulation Kim Phillips
2020-09-11 7:02 ` [tip: perf/core] " tip-bot2 for Kim Phillips
2020-09-08 21:47 ` [PATCH v2 6/7] perf/x86/amd/ibs: Support 27-bit extended Op/cycle counter Kim Phillips
2020-09-11 7:02 ` [tip: perf/core] " tip-bot2 for Kim Phillips
2020-09-08 21:47 ` [PATCH v2 7/7] perf/x86/rapl: Add AMD Fam19h RAPL support Kim Phillips
2020-09-11 7:02 ` [tip: perf/core] " tip-bot2 for Kim Phillips
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=20200910085036.GD35926@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=bp@alien8.de \
--cc=bp@suse.de \
--cc=eranian@google.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=kim.phillips@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=mpetlan@redhat.com \
--cc=namhyung@kernel.org \
--cc=stable@vger.kernel.org \
--cc=stephane.eranian@google.com \
--cc=tglx@linutronix.de \
--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.