Skip to content

Backport AMD IBS raw-sample decoding and perf tooling updates to velinux v6.6 - #157

Open
mohanasv2 wants to merge 15 commits into
openvelinux:6.6-velinuxfrom
mohanasv2:venice_perf_ibs_pmu_velinux_6.6
Open

mohanasv2 wants to merge 15 commits into
openvelinux:6.6-velinuxfrom
mohanasv2:venice_perf_ibs_pmu_velinux_6.6

Conversation

@mohanasv2

Copy link
Copy Markdown

Backport AMD IBS raw-sample decoding and perf tooling updates to velinux v6.6

Patch List:

  1. perf/x86/amd/uncore: Use Node ID to identify DF and UMC domains
  2. perf doc: Add AMD IBS usage document
  3. perf amd ibs: Sync arch/x86/include/asm/amd-ibs.h header with the kernel
  4. perf amd ibs: Add Load Latency bits in raw dump
  5. perf amd ibs: Incorporate Zen5 DTLB and PageSize information
  6. perf test: Add AMD IBS sw filter test
  7. perf test: AMD IBS swfilt skip kernel tests if paranoia is >1
  8. perf tool ibs: Sync AMD IBS header file
  9. perf test ibs: Skip privilege test on Zen6 and newer platforms
  10. perf amd ibs: Suppress bogus TlbRefillLat and DCPhysAd on Zen4+
  11. perf amd ibs: Make Fetch status bits dependent on PhyAddrValid for newer platforms
  12. perf amd ibs: Decode Remote-Socket flag in IBS OP raw dump
  13. perf amd ibs: Decode Streaming-store flag in IBS OP raw dump
  14. perf doc: Document new IBS capabilities in man page
  15. perf vendor events amd: Update Zen 6 core events

Patch Series Overview:
• AMD IBS (Instruction-Based Sampling) is the hardware sampling facility on AMD processors. It tags individual fetch and load/store operations and reports detailed information about each one, such as cache and TLB behaviour, data source, page size and memory latency.
• The velinux 6.6 kernel already supports the newer IBS features exposed by recent AMD core generations. The perf tool in this tree does not, so that information cannot be requested from the hardware or read back from a recording.
• This series adds the missing tool-side support. perf can now filter by load latency, and can decode the newer DTLB and page-size fields, the remote-socket flag and the streaming-store flag. Fields that the hardware marks invalid are no longer printed as if they were real measurements. The series also adds an IBS selftest, an AMD IBS man page, and fixes in the core event tables where multiple FP stall events shared the same unit mask and could not be distinguished.
Key Bug Fixes:
• On newer cores, raw dumps printed TlbRefillLat and IbsDCPhysAd even when the address was invalid; these were meaningless values and are now suppressed.
• Fetch status bits were printed as zeros when PhyAddrValid was clear; those fields are now suppressed when invalid.
• Several FP non-squelched read-stall events on a newer core generation shared the same unit mask, so they could not be told apart; their unit masks have been corrected.
• Missing PMCx00C and PMCx00D unit masks have been added, and PMCx00A descriptions fixed.
• Uncore DF and UMC PMUs used Package ID, which is wrong on first-generation and multi-IOD parts; they now use Node ID.
• The swfilt test failed instead of skipping when perf_event_paranoid was above 1; it now skips appropriately.
• The swfilt test ran a privilege subtest that does not apply to the newest core generations; that subtest is now gated on hardware support.
Feature Additions:
• Decode the remote-socket flag (RmtSocket) in the IBS OP raw dump.
• Decode the streaming-store flag (StrmSt) in the IBS OP raw dump.
• Decode load-latency fields LdLatThrsh and LdLatEn.
• Decode the newer DTLB and DcPageSize information.
• Add a new AMD IBS software filtering selftest.
• Add a new perf-amd-ibs man page, plus documentation for ldlat, dtlb_pgsize, rmtsocket, strmst and fetchlat.
Logic and Consistency Improvements:
• Two header syncs keep the tool copy of the IBS register layout in step with the kernel.
• Decoding is gated on hardware validity bits and CPU family/model instead of being unconditional.
• Test skips are decided at runtime from paranoia level and hardware support.

