[PATCH] Add support for pebs fmt6(Lunar Lake)

From: Yiwei Yang
Date: Thu Dec 26 2024 - 03:56:33 EST


Signed-off-by: Yiwei Yang <victoryang00@xxxxxxxx>

Lunar lake's pebs is not kernel ready. in dmesg I found

victoryang00@victoryang00-ASUS-Zenbook-S-14-UX5406SA-UX5406SA:~$ sudo dmesg|grep PMU
[sudo] password for victoryang00:
[ 0.107418] Performance Events: XSAVE Architectural LBR, no PEBS fmt6+, AnyThread deprecated, Lunarlake Hybrid events, 32-deep LBR, full-width counters, Intel PMU driver.
[ 0.107418] core: cpu_core PMU driver:
[ 0.107418] NMI watchdog: Enabled. Permanently consumes one hw-PMU counter.
[ 0.007380] core: cpu_atom PMU driver:
[ 2.802582] RAPL PMU: API unit is 2^-32 Joules, 4 fixed counters, 655360 ms ovfl timer
[ 2.802585] RAPL PMU: hw unit of domain pp0-core 2^-14 Joules
[ 2.802586] RAPL PMU: hw unit of domain package 2^-14 Joules
[ 2.802587] RAPL PMU: hw unit of domain dram 2^-14 Joules
[ 2.802587] RAPL PMU: hw unit of domain pp1-gpu 2^-14 Joules

But lunar lake has the pebs extension in lscpu

Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge m
ca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 s
s ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc
art arch_perfmon pebs bts rep_good nopl xtopology nons
top_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq
dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma c
x16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt t
sc_deadline_timer aes xsave avx f16c rdrand lahf_lm ab
m 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp i
brs_enhanced tpr_shadow flexpriority ept vpid ept_ad f
sgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rd
t_a rdseed adx smap clflushopt clwb intel_pt sha_ni xs
aveopt xsavec xgetbv1 xsaves split_lock_detect avx_vnn
i lam wbnoinvd dtherm ida arat pln pts hwp hwp_notify
hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku o
spke waitpkg gfni vaes vpclmulqdq rdpid bus_lock_detec
t movdiri movdir64b fsrm md_clear serialize pconfig ar
ch_lbr ibt flush_l1d arch_capabilities


But I found implementation [1] and [2].

The code in the kernel seems not updated [3].

[1] https://github.com/search?q=repo%3Atorvalds%2Flinux%20MSR_IA32_PMC_V6_FX0_CTR&type=code
[2] https://lwn.net/ml/all/20240625182256.291914-9-kan.liang@xxxxxxxxxxxxxxx/
[3] https://elixir.bootlin.com/linux/v6.13-rc3/source/arch/x86/events/intel/ds.c#L2480