Skip to content

Commit 9689dbb

Browse files
kimphillamdsuryasaimadhu
authored andcommitted
perf/amd/uncore: Make L3 thread mask code more readable
Convert the l3_thread_slice_mask() function to use the more readable topology_* helper functions, more intuitive variable names like shift and thread_mask, and BIT_ULL(). No functional changes. 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 4dcc3df commit 9689dbb

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

arch/x86/events/amd/uncore.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,16 @@ static void amd_uncore_del(struct perf_event *event, int flags)
185185
*/
186186
static u64 l3_thread_slice_mask(int cpu)
187187
{
188-
int thread = 2 * (cpu_data(cpu).cpu_core_id % 4);
188+
u64 thread_mask, core = topology_core_id(cpu);
189+
unsigned int shift, thread = 0;
189190

190-
if (smp_num_siblings > 1)
191-
thread += cpu_data(cpu).apicid & 1;
191+
if (topology_smt_supported() && !topology_is_primary_thread(cpu))
192+
thread = 1;
192193

193-
return (1ULL << (AMD64_L3_THREAD_SHIFT + thread) &
194-
AMD64_L3_THREAD_MASK) | AMD64_L3_SLICE_MASK;
194+
shift = AMD64_L3_THREAD_SHIFT + 2 * (core % 4) + thread;
195+
thread_mask = BIT_ULL(shift);
196+
197+
return AMD64_L3_SLICE_MASK | thread_mask;
195198
}
196199

197200
static int amd_uncore_event_init(struct perf_event *event)

0 commit comments

Comments
 (0)