mirror-linux/arch/x86/kernel/cpu
Sandipan Das 598c2fafc0 perf/x86/amd/lbr: Use freeze based on availability
Currently, the LBR code assumes that LBR Freeze is supported on all processors
when X86_FEATURE_AMD_LBR_V2 is available i.e. CPUID leaf 0x80000022[EAX]
bit 1 is set. This is incorrect as the availability of the feature is
additionally dependent on CPUID leaf 0x80000022[EAX] bit 2 being set,
which may not be set for all Zen 4 processors.

Define a new feature bit for LBR and PMC freeze and set the freeze enable bit
(FLBRI) in DebugCtl (MSR 0x1d9) conditionally.

It should still be possible to use LBR without freeze for profile-guided
optimization of user programs by using an user-only branch filter during
profiling. When the user-only filter is enabled, branches are no longer
recorded after the transition to CPL 0 upon PMI arrival. When branch
entries are read in the PMI handler, the branch stack does not change.

E.g.

  $ perf record -j any,u -e ex_ret_brn_tkn ./workload

Since the feature bit is visible under flags in /proc/cpuinfo, it can be
used to determine the feasibility of use-cases which require LBR Freeze
to be supported by the hardware such as profile-guided optimization of
kernels.

Fixes: ca5b7c0d96 ("perf/x86/amd/lbr: Add LbrExtV2 branch record support")
Signed-off-by: Sandipan Das <sandipan.das@amd.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/69a453c97cfd11c6f2584b19f937fe6df741510f.1711091584.git.sandipan.das@amd.com
2024-03-25 11:16:55 +01:00
..
mce - Constify yet another static struct bus_type instance now that the 2024-03-11 17:22:57 -07:00
microcode x86/cpu/topology: Get rid of cpuinfo::x86_max_cores 2024-02-16 15:51:32 +01:00
mtrr x86/mtrr: Don't print errors if MtrrFixDramModEn is set when SNP enabled 2024-01-29 17:24:27 +01:00
resctrl x86/resctrl: Remove lockdep annotation that triggers false positive 2024-02-22 16:15:38 +01:00
sgx arch/x86: Fix typos 2024-01-03 11:46:22 +01:00
.gitignore
Makefile x86/cpu/topology: Move registration out of APIC code 2024-02-15 22:07:41 +01:00
acrn.c x86/traps: Add sysvec_install() to install a system interrupt handler 2024-01-31 22:02:36 +01:00
amd.c x86/CPU/AMD: Update the Zenbleed microcode revisions 2024-03-16 09:04:09 -07:00
aperfmperf.c x86/aperfmperf: Erase stale arch_freq_scale values when disabling frequency invariance readings 2023-01-16 10:19:15 +01:00
bugs.c * Mitigate RFDS vulnerability 2024-03-12 09:31:39 -07:00
cacheinfo.c - Relax the PAT MSR programming which was unnecessarily using the MTRR 2024-03-11 17:27:12 -07:00
centaur.c x86/cpu: Use common topology code for Centaur and Zhaoxin 2024-02-15 22:07:37 +01:00
common.c x86/cpu: Ensure that CPU info updates are propagated on UP 2024-03-23 12:22:04 +01:00
cpu.h x86/cpu: Use common topology code for HYGON 2024-02-15 22:07:38 +01:00
cpuid-deps.c x86/cpufeatures: Add the CPU feature bit for FRED 2024-01-25 19:10:30 +01:00
cyrix.c
debugfs.c x86/cpu/topology: Get rid of cpuinfo::x86_max_cores 2024-02-16 15:51:32 +01:00
feat_ctl.c x86/cpu: Add a VMX flag to enumerate 5-level EPT support to userspace 2024-02-22 16:03:56 -08:00
hygon.c x86/cpu: Use common topology code for HYGON 2024-02-15 22:07:38 +01:00
hypervisor.c
intel.c Merge branch 'x86/urgent' into x86/apic, to resolve conflicts 2024-02-27 10:09:49 +01:00
intel_epb.c x86/cpu/intel_epb: Don't rely on link order 2023-11-24 13:54:31 +01:00
intel_pconfig.c x86/msr: Prepare for including <linux/percpu.h> into <asm/msr.h> 2024-03-04 12:01:39 +01:00
match.c
mkcapflags.sh
mshyperv.c hyperv-next for v6.9 2024-03-21 10:01:02 -07:00
perfctr-watchdog.c
powerflags.c
proc.c x86/cpu: Move cpu_core_id into topology info 2023-10-10 14:38:17 +02:00
rdrand.c x86/msr: Prepare for including <linux/percpu.h> into <asm/msr.h> 2024-03-04 12:01:39 +01:00
scattered.c perf/x86/amd/lbr: Use freeze based on availability 2024-03-25 11:16:55 +01:00
topology.c x86/topology: Handle the !APIC case gracefully 2024-03-23 12:35:56 +01:00
topology.h x86/cpu/topology: Retrieve cores per package from topology bitmaps 2024-02-15 22:07:45 +01:00
topology_amd.c x86/cpu: Provide an AMD/HYGON specific topology parser 2024-02-15 22:07:37 +01:00
topology_common.c x86/topology: Don't evaluate logical IDs during early boot 2024-03-23 12:28:06 +01:00
topology_ext.c x86/cpu: Provide a sane leaf 0xb/0x1f parser 2024-02-15 22:07:37 +01:00
transmeta.c
tsx.c x86/cpu: Remove redundant extern x86_read_arch_cap_msr() 2023-01-10 12:40:24 +01:00
umc.c
umwait.c x86/umwait: move to use bus_get_dev_root() 2023-03-17 15:29:29 +01:00
vmware.c sched/clock/x86: Mark sched_clock() noinstr 2023-01-31 15:01:47 +01:00
vortex.c
zhaoxin.c x86/cpu: Use common topology code for Centaur and Zhaoxin 2024-02-15 22:07:37 +01:00