Skip to content

Commit 5624986

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/intel/lbr: Unify the stored format of LBR information
Current LBR information in the structure x86_perf_task_context is stored in a different format from the PEBS LBR record and Architecture LBR, which prevents the sharing of the common codes. Use the format of the PEBS LBR record as a unified format. Use a generic name lbr_entry to replace pebs_lbr_entry. Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 49d8184 commit 5624986

File tree

4 files changed

+16
-22
lines changed

4 files changed

+16
-22
lines changed

arch/x86/events/intel/ds.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ static void adaptive_pebs_record_size_update(void)
954954
if (pebs_data_cfg & PEBS_DATACFG_XMMS)
955955
sz += sizeof(struct pebs_xmm);
956956
if (pebs_data_cfg & PEBS_DATACFG_LBRS)
957-
sz += x86_pmu.lbr_nr * sizeof(struct pebs_lbr_entry);
957+
sz += x86_pmu.lbr_nr * sizeof(struct lbr_entry);
958958

959959
cpuc->pebs_record_size = sz;
960960
}
@@ -1595,10 +1595,10 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event,
15951595
}
15961596

15971597
if (format_size & PEBS_DATACFG_LBRS) {
1598-
struct pebs_lbr *lbr = next_record;
1598+
struct lbr_entry *lbr = next_record;
15991599
int num_lbr = ((format_size >> PEBS_DATACFG_LBR_SHIFT)
16001600
& 0xff) + 1;
1601-
next_record = next_record + num_lbr*sizeof(struct pebs_lbr_entry);
1601+
next_record = next_record + num_lbr * sizeof(struct lbr_entry);
16021602

16031603
if (has_branch_stack(event)) {
16041604
intel_pmu_store_pebs_lbrs(lbr);

arch/x86/events/intel/lbr.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,11 @@ void intel_pmu_lbr_restore(void *ctx)
372372
mask = x86_pmu.lbr_nr - 1;
373373
for (i = 0; i < task_ctx->valid_lbrs; i++) {
374374
lbr_idx = (tos - i) & mask;
375-
wrlbr_from(lbr_idx, task_ctx->lbr_from[i]);
376-
wrlbr_to (lbr_idx, task_ctx->lbr_to[i]);
375+
wrlbr_from(lbr_idx, task_ctx->lbr[i].from);
376+
wrlbr_to(lbr_idx, task_ctx->lbr[i].to);
377377

378378
if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
379-
wrmsrl(MSR_LBR_INFO_0 + lbr_idx, task_ctx->lbr_info[i]);
379+
wrmsrl(MSR_LBR_INFO_0 + lbr_idx, task_ctx->lbr[i].info);
380380
}
381381

382382
for (; i < x86_pmu.lbr_nr; i++) {
@@ -440,10 +440,10 @@ void intel_pmu_lbr_save(void *ctx)
440440
from = rdlbr_from(lbr_idx);
441441
if (!from)
442442
break;
443-
task_ctx->lbr_from[i] = from;
444-
task_ctx->lbr_to[i] = rdlbr_to(lbr_idx);
443+
task_ctx->lbr[i].from = from;
444+
task_ctx->lbr[i].to = rdlbr_to(lbr_idx);
445445
if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
446-
rdmsrl(MSR_LBR_INFO_0 + lbr_idx, task_ctx->lbr_info[i]);
446+
rdmsrl(MSR_LBR_INFO_0 + lbr_idx, task_ctx->lbr[i].info);
447447
}
448448
task_ctx->valid_lbrs = i;
449449
task_ctx->tos = tos;
@@ -1179,7 +1179,7 @@ intel_pmu_lbr_filter(struct cpu_hw_events *cpuc)
11791179
}
11801180
}
11811181

1182-
void intel_pmu_store_pebs_lbrs(struct pebs_lbr *lbr)
1182+
void intel_pmu_store_pebs_lbrs(struct lbr_entry *lbr)
11831183
{
11841184
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
11851185
int i;
@@ -1193,11 +1193,11 @@ void intel_pmu_store_pebs_lbrs(struct pebs_lbr *lbr)
11931193
cpuc->lbr_stack.hw_idx = intel_pmu_lbr_tos();
11941194

11951195
for (i = 0; i < x86_pmu.lbr_nr; i++) {
1196-
u64 info = lbr->lbr[i].info;
1196+
u64 info = lbr[i].info;
11971197
struct perf_branch_entry *e = &cpuc->lbr_entries[i];
11981198

1199-
e->from = lbr->lbr[i].from;
1200-
e->to = lbr->lbr[i].to;
1199+
e->from = lbr[i].from;
1200+
e->to = lbr[i].to;
12011201
e->mispred = !!(info & LBR_INFO_MISPRED);
12021202
e->predicted = !(info & LBR_INFO_MISPRED);
12031203
e->in_tx = !!(info & LBR_INFO_IN_TX);

arch/x86/events/perf_event.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -765,13 +765,11 @@ struct x86_perf_task_context_opt {
765765
};
766766

767767
struct x86_perf_task_context {
768-
u64 lbr_from[MAX_LBR_ENTRIES];
769-
u64 lbr_to[MAX_LBR_ENTRIES];
770-
u64 lbr_info[MAX_LBR_ENTRIES];
771768
u64 lbr_sel;
772769
int tos;
773770
int valid_lbrs;
774771
struct x86_perf_task_context_opt opt;
772+
struct lbr_entry lbr[MAX_LBR_ENTRIES];
775773
};
776774

777775
#define x86_add_quirk(func_) \
@@ -1092,7 +1090,7 @@ void intel_pmu_pebs_sched_task(struct perf_event_context *ctx, bool sched_in);
10921090

10931091
void intel_pmu_auto_reload_read(struct perf_event *event);
10941092

1095-
void intel_pmu_store_pebs_lbrs(struct pebs_lbr *lbr);
1093+
void intel_pmu_store_pebs_lbrs(struct lbr_entry *lbr);
10961094

10971095
void intel_ds_init(void);
10981096

arch/x86/include/asm/perf_event.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,10 @@ struct pebs_xmm {
282282
u64 xmm[16*2]; /* two entries for each register */
283283
};
284284

285-
struct pebs_lbr_entry {
285+
struct lbr_entry {
286286
u64 from, to, info;
287287
};
288288

289-
struct pebs_lbr {
290-
struct pebs_lbr_entry lbr[0]; /* Variable length */
291-
};
292-
293289
/*
294290
* IBS cpuid feature detection
295291
*/

0 commit comments

Comments
 (0)