linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] perf/x86/rapl: Add msr mask support
@ 2021-01-15  9:22 Zhang Rui
  2021-01-15  9:22 ` [PATCH 2/3] perf/x86/rapl: Fix energy counter detection Zhang Rui
  2021-01-15  9:22 ` [PATCH 3/3] perf/x86/rapl: Fix psys-energy event on Intel SPR platform Zhang Rui
  0 siblings, 2 replies; 14+ messages in thread
From: Zhang Rui @ 2021-01-15  9:22 UTC (permalink / raw)
  To: peterz, mingo, acme
  Cc: mark.rutland, alexander.shishkin, jolsa, namhyung, linux-kernel,
	x86, kan.liang, ak

In some cases, when probing a perf MSR, we're probing certain bits of the
MSR instead of the whole register, thus only these bits should be checked.

For example, for RAPL ENERGY_STATUS MSR, only the lower 32 bits represents
the energy counter, and the higher 32bits are reserved.

Introduce a new mask field in struct perf_msr to allow probing certain
bits of a MSR.

This change is transparent to the current perf_msr_probe() users.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
---
 arch/x86/events/probe.c | 5 ++++-
 arch/x86/events/probe.h | 7 ++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/x86/events/probe.c b/arch/x86/events/probe.c
index 136a1e847254..a0a19c404cb5 100644
--- a/arch/x86/events/probe.c
+++ b/arch/x86/events/probe.c
@@ -28,6 +28,7 @@ perf_msr_probe(struct perf_msr *msr, int cnt, bool zero, void *data)
 	for (bit = 0; bit < cnt; bit++) {
 		if (!msr[bit].no_check) {
 			struct attribute_group *grp = msr[bit].grp;
+			u64 mask;
 
 			/* skip entry with no group */
 			if (!grp)
@@ -44,8 +45,10 @@ perf_msr_probe(struct perf_msr *msr, int cnt, bool zero, void *data)
 			/* Virt sucks; you cannot tell if a R/O MSR is present :/ */
 			if (rdmsrl_safe(msr[bit].msr, &val))
 				continue;
+
+			mask = msr[bit].mask ? msr[bit].mask : U64_MAX;
 			/* Disable zero counters if requested. */
-			if (!zero && !val)
+			if (!zero && !(val & mask))
 				continue;
 
 			grp->is_visible = NULL;
diff --git a/arch/x86/events/probe.h b/arch/x86/events/probe.h
index 4c8e0afc5fb5..261b9bda24e3 100644
--- a/arch/x86/events/probe.h
+++ b/arch/x86/events/probe.h
@@ -4,10 +4,11 @@
 #include <linux/sysfs.h>
 
 struct perf_msr {
-	u64			  msr;
-	struct attribute_group	 *grp;
+	u64			msr;
+	struct attribute_group	*grp;
 	bool			(*test)(int idx, void *data);
-	bool			  no_check;
+	bool			no_check;
+	u64			mask;
 };
 
 unsigned long
-- 
2.17.1


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

end of thread, other threads:[~2021-02-04 16:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-15  9:22 [PATCH 1/3] perf/x86/rapl: Add msr mask support Zhang Rui
2021-01-15  9:22 ` [PATCH 2/3] perf/x86/rapl: Fix energy counter detection Zhang Rui
2021-01-15 20:03   ` Peter Zijlstra
2021-01-16  8:19     ` Zhang, Rui
2021-01-16 12:48       ` Peter Zijlstra
2021-01-17 14:44         ` Zhang, Rui
2021-02-03 14:21           ` Peter Zijlstra
2021-01-15  9:22 ` [PATCH 3/3] perf/x86/rapl: Fix psys-energy event on Intel SPR platform Zhang Rui
2021-01-16 12:50   ` Peter Zijlstra
2021-01-17 14:33     ` Zhang, Rui
2021-01-25  6:11       ` Zhang, Rui
2021-02-03 14:17         ` Zhang, Rui
2021-02-03 14:47         ` Peter Zijlstra
2021-02-04 16:04           ` Zhang Rui

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