linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf/x86/intel/ds: fix precise store latency handling
@ 2022-08-18  5:46 Stephane Eranian
  2022-08-18  8:36 ` Peter Zijlstra
  2022-08-22  9:00 ` [tip: perf/urgent] perf/x86/intel/ds: Fix " tip-bot2 for Stephane Eranian
  0 siblings, 2 replies; 3+ messages in thread
From: Stephane Eranian @ 2022-08-18  5:46 UTC (permalink / raw)
  To: linux-kernel; +Cc: peterz, kan.liang, ak, acme, namhyung, irogers

With the existing code in store_latency_data(), the memory operation (mem_op)
returned to the user is always OP_LOAD where in fact, it should be OP_STORE.
This comes from the fact that the function is simply grabbing the information
from a data source map which covers only load accesses. Intel 12th gen CPU
offers precise store sampling that captures both the data source and latency.
Therefore it can use the data source mapping table but must override the
memory operation to reflect stores instead of loads.

Fixes: 61b985e3e775 ("perf/x86/intel: Add perf core PMU support for Sapphire Rapids")

Signed-off-by: Stephane Eranian <eranian@google.com>
---
 arch/x86/events/intel/ds.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
index ba60427caa6d..189fc6e9ea65 100644
--- a/arch/x86/events/intel/ds.c
+++ b/arch/x86/events/intel/ds.c
@@ -291,6 +291,7 @@ static u64 load_latency_data(struct perf_event *event, u64 status)
 static u64 store_latency_data(struct perf_event *event, u64 status)
 {
 	union intel_x86_pebs_dse dse;
+	union perf_mem_data_src src;
 	u64 val;
 
 	dse.val = status;
@@ -304,7 +305,14 @@ static u64 store_latency_data(struct perf_event *event, u64 status)
 
 	val |= P(BLK, NA);
 
-	return val;
+	/*
+	 * the pebs_data_source table is only for loads
+	 * so override the mem_op to say STORE instead
+	 */
+	src.val = val;
+	src.mem_op = P(OP,STORE);
+
+	return src.val;
 }
 
 struct pebs_record_core {
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf/x86/intel/ds: fix precise store latency handling
  2022-08-18  5:46 [PATCH] perf/x86/intel/ds: fix precise store latency handling Stephane Eranian
@ 2022-08-18  8:36 ` Peter Zijlstra
  2022-08-22  9:00 ` [tip: perf/urgent] perf/x86/intel/ds: Fix " tip-bot2 for Stephane Eranian
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2022-08-18  8:36 UTC (permalink / raw)
  To: Stephane Eranian; +Cc: linux-kernel, kan.liang, ak, acme, namhyung, irogers

On Wed, Aug 17, 2022 at 10:46:13PM -0700, Stephane Eranian wrote:
> With the existing code in store_latency_data(), the memory operation (mem_op)
> returned to the user is always OP_LOAD where in fact, it should be OP_STORE.
> This comes from the fact that the function is simply grabbing the information
> from a data source map which covers only load accesses. Intel 12th gen CPU
> offers precise store sampling that captures both the data source and latency.
> Therefore it can use the data source mapping table but must override the
> memory operation to reflect stores instead of loads.
> 
> Fixes: 61b985e3e775 ("perf/x86/intel: Add perf core PMU support for Sapphire Rapids")
> Signed-off-by: Stephane Eranian <eranian@google.com>

Thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip: perf/urgent] perf/x86/intel/ds: Fix precise store latency handling
  2022-08-18  5:46 [PATCH] perf/x86/intel/ds: fix precise store latency handling Stephane Eranian
  2022-08-18  8:36 ` Peter Zijlstra
@ 2022-08-22  9:00 ` tip-bot2 for Stephane Eranian
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Stephane Eranian @ 2022-08-22  9:00 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Stephane Eranian, Peter Zijlstra (Intel), x86, linux-kernel

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     d4bdb0bebc5ba3299d74f123c782d99cd4e25c49
Gitweb:        https://git.kernel.org/tip/d4bdb0bebc5ba3299d74f123c782d99cd4e25c49
Author:        Stephane Eranian <eranian@google.com>
AuthorDate:    Wed, 17 Aug 2022 22:46:13 -07:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 19 Aug 2022 19:47:31 +02:00

perf/x86/intel/ds: Fix precise store latency handling

With the existing code in store_latency_data(), the memory operation (mem_op)
returned to the user is always OP_LOAD where in fact, it should be OP_STORE.
This comes from the fact that the function is simply grabbing the information
from a data source map which covers only load accesses. Intel 12th gen CPU
offers precise store sampling that captures both the data source and latency.
Therefore it can use the data source mapping table but must override the
memory operation to reflect stores instead of loads.

Fixes: 61b985e3e775 ("perf/x86/intel: Add perf core PMU support for Sapphire Rapids")
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220818054613.1548130-1-eranian@google.com
---
 arch/x86/events/intel/ds.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
index ac6dd4c..e5b5874 100644
--- a/arch/x86/events/intel/ds.c
+++ b/arch/x86/events/intel/ds.c
@@ -291,6 +291,7 @@ static u64 load_latency_data(struct perf_event *event, u64 status)
 static u64 store_latency_data(struct perf_event *event, u64 status)
 {
 	union intel_x86_pebs_dse dse;
+	union perf_mem_data_src src;
 	u64 val;
 
 	dse.val = status;
@@ -304,7 +305,14 @@ static u64 store_latency_data(struct perf_event *event, u64 status)
 
 	val |= P(BLK, NA);
 
-	return val;
+	/*
+	 * the pebs_data_source table is only for loads
+	 * so override the mem_op to say STORE instead
+	 */
+	src.val = val;
+	src.mem_op = P(OP,STORE);
+
+	return src.val;
 }
 
 struct pebs_record_core {

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-22  9:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18  5:46 [PATCH] perf/x86/intel/ds: fix precise store latency handling Stephane Eranian
2022-08-18  8:36 ` Peter Zijlstra
2022-08-22  9:00 ` [tip: perf/urgent] perf/x86/intel/ds: Fix " tip-bot2 for Stephane Eranian

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).