!4099 Intel: Backport SRF LBR branch counter support to kernel v6.6
Merge Pull Request from: @yunyingsun Title: Backport SRF LBR branch counter support to kernel v6.6 Content: The branch counters logging (A.K.A LBR event logging) introduces a per-counter indication of precise event occurrences in LBRs. It can provide a means to attribute exposed retirement latency to combinations of events across a block of instructions. It also provides a means of attributing Timed LBR latencies to events. The feature is first introduced on SRF/GRR. It is an enhancement of the ARCH LBR. It adds new fields in the LBR_INFO MSRs to log the occurrences of events on the GP counters. The information is displayed by the order of counters. To support this feature, both kernel PMU changes and user space perf tool changes are needed. Kernel commits(5 patches, will be included in the upcoming mainline v6.8-rc1 release): 33744916196b perf/x86/intel: Support branch counters logging 318c49859112 perf/x86/intel: Reorganize attrs and is_visible 1f2376cd03dd perf: Add branch_sample_call_stack 85846b27072d perf/x86: Add PERF_X86_EVENT_NEEDS_BRANCH_STACK flag 571d91dcadfa perf: Add branch stack counters Reference: https://lore.kernel.org/lkml/20231025201626.3000228-5-kan.liang@linux.intel.com/ Perf tool commits(4 patches, will be included in the upcoming mainline v6.8-rc1 release)): 697579629f85 perf test: Basic branch counter support 9fbb4b02302b perf tools: Add branch counter knob ac9cd7245fff perf header: Support num and width of branch counters 76db7aab1fca tools headers UAPI: Sync include/uapi/linux/perf_event.h header with the kernel Reference: https://lore.kernel.org/lkml/20240109222804.28583-1-acme@kernel.org/ Since perf tool changes are independent to kernel versions, this ticket is only created for backporting the kernel commits to kernel v6.6. The perf tool commits should be included in the perf binary when testing the backported kernel patches. Note: code of the 5 backported kernel commits are totally identical as the mainline version. Intel-kernel issue: https://gitee.com/openeuler/intel-kernel/issues/I8XR3G Test: With the perf binary which has included the perf tool patches listed above, the backported patches have been verified on Intel internal SRF servers. Regarding how to test this feature, check this: https://lore.kernel.org/lkml/20231107184020.1497571-1-kan.liang@linux.intel.com/ Before backport, with OLK-6.6 kernel on Sierra Forest(SRF) server: 1. There's no "branch_counter_{nr,width}" devices under "/sys/bus/event_source/devices/cpu/caps". ``` # ls -l /sys/bus/event_source/devices/cpu*/caps | grep branch_counter # ``` 2. There's no "branch stack counters" in the sampling output from the second command below: ``` # perf record -j any,counter perf test -w thloop # perf report -D -q | grep "branch stack counters" | sort | uniq -c | sort -n ``` After backport, with the 5 patches applied upon OLK-6.6 kernel, on Sierra Forest(SRF) server: 1. "branch_counter_{nr,width}" devices are available under "/sys/bus/event_source/devices/cpu/caps". ``` # ls -l /sys/bus/event_source/devices/cpu/caps | grep branch_counter -r--r--r--. 1 root root 4096 Jan 21 11:55 branch_counter_nr -r--r--r--. 1 root root 4096 Jan 21 11:55 branch_counter_width ``` 2. There're "branch stack counters" available in the sampling output from the second command below: ``` # perf record -j any,counter perf test -w thloop [ perf record: Woken up 33 times to write data ] [ perf record: Captured and wrote 8.264 MB perf.data (8058 samples) ] # perf report -D -q | grep "branch stack counters" | sort | uniq -c | sort -n 1 ... branch stack counters: nr:12 (counter width: 2 max counter nr:4) 1 ... branch stack counters: nr:27 (counter width: 2 max counter nr:4) 8056 ... branch stack counters: nr:32 (counter width: 2 max counter nr:4) ``` Known issue: N/A Default config change: N/A Link:https://gitee.com/openeuler/kernel/pulls/4099 Reviewed-by:Jason Zeng <jason.zeng@intel.com> Reviewed-by:
Aichun Shi <aichun.shi@intel.com> Signed-off-by:
Zheng Zengkai <zhengzengkai@huawei.com>
Loading
Please sign in to comment