All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3 v2] perf/amd/uncore: Prepare L3 thread mask code for Family 19h support
@ 2020-03-13 23:10 Kim Phillips
  2020-03-13 23:10 ` [PATCH 2/3 v2] perf/amd/uncore: Make L3 thread mask code more readable Kim Phillips
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Kim Phillips @ 2020-03-13 23:10 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Ingo Molnar, Thomas Gleixner,
	Borislav Petkov, Kim Phillips
  Cc: Alexander Shishkin, Arnaldo Carvalho de Melo, H. Peter Anvin,
	Jiri Olsa, Mark Rutland, Michael Petlan, Namhyung Kim,
	Stephane Eranian, linux-kernel, x86

In order to better accommodate the upcoming Family 19h support,
given the 80-char line limit, move the existing code into a new
l3_thread_slice_mask function.

Signed-off-by: Kim Phillips <kim.phillips@amd.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Cc: x86@kernel.org
---
v2: split into two parts, this one being the mechanical
    move based on Boris' review comments:

	https://lkml.org/lkml/2020/3/12/581

 arch/x86/events/amd/uncore.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c
index a6ea07f2aa84..dcdac001431e 100644
--- a/arch/x86/events/amd/uncore.c
+++ b/arch/x86/events/amd/uncore.c
@@ -180,6 +180,20 @@ static void amd_uncore_del(struct perf_event *event, int flags)
 	hwc->idx = -1;
 }
 
+/*
+ * Convert logical cpu number to L3 PMC Config ThreadMask format
+ */
+static u64 l3_thread_slice_mask(int cpu)
+{
+	int thread = 2 * (cpu_data(cpu).cpu_core_id % 4);
+
+	if (smp_num_siblings > 1)
+		thread += cpu_data(cpu).apicid & 1;
+
+	return (1ULL << (AMD64_L3_THREAD_SHIFT + thread) &
+		AMD64_L3_THREAD_MASK) | AMD64_L3_SLICE_MASK;
+}
+
 static int amd_uncore_event_init(struct perf_event *event)
 {
 	struct amd_uncore *uncore;
@@ -209,15 +223,8 @@ static int amd_uncore_event_init(struct perf_event *event)
 	 * SliceMask and ThreadMask need to be set for certain L3 events in
 	 * Family 17h. For other events, the two fields do not affect the count.
 	 */
-	if (l3_mask && is_llc_event(event)) {
-		int thread = 2 * (cpu_data(event->cpu).cpu_core_id % 4);
-
-		if (smp_num_siblings > 1)
-			thread += cpu_data(event->cpu).apicid & 1;
-
-		hwc->config |= (1ULL << (AMD64_L3_THREAD_SHIFT + thread) &
-				AMD64_L3_THREAD_MASK) | AMD64_L3_SLICE_MASK;
-	}
+	if (l3_mask && is_llc_event(event))
+		hwc->config |= l3_thread_slice_mask(event->cpu);
 
 	uncore = event_to_amd_uncore(event);
 	if (!uncore)
-- 
2.25.1


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

end of thread, other threads:[~2020-03-23 20:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-13 23:10 [PATCH 1/3 v2] perf/amd/uncore: Prepare L3 thread mask code for Family 19h support Kim Phillips
2020-03-13 23:10 ` [PATCH 2/3 v2] perf/amd/uncore: Make L3 thread mask code more readable Kim Phillips
2020-03-17 12:07   ` [tip: perf/core] " tip-bot2 for Kim Phillips
2020-03-13 23:10 ` [PATCH 3/3 v2] perf/amd/uncore: Add support for Family 19h L3 PMU Kim Phillips
2020-03-17 12:07   ` [tip: perf/core] " tip-bot2 for Kim Phillips
2020-03-17 12:07 ` [tip: perf/core] perf/amd/uncore: Prepare L3 thread mask code for Family 19h tip-bot2 for Kim Phillips
2020-03-18  2:09 ` [PATCH 1/3 v2] perf/amd/uncore: Prepare L3 thread mask code for Family 19h support Stephane Eranian
2020-03-18 14:46   ` Kim Phillips
2020-03-18 20:42     ` Peter Zijlstra
2020-03-18 21:26       ` Stephane Eranian
2020-03-23 20:50         ` Kim Phillips

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.