Skip to content

Commit af6cf12

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86: Expose CPUID enumeration bits for arch LBR
The LBR capabilities of Architecture LBR are retrieved from the CPUID enumeration once at boot time. The capabilities have to be saved for future usage. Several new fields are added into structure x86_pmu to indicate the capabilities. The fields will be used in the following patches. 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 d6a162a commit af6cf12

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

arch/x86/events/perf_event.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,19 @@ struct x86_pmu {
693693
bool lbr_double_abort; /* duplicated lbr aborts */
694694
bool lbr_pt_coexist; /* (LBR|BTS) may coexist with PT */
695695

696+
/*
697+
* Intel Architectural LBR CPUID Enumeration
698+
*/
699+
unsigned int lbr_depth_mask:8;
700+
unsigned int lbr_deep_c_reset:1;
701+
unsigned int lbr_lip:1;
702+
unsigned int lbr_cpl:1;
703+
unsigned int lbr_filter:1;
704+
unsigned int lbr_call_stack:1;
705+
unsigned int lbr_mispred:1;
706+
unsigned int lbr_timed_lbr:1;
707+
unsigned int lbr_br_type:1;
708+
696709
void (*lbr_reset)(void);
697710
void (*lbr_read)(struct cpu_hw_events *cpuc);
698711
void (*lbr_save)(void *ctx);

arch/x86/include/asm/perf_event.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,46 @@ union cpuid10_edx {
142142
unsigned int full;
143143
};
144144

145+
/*
146+
* Intel Architectural LBR CPUID detection/enumeration details:
147+
*/
148+
union cpuid28_eax {
149+
struct {
150+
/* Supported LBR depth values */
151+
unsigned int lbr_depth_mask:8;
152+
unsigned int reserved:22;
153+
/* Deep C-state Reset */
154+
unsigned int lbr_deep_c_reset:1;
155+
/* IP values contain LIP */
156+
unsigned int lbr_lip:1;
157+
} split;
158+
unsigned int full;
159+
};
160+
161+
union cpuid28_ebx {
162+
struct {
163+
/* CPL Filtering Supported */
164+
unsigned int lbr_cpl:1;
165+
/* Branch Filtering Supported */
166+
unsigned int lbr_filter:1;
167+
/* Call-stack Mode Supported */
168+
unsigned int lbr_call_stack:1;
169+
} split;
170+
unsigned int full;
171+
};
172+
173+
union cpuid28_ecx {
174+
struct {
175+
/* Mispredict Bit Supported */
176+
unsigned int lbr_mispred:1;
177+
/* Timed LBRs Supported */
178+
unsigned int lbr_timed_lbr:1;
179+
/* Branch Type Field Supported */
180+
unsigned int lbr_br_type:1;
181+
} split;
182+
unsigned int full;
183+
};
184+
145185
struct x86_pmu_capability {
146186
int version;
147187
int num_counters_gp;

0 commit comments

Comments
 (0)