Skip to content

Commit 4dcc3df

Browse files
kimphillamdsuryasaimadhu
authored andcommitted
perf/amd/uncore: Prepare L3 thread mask code for Family 19h
In order to better accommodate the upcoming Family 19h, given the 80-char line limit, move the existing code into a new l3_thread_slice_mask() function. No functional changes. [ bp: Touchups. ] Signed-off-by: Kim Phillips <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 95ed6c7 commit 4dcc3df

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

arch/x86/events/amd/uncore.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,20 @@ static void amd_uncore_del(struct perf_event *event, int flags)
180180
hwc->idx = -1;
181181
}
182182

183+
/*
184+
* Convert logical CPU number to L3 PMC Config ThreadMask format
185+
*/
186+
static u64 l3_thread_slice_mask(int cpu)
187+
{
188+
int thread = 2 * (cpu_data(cpu).cpu_core_id % 4);
189+
190+
if (smp_num_siblings > 1)
191+
thread += cpu_data(cpu).apicid & 1;
192+
193+
return (1ULL << (AMD64_L3_THREAD_SHIFT + thread) &
194+
AMD64_L3_THREAD_MASK) | AMD64_L3_SLICE_MASK;
195+
}
196+
183197
static int amd_uncore_event_init(struct perf_event *event)
184198
{
185199
struct amd_uncore *uncore;
@@ -209,15 +223,8 @@ static int amd_uncore_event_init(struct perf_event *event)
209223
* SliceMask and ThreadMask need to be set for certain L3 events in
210224
* Family 17h. For other events, the two fields do not affect the count.
211225
*/
212-
if (l3_mask && is_llc_event(event)) {
213-
int thread = 2 * (cpu_data(event->cpu).cpu_core_id % 4);
214-
215-
if (smp_num_siblings > 1)
216-
thread += cpu_data(event->cpu).apicid & 1;
217-
218-
hwc->config |= (1ULL << (AMD64_L3_THREAD_SHIFT + thread) &
219-
AMD64_L3_THREAD_MASK) | AMD64_L3_SLICE_MASK;
220-
}
226+
if (l3_mask && is_llc_event(event))
227+
hwc->config |= l3_thread_slice_mask(event->cpu);
221228

222229
uncore = event_to_amd_uncore(event);
223230
if (!uncore)

0 commit comments

Comments
 (0)