Skip to content

Commit 1f2569f

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
perf/x86/intel/uncore: Store box in event->pmu_private
Store the PMU pointer in event->pmu_private, so we can get rid of the per CPU data storage. We keep it after converting to per package data, because a CPU to package lookup will be 3 loads versus one and these usage sites are in the perf fast path. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Harish Chegondi <[email protected]> Cc: Jacob Pan <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Vince Weaver <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 54d751d commit 1f2569f

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

arch/x86/events/intel/uncore.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ ssize_t uncore_event_show(struct kobject *kobj,
9292
return sprintf(buf, "%s", event->config);
9393
}
9494

95-
struct intel_uncore_pmu *uncore_event_to_pmu(struct perf_event *event)
96-
{
97-
return container_of(event->pmu, struct intel_uncore_pmu, pmu);
98-
}
99-
10095
struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu)
10196
{
10297
struct intel_uncore_box *box;
@@ -122,15 +117,6 @@ struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu
122117
return *per_cpu_ptr(pmu->box, cpu);
123118
}
124119

125-
struct intel_uncore_box *uncore_event_to_box(struct perf_event *event)
126-
{
127-
/*
128-
* perf core schedules event on the basis of cpu, uncore events are
129-
* collected by one of the cpus inside a physical package.
130-
*/
131-
return uncore_pmu_to_box(uncore_event_to_pmu(event), smp_processor_id());
132-
}
133-
134120
u64 uncore_msr_read_counter(struct intel_uncore_box *box, struct perf_event *event)
135121
{
136122
u64 count;
@@ -690,6 +676,7 @@ static int uncore_pmu_event_init(struct perf_event *event)
690676
if (!box || box->cpu < 0)
691677
return -EINVAL;
692678
event->cpu = box->cpu;
679+
event->pmu_private = box;
693680

694681
event->hw.idx = -1;
695682
event->hw.last_tag = ~0ULL;

arch/x86/events/intel/uncore.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,17 @@ static inline bool uncore_box_is_fake(struct intel_uncore_box *box)
319319
return (box->phys_id < 0);
320320
}
321321

322-
struct intel_uncore_pmu *uncore_event_to_pmu(struct perf_event *event);
322+
static inline struct intel_uncore_pmu *uncore_event_to_pmu(struct perf_event *event)
323+
{
324+
return container_of(event->pmu, struct intel_uncore_pmu, pmu);
325+
}
326+
327+
static inline struct intel_uncore_box *uncore_event_to_box(struct perf_event *event)
328+
{
329+
return event->pmu_private;
330+
}
331+
323332
struct intel_uncore_box *uncore_pmu_to_box(struct intel_uncore_pmu *pmu, int cpu);
324-
struct intel_uncore_box *uncore_event_to_box(struct perf_event *event);
325333
u64 uncore_msr_read_counter(struct intel_uncore_box *box, struct perf_event *event);
326334
void uncore_pmu_start_hrtimer(struct intel_uncore_box *box);
327335
void uncore_pmu_cancel_hrtimer(struct intel_uncore_box *box);

arch/x86/events/intel/uncore_snb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ static int snb_uncore_imc_event_init(struct perf_event *event)
313313
return -EINVAL;
314314

315315
event->cpu = box->cpu;
316+
event->pmu_private = box;
316317

317318
event->hw.idx = -1;
318319
event->hw.last_tag = ~0ULL;

0 commit comments

Comments
 (0)