Testing:

1. IBS PMU capabilities

  $ sudo  grep . /sys/bus/event_source/devices/ibs_op/caps/*
  /sys/bus/event_source/devices/ibs_op/caps/dtlb_pgsize:1
  /sys/bus/event_source/devices/ibs_op/caps/ldlat:1
  /sys/bus/event_source/devices/ibs_op/caps/rmtsocket:1
  /sys/bus/event_source/devices/ibs_op/caps/strmst:1
  /sys/bus/event_source/devices/ibs_op/caps/zen4_ibs_extensions:1

2. IBS selftests

  $ sudo perf test "AMD IBS"
   69: AMD IBS via core pmu                       : Ok
   71: AMD IBS software filtering                 : Ok

3. IBS OP raw dump decoding

  $ sudo perf record -e ibs_op/cnt_ctl=1,ldlat=128/ -c 100000 -a --raw-samples \
      -o ibs2.data -- sleep 2
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 1.260 MB ibs2.data (7 samples) ]

  $sudo  perf report -i ibs2.data -D          (backported)
  ibs_op_ctl:	8000032f000e186a MaxCnt    100000 L3MissOnly 0 En 1 Val 1 CntCtl 1=uOps CurCnt       815 LdLatThrsh  0 LdLatEn 1
  IbsOpRip:	<kernel-addr>
  ibs_op_data:	0000000001fa0002 CompToRetCtr     2 TagToRetCtr   506 BrnRet 0  RipInvalid 0 BrnFuse 0 Microcode 0
  ibs_op_data2:	0000000000000003 RmtSocket 0 StrmSt 0 RmtNode 0 DataSrc 3=DRAM
  ibs_op_data3:	000001d614d700a1 LdOp 1 StOp 0 DcL1TlbMiss 0 DcL2TlbMiss 0 DcPageSize   1G DcMiss 1 DcMisAcc 0 DcWcMemAcc 0 DcUcMemAcc 0 DcLockedOp 0 DcMissNoMabAlloc 1 DcLinAddrValid 1 DcPhyAddrValid 1 L2Miss 1 SwPf 0 OpMemWidth  4 bytes OpDcMissOpenMemReqs  5 DcMissLat   470 TlbRefillLat     0
  IbsDCLinAd:	<kernel-addr>
  IbsDCPhysAd:	<phys-addr>

  $ sudo  perf-base report -i ibs2.data -D     (baseline, same file)
  ibs_op_ctl:	8000032f000e186a MaxCnt    100000 L3MissOnly 0 En 1 Val 1 CntCtl 1=uOps CurCnt       815
  IbsOpRip:	<kernel-addr>
  ibs_op_data:	0000000001fa0002 CompToRetCtr     2 TagToRetCtr   506 BrnRet 0  RipInvalid 0 BrnFuse 0 Microcode 0
  ibs_op_data2:	0000000000000003 RmtNode 0 DataSrc 3=DRAM
  ibs_op_data3:	000001d614d700a1 LdOp 1 StOp 0 DcL1TlbMiss 0 DcL2TlbMiss 0 DcL1TlbHit2M 0 DcL1TlbHit1G 1 DcL2TlbHit2M 0 DcMiss 1 DcMisAcc 0 DcWcMemAcc 0 DcUcMemAcc 0 DcLockedOp 0 DcMissNoMabAlloc 1 DcLinAddrValid 1 DcPhyAddrValid 1 DcL2TlbHit1G 0 L2Miss 1 SwPf 0 OpMemWidth  4 bytes OpDcMissOpenMemReqs  5 DcMissLat   470 TlbRefillLat     0
  IbsDCLinAd:	<kernel-addr>
  IbsDCPhysAd:	<phys-addr>

  field occurrences across the whole dump:
    LdLatThrsh    baseline=0      backported=7
    LdLatEn       baseline=0      backported=7
    RmtSocket     baseline=0      backported=7
    StrmSt        baseline=0      backported=7
    DcPageSize    baseline=0      backported=7
    DcL1TlbHit2M  baseline=7      backported=0

4. IBS FETCH raw dump decoding

  $ sudo perf record -e ibs_fetch// -c 100000 -a --raw-samples \
      -o ibsfetch.data -- sleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 1.275 MB ibsfetch.data (237 samples) ]

  $ sudo perf-base report -i ibsfetch.data -D    (baseline, PhyAddrValid 0 sample)
  ibs_fetch_ctl:	00230000186a186a MaxCnt  100000 Cnt  100000 Lat     0 En 1 Val 1 Comp 0 IcMiss 0 PhyAddrValid 0 L1TlbMiss 0 L2TlbMiss 0 RandEn 0 L3MissOnly 0 FetchOcMiss 0 FetchL3Miss 0

  $sudo perf report -i ibsfetch.data -D         (backported, same sample)
  ibs_fetch_ctl:	00230000186a186a MaxCnt  100000 Cnt  100000 En 1 Val 1 Comp 0 PhyAddrValid 0 RandEn 0 L3MissOnly 0

5. Load latency sweep

  for l in 128 256 512 1024 2048; do
  perf record -e ibs_op/cnt_ctl=1,ldlat=$l/ -c 1000 -a --raw-samples \
      -o l.data -- sleep 4
     perf report -i l.data -D
   done

  ldlat  128 ->  LdLatThrsh  0 LdLatEn 1   (252338 samples)
  ldlat  256 ->  LdLatThrsh  1 LdLatEn 1   (64348 samples)
  ldlat  512 ->  LdLatThrsh  3 LdLatEn 1   (6360 samples)
  ldlat 1024 ->  LdLatThrsh  7 LdLatEn 1   (1442 samples)
  ldlat 2048 ->  LdLatThrsh 15 LdLatEn 1   (76 samples)

6. Remote-socket flag

  $sudo  perf record -e ibs_op/cnt_ctl=1/ -c 50000 --raw-samples -- \
      numactl --cpunodebind=0 --membind=<remote-node> \
      ibs-workload chase 512 40000000        (remote socket)
      RmtSocket 1:    1882
      RmtSocket 0:    73076
      DataSrc 3=DRAM: 1883

  $sudo perf record -e ibs_op/cnt_ctl=1/ -c 50000 --raw-samples -- \
      numactl --cpunodebind=0 --membind=<local-node> \
      ibs-workload chase 512 40000000        (control, same socket)
      RmtSocket 1:    1
      RmtSocket 0:    43487
      DataSrc 3=DRAM: 1199

7. Streaming-store flag

  $sudo  perf record -e ibs_op/cnt_ctl=1/ -c 50000 --raw-samples -- \
      ibs-workload nts                       (MOVNTI non-temporal stores)
      StrmSt 1:       6437
      StrmSt 0:       22742

  $sudo perf record -e ibs_op/cnt_ctl=1/ -c 50000 --raw-samples -- \
      ibs-workload chase                     (control, load only)
      StrmSt 1:       0
      StrmSt 0:       42767

  bit-level audit over every distinct ibs_op_data2 value seen above:
      distinct values: 14   RmtSocket(bit9) violations: 0   StrmSt(bit8) violations: 0

8. Core event table fix

  $sudo perf-base stat -e fp_nsq_read_stalls.fp_prf,fp_nsq_read_stalls.k_prf,\
      fp_nsq_read_stalls.fp_sq -- ibs-workload chase 256 20000000   (pre-fix table)
   Performance counter stats for 'ibs-workload chase 256 20000000':
               1,513      fp_nsq_read_stalls.fp_prf
               1,513      fp_nsq_read_stalls.k_prf
               1,513      fp_nsq_read_stalls.fp_sq
         2.223209762 seconds time elapsed

  $sudo perf stat -e fp_nsq_read_stalls.fp_prf,fp_nsq_read_stalls.k_prf,\
      fp_nsq_read_stalls.fp_sq -- ibs-workload chase 256 20000000   (post-fix table)
   Performance counter stats for 'ibs-workload chase 256 20000000':
                   0      fp_nsq_read_stalls.fp_prf
                   0      fp_nsq_read_stalls.k_prf
               1,110      fp_nsq_read_stalls.fp_sq
         2.216135300 seconds time elapsed

sandip4n and others added 15 commits September 15, 2026 06:33
commit 67d27727854def4a7e2b386429941f5c4741ccc4 upstream.

For DF and UMC PMUs, a single context is shared across all CPUs that
are connected to the same Data Fabric (DF) instance. Currently, the
Package ID, which also happens to be the Socket ID, is used to identify
DF instances. This approach works for configurations having a single IO
Die (IOD) but fails in the following cases.
  * Older Zen 1 processors, where each chiplet has its own DF instance.
  * Any configurations with multiple DF instances or multiple IODs in
    the same package.

The correct way to identify DF instances is through the Node ID (not to
be confused with NUMA Node ID). This is available in ECX[7:0] of CPUID
leaf 0x8000001e and returned via topology_amd_node_id(). Hence, replace
usage of topology_logical_package_id() with topology_amd_node_id().

Fixes: 07888da ("perf/x86/amd/uncore: Move discovery and registration")
Signed-off-by: Sandipan Das <sandipan.das@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/e7a71a727c6a7b118c23d3e469929c538c4665aa.1780315832.git.sandipan.das@amd.com
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
commit b739759 upstream.

Add a perf man page document that describes how to exploit AMD IBS with
Linux perf. Brief intro about IBS and simple one-liner examples will help
naive users to get started. This is not meant to be an exhaustive IBS
guide. User should refer latest AMD64 Architecture Programmer's Manual
for detailed description of IBS.

Usage:

  $ man perf-amd-ibs

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: ananth.narayan@amd.com
Cc: sandipan.das@amd.com
Cc: santosh.shukla@amd.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240620054104.815-1-ravi.bangoria@amd.com
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
commit 3201bfa368fee5e70927e45222ff0b235352c01c upstream.

Sync load latency related bit fields into the tool's header copy

[Backport Changes]
1. tools/arch/x86/include/asm/amd-ibs.h:
   Retargeted to tools/arch/x86/include/asm/amd/ibs.h. This branch already
   carries the upstream rename of the IBS header from asm/amd-ibs.h to
   asm/amd/ibs.h, so the upstream hunk was applied to the renamed file. The
   added ldlat_thrsh and ldlat_en bitfields in union ibs_op_ctl are identical
   to upstream; only the file path differs.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20250205060547.1337-4-ravi.bangoria@amd.com
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
commit eeefc13c71e243108f7d0c0b26eb9e8592921ee6 upstream.

IBS OP PMU on Zen5 supports Load Latency filtering. Decode and dump Load
Latency filtering related bits into perf script raw dump.

Also add oneliner example in the perf-amd-ibs man page.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Joe Mario <jmario@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Santosh Shukla <santosh.shukla@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20250429035938.1301-2-ravi.bangoria@amd.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
commit fc481adc97f45328e242b6dba9fabd24f2082a6e upstream.

IBS Op PMU on Zen5 reports DTLB and page size information differently
compared to prior generation.

  IBS_OP_DATA3     Zen3/4                 Zen5
  ----------------------------------------------------------------
  19               IbsDcL2TlbHit1G        Reserved
  ----------------------------------------------------------------
   6               IbsDcL2tlbHit2M        Reserved
  ----------------------------------------------------------------
   5               IbsDcL1TlbHit1G        PageSize:
   4               IbsDcL1TlbHit2M          0 - 4K
                                            1 - 2M
                                            2 - 1G
                                            3 - Reserved
                                          Valid only if
                                            IbsDcPhyAddrValid = 1
  ----------------------------------------------------------------
   3               IbsDcL2TlbMiss         IbsDcL2TlbMiss
                                          Valid only if
                                            IbsDcPhyAddrValid = 1
  ----------------------------------------------------------------
   2               IbsDcL1tlbMiss         IbsDcL1tlbMiss
                                          Valid only if
                                            IbsDcPhyAddrValid = 1
  ----------------------------------------------------------------

Kernel expose this change as "dtlb_pgsize" capability in PMU sysfs.

Change IBS register raw-dump logic according to new bit definitions.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Joe Mario <jmario@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Santosh Shukla <santosh.shukla@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20250429035938.1301-3-ravi.bangoria@amd.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
commit 0e71bcdcf1f0b10b435932907fb0d205deecf7a0 upstream.

The kernel v6.14 added 'swfilt' to support privilege filtering in
software so that IBS can be used by regular users.  Add a test case in
x86 to verify the behavior.

  $ sudo perf test -vv 'IBS software filter'
  113: AMD IBS software filtering:
  --- start ---
  test child forked, pid 178826
  check availability of IBS swfilt
  run perf record with modifier and swfilt
  [ perf record: Woken up 3 times to write data ]
  [ perf record: Captured and wrote 0.000 MB /dev/null ]
  [ perf record: Woken up 3 times to write data ]
  [ perf record: Captured and wrote 0.000 MB /dev/null ]
  [ perf record: Woken up 3 times to write data ]
  [ perf record: Captured and wrote 0.000 MB /dev/null ]
  [ perf record: Woken up 0 times to write data ]
  [ perf record: Captured and wrote 0.000 MB /dev/null ]
  check number of samples with swfilt
  [ perf record: Woken up 3 times to write data ]
  [ perf record: Captured and wrote 0.037 MB - ]
  [ perf record: Woken up 3 times to write data ]
  [ perf record: Captured and wrote 0.041 MB - ]
  ---- end(0) ----
  113: AMD IBS software filtering                                      : Ok

Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> # On a 9950x3d
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250524002754.1266681-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
commit 2e3501212293c5005873c6ca6bb4f963a7eec442 upstream.

If not root and the perf_event_paranoid is set >1 swfilt will fail to
open the event failing the test. Add check to skip the test in that
case.

Fixes: 0e71bcdcf1f0b10b ("perf test: Add AMD IBS sw filter test")
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Collin Funk <collin.funk1@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Link: https://lore.kernel.org/r/20250913000350.1306948-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
commit 45bd2d77fbedec862204bb5c0fcaba2b7fa5fb56 upstream.

IBS_OP_DATA2 register will have two more fields: strm_st and rmt_socket
in Zen6 and future AMD platforms. Kernel header file is already updated.
Add those fields in tools copy as well.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Manali Shukla <manali.shukla@amd.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Santosh Shukla <santosh.shukla@amd.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
commit 540dc628ab5dc2cf176053c9794ed9891269484b upstream.

IBS on pre-Zen6 platforms lacked a hardware privilege filter, so the
kernel enabled swfilt=1. Zen6 and newer platforms provides privilege
filtering via the RIP[63] bit, making swfilt redundant. Skip the perf
unit test that assumes IBS has no hardware-assisted privilege filter
on Zen6 and newer platforms.

swfilt is ignored by kernel on platforms that support RIP[63] bit filter
i.e. all amd-ibs-swfilt.sh tests will test hardware assisted privilege
filter.

Without the patch on Zen6:

  # sudo ./perf test -vv 77
   77: AMD IBS software filtering:
  --- start ---
  test child forked, pid 30813
  check availability of IBS swfilt
  run perf record with modifier and swfilt
  [FAIL] IBS PMU should not accept exclude_kernel
  ---- end(-1) ----
   77: AMD IBS software filtering                            : FAILED!

With the patch:

  # ./perf test -vv 77
   77: AMD IBS software filtering:
  --- start ---
  test child forked, pid 30903
  check availability of IBS swfilt
  run perf record with modifier and swfilt
  [ perf record: Woken up 2 times to write data ]
  [ perf record: Captured and wrote 0.000 MB /dev/null ]
  [ perf record: Woken up 3 times to write data ]
  [ perf record: Captured and wrote 0.000 MB /dev/null ]
  [ perf record: Woken up 3 times to write data ]
  [ perf record: Captured and wrote 0.000 MB /dev/null ]
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.000 MB /dev/null ]
  check number of samples with swfilt
  [ perf record: Woken up 4 times to write data ]
  [ perf record: Captured and wrote 0.051 MB - ]
  [ perf record: Woken up 4 times to write data ]
  [ perf record: Captured and wrote 0.063 MB - ]
  ---- end(0) ----
   77: AMD IBS software filtering                            : Ok

[Backport Changes]
1. tools/perf/tests/shell/amd-ibs-swfilt.sh:
   Upstream's pre-image already carries "#!/bin/bash" because of the tree-wide
   conversion in upstream commit 2f5d370dec3f ("perf test: Change all remaining
   #!/bin/sh to #!/bin/bash"), which is out of scope for this series. Here the
   script is still "#!/bin/sh", so the shebang is changed to "#!/bin/bash" as
   part of this patch. Without it the "(( ... ))" arithmetic added by
   hw_priv_filter_supported() is not understood by dash, which parses it as a
   subshell and makes the helper always report "not supported". Only the
   shebang line is added; the rest of the hunk is identical to upstream.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Manali Shukla <manali.shukla@amd.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Santosh Shukla <santosh.shukla@amd.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
commit f04a8a7649f9b248f89971b7a440f5d158d57d46 upstream.

On Zen4 (and future) CPUs, IBS_OP_DATA3[TlbRefillLat] is valid only if
IBS_OP_DATA3[DcPhyAddrValid] is set. Similarly, IBS_DC_PHYSADDR is valid
if IBS_OP_DATA3[DcLinAddrValid] is _also_ set. Add these checks while
decoding IBS MSRs.

When IBS is triggered by an unprivileged user, the kernel now zeroes
PhysAddr before storing raw IBS register values in the perf sample. The
perf tool, however, still outputs these zero physical addresses, which
serves no purpose. So avoid printing zero physical addresses.

Instead of explicit family/model checks use the !zen4_ibs_extensions as
a proxy flag to cover Zen 3 and earlier revisions.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Manali Shukla <manali.shukla@amd.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Santosh Shukla <santosh.shukla@amd.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
…wer platforms

commit ea0ce2e12ed5347ecefc7b7c2a01623b855d9ddb upstream.

On Zen6 and future platforms, IBS_FETCH_CTL status fields are valid only
if IBS_FETCH_CTL[IbsPhyAddrValid] is set. Same for IBS_FETCH_CTL_EXT.
Add these checks while decoding IBS MSRs.

Unfortunately, there is no CPUID bit to indicate the change. Fallback
to Family/Model check.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Manali Shukla <manali.shukla@amd.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Santosh Shukla <santosh.shukla@amd.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
commit 7c04195ccefcfc95d46abfd30a435679a28493b2 upstream.

IBS OP on Zen6 and future platform can mark a data source as coming from
a remote socket. When the PMU advertises this feature, interpret
IBS_OP_DATA2[9] bit as the Remote-Socket indicator and show it in the
raw dump output.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Manali Shukla <manali.shukla@amd.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Santosh Shukla <santosh.shukla@amd.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
commit 873f232d09622767c57557003d4bd98ed6c6f327 upstream.

IBS OP on Zen6 and future platform can tag IBS samples that originate from
streaming-store instruction. When the PMU advertises this feature,
interpret IBS_OP_DATA2[8] bit as the streaming store indicator and show
it in the raw dump output.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Manali Shukla <manali.shukla@amd.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Santosh Shukla <santosh.shukla@amd.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
commit a31423e67c0e8c716c9ecdf0d4836dd7049ad78b upstream.

Include examples of:

o Privilege filter with Fetch and Op PMUs, including swfilt approach on
  Zen5 and older platforms and hardware assisted filter on Zen6 and newer
  platforms

o Streaming store filter with Op PMU

o Fetch latency filter with Fetch PMU

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ananth Narayan <ananth.narayan@amd.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Manali Shukla <manali.shukla@amd.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Santosh Shukla <santosh.shukla@amd.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>
commit 6744430f106b0e46d6318d44a99cb27b0ee937ae upstream.

Update definitions for the following events.
  * PMCx00A - Fix descriptions
  * PMCx00C - Add missing unit masks
  * PMCx00D - Add missing unit masks and fix descriptions
  * PMCx013 - Fix incorrect unit masks

Fixes: 2f42fb0661d9 ("perf vendor events amd: Add Zen 6 core events")
Signed-off-by: Sandipan Das <sandipan.das@amd.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Hemanth Selam <Hemanth.Selam@amd.com>
Signed-off-by: mohanasv2 <mohanasv@amd.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants