Skip to contentSkip to conversation

TPEBS counting mode support

RFC PATCH In review [email protected] 4 participants 28 messages Jul 20, 2024 – Aug 13, 2024 perf events

lore
Share & tools
lore
#0 lore raw

v18 cover TPEBS counting mode support

From: Weilin Wang <[email protected]>

Change in v18:
- Update to exit 2 in TPEBS shell test when not on Intel platform.
- Several updates to use EVLIST_CTL_CMD_ENABLE_TAG, EVLIST_CTL_CMD_ACK_TAG, and etc.

Changes in v17:
- Add a poll on control fifo ack_fd to ensure program returns successfully when perf record failed for any reason.
- Add a check in the tpebs test to only run on Intel platforms.

Changes in v16:
- Update tpebs bash test code and variable name.
- Add a check to ensure only use "-C" option when cpumap is not "-1" when forking "perf record".

Changes in v15:
- Revert changes added for python import test failure in v14 because the code works correctly with the new python build code.
- Update the command line option to --record-tpebs.

Changes in v14:
- Fix the python import test failure. We cannot support PYTHON_PERF because it will trigger a chain of dependency issues if we add intel-tpebs.c to it. So, only enable tpebs functions in evsel and evlist when PYTHON_PERF is not defined.
- Fix shellcheck warning for the tpebs test.

Changes in v13:
- Add document for the command line option and fix build error in non-x86_64.
- Update example with non-zero retire_latency value when tpebs recording is enabled.
- Add tpebs_stop() back to tpebs_set_evsel() because in hybrid platform, when the forked perf record is not killed, the reader thread does not get any sampled data from the PIPE. As a result, tpebs_set_evesel() will always return zero on retire_latency values. This does not happen on my test GNR machine. Since -I is not supported yet, I think we should add tpebs_stop() to ensure correctness for now. More investigation is required here when we work on supporting -I mode.
- Rebase code on top of perf-tools-next.

Changes in v12:
- Update MTL metric JSON file to include E-Core TMA3.6 changes.
- Update comments and code for better code quality. Keep tpebs_start() and tpebs_delete() at evsel level for now and add comments on these functions with more details about potential future changes. Remove tpebs_stop() call from tpebs_set_evsel(). Simplify the tpebs_start() and tpebs_stop()/tpebs_delete() interfaces. Also fixed the bugs on not freed "new" pointer and the incorrect variable value assignment to val instead of counter->val.

Changes in v11:
- Make retire_latency evsels not opened for counting. This works correctly now with the code Namhyung suggested that adjusting group read size when retire_latency evsels included in the group.
- Update retire_latency value assignment using rint() to reduce precision loss while keeping code generic.
- Fix the build error caused by not used variable in the test.

Other changes in v10:
- Change perf record fork from perf stat to evsel. All the major operations like tpebs start, stop, read_evsel should directly work through evsel.
- Make intel-tpebs x86_64 only. This change is cross-compiled to arm64.
- Put tpebs code to intel-tepbs and simplify intel-tpebs APIs to minimum number
of functions and variables. Update funtion name and variable names to use consistent prefix. Also improve error handling.
- Integrate code patch from Ian for the :R parser.
- Update MTL metrics to TMA 4.8.

V9: https://lore.kernel.org/all/[email protected]/

Changes in v9:
- Update the retire_latency result print and metric calculation method. Plugin
the value to evsel so that no special code is required.
- Update --control:fifo to use pipe instead of named pipe.
- Add test for TPEBS counting mode.
- Update Document with more details.

Changes in v8:
- In this revision, the code is updated to base on Ian's patch on R modifier
parser https://lore.kernel.org/lkml/[email protected]/
After this change, there is no special code required for R modifier in metricgroup.c and metricgroup.h files.

Caveat of this change:
Ideally, we will need to add special handling to skip counting events with R
modifier in evsel. Currently, this is not implemented so the event with :R will be both counted and sampled. Usually, in a metric formula that uses retire_latency, it would already require to count the event. As a result, we will endup count the same event twice. This should be able to be handled properly when we finalize our design on evsel R modifier support.

- Move TPEBS specific code out from main perf stat code to separate files in
util/intel-tpebs.c and util/intel-tpebs.h. [Namhyung]
- Use --control:fifo to ack perf stat from forked perf record instead of sleep(2) [Namhyung]
- Add introductions about TPEBS and R modifier in Documents. [Namhyung]

Changes in v7:
- Update code and comments for better code quality [Namhyung]
- Add a separate commit for perf data [Namhyung]
- Update retire latency print function to improve alignment [Namhyung]

Changes in v6:
- Update code and add comments for better code quality [Namhyung]
- Remove the added fd var and directly pass the opened fd to data.file.fd [Namhyung]
- Add kill() to stop perf record when perf stat exists early [Namhyung]
- Add command opt check to ensure only start perf record when -a/-C given [Namhyung]
- Squash commits [Namhyung]

Changes in v5:
- Update code and add comments for better code quality [Ian]

Changes in v4:
- Remove uncessary debug print and update code and comments for better
readability and quality [Namhyung]
- Update mtl metric json file with consistent TmaL1 and TopdownL1 metricgroup

Changes in v3:
- Remove ':' when event name has '@' [Ian]
- Use 'R' as the modifier instead of "retire_latency" [Ian]

Changes in v2:
- Add MTL metric file
- Add more descriptions and example to the patch [Arnaldo]

Here is an example of running perf stat to collect a metric that uses retire_latency value of event MEM_INST_RETIRED.STLB_HIT_STORES on a MTL system.

In this simple example, there is no MEM_INST_RETIRED.STLB_HIT_STORES sample. Therefore, the MEM_INST_RETIRED.STLB_HIT_STORES:p count and retire_latency value are all 0.

./perf stat -M tma_dtlb_store -a -- sleep 1

[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]

Performance counter stats for 'system wide':

       181,047,168      cpu_core/TOPDOWN.SLOTS/          #      0.6 %  tma_dtlb_store
         3,195,608      cpu_core/topdown-retiring/
        40,156,649      cpu_core/topdown-mem-bound/
         3,550,925      cpu_core/topdown-bad-spec/
       117,571,818      cpu_core/topdown-fe-bound/
        57,118,087      cpu_core/topdown-be-bound/
            69,179      cpu_core/EXE_ACTIVITY.BOUND_ON_STORES/
             4,582      cpu_core/MEM_INST_RETIRED.STLB_HIT_STORES/
        30,183,104      cpu_core/CPU_CLK_UNHALTED.DISTRIBUTED/
        30,556,790      cpu_core/CPU_CLK_UNHALTED.THREAD/
           168,486      cpu_core/DTLB_STORE_MISSES.WALK_ACTIVE/

0.00 MEM_INST_RETIRED.STLB_HIT_STORES:p 0 0

1.003105924 seconds time elapsed

v1:
TPEBS is one of the features provided by the next generation of Intel PMU. Please refer to Section 8.4.1 of "Intel® Architecture Instruction Set Extensions Programming Reference" [1] for more details about this feature.

This set of patches supports TPEBS in counting mode. The code works in the following way: it forks a perf record process from perf stat when retire_latency of one or more events are used in a metric formula. Perf stat would send a SIGTERM signal to perf record before it needs the retire latency value for metric calculation. Perf stat will then process sample data to extract the retire latency data for metric calculations. Currently, the code uses the arithmetic average of retire latency values.

[1] https://www.intel.com/content/www/us/en/content-details/812218/intel-architecture-instruction-set-extensions-programming-reference.html?wapkw=future%20features

Ian Rogers (1):
perf parse-events: Add a retirement latency modifier

Weilin Wang (7):
perf data: Allow to use given fd in data->file.fd
perf stat: Fork and launch perf record when perf stat needs to get
retire latency value for a metric.
perf stat: Plugin retire_lat value from sampled data to evsel perf vendor events intel: Add MTL metric json files perf stat: Add command line option for enabling tpebs recording perf Document: Add TPEBS to Documents
perf test: Add test for Intel TPEBS counting mode

 tools/perf/Documentation/perf-list.txt        |    1 +
 tools/perf/Documentation/perf-stat.txt        |    8 +
 tools/perf/Documentation/topdown.txt          |   30 +
 tools/perf/arch/x86/util/evlist.c             |    6 +
 tools/perf/builtin-stat.c                     |    8 +
 .../arch/x86/meteorlake/metricgroups.json     |  142 +
 .../arch/x86/meteorlake/mtl-metrics.json      | 2535 +++++++++++++++++
 .../perf/tests/shell/test_stat_intel_tpebs.sh |   19 +
 tools/perf/util/Build                         |    1 +
 tools/perf/util/data.c                        |    7 +-
 tools/perf/util/evlist.c                      |    2 +
 tools/perf/util/evsel.c                       |   81 +-
 tools/perf/util/evsel.h                       |    6 +
 tools/perf/util/intel-tpebs.c                 |  431 +++
 tools/perf/util/intel-tpebs.h                 |   35 +
 tools/perf/util/parse-events.c                |    2 +
 tools/perf/util/parse-events.h                |    1 +
 tools/perf/util/parse-events.l                |    3 +-
 18 files changed, 3314 insertions(+), 4 deletions(-)
 create mode 100644 tools/perf/pmu-events/arch/x86/meteorlake/metricgroups.json
 create mode 100644 tools/perf/pmu-events/arch/x86/meteorlake/mtl-metrics.json
 create mode 100755 tools/perf/tests/shell/test_stat_intel_tpebs.sh
 create mode 100644 tools/perf/util/intel-tpebs.c
 create mode 100644 tools/perf/util/intel-tpebs.h

--
2.43.0

#1 lore raw

RFC PATCH v18 1/8 perf parse-events: Add a retirement latency modifier

From: Ian Rogers <[email protected]>

Retirement latency is a separate sampled count used on newer Intel CPUs.

---
 tools/perf/util/evsel.h        | 1 +
 tools/perf/util/parse-events.c | 2 ++
 tools/perf/util/parse-events.h | 1 +
 tools/perf/util/parse-events.l | 3 ++-
 4 files changed, 6 insertions(+), 1 deletion(-)
tools/perf/util/evsel.h +1 -0
index 80b5f6dd868e..14f777b9e03e 100644
@@ -98,6 +98,7 @@ struct evsel {
 		bool			bpf_counter;
 		bool			use_config_name;
 		bool			skippable;
+		bool			retire_lat;
 		int			bpf_fd;
 		struct bpf_object	*bpf_obj;
 		struct list_head	config_terms;
tools/perf/util/parse-events.c +2 -0
index 321586fb5556..fab01ba54e34 100644
@@ -1811,6 +1811,8 @@ static int parse_events__modifier_list(struct parse_events_state *parse_state,
 			evsel->weak_group = true;
 		if (mod.bpf)
 			evsel->bpf_counter = true;
+		if (mod.retire_lat)
+			evsel->retire_lat = true;
 	}
 	return 0;
 }
tools/perf/util/parse-events.h +1 -0
index e13de2c8b706..b735cd9e0acf 100644
@@ -203,6 +203,7 @@ struct parse_events_modifier {
 	bool hypervisor : 1;	/* 'h' */
 	bool guest : 1;		/* 'G' */
 	bool host : 1;		/* 'H' */
+	bool retire_lat : 1;	/* 'R' */
 };
 
 int parse_events__modifier_event(struct parse_events_state *parse_state, void *loc,
tools/perf/util/parse-events.l +2 -1
index 16045c383ada..5a0bcd7f166a 100644
@@ -209,6 +209,7 @@ static int modifiers(struct parse_events_state *parse_state, yyscan_t scanner)
 		CASE('W', weak);
 		CASE('e', exclusive);
 		CASE('b', bpf);
+		CASE('R', retire_lat);
 		default:
 			return PE_ERROR;
 		}
@@ -250,7 +251,7 @@ drv_cfg_term	[a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)?
  * If you add a modifier you need to update check_modifier().
  * Also, the letters in modifier_event must not be in modifier_bp.
  */
-modifier_event	[ukhpPGHSDIWeb]{1,15}
+modifier_event	[ukhpPGHSDIWebR]{1,16}
 modifier_bp	[rwx]{1,3}
 lc_type 	(L1-dcache|l1-d|l1d|L1-data|L1-icache|l1-i|l1i|L1-instruction|LLC|L2|dTLB|d-tlb|Data-TLB|iTLB|i-tlb|Instruction-TLB|branch|branches|bpu|btb|bpc|node)
 lc_op_result	(load|loads|read|store|stores|write|prefetch|prefetches|speculative-read|speculative-load|refs|Reference|ops|access|misses|miss)
Signature · 1 line
2.43.0
#2 lore raw

RFC PATCH v18 2/8 perf data: Allow to use given fd in data->file.fd

In reply to [email protected]

From: Weilin Wang <[email protected]>

When in PIPE mode, allow to use fd dynamically opened and asigned to data->file.fd instead of STDIN_FILENO or STDOUT_FILENO.

---
 tools/perf/util/data.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/perf/util/data.c +6 -1
index 08c4bfbd817f..98661ede2a73 100644
@@ -204,7 +204,12 @@ static bool check_pipe(struct perf_data *data)
 				data->file.fd = fd;
 				data->use_stdio = false;
 			}
-		} else {
+
+		/*
+		 * When is_pipe and data->file.fd is given, use given fd
+		 * instead of STDIN_FILENO or STDOUT_FILENO
+		 */
+		} else if (data->file.fd <= 0) {
 			data->file.fd = fd;
 		}
 	}
Signature · 1 line
2.43.0
#3 lore raw

RFC PATCH v18 3/8 perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric.

In reply to [email protected]

From: Weilin Wang <[email protected]>

When retire_latency value is used in a metric formula, evsel would fork a perf record process with "-e" and "-W" options. Perf record will collect required retire_latency values in parallel while perf stat is collecting counting values.

At the point of time that perf stat stops counting, evsel would stop perf record by sending sigterm signal to perf record process. Sampled data will be process to get retire latency value. Another thread is required to synchronize between perf stat and perf record when we pass data through pipe.

Retire_latency evsel is not opened for perf stat so that there is no counter wasted on it. This commit includes code suggested by Namhyung to adjust reading size for groups that include retire_latency evsels.

---
 tools/perf/builtin-stat.c     |   4 +
 tools/perf/util/Build         |   1 +
 tools/perf/util/evlist.c      |   2 +
 tools/perf/util/evsel.c       |  66 +++++-
 tools/perf/util/intel-tpebs.c | 431 ++++++++++++++++++++++++++++++++++
 tools/perf/util/intel-tpebs.h |  35 +++
 6 files changed, 537 insertions(+), 2 deletions(-)
 create mode 100644 tools/perf/util/intel-tpebs.c
 create mode 100644 tools/perf/util/intel-tpebs.h
tools/perf/builtin-stat.c +4 -0
index 661832756a24..68125bd75b37 100644
@@ -70,6 +70,7 @@
 #include "util/bpf_counter.h"
 #include "util/iostat.h"
 #include "util/util.h"
+#include "util/intel-tpebs.h"
 #include "asm/bug.h"
 
 #include <linux/time64.h>
@@ -683,6 +684,9 @@ static enum counter_recovery stat_handle_error(struct evsel *counter)
 
 	if (child_pid != -1)
 		kill(child_pid, SIGTERM);
+
+	tpebs_delete();
+
 	return COUNTER_FATAL;
 }
 
tools/perf/util/Build +1 -0
index 0f18fe81ef0b..25cae5c613ad 100644
@@ -154,6 +154,7 @@ perf-util-y += clockid.o
 perf-util-y += list_sort.o
 perf-util-y += mutex.o
 perf-util-y += sharded_mutex.o
+perf-util-$(CONFIG_X86_64) += intel-tpebs.o
 
 perf-util-$(CONFIG_LIBBPF) += bpf_map.o
 perf-util-$(CONFIG_PERF_BPF_SKEL) += bpf_counter.o
tools/perf/util/evlist.c +2 -0
index 3a719edafc7a..78ce80f227aa 100644
@@ -33,6 +33,7 @@
 #include "util/bpf-filter.h"
 #include "util/stat.h"
 #include "util/util.h"
+#include "util/intel-tpebs.h"
 #include <signal.h>
 #include <unistd.h>
 #include <sched.h>
@@ -179,6 +180,7 @@ void evlist__delete(struct evlist *evlist)
 	if (evlist == NULL)
 		return;
 
+	tpebs_delete();
 	evlist__free_stats(evlist);
 	evlist__munmap(evlist);
 	evlist__close(evlist);
tools/perf/util/evsel.c +64 -2

102 lines not on this page · raw message

tools/perf/util/intel-tpebs.c new file +431 -0

431 lines not on this page · raw message

tools/perf/util/intel-tpebs.h new file +35 -0
new file mode 100644
index 000000000000..766b3fbd79f1
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * intel_tpebs.h: Intel TEPBS support
+ */
+#ifndef INCLUDE__PERF_INTEL_TPEBS_H__
+#define INCLUDE__PERF_INTEL_TPEBS_H__
+
+#include "stat.h"
+#include "evsel.h"
+
+#ifdef HAVE_ARCH_X86_64_SUPPORT
+
+extern bool tpebs_recording;
+int tpebs_start(struct evlist *evsel_list);
+void tpebs_delete(void);
+int tpebs_set_evsel(struct evsel *evsel, int cpu_map_idx, int thread);
+
+#else
+
+static inline int tpebs_start(struct evlist *evsel_list __maybe_unused)
+{
+	return 0;
+}
+
+static inline void tpebs_delete(void) {};
+
+static inline int tpebs_set_evsel(struct evsel *evsel  __maybe_unused,
+				int cpu_map_idx  __maybe_unused,
+				int thread  __maybe_unused)
+{
+	return 0;
+}
+
+#endif
+#endif
Signature · 1 line
2.43.0
#4 lore raw

Re: [RFC PATCH v18 3/8] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric.

Quoted 6 lines · On Sat, Jul 20, 2024 at 02:20:56AM -0400, [email protected] wrote:

From: Weilin Wang <[email protected]>

When retire_latency value is used in a metric formula, evsel would fork a perf record process with "-e" and "-W" options. Perf record will collect required retire_latency values in parallel while perf stat is collecting counting values.

Quoted 8 lines

At the point of time that perf stat stops counting, evsel would stop perf record by sending sigterm signal to perf record process. Sampled data will be process to get retire latency value. Another thread is required to synchronize between perf stat and perf record when we pass data through pipe.

Retire_latency evsel is not opened for perf stat so that there is no counter wasted on it. This commit includes code suggested by Namhyung to adjust reading size for groups that include retire_latency evsels.

Failing at this point:

⬢[acme@toolbox perf-tools-next]$ git log --oneline -5
13430131acc4f88b (HEAD) perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric. b7b9adefb5d57aaf perf data: Allow to use given fd in data->file.fd
3a442bf266d1f3c7 perf parse-events: Add a retirement latency modifier
ce533c9bc6deb125 (perf-tools-next.korg/tmp.perf-tools-next, acme.korg/tmp.perf-tools-next) perf annotate: Add --skip-empty option bb588e38290fb723 perf annotate: Set al->data_nr using the notes->src->nr_events
⬢[acme@toolbox perf-tools-next]$

I'll see if when a followup patch gets applied this gets solved, if so will try to fixup things or ask for help, since this seems to be breaking 'git bisect' for this codebase.

⬢[acme@toolbox perf-tools-next]$ m
rm: cannot remove '/home/acme/libexec/perf-core/scripts/python/Perf-Trace-Util/lib/Perf/Trace/__pycache__/Core.cpython-312.pyc': Permission denied
make: Entering directory '/home/acme/git/perf-tools-next/tools/perf'
BUILD: Doing 'make -j2' parallel build
Warning: Kernel ABI header differences:
diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h
diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h
diff -u tools/include/uapi/linux/perf_event.h include/uapi/linux/perf_event.h
diff -u tools/include/uapi/linux/stat.h include/uapi/linux/stat.h
diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
diff -u tools/arch/x86/include/uapi/asm/kvm.h arch/x86/include/uapi/asm/kvm.h
diff -u tools/arch/x86/include/uapi/asm/svm.h arch/x86/include/uapi/asm/svm.h
diff -u tools/arch/powerpc/include/uapi/asm/kvm.h arch/powerpc/include/uapi/asm/kvm.h
diff -u tools/arch/arm64/include/uapi/asm/unistd.h arch/arm64/include/uapi/asm/unistd.h
diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/asm-generic/unistd.h
diff -u tools/arch/arm64/include/asm/cputype.h arch/arm64/include/asm/cputype.h
diff -u tools/lib/list_sort.c lib/list_sort.c
diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
diff -u tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/syscalls/syscall.tbl
diff -u tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl
diff -u tools/perf/trace/beauty/include/linux/socket.h include/linux/socket.h
diff -u tools/perf/trace/beauty/include/uapi/linux/fs.h include/uapi/linux/fs.h
diff -u tools/perf/trace/beauty/include/uapi/linux/mount.h include/uapi/linux/mount.h
diff -u tools/perf/trace/beauty/include/uapi/linux/stat.h include/uapi/linux/stat.h
diff -u tools/perf/trace/beauty/include/uapi/sound/asound.h include/uapi/sound/asound.h
git showMakefile.config:1223: libtracefs is missing. Please install libtracefs-dev/libtracefs-devel

Auto-detecting system features:

...                                   dwarf: [ on  ]
...                      dwarf_getlocations: [ on  ]
...                                   glibc: [ on  ]
...                                  libbfd: [ on  ]
...                          libbfd-buildid: [ on  ]
...                                  libcap: [ on  ]
...                                  libelf: [ on  ]
...                                 libnuma: [ on  ]
...                  numa_num_possible_cpus: [ on  ]
...                                 libperl: [ on  ]
...                               libpython: [ on  ]
...                               libcrypto: [ on  ]
...                               libunwind: [ on  ]
...                      libdw-dwarf-unwind: [ on  ]
...                             libcapstone: [ on  ]
...                                    zlib: [ on  ]
...                                    lzma: [ on  ]
...                               get_cpuid: [ on  ]
...                                     bpf: [ on  ]
...                                  libaio: [ on  ]
...                                 libzstd: [ on  ]

INSTALL libperf_headers
INSTALL libapi_headers
INSTALL libsubcmd_headers
INSTALL libsymbol_headers
PERF_VERSION = 6.11.rc1.g13430131acc4
CC /tmp/build/perf-tools-next/perf-read-vdso32
INSTALL libbpf_headers

  GEN     perf-archive
  GEN     perf-iostat
  CC      /tmp/build/perf-tools-next/util/evlist.o
  CC      /tmp/build/perf-tools-next/builtin-stat.o
  CC      /tmp/build/perf-tools-next/util/evsel.o
  LD      /tmp/build/perf-tools-next/perf-in.o
  LINK    /tmp/build/perf-tools-next/libperf-jvmti.so
  CC      /tmp/build/perf-tools-next/util/header.o
util/evsel.c: In function ‘evsel__group_has_tpebs’:
util/evsel.c:1562:21: error: implicit declaration of function ‘evsel__is_retire_lat’ [-Werror=implicit-function-declaration]
 1562 |                 if (evsel__is_retire_lat(evsel))
      |                     ^~~~~~~~~~~~~~~~~~~~
util/evsel.c: In function ‘evsel__open_cpu’:
util/evsel.c:2258:24: error: implicit declaration of function ‘tpebs_start’ [-Werror=implicit-function-declaration]
 2258 |                 return tpebs_start(evsel->evlist);
      |                        ^~~~~~~~~~~
util/evsel.c: In function ‘evsel__close’:
util/evsel.c:2453:17: error: implicit declaration of function ‘tpebs_delete’; did you mean ‘timer_delete’? [-Werror=implicit-function-declaration]
 2453 |                 tpebs_delete();
      |                 ^~~~~~~~~~~~
      |                 timer_delete

cc1: all warnings being treated as errors
make[4]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:105: /tmp/build/perf-tools-next/util/evsel.o] Error 1 make[4]: *** Waiting for unfinished jobs....
make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:158: util] Error 2
make[2]: *** [Makefile.perf:787: /tmp/build/perf-tools-next/perf-util-in.o] Error 2
make[1]: *** [Makefile.perf:290: sub-make] Error 2
make: *** [Makefile:119: install-bin] Error 2
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'
⬢[acme@toolbox perf-tools-next]$

#5 lore raw

Re: [RFC PATCH v18 3/8] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric.

Quoted 26 lines · Arnaldo Carvalho de Melo
Quoted 6 lines · On Sat, Jul 20, 2024 at 02:20:56AM -0400, [email protected] wrote:

From: Weilin Wang <[email protected]>

When retire_latency value is used in a metric formula, evsel would fork a perf record process with "-e" and "-W" options. Perf record will collect required retire_latency values in parallel while perf stat is collecting counting values.

Quoted 8 lines

At the point of time that perf stat stops counting, evsel would stop perf record by sending sigterm signal to perf record process. Sampled data will be process to get retire latency value. Another thread is required to synchronize between perf stat and perf record when we pass data through pipe.

Retire_latency evsel is not opened for perf stat so that there is no counter wasted on it. This commit includes code suggested by Namhyung to adjust reading size for groups that include retire_latency evsels.

Failing at this point:

⬢[acme@toolbox perf-tools-next]$ git log --oneline -5
13430131acc4f88b (HEAD) perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric. b7b9adefb5d57aaf perf data: Allow to use given fd in data->file.fd
3a442bf266d1f3c7 perf parse-events: Add a retirement latency modifier
ce533c9bc6deb125 (perf-tools-next.korg/tmp.perf-tools-next, acme.korg/tmp.perf-tools-next) perf annotate: Add --skip-empty option bb588e38290fb723 perf annotate: Set al->data_nr using the notes->src->nr_events
⬢[acme@toolbox perf-tools-next]$

Quoted 3 lines

I'll see if when a followup patch gets applied this gets solved, if so will try to fixup things or ask for help, since this seems to be breaking 'git bisect' for this codebase.

Indeed, when the next patch gets applied it builds without problems. I.e. patch 4/8 fixes problems in patch 3/8, maybe just combine them into one single patch?

- Arnaldo

Quoted 90 lines

⬢[acme@toolbox perf-tools-next]$ m
rm: cannot remove '/home/acme/libexec/perf-core/scripts/python/Perf-Trace-Util/lib/Perf/Trace/__pycache__/Core.cpython-312.pyc': Permission denied
make: Entering directory '/home/acme/git/perf-tools-next/tools/perf'
BUILD: Doing 'make -j2' parallel build
Warning: Kernel ABI header differences:
diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h
diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h
diff -u tools/include/uapi/linux/perf_event.h include/uapi/linux/perf_event.h
diff -u tools/include/uapi/linux/stat.h include/uapi/linux/stat.h
diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
diff -u tools/arch/x86/include/uapi/asm/kvm.h arch/x86/include/uapi/asm/kvm.h
diff -u tools/arch/x86/include/uapi/asm/svm.h arch/x86/include/uapi/asm/svm.h
diff -u tools/arch/powerpc/include/uapi/asm/kvm.h arch/powerpc/include/uapi/asm/kvm.h
diff -u tools/arch/arm64/include/uapi/asm/unistd.h arch/arm64/include/uapi/asm/unistd.h
diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/asm-generic/unistd.h
diff -u tools/arch/arm64/include/asm/cputype.h arch/arm64/include/asm/cputype.h
diff -u tools/lib/list_sort.c lib/list_sort.c
diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
diff -u tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/syscalls/syscall.tbl
diff -u tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl
diff -u tools/perf/trace/beauty/include/linux/socket.h include/linux/socket.h
diff -u tools/perf/trace/beauty/include/uapi/linux/fs.h include/uapi/linux/fs.h
diff -u tools/perf/trace/beauty/include/uapi/linux/mount.h include/uapi/linux/mount.h
diff -u tools/perf/trace/beauty/include/uapi/linux/stat.h include/uapi/linux/stat.h
diff -u tools/perf/trace/beauty/include/uapi/sound/asound.h include/uapi/sound/asound.h
git showMakefile.config:1223: libtracefs is missing. Please install libtracefs-dev/libtracefs-devel

Auto-detecting system features:

...                                   dwarf: [ on  ]
...                      dwarf_getlocations: [ on  ]
...                                   glibc: [ on  ]
...                                  libbfd: [ on  ]
...                          libbfd-buildid: [ on  ]
...                                  libcap: [ on  ]
...                                  libelf: [ on  ]
...                                 libnuma: [ on  ]
...                  numa_num_possible_cpus: [ on  ]
...                                 libperl: [ on  ]
...                               libpython: [ on  ]
...                               libcrypto: [ on  ]
...                               libunwind: [ on  ]
...                      libdw-dwarf-unwind: [ on  ]
...                             libcapstone: [ on  ]
...                                    zlib: [ on  ]
...                                    lzma: [ on  ]
...                               get_cpuid: [ on  ]
...                                     bpf: [ on  ]
...                                  libaio: [ on  ]
...                                 libzstd: [ on  ]

INSTALL libperf_headers
INSTALL libapi_headers
INSTALL libsubcmd_headers
INSTALL libsymbol_headers
PERF_VERSION = 6.11.rc1.g13430131acc4
CC /tmp/build/perf-tools-next/perf-read-vdso32
INSTALL libbpf_headers

  GEN     perf-archive
  GEN     perf-iostat
  CC      /tmp/build/perf-tools-next/util/evlist.o
  CC      /tmp/build/perf-tools-next/builtin-stat.o
  CC      /tmp/build/perf-tools-next/util/evsel.o
  LD      /tmp/build/perf-tools-next/perf-in.o
  LINK    /tmp/build/perf-tools-next/libperf-jvmti.so
  CC      /tmp/build/perf-tools-next/util/header.o
util/evsel.c: In function ‘evsel__group_has_tpebs’:
util/evsel.c:1562:21: error: implicit declaration of function ‘evsel__is_retire_lat’ [-Werror=implicit-function-declaration]
 1562 |                 if (evsel__is_retire_lat(evsel))
      |                     ^~~~~~~~~~~~~~~~~~~~
util/evsel.c: In function ‘evsel__open_cpu’:
util/evsel.c:2258:24: error: implicit declaration of function ‘tpebs_start’ [-Werror=implicit-function-declaration]
 2258 |                 return tpebs_start(evsel->evlist);
      |                        ^~~~~~~~~~~
util/evsel.c: In function ‘evsel__close’:
util/evsel.c:2453:17: error: implicit declaration of function ‘tpebs_delete’; did you mean ‘timer_delete’? [-Werror=implicit-function-declaration]
 2453 |                 tpebs_delete();
      |                 ^~~~~~~~~~~~
      |                 timer_delete

cc1: all warnings being treated as errors
make[4]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:105: /tmp/build/perf-tools-next/util/evsel.o] Error 1 make[4]: *** Waiting for unfinished jobs....
make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:158: util] Error 2
make[2]: *** [Makefile.perf:787: /tmp/build/perf-tools-next/perf-util-in.o] Error 2
make[1]: *** [Makefile.perf:290: sub-make] Error 2
make: *** [Makefile:119: install-bin] Error 2
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf'
⬢[acme@toolbox perf-tools-next]$

#6 lore raw

RE: [RFC PATCH v18 3/8] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric.

Quoted 53 lines

-----Original Message-----
From: Arnaldo Carvalho de Melo <[email protected]>
Sent: Monday, August 5, 2024 12:43 PM
To: Wang, Weilin <[email protected]>
Cc: Namhyung Kim <[email protected]>; Ian Rogers <[email protected]>; Peter Zijlstra <[email protected]>; Ingo Molnar <[email protected]>; Alexander Shishkin <[email protected]>; Jiri Olsa <[email protected]>; Hunter, Adrian <[email protected]>; Kan Liang <[email protected]>; [email protected]; [email protected]; Taylor, Perry <[email protected]>; Alt, Samantha <[email protected]>; Biggers, Caleb <[email protected]>
Subject: Re: [RFC PATCH v18 3/8] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric.

Quoted 4 lines · Arnaldo Carvalho de Melo
Quoted 3 lines · On Sat, Jul 20, 2024 at 02:20:56AM -0400, [email protected] wrote:

From: Weilin Wang <[email protected]>

When retire_latency value is used in a metric formula, evsel would fork a

perf

Quoted 4 lines
Quoted 4 lines

record process with "-e" and "-W" options. Perf record will collect required retire_latency values in parallel while perf stat is collecting counting values.

At the point of time that perf stat stops counting, evsel would stop perf

record

Quoted 1 line
Quoted 1 line

by sending sigterm signal to perf record process. Sampled data will be

process

Quoted 1 line
Quoted 1 line

to get retire latency value. Another thread is required to synchronize

between

Quoted 4 lines
Quoted 4 lines

perf stat and perf record when we pass data through pipe.

Retire_latency evsel is not opened for perf stat so that there is no counter wasted on it. This commit includes code suggested by Namhyung to adjust

reading

Quoted 6 lines
Quoted 1 line

size for groups that include retire_latency evsels.

Failing at this point:

⬢[acme@toolbox perf-tools-next]$ git log --oneline -5 13430131acc4f88b (HEAD) perf stat: Fork and launch perf record when perf

stat needs to get retire latency value for a metric.

Quoted 3 lines

b7b9adefb5d57aaf perf data: Allow to use given fd in data->file.fd 3a442bf266d1f3c7 perf parse-events: Add a retirement latency modifier ce533c9bc6deb125 (perf-tools-next.korg/tmp.perf-tools-next,

acme.korg/tmp.perf-tools-next) perf annotate: Add --skip-empty option

Quoted 4 lines

bb588e38290fb723 perf annotate: Set al->data_nr using the notes->src- nr_events
⬢[acme@toolbox perf-tools-next]$

Quoted 8 lines
Quoted 3 lines

I'll see if when a followup patch gets applied this gets solved, if so will try to fixup things or ask for help, since this seems to be breaking 'git bisect' for this codebase.

Indeed, when the next patch gets applied it builds without problems. I.e. patch 4/8 fixes problems in patch 3/8, maybe just combine them into one single patch?

Hi Arnaldo,

Please feel free to combine them. And let me know if there is anything I need to do.

Thanks,
Weilin

Quoted 119 lines

- Arnaldo

Quoted 2 lines

⬢[acme@toolbox perf-tools-next]$ m
rm: cannot remove '/home/acme/libexec/perf-core/scripts/python/Perf-

Trace-Util/lib/Perf/Trace/__pycache__/Core.cpython-312.pyc': Permission denied

Quoted 7 lines

make: Entering directory '/home/acme/git/perf-tools-next/tools/perf'
BUILD: Doing 'make -j2' parallel build
Warning: Kernel ABI header differences:
diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h diff -u tools/include/uapi/linux/perf_event.h

include/uapi/linux/perf_event.h

Quoted 2 lines

diff -u tools/include/uapi/linux/stat.h include/uapi/linux/stat.h diff -u tools/arch/x86/include/asm/cpufeatures.h

arch/x86/include/asm/cpufeatures.h

Quoted 1 line

diff -u tools/arch/x86/include/asm/msr-index.h

arch/x86/include/asm/msr-index.h

Quoted 1 line

diff -u tools/arch/x86/include/uapi/asm/kvm.h

arch/x86/include/uapi/asm/kvm.h

Quoted 1 line

diff -u tools/arch/x86/include/uapi/asm/svm.h

arch/x86/include/uapi/asm/svm.h

Quoted 1 line

diff -u tools/arch/powerpc/include/uapi/asm/kvm.h

arch/powerpc/include/uapi/asm/kvm.h

Quoted 1 line

diff -u tools/arch/arm64/include/uapi/asm/unistd.h

arch/arm64/include/uapi/asm/unistd.h

Quoted 1 line

diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/asm-

generic/unistd.h

Quoted 1 line

diff -u tools/arch/arm64/include/asm/cputype.h

arch/arm64/include/asm/cputype.h

Quoted 2 lines

diff -u tools/lib/list_sort.c lib/list_sort.c diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl

arch/x86/entry/syscalls/syscall_64.tbl

Quoted 1 line

diff -u tools/perf/arch/powerpc/entry/syscalls/syscall.tbl

arch/powerpc/kernel/syscalls/syscall.tbl

Quoted 1 line

diff -u tools/perf/arch/s390/entry/syscalls/syscall.tbl

arch/s390/kernel/syscalls/syscall.tbl

Quoted 1 line

diff -u tools/perf/trace/beauty/include/linux/socket.h

include/linux/socket.h

Quoted 1 line

diff -u tools/perf/trace/beauty/include/uapi/linux/fs.h

include/uapi/linux/fs.h

Quoted 1 line

diff -u tools/perf/trace/beauty/include/uapi/linux/mount.h

include/uapi/linux/mount.h

Quoted 1 line

diff -u tools/perf/trace/beauty/include/uapi/linux/stat.h

include/uapi/linux/stat.h

Quoted 1 line

diff -u tools/perf/trace/beauty/include/uapi/sound/asound.h

include/uapi/sound/asound.h

Quoted 1 line

git showMakefile.config:1223: libtracefs is missing. Please install libtracefs-

dev/libtracefs-devel

Quoted 39 lines

Auto-detecting system features:

...                                   dwarf: [ on  ]
...                      dwarf_getlocations: [ on  ]
...                                   glibc: [ on  ]
...                                  libbfd: [ on  ]
...                          libbfd-buildid: [ on  ]
...                                  libcap: [ on  ]
...                                  libelf: [ on  ]
...                                 libnuma: [ on  ]
...                  numa_num_possible_cpus: [ on  ]
...                                 libperl: [ on  ]
...                               libpython: [ on  ]
...                               libcrypto: [ on  ]
...                               libunwind: [ on  ]
...                      libdw-dwarf-unwind: [ on  ]
...                             libcapstone: [ on  ]
...                                    zlib: [ on  ]
...                                    lzma: [ on  ]
...                               get_cpuid: [ on  ]
...                                     bpf: [ on  ]
...                                  libaio: [ on  ]
...                                 libzstd: [ on  ]

INSTALL libperf_headers
INSTALL libapi_headers
INSTALL libsubcmd_headers
INSTALL libsymbol_headers
PERF_VERSION = 6.11.rc1.g13430131acc4
CC /tmp/build/perf-tools-next/perf-read-vdso32
INSTALL libbpf_headers

  GEN     perf-archive
  GEN     perf-iostat
  CC      /tmp/build/perf-tools-next/util/evlist.o
  CC      /tmp/build/perf-tools-next/builtin-stat.o
  CC      /tmp/build/perf-tools-next/util/evsel.o
  LD      /tmp/build/perf-tools-next/perf-in.o
  LINK    /tmp/build/perf-tools-next/libperf-jvmti.so
  CC      /tmp/build/perf-tools-next/util/header.o
Quoted 2 lines

util/evsel.c: In function ‘evsel__group_has_tpebs’:
util/evsel.c:1562:21: error: implicit declaration of function

‘evsel__is_retire_lat’ [-Werror=implicit-function-declaration]

Quoted 4 lines

1562 | if (evsel__is_retire_lat(evsel))

      |                     ^~~~~~~~~~~~~~~~~~~~

util/evsel.c: In function ‘evsel__open_cpu’:
util/evsel.c:2258:24: error: implicit declaration of function ‘tpebs_start’ [-

Werror=implicit-function-declaration]

Quoted 4 lines
 2258 |                 return tpebs_start(evsel->evlist);
      |                        ^~~~~~~~~~~

util/evsel.c: In function ‘evsel__close’:
util/evsel.c:2453:17: error: implicit declaration of function ‘tpebs_delete’;

did you mean ‘timer_delete’? [-Werror=implicit-function-declaration]

Quoted 5 lines
 2453 |                 tpebs_delete();
      |                 ^~~~~~~~~~~~
      |                 timer_delete

cc1: all warnings being treated as errors
make[4]: *** [/home/acme/git/perf-tools-

next/tools/build/Makefile.build:105: /tmp/build/perf-tools-next/util/evsel.o] Error 1

Quoted 2 lines

make[4]: *** Waiting for unfinished jobs....
make[3]: *** [/home/acme/git/perf-tools-

next/tools/build/Makefile.build:158: util] Error 2

Quoted 1 line

make[2]: *** [Makefile.perf:787: /tmp/build/perf-tools-next/perf-util-in.o]

Error 2

Quoted 5 lines

make[1]: *** [Makefile.perf:290: sub-make] Error 2
make: *** [Makefile:119: install-bin] Error 2
make: Leaving directory '/home/acme/git/perf-tools-next/tools/perf' ⬢[acme@toolbox perf-tools-next]$

#7 lore raw

Re: [RFC PATCH v18 3/8] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric.

In reply to Arnaldo Carvalho de Melo
Quoted 27 lines · Arnaldo Carvalho de Melo
Quoted 26 lines · Arnaldo Carvalho de Melo
Quoted 6 lines · On Sat, Jul 20, 2024 at 02:20:56AM -0400, [email protected] wrote:

From: Weilin Wang <[email protected]>

When retire_latency value is used in a metric formula, evsel would fork a perf record process with "-e" and "-W" options. Perf record will collect required retire_latency values in parallel while perf stat is collecting counting values.

Quoted 8 lines

At the point of time that perf stat stops counting, evsel would stop perf record by sending sigterm signal to perf record process. Sampled data will be process to get retire latency value. Another thread is required to synchronize between perf stat and perf record when we pass data through pipe.

Retire_latency evsel is not opened for perf stat so that there is no counter wasted on it. This commit includes code suggested by Namhyung to adjust reading size for groups that include retire_latency evsels.

Failing at this point:

⬢[acme@toolbox perf-tools-next]$ git log --oneline -5
13430131acc4f88b (HEAD) perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric. b7b9adefb5d57aaf perf data: Allow to use given fd in data->file.fd
3a442bf266d1f3c7 perf parse-events: Add a retirement latency modifier
ce533c9bc6deb125 (perf-tools-next.korg/tmp.perf-tools-next, acme.korg/tmp.perf-tools-next) perf annotate: Add --skip-empty option bb588e38290fb723 perf annotate: Set al->data_nr using the notes->src->nr_events
⬢[acme@toolbox perf-tools-next]$

Quoted 7 lines
Quoted 3 lines

I'll see if when a followup patch gets applied this gets solved, if so will try to fixup things or ask for help, since this seems to be breaking 'git bisect' for this codebase.

Indeed, when the next patch gets applied it builds without problems. I.e. patch 4/8 fixes problems in patch 3/8, maybe just combine them into one single patch?

I have everything in the tmp.perf-tools-next branch at:

https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git

I'll check later or tomorrow if I can fixup the bisection breakage described above or if just sqashing together 3/8 with 4/8 is better, please advise.

Then I'll move it to the perf-tools-next branch.

- Arnaldo

#8 lore raw

RE: [RFC PATCH v18 3/8] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric.

Quoted 65 lines

-----Original Message-----
From: Arnaldo Carvalho de Melo <[email protected]>
Sent: Monday, August 5, 2024 1:20 PM
To: Wang, Weilin <[email protected]>
Cc: Namhyung Kim <[email protected]>; Ian Rogers <[email protected]>; Peter Zijlstra <[email protected]>; Ingo Molnar <[email protected]>; Alexander Shishkin <[email protected]>; Jiri Olsa <[email protected]>; Hunter, Adrian <[email protected]>; Kan Liang <[email protected]>; [email protected]; [email protected]; Taylor, Perry <[email protected]>; Alt, Samantha <[email protected]>; Biggers, Caleb <[email protected]>
Subject: Re: [RFC PATCH v18 3/8] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric.

Quoted 1 line · Arnaldo Carvalho de Melo

On Mon, Aug 05, 2024 at 04:40:37PM -0300, Arnaldo Carvalho de Melo

Quoted 4 lines · wrote:
Quoted 4 lines · On Sat, Jul 20, 2024 at 02:20:56AM -0400, [email protected] wrote:
Quoted 3 lines

From: Weilin Wang <[email protected]>

When retire_latency value is used in a metric formula, evsel would fork a

perf

Quoted 1 line
Quoted 1 line
Quoted 1 line

record process with "-e" and "-W" options. Perf record will collect

required

Quoted 1 line
Quoted 1 line
Quoted 1 line

retire_latency values in parallel while perf stat is collecting counting

values.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

At the point of time that perf stat stops counting, evsel would stop perf

record

Quoted 1 line
Quoted 1 line
Quoted 1 line

by sending sigterm signal to perf record process. Sampled data will be

process

Quoted 1 line
Quoted 1 line
Quoted 1 line

to get retire latency value. Another thread is required to synchronize

between

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

perf stat and perf record when we pass data through pipe.

Retire_latency evsel is not opened for perf stat so that there is no counter wasted on it. This commit includes code suggested by Namhyung to

adjust reading

Quoted 6 lines
Quoted 6 lines
Quoted 1 line

size for groups that include retire_latency evsels.

Failing at this point:

⬢[acme@toolbox perf-tools-next]$ git log --oneline -5 13430131acc4f88b (HEAD) perf stat: Fork and launch perf record when

perf stat needs to get retire latency value for a metric.

Quoted 3 lines
Quoted 3 lines

b7b9adefb5d57aaf perf data: Allow to use given fd in data->file.fd 3a442bf266d1f3c7 perf parse-events: Add a retirement latency modifier ce533c9bc6deb125 (perf-tools-next.korg/tmp.perf-tools-next,

acme.korg/tmp.perf-tools-next) perf annotate: Add --skip-empty option

Quoted 11 lines
Quoted 1 line

bb588e38290fb723 perf annotate: Set al->data_nr using the notes->src-

nr_events

Quoted 5 lines

⬢[acme@toolbox perf-tools-next]$

I'll see if when a followup patch gets applied this gets solved, if so will try to fixup things or ask for help, since this seems to be breaking 'git bisect' for this codebase.

Indeed, when the next patch gets applied it builds without problems. I.e. patch 4/8 fixes problems in patch 3/8, maybe just combine them into one single patch?

Quoted 8 lines

I have everything in the tmp.perf-tools-next branch at:

https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git

I'll check later or tomorrow if I can fixup the bisection breakage described above or if just sqashing together 3/8 with 4/8 is better, please advise.

Squashing 3/8 and 4/8 looks good to me. We would then have all the major functions in one patch.

Thanks,
Weilin

Quoted 3 lines

Then I'll move it to the perf-tools-next branch.

- Arnaldo

#9 lore raw

RFC PATCH v18 4/8 perf stat: Plugin retire_lat value from sampled data to evsel

In reply to [email protected]

From: Weilin Wang <[email protected]>

In current :R parsing implementation, the parser would recognize events with retire_latency modifier and insert them into the evlist like a normal event. Ideally, we need to avoid counting these events.

In this commit, at the time when a retire_latency evsel is read, set the retire latency value processed from the sampled data to count value. This sampled retire latency value will be used for metric calculation and final event count print out. No special metric calculation and event print out code required for retire_latency events.

---
 tools/perf/arch/x86/util/evlist.c |  6 ++++++
 tools/perf/util/evsel.c           | 15 +++++++++++++++
 tools/perf/util/evsel.h           |  5 +++++
 3 files changed, 26 insertions(+)
tools/perf/arch/x86/util/evlist.c +6 -0
index b1ce0c52d88d..cebdd483149e 100644
@@ -89,6 +89,12 @@ int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs)
 			return 1;
 	}
 
+	/* Retire latency event should not be group leader*/
+	if (lhs->retire_lat && !rhs->retire_lat)
+		return 1;
+	if (!lhs->retire_lat && rhs->retire_lat)
+		return -1;
+
 	/* Default ordering by insertion index. */
 	return lhs->core.idx - rhs->core.idx;
 }
tools/perf/util/evsel.c +15 -0
index 1d000fa2c6cf..d607056b73c9 100644
@@ -59,6 +59,7 @@
 #include <internal/xyarray.h>
 #include <internal/lib.h>
 #include <internal/threadmap.h>
+#include "util/intel-tpebs.h"
 
 #include <linux/ctype.h>
 
@@ -1539,6 +1540,11 @@ static int evsel__read_one(struct evsel *evsel, int cpu_map_idx, int thread)
 	return perf_evsel__read(&evsel->core, cpu_map_idx, thread, count);
 }
 
+static int evsel__read_retire_lat(struct evsel *evsel, int cpu_map_idx, int thread)
+{
+	return tpebs_set_evsel(evsel, cpu_map_idx, thread);
+}
+
 static void evsel__set_count(struct evsel *counter, int cpu_map_idx, int thread,
 			     u64 val, u64 ena, u64 run, u64 lost)
 {
@@ -1546,6 +1552,12 @@ static void evsel__set_count(struct evsel *counter, int cpu_map_idx, int thread,
 
 	count = perf_counts(counter->counts, cpu_map_idx, thread);
 
+	if (counter->retire_lat) {
+		evsel__read_retire_lat(counter, cpu_map_idx, thread);
+		perf_counts__set_loaded(counter->counts, cpu_map_idx, thread, true);
+		return;
+	}
+
 	count->val    = val;
 	count->ena    = ena;
 	count->run    = run;
@@ -1838,6 +1850,9 @@ int evsel__read_counter(struct evsel *evsel, int cpu_map_idx, int thread)
 	if (evsel__is_tool(evsel))
 		return evsel__read_tool(evsel, cpu_map_idx, thread);
 
+	if (evsel__is_retire_lat(evsel))
+		return evsel__read_retire_lat(evsel, cpu_map_idx, thread);
+
 	if (evsel->core.attr.read_format & PERF_FORMAT_GROUP)
 		return evsel__read_group(evsel, cpu_map_idx, thread);
 
tools/perf/util/evsel.h +5 -0
index 14f777b9e03e..a5da4b03bb1c 100644
@@ -311,6 +311,11 @@ static inline bool evsel__is_tool(const struct evsel *evsel)
 	return evsel->tool_event != PERF_TOOL_NONE;
 }
 
+static inline bool evsel__is_retire_lat(const struct evsel *evsel)
+{
+	return evsel->retire_lat;
+}
+
 const char *evsel__group_name(struct evsel *evsel);
 int evsel__group_desc(struct evsel *evsel, char *buf, size_t size);
 
Signature · 1 line
2.43.0
#10 lore raw

RFC PATCH v18 5/8 perf vendor events intel: Add MTL metric json files

In reply to [email protected]

From: Weilin Wang <[email protected]>

Add MTL metric json file for TMA4.8. Some of the metrics' formulas use TPEBS retire_latency in MTL.

This also includes lated E-Core TMA3.6 changes.

---
 .../arch/x86/meteorlake/metricgroups.json     |  142 +
 .../arch/x86/meteorlake/mtl-metrics.json      | 2535 +++++++++++++++++
 2 files changed, 2677 insertions(+)
 create mode 100644 tools/perf/pmu-events/arch/x86/meteorlake/metricgroups.json
 create mode 100644 tools/perf/pmu-events/arch/x86/meteorlake/mtl-metrics.json
tools/perf/pmu-events/arch/x86/meteorlake/metricgroups.json new file +142 -0
new file mode 100644
index 000000000000..b54a5fc0861f
@@ -0,0 +1,142 @@
+{
+    "Backend": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Bad": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BadSpec": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BigFootprint": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BrMispredicts": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Branches": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BvBC": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BvBO": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BvCB": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BvFB": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BvIO": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BvMB": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BvML": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BvMP": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BvMS": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BvMT": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BvOB": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "BvUW": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "C0Wait": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "CacheHits": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "CacheMisses": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "CodeGen": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Compute": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Cor": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "DSB": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "DSBmiss": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "DataSharing": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Fed": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "FetchBW": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "FetchLat": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Flops": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "FpScalar": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "FpVector": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Frontend": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "HPC": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "IcMiss": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Ifetch": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "InsType": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "IntVector": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "L2Evicts": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "LSD": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Load_Store_Miss": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "MachineClears": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Machine_Clears": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Mem": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "MemOffcore": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Mem_Exec": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "MemoryBW": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "MemoryBound": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "MemoryLat": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "MemoryTLB": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Memory_BW": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Memory_Lat": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "MicroSeq": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "OS": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Offcore": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "PGO": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Pipeline": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "PortsUtil": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Power": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Prefetches": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Ret": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Retire": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "SMT": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Server": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Snoop": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "SoC": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "Summary": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "TmaL1": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "TmaL2": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "TmaL3mem": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "TopdownL1": "Metrics for top-down breakdown at level 1",
+    "TopdownL2": "Metrics for top-down breakdown at level 2",
+    "TopdownL3": "Metrics for top-down breakdown at level 3",
+    "TopdownL4": "Metrics for top-down breakdown at level 4",
+    "TopdownL5": "Metrics for top-down breakdown at level 5",
+    "TopdownL6": "Metrics for top-down breakdown at level 6",
+    "load_store_bound": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet",
+    "tma_L1_group": "Metrics for top-down breakdown at level 1",
+    "tma_L2_group": "Metrics for top-down breakdown at level 2",
+    "tma_L3_group": "Metrics for top-down breakdown at level 3",
+    "tma_L4_group": "Metrics for top-down breakdown at level 4",
+    "tma_L5_group": "Metrics for top-down breakdown at level 5",
+    "tma_L6_group": "Metrics for top-down breakdown at level 6",
+    "tma_alu_op_utilization_group": "Metrics contributing to tma_alu_op_utilization category",
+    "tma_assists_group": "Metrics contributing to tma_assists category",
+    "tma_backend_bound_group": "Metrics contributing to tma_backend_bound category",
+    "tma_bad_speculation_group": "Metrics contributing to tma_bad_speculation category",
+    "tma_branch_mispredicts_group": "Metrics contributing to tma_branch_mispredicts category",
+    "tma_branch_resteers_group": "Metrics contributing to tma_branch_resteers category",
+    "tma_core_bound_group": "Metrics contributing to tma_core_bound category",
+    "tma_dram_bound_group": "Metrics contributing to tma_dram_bound category",
+    "tma_dtlb_load_group": "Metrics contributing to tma_dtlb_load category",
+    "tma_dtlb_store_group": "Metrics contributing to tma_dtlb_store category",
+    "tma_fetch_bandwidth_group": "Metrics contributing to tma_fetch_bandwidth category",
+    "tma_fetch_latency_group": "Metrics contributing to tma_fetch_latency category",
+    "tma_fp_arith_group": "Metrics contributing to tma_fp_arith category",
+    "tma_fp_vector_group": "Metrics contributing to tma_fp_vector category",
+    "tma_frontend_bound_group": "Metrics contributing to tma_frontend_bound category",
+    "tma_heavy_operations_group": "Metrics contributing to tma_heavy_operations category",
+    "tma_ifetch_bandwidth_group": "Metrics contributing to tma_ifetch_bandwidth category",
+    "tma_ifetch_latency_group": "Metrics contributing to tma_ifetch_latency category",
+    "tma_int_operations_group": "Metrics contributing to tma_int_operations category",
+    "tma_issue2P": "Metrics related by the issue $issue2P",
+    "tma_issueBM": "Metrics related by the issue $issueBM",
+    "tma_issueBW": "Metrics related by the issue $issueBW",
+    "tma_issueComp": "Metrics related by the issue $issueComp",
+    "tma_issueD0": "Metrics related by the issue $issueD0",
+    "tma_issueFB": "Metrics related by the issue $issueFB",
+    "tma_issueFL": "Metrics related by the issue $issueFL",
+    "tma_issueL1": "Metrics related by the issue $issueL1",
+    "tma_issueLat": "Metrics related by the issue $issueLat",
+    "tma_issueMC": "Metrics related by the issue $issueMC",
+    "tma_issueMS": "Metrics related by the issue $issueMS",
+    "tma_issueMV": "Metrics related by the issue $issueMV",
+    "tma_issueRFO": "Metrics related by the issue $issueRFO",
+    "tma_issueSL": "Metrics related by the issue $issueSL",
+    "tma_issueSO": "Metrics related by the issue $issueSO",
+    "tma_issueSmSt": "Metrics related by the issue $issueSmSt",
+    "tma_issueSpSt": "Metrics related by the issue $issueSpSt",
+    "tma_issueSyncxn": "Metrics related by the issue $issueSyncxn",
+    "tma_issueTLB": "Metrics related by the issue $issueTLB",
+    "tma_l1_bound_group": "Metrics contributing to tma_l1_bound category",
+    "tma_l3_bound_group": "Metrics contributing to tma_l3_bound category",
+    "tma_light_operations_group": "Metrics contributing to tma_light_operations category",
+    "tma_load_op_utilization_group": "Metrics contributing to tma_load_op_utilization category",
+    "tma_machine_clears_group": "Metrics contributing to tma_machine_clears category",
+    "tma_mem_latency_group": "Metrics contributing to tma_mem_latency category",
+    "tma_memory_bound_group": "Metrics contributing to tma_memory_bound category",
+    "tma_microcode_sequencer_group": "Metrics contributing to tma_microcode_sequencer category",
+    "tma_mite_group": "Metrics contributing to tma_mite category",
+    "tma_other_light_ops_group": "Metrics contributing to tma_other_light_ops category",
+    "tma_ports_utilization_group": "Metrics contributing to tma_ports_utilization category",
+    "tma_ports_utilized_0_group": "Metrics contributing to tma_ports_utilized_0 category",
+    "tma_ports_utilized_3m_group": "Metrics contributing to tma_ports_utilized_3m category",
+    "tma_resource_bound_group": "Metrics contributing to tma_resource_bound category",
+    "tma_retiring_group": "Metrics contributing to tma_retiring category",
+    "tma_serializing_operation_group": "Metrics contributing to tma_serializing_operation category",
+    "tma_store_bound_group": "Metrics contributing to tma_store_bound category",
+    "tma_store_op_utilization_group": "Metrics contributing to tma_store_op_utilization category"
+}
tools/perf/pmu-events/arch/x86/meteorlake/mtl-metrics.json new file +2535 -0

2,535 lines not on this page · raw message

Signature · 1 line
2.43.0
#11 lore raw

RFC PATCH v18 6/8 perf stat: Add command line option for enabling tpebs recording

In reply to [email protected]

From: Weilin Wang <[email protected]>

With this command line option, tpebs recording is turned off in perf stat on default. It will only be turned on when this option is given in perf stat command.

Exampe with --record-tpebs:

perf stat -M tma_split_loads -C1-4 --record-tpebs sleep 1

[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 0.044 MB - ]

Performance counter stats for 'CPU(s) 1-4':

    53,259,156,071      cpu_core/TOPDOWN.SLOTS/          #      1.6 %  tma_split_loads          (50.00%)
    15,867,565,250      cpu_core/topdown-retiring/                                              (50.00%)
    15,655,580,731      cpu_core/topdown-mem-bound/                                             (50.00%)
    11,738,022,218      cpu_core/topdown-bad-spec/                                              (50.00%)
     6,151,265,424      cpu_core/topdown-fe-bound/                                              (50.00%)
    20,445,917,581      cpu_core/topdown-be-bound/                                              (50.00%)
     6,925,098,013      cpu_core/L1D_PEND_MISS.PENDING/                                         (50.00%)
     3,838,653,421      cpu_core/MEMORY_ACTIVITY.STALLS_L1D_MISS/                                        (50.00%)
     4,797,059,783      cpu_core/EXE_ACTIVITY.BOUND_ON_LOADS/                                        (50.00%)
    11,931,916,714      cpu_core/CPU_CLK_UNHALTED.THREAD/                                        (50.00%)
       102,576,164      cpu_core/MEM_LOAD_COMPLETED.L1_MISS_ANY/                                        (50.00%)
        64,071,854      cpu_core/MEM_INST_RETIRED.SPLIT_LOADS/                                        (50.00%)
                 3      cpu_core/MEM_INST_RETIRED.SPLIT_LOADS/R
       1.003049679 seconds time elapsed

Exampe without --record-tpebs:

perf stat -M tma_contested_accesses -C1 sleep 1

Performance counter stats for 'CPU(s) 1':

        50,203,891      cpu_core/TOPDOWN.SLOTS/          #      0.0 %  tma_contested_accesses   (63.60%)
        10,040,777      cpu_core/topdown-retiring/                                              (63.60%)
         6,890,729      cpu_core/topdown-mem-bound/                                             (63.60%)
         2,756,463      cpu_core/topdown-bad-spec/                                              (63.60%)
        10,828,288      cpu_core/topdown-fe-bound/                                              (63.60%)
        28,350,432      cpu_core/topdown-be-bound/                                              (63.60%)
                98      cpu_core/OCR.DEMAND_DATA_RD.L3_HIT.SNOOP_HITM/                                        (63.70%)
           577,520      cpu_core/MEMORY_ACTIVITY.STALLS_L2_MISS/                                        (54.62%)
           313,339      cpu_core/MEMORY_ACTIVITY.STALLS_L3_MISS/                                        (54.62%)
            14,155      cpu_core/MEM_LOAD_RETIRED.L1_MISS/                                        (45.54%)
                 0      cpu_core/OCR.DEMAND_DATA_RD.L3_HIT.SNOOP_HIT_WITH_FWD/                                        (36.30%)
         8,468,077      cpu_core/CPU_CLK_UNHALTED.THREAD/                                        (45.38%)
               198      cpu_core/MEM_LOAD_L3_HIT_RETIRED.XSNP_MISS/                                        (45.38%)
             8,324      cpu_core/MEM_LOAD_RETIRED.FB_HIT/                                        (45.38%)
     3,388,031,520      TSC
        23,226,785      cpu_core/CPU_CLK_UNHALTED.REF_TSC/                                        (54.46%)
                80      cpu_core/MEM_LOAD_L3_HIT_RETIRED.XSNP_FWD/                                        (54.46%)
                 0      cpu_core/MEM_LOAD_L3_HIT_RETIRED.XSNP_FWD/R
                 0      cpu_core/MEM_LOAD_L3_HIT_RETIRED.XSNP_MISS/R
     1,006,816,667 ns   duration_time
       1.002537737 seconds time elapsed
---
 tools/perf/Documentation/perf-stat.txt | 8 ++++++++
 tools/perf/builtin-stat.c              | 4 ++++
 2 files changed, 12 insertions(+)
tools/perf/Documentation/perf-stat.txt +8 -0
index 29756a87ab6f..2bc063672486 100644
@@ -498,6 +498,14 @@ To interpret the results it is usually needed to know on which
 CPUs the workload runs on. If needed the CPUs can be forced using
 taskset.
 
+--record-tpebs::
+Enable automatic sampling on Intel TPEBS retire_latency events (event with :R
+modifier). Without this option, perf would not capture dynamic retire_latency
+at runtime. Currently, a zero value is assigned to the retire_latency event when
+this option is not set. The TPEBS hardware feature starts from Intel Granite
+Rapids microarchitecture. This option only exists in X86_64 and is meaningful on
+Intel platforms with TPEBS feature.
+
 --td-level::
 Print the top-down statistics that equal the input level. It allows
 users to print the interested top-down metrics level instead of the
tools/perf/builtin-stat.c +4 -0
index 68125bd75b37..935386a02e78 100644
@@ -2475,6 +2475,10 @@ int cmd_stat(int argc, const char **argv)
 			"disable adding events for the metric threshold calculation"),
 		OPT_BOOLEAN(0, "topdown", &topdown_run,
 			"measure top-down statistics"),
+#ifdef HAVE_ARCH_X86_64_SUPPORT
+		OPT_BOOLEAN(0, "record-tpebs", &tpebs_recording,
+			"enable recording for tpebs when retire_latency required"),
+#endif
 		OPT_UINTEGER(0, "td-level", &stat_config.topdown_level,
 			"Set the metrics level for the top-down statistics (0: max level)"),
 		OPT_BOOLEAN(0, "smi-cost", &smi_cost,
Signature · 1 line
2.43.0
#12 lore raw

RFC PATCH v18 7/8 perf Document: Add TPEBS to Documents

In reply to [email protected]

From: Weilin Wang <[email protected]>

TPEBS is a new feature Intel PMU from Granite Rapids microarchitecture. It will be used in new TMA releases. Adding related introduction to documents while adding new code to support it in perf stat.

---
 tools/perf/Documentation/perf-list.txt |  1 +
 tools/perf/Documentation/topdown.txt   | 30 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)
tools/perf/Documentation/perf-list.txt +1 -0
index 6bf2468f59d3..dea005410ec0 100644
@@ -72,6 +72,7 @@ counted. The following modifiers exist:
  W - group is weak and will fallback to non-group if not schedulable,
  e - group or event are exclusive and do not share the PMU
  b - use BPF aggregration (see perf stat --bpf-counters)
+ R - retire latency value of the event
 
 The 'p' modifier can be used for specifying how precise the instruction
 address should be. The 'p' modifier can be specified multiple times:
tools/perf/Documentation/topdown.txt +30 -0
index ae0aee86844f..5c17fff694ee 100644
@@ -325,6 +325,36 @@ other four level 2 metrics by subtracting corresponding metrics as below.
     Fetch_Bandwidth = Frontend_Bound - Fetch_Latency
     Core_Bound = Backend_Bound - Memory_Bound
 
+TPEBS in TopDown
+================
+
+TPEBS (Timed PEBS) is one of the new Intel PMU features provided since Granite
+Rapids microarchitecture. The TPEBS feature adds a 16 bit retire_latency field
+in the Basic Info group of the PEBS record. It records the Core cycles since the
+retirement of the previous instruction to the retirement of current instruction.
+Please refer to Section 8.4.1 of "Intel® Architecture Instruction Set Extensions
+Programming Reference" for more details about this feature. Because this feature
+extends PEBS record, sampling with weight option is required to get the
+retire_latency value.
+
+	perf record -e event_name -W ...
+
+In the most recent release of TMA, the metrics begin to use event retire_latency
+values in some of the metrics’ formulas on processors that support TPEBS feature.
+For previous generations that do not support TPEBS, the values are static and
+predefined per processor family by the hardware architects. Due to the diversity
+of workloads in execution environments, retire_latency values measured at real
+time are more accurate. Therefore, new TMA metrics that use TPEBS will provide
+more accurate performance analysis results.
+
+To support TPEBS in TMA metrics, a new modifier :R on event is added. Perf would
+capture retire_latency value of required events(event with :R in metric formula)
+with perf record. The retire_latency value would be used in metric calculation.
+Currently, this feature is supported through perf stat
+
+	perf stat -M metric_name --record-tpebs ...
+
+
 
 [1] https://software.intel.com/en-us/top-down-microarchitecture-analysis-method-win
 [2] https://sites.google.com/site/analysismethods/yasin-pubs
Signature · 1 line
2.43.0
#13 lore raw

RFC PATCH v18 8/8 perf test: Add test for Intel TPEBS counting mode

In reply to [email protected]

From: Weilin Wang <[email protected]>

Intel TPEBS sampling mode is supported through perf record. The counting mode code uses perf record to capture retire_latency value and use it in metric calculation. This test checks the counting mode code on Intel platforms.

---
 .../perf/tests/shell/test_stat_intel_tpebs.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100755 tools/perf/tests/shell/test_stat_intel_tpebs.sh
tools/perf/tests/shell/test_stat_intel_tpebs.sh new file +19 -0
new file mode 100755
index 000000000000..c60b29add980
@@ -0,0 +1,19 @@
+#!/bin/bash
+# test Intel TPEBS counting mode
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
+
+# Use this event for testing because it should exist in all platforms
+event=cache-misses:R
+
+# Without this cmd option, default value or zero is returned
+echo "Testing without --record-tpebs"
+result=$(perf stat -e "$event" true 2>&1)
+[[ "$result" =~ $event ]] || exit 1
+
+# In platforms that do not support TPEBS, it should execute without error.
+echo "Testing with --record-tpebs"
+result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
+[[ "$result" =~ "perf record" && "$result" =~ $event ]] || exit 1
Signature · 1 line
2.43.0
#14 lore raw

Re: [RFC PATCH v18 8/8] perf test: Add test for Intel TPEBS counting mode

Quoted 5 lines · On Sat, Jul 20, 2024 at 02:21:01AM -0400, [email protected] wrote:

From: Weilin Wang <[email protected]>

Intel TPEBS sampling mode is supported through perf record. The counting mode code uses perf record to capture retire_latency value and use it in metric calculation. This test checks the counting mode code on Intel platforms.

root@x1:~# perf test -vvvvv 123
123: test Intel TPEBS counting mode:
--- start ---
test child forked, pid 2600160
Testing without --record-tpebs
Testing with --record-tpebs
---- end(-1) ----
123: test Intel TPEBS counting mode                                  : FAILED!
root@x1:~# grep -m1 "model name" /proc/cpuinfo 
model name	: 13th Gen Intel(R) Core(TM) i7-1365U
root@x1:~#

What am I missing?

The current codebase is in tmp.perf-tools-next

- Arnaldo

Quoted 34 lines
---
 .../perf/tests/shell/test_stat_intel_tpebs.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100755 tools/perf/tests/shell/test_stat_intel_tpebs.sh
tools/perf/tests/shell/test_stat_intel_tpebs.sh new file +19 -0
new file mode 100755
index 000000000000..c60b29add980
@@ -0,0 +1,19 @@
+#!/bin/bash
+# test Intel TPEBS counting mode
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
+
+# Use this event for testing because it should exist in all platforms
+event=cache-misses:R
+
+# Without this cmd option, default value or zero is returned
+echo "Testing without --record-tpebs"
+result=$(perf stat -e "$event" true 2>&1)
+[[ "$result" =~ $event ]] || exit 1
+
+# In platforms that do not support TPEBS, it should execute without error.
+echo "Testing with --record-tpebs"
+result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
+[[ "$result" =~ "perf record" && "$result" =~ $event ]] || exit 1
Signature · 1 line
2.43.0
#15 lore raw

Re: [RFC PATCH v18 8/8] perf test: Add test for Intel TPEBS counting mode

Quoted 19 lines · Arnaldo Carvalho de Melo
Quoted 5 lines · On Sat, Jul 20, 2024 at 02:21:01AM -0400, [email protected] wrote:

From: Weilin Wang <[email protected]>

Intel TPEBS sampling mode is supported through perf record. The counting mode code uses perf record to capture retire_latency value and use it in metric calculation. This test checks the counting mode code on Intel platforms.

root@x1:~# perf test -vvvvv 123
123: test Intel TPEBS counting mode:
--- start ---
test child forked, pid 2600160
Testing without --record-tpebs
Testing with --record-tpebs
---- end(-1) ----
123: test Intel TPEBS counting mode                                  : FAILED!
root@x1:~# grep -m1 "model name" /proc/cpuinfo 
model name	: 13th Gen Intel(R) Core(TM) i7-1365U
root@x1:~#
Quoted 3 lines

What am I missing?

The current codebase is in tmp.perf-tools-next

acme@x1:~/git/perf-tools-next$ uname -a
Linux x1 6.8.11-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Sun May 26 20:05:41 UTC 2024 x86_64 GNU/Linux
Quoted 36 lines

- Arnaldo

Quoted 34 lines
---
 .../perf/tests/shell/test_stat_intel_tpebs.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100755 tools/perf/tests/shell/test_stat_intel_tpebs.sh
tools/perf/tests/shell/test_stat_intel_tpebs.sh new file +19 -0
new file mode 100755
index 000000000000..c60b29add980
@@ -0,0 +1,19 @@
+#!/bin/bash
+# test Intel TPEBS counting mode
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
+
+# Use this event for testing because it should exist in all platforms
+event=cache-misses:R
+
+# Without this cmd option, default value or zero is returned
+echo "Testing without --record-tpebs"
+result=$(perf stat -e "$event" true 2>&1)
+[[ "$result" =~ $event ]] || exit 1
+
+# In platforms that do not support TPEBS, it should execute without error.
+echo "Testing with --record-tpebs"
+result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
+[[ "$result" =~ "perf record" && "$result" =~ $event ]] || exit 1
Signature · 1 line
2.43.0
#16 lore raw

RE: [RFC PATCH v18 8/8] perf test: Add test for Intel TPEBS counting mode

Quoted 39 lines

-----Original Message-----
From: Arnaldo Carvalho de Melo <[email protected]>
Sent: Monday, August 12, 2024 6:26 PM
To: Wang, Weilin <[email protected]>
Cc: Namhyung Kim <[email protected]>; Ian Rogers <[email protected]>; Peter Zijlstra <[email protected]>; Ingo Molnar <[email protected]>; Alexander Shishkin <[email protected]>; Jiri Olsa <[email protected]>; Hunter, Adrian <[email protected]>; Kan Liang <[email protected]>; [email protected]; [email protected]; Taylor, Perry <[email protected]>; Alt, Samantha <[email protected]>; Biggers, Caleb <[email protected]>
Subject: Re: [RFC PATCH v18 8/8] perf test: Add test for Intel TPEBS counting mode

Quoted 4 lines · Arnaldo Carvalho de Melo
Quoted 3 lines · On Sat, Jul 20, 2024 at 02:21:01AM -0400, [email protected] wrote:

From: Weilin Wang <[email protected]>

Intel TPEBS sampling mode is supported through perf record. The counting

mode

Quoted 15 lines
Quoted 2 lines

code uses perf record to capture retire_latency value and use it in metric calculation. This test checks the counting mode code on Intel platforms.

root@x1:~# perf test -vvvvv 123
123: test Intel TPEBS counting mode:
--- start ---
test child forked, pid 2600160
Testing without --record-tpebs
Testing with --record-tpebs
---- end(-1) ----
123: test Intel TPEBS counting mode                                  : FAILED!
root@x1:~# grep -m1 "model name" /proc/cpuinfo
model name	: 13th Gen Intel(R) Core(TM) i7-1365U
root@x1:~#
Quoted 8 lines
Quoted 3 lines

What am I missing?

The current codebase is in tmp.perf-tools-next

acme@x1:~/git/perf-tools-next$ uname -a
Linux x1 6.8.11-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Sun May 26
20:05:41 UTC 2024 x86_64 GNU/Linux

Hi Arnaldo,
I just checkout the code and tested it. The failure is caused by a seg fault on a perf_tool struct that is not initialized correctly. I think this is related to the patches on struct perf_tool in this branch that applied right before the tpebs patches.

I was able to fix the seg fault by adding the perf_tool__fill_defaults() back. Since Ian updated the code to replace this function, I think I need some advice on how to use the new code to initialize perf_tool correctly here. Should I call the perf_tool__init()?

Thanks,
Weilin

Quoted 37 lines
Quoted 9 lines

- Arnaldo

Review

Quoted 7 lines
---
 .../perf/tests/shell/test_stat_intel_tpebs.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100755 tools/perf/tests/shell/test_stat_intel_tpebs.sh
(quoted diff) +0 -0

b/tools/perf/tests/shell/test_stat_intel_tpebs.sh

Quoted 27 lines
Quoted 27 lines

new file mode 100755
index 000000000000..c60b29add980

tools/perf/tests/shell/test_stat_intel_tpebs.sh new file +19 -1
@@ -0,0 +1,19 @@
+#!/bin/bash
+# test Intel TPEBS counting mode
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
+
+# Use this event for testing because it should exist in all platforms
+event=cache-misses:R
+
+# Without this cmd option, default value or zero is returned
+echo "Testing without --record-tpebs"
+result=$(perf stat -e "$event" true 2>&1)
+[[ "$result" =~ $event ]] || exit 1
+
+# In platforms that do not support TPEBS, it should execute without error.
+echo "Testing with --record-tpebs"
+result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
+[[ "$result" =~ "perf record" && "$result" =~ $event ]] || exit 1
--

2.43.0

reviewer
#17 lore raw

Re: [RFC PATCH v18 8/8] perf test: Add test for Intel TPEBS counting mode

Quoted 54 lines · Weilin
Quoted 40 lines

-----Original Message-----
From: Arnaldo Carvalho de Melo <[email protected]>
Sent: Monday, August 12, 2024 6:26 PM
To: Wang, Weilin <[email protected]>
Cc: Namhyung Kim <[email protected]>; Ian Rogers <[email protected]>; Peter Zijlstra <[email protected]>; Ingo Molnar <[email protected]>; Alexander Shishkin <[email protected]>; Jiri Olsa <[email protected]>; Hunter, Adrian <[email protected]>; Kan Liang <[email protected]>; [email protected]; [email protected]; Taylor, Perry <[email protected]>; Alt, Samantha <[email protected]>; Biggers, Caleb <[email protected]>
Subject: Re: [RFC PATCH v18 8/8] perf test: Add test for Intel TPEBS counting mode

Quoted 4 lines · Arnaldo Carvalho de Melo
Quoted 3 lines · On Sat, Jul 20, 2024 at 02:21:01AM -0400, [email protected] wrote:

From: Weilin Wang <[email protected]>

Intel TPEBS sampling mode is supported through perf record. The counting

mode

Quoted 15 lines
Quoted 2 lines

code uses perf record to capture retire_latency value and use it in metric calculation. This test checks the counting mode code on Intel platforms.

root@x1:~# perf test -vvvvv 123
123: test Intel TPEBS counting mode:
--- start ---
test child forked, pid 2600160
Testing without --record-tpebs
Testing with --record-tpebs
---- end(-1) ----
123: test Intel TPEBS counting mode                                  : FAILED!
root@x1:~# grep -m1 "model name" /proc/cpuinfo
model name  : 13th Gen Intel(R) Core(TM) i7-1365U
root@x1:~#
Quoted 8 lines
Quoted 3 lines

What am I missing?

The current codebase is in tmp.perf-tools-next

acme@x1:~/git/perf-tools-next$ uname -a
Linux x1 6.8.11-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Sun May 26
20:05:41 UTC 2024 x86_64 GNU/Linux

Hi Arnaldo,
I just checkout the code and tested it. The failure is caused by a seg fault on a perf_tool struct that is not initialized correctly. I think this is related to the patches on struct perf_tool in this branch that applied right before the tpebs patches.

Quoted 4 lines

I was able to fix the seg fault by adding the perf_tool__fill_defaults() back. Since Ian updated the code to replace this function, I think I need some advice on how to use the new code to initialize perf_tool correctly here. Should I call the perf_tool__init()?

Yep. If you've added or refactored a tool struct the intent now is that you call perf_tool__init then override the functions you want to override. I don't mind to rebase those changes over your changes, Arnaldo if you want to drop those changes.

Thanks,
Ian

Quoted 43 lines

Thanks,
Weilin

Quoted 37 lines
Quoted 9 lines

- Arnaldo

Review

Quoted 7 lines
---
 .../perf/tests/shell/test_stat_intel_tpebs.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100755 tools/perf/tests/shell/test_stat_intel_tpebs.sh
(quoted diff) +0 -0

b/tools/perf/tests/shell/test_stat_intel_tpebs.sh

Quoted 27 lines
Quoted 27 lines

new file mode 100755
index 000000000000..c60b29add980

tools/perf/tests/shell/test_stat_intel_tpebs.sh new file +19 -1
@@ -0,0 +1,19 @@
+#!/bin/bash
+# test Intel TPEBS counting mode
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+grep -q GenuineIntel /proc/cpuinfo || { echo Skipping non-Intel; exit 2; }
+
+# Use this event for testing because it should exist in all platforms
+event=cache-misses:R
+
+# Without this cmd option, default value or zero is returned
+echo "Testing without --record-tpebs"
+result=$(perf stat -e "$event" true 2>&1)
+[[ "$result" =~ $event ]] || exit 1
+
+# In platforms that do not support TPEBS, it should execute without error.
+echo "Testing with --record-tpebs"
+result=$(perf stat -e "$event" --record-tpebs -a sleep 0.01 2>&1)
+[[ "$result" =~ "perf record" && "$result" =~ $event ]] || exit 1
--

2.43.0

#18 lore raw

Re: [RFC PATCH v18 8/8] perf test: Add test for Intel TPEBS counting mode

Quoted 10 lines · Ian Rogers
Quoted 8 lines · Weilin

I just checkout the code and tested it. The failure is caused by a seg fault on a perf_tool struct that is not initialized correctly. I think this is related to the patches on struct perf_tool in this branch that applied right before the tpebs patches.

I was able to fix the seg fault by adding the perf_tool__fill_defaults() back. Since Ian updated the code to replace this function, I think I need some advice on how to use the new code to initialize perf_tool correctly here. Should I call the perf_tool__init()?

Quoted 4 lines

Yep. If you've added or refactored a tool struct the intent now is that you call perf_tool__init then override the functions you want to override. I don't mind to rebase those changes over your changes, Arnaldo if you want to drop those changes.

So I'm adding the patch below, which should be enough, right?

Now:

root@x1:~# perf test tpebs
123: test Intel TPEBS counting mode                                  : Ok
root@x1:~# set -o vi
root@x1:~# perf test tpebs
123: test Intel TPEBS counting mode                                  : Ok
root@x1:~# perf test -v tpebs
123: test Intel TPEBS counting mode                                  : Ok
root@x1:~# perf test -vvv tpebs
123: test Intel TPEBS counting mode:
--- start ---
test child forked, pid 16603
Testing without --record-tpebs
Testing with --record-tpebs
---- end(0) ----
123: test Intel TPEBS counting mode                                  : Ok
root@x1:~#
tools/perf/util/intel-tpebs.c +6 -5
index 3729caeba645a3e8..50a3c3e0716065f8 100644
@@ -164,11 +164,12 @@ static void *__sample_reader(void *arg)
 		.path = PERF_DATA,
 		.file.fd = child->out,
 	};
-	struct perf_tool tool = {
-		.sample = process_sample_event,
-		.feature = process_feature_event,
-		.attr = perf_event__process_attr,
-	};
+	struct perf_tool tool;
+
+	perf_tool__init(&tool, /*ordered_events=*/false);
+	tool.sample = process_sample_event;
+	tool.feature = process_feature_event;
+	tool.attr = perf_event__process_attr;
 
 	session = perf_session__new(&data, &tool);
 	if (IS_ERR(session))

Thanks for root causing, my mistake,

- Arnaldo

#19 lore raw

Re: [RFC PATCH v18 8/8] perf test: Add test for Intel TPEBS counting mode

Quoted 11 lines · Arnaldo Carvalho de Melo
Quoted 9 lines · Ian Rogers
Quoted 8 lines · Weilin

I just checkout the code and tested it. The failure is caused by a seg fault on a perf_tool struct that is not initialized correctly. I think this is related to the patches on struct perf_tool in this branch that applied right before the tpebs patches.

I was able to fix the seg fault by adding the perf_tool__fill_defaults() back. Since Ian updated the code to replace this function, I think I need some advice on how to use the new code to initialize perf_tool correctly here. Should I call the perf_tool__init()?

Quoted 6 lines
Quoted 4 lines

Yep. If you've added or refactored a tool struct the intent now is that you call perf_tool__init then override the functions you want to override. I don't mind to rebase those changes over your changes, Arnaldo if you want to drop those changes.

So I'm adding the patch below, which should be enough, right?

Everything is in tmp.perf-tools-next, will move to perf-tools-next at the end of the day/early tomorrow, after the container build tests finish.

- Arnaldo

maintainer Reviewed-by on the v18 series
#20 lore raw
In reply to [email protected]

Hello Weilin,

Quoted 177 lines · On Fri, Jul 19, 2024 at 11:21 PM <[email protected]> wrote:

From: Weilin Wang <[email protected]>

Change in v18:
- Update to exit 2 in TPEBS shell test when not on Intel platform.
- Several updates to use EVLIST_CTL_CMD_ENABLE_TAG, EVLIST_CTL_CMD_ACK_TAG, and etc.

Changes in v17:
- Add a poll on control fifo ack_fd to ensure program returns successfully when perf record failed for any reason.
- Add a check in the tpebs test to only run on Intel platforms.

Changes in v16:
- Update tpebs bash test code and variable name.
- Add a check to ensure only use "-C" option when cpumap is not "-1" when forking "perf record".

Changes in v15:
- Revert changes added for python import test failure in v14 because the code works correctly with the new python build code.
- Update the command line option to --record-tpebs.

Changes in v14:
- Fix the python import test failure. We cannot support PYTHON_PERF because it will trigger a chain of dependency issues if we add intel-tpebs.c to it. So, only enable tpebs functions in evsel and evlist when PYTHON_PERF is not defined.
- Fix shellcheck warning for the tpebs test.

Changes in v13:
- Add document for the command line option and fix build error in non-x86_64.
- Update example with non-zero retire_latency value when tpebs recording is enabled.
- Add tpebs_stop() back to tpebs_set_evsel() because in hybrid platform, when the forked perf record is not killed, the reader thread does not get any sampled data from the PIPE. As a result, tpebs_set_evesel() will always return zero on retire_latency values. This does not happen on my test GNR machine. Since -I is not supported yet, I think we should add tpebs_stop() to ensure correctness for now. More investigation is required here when we work on supporting -I mode.
- Rebase code on top of perf-tools-next.

Changes in v12:
- Update MTL metric JSON file to include E-Core TMA3.6 changes.
- Update comments and code for better code quality. Keep tpebs_start() and tpebs_delete() at evsel level for now and add comments on these functions with more details about potential future changes. Remove tpebs_stop() call from tpebs_set_evsel(). Simplify the tpebs_start() and tpebs_stop()/tpebs_delete() interfaces. Also fixed the bugs on not freed "new" pointer and the incorrect variable value assignment to val instead of counter->val.

Changes in v11:
- Make retire_latency evsels not opened for counting. This works correctly now with the code Namhyung suggested that adjusting group read size when retire_latency evsels included in the group.
- Update retire_latency value assignment using rint() to reduce precision loss while keeping code generic.
- Fix the build error caused by not used variable in the test.

Other changes in v10:
- Change perf record fork from perf stat to evsel. All the major operations like tpebs start, stop, read_evsel should directly work through evsel.
- Make intel-tpebs x86_64 only. This change is cross-compiled to arm64.
- Put tpebs code to intel-tepbs and simplify intel-tpebs APIs to minimum number
of functions and variables. Update funtion name and variable names to use consistent prefix. Also improve error handling.
- Integrate code patch from Ian for the :R parser.
- Update MTL metrics to TMA 4.8.

V9: https://lore.kernel.org/all/[email protected]/

Changes in v9:
- Update the retire_latency result print and metric calculation method. Plugin
the value to evsel so that no special code is required.
- Update --control:fifo to use pipe instead of named pipe.
- Add test for TPEBS counting mode.
- Update Document with more details.

Changes in v8:
- In this revision, the code is updated to base on Ian's patch on R modifier
parser https://lore.kernel.org/lkml/[email protected]/
After this change, there is no special code required for R modifier in metricgroup.c and metricgroup.h files.

Caveat of this change:
Ideally, we will need to add special handling to skip counting events with R
modifier in evsel. Currently, this is not implemented so the event with :R will be both counted and sampled. Usually, in a metric formula that uses retire_latency, it would already require to count the event. As a result, we will endup count the same event twice. This should be able to be handled properly when we finalize our design on evsel R modifier support.

- Move TPEBS specific code out from main perf stat code to separate files in
util/intel-tpebs.c and util/intel-tpebs.h. [Namhyung]
- Use --control:fifo to ack perf stat from forked perf record instead of sleep(2) [Namhyung]
- Add introductions about TPEBS and R modifier in Documents. [Namhyung]

Changes in v7:
- Update code and comments for better code quality [Namhyung]
- Add a separate commit for perf data [Namhyung]
- Update retire latency print function to improve alignment [Namhyung]

Changes in v6:
- Update code and add comments for better code quality [Namhyung]
- Remove the added fd var and directly pass the opened fd to data.file.fd [Namhyung]
- Add kill() to stop perf record when perf stat exists early [Namhyung]
- Add command opt check to ensure only start perf record when -a/-C given [Namhyung]
- Squash commits [Namhyung]

Changes in v5:
- Update code and add comments for better code quality [Ian]

Changes in v4:
- Remove uncessary debug print and update code and comments for better
readability and quality [Namhyung]
- Update mtl metric json file with consistent TmaL1 and TopdownL1 metricgroup

Changes in v3:
- Remove ':' when event name has '@' [Ian]
- Use 'R' as the modifier instead of "retire_latency" [Ian]

Changes in v2:
- Add MTL metric file
- Add more descriptions and example to the patch [Arnaldo]

Here is an example of running perf stat to collect a metric that uses retire_latency value of event MEM_INST_RETIRED.STLB_HIT_STORES on a MTL system.

In this simple example, there is no MEM_INST_RETIRED.STLB_HIT_STORES sample. Therefore, the MEM_INST_RETIRED.STLB_HIT_STORES:p count and retire_latency value are all 0.

./perf stat -M tma_dtlb_store -a -- sleep 1

[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]

Performance counter stats for 'system wide':

       181,047,168      cpu_core/TOPDOWN.SLOTS/          #      0.6 %  tma_dtlb_store
         3,195,608      cpu_core/topdown-retiring/
        40,156,649      cpu_core/topdown-mem-bound/
         3,550,925      cpu_core/topdown-bad-spec/
       117,571,818      cpu_core/topdown-fe-bound/
        57,118,087      cpu_core/topdown-be-bound/
            69,179      cpu_core/EXE_ACTIVITY.BOUND_ON_STORES/
             4,582      cpu_core/MEM_INST_RETIRED.STLB_HIT_STORES/
        30,183,104      cpu_core/CPU_CLK_UNHALTED.DISTRIBUTED/
        30,556,790      cpu_core/CPU_CLK_UNHALTED.THREAD/
           168,486      cpu_core/DTLB_STORE_MISSES.WALK_ACTIVE/

0.00 MEM_INST_RETIRED.STLB_HIT_STORES:p 0 0

1.003105924 seconds time elapsed

v1:
TPEBS is one of the features provided by the next generation of Intel PMU. Please refer to Section 8.4.1 of "Intel® Architecture Instruction Set Extensions Programming Reference" [1] for more details about this feature.

This set of patches supports TPEBS in counting mode. The code works in the following way: it forks a perf record process from perf stat when retire_latency of one or more events are used in a metric formula. Perf stat would send a SIGTERM signal to perf record before it needs the retire latency value for metric calculation. Perf stat will then process sample data to extract the retire latency data for metric calculations. Currently, the code uses the arithmetic average of retire latency values.

[1] https://www.intel.com/content/www/us/en/content-details/812218/intel-architecture-instruction-set-extensions-programming-reference.html?wapkw=future%20features

Ian Rogers (1):
perf parse-events: Add a retirement latency modifier

Quoted 9 lines

Weilin Wang (7):
perf data: Allow to use given fd in data->file.fd
perf stat: Fork and launch perf record when perf stat needs to get
retire latency value for a metric.
perf stat: Plugin retire_lat value from sampled data to evsel perf vendor events intel: Add MTL metric json files perf stat: Add command line option for enabling tpebs recording perf Document: Add TPEBS to Documents
perf test: Add test for Intel TPEBS counting mode

Thanks for your persistence!

Thanks,
Namhyung

Quoted 29 lines
 tools/perf/Documentation/perf-list.txt        |    1 +
 tools/perf/Documentation/perf-stat.txt        |    8 +
 tools/perf/Documentation/topdown.txt          |   30 +
 tools/perf/arch/x86/util/evlist.c             |    6 +
 tools/perf/builtin-stat.c                     |    8 +
 .../arch/x86/meteorlake/metricgroups.json     |  142 +
 .../arch/x86/meteorlake/mtl-metrics.json      | 2535 +++++++++++++++++
 .../perf/tests/shell/test_stat_intel_tpebs.sh |   19 +
 tools/perf/util/Build                         |    1 +
 tools/perf/util/data.c                        |    7 +-
 tools/perf/util/evlist.c                      |    2 +
 tools/perf/util/evsel.c                       |   81 +-
 tools/perf/util/evsel.h                       |    6 +
 tools/perf/util/intel-tpebs.c                 |  431 +++
 tools/perf/util/intel-tpebs.h                 |   35 +
 tools/perf/util/parse-events.c                |    2 +
 tools/perf/util/parse-events.h                |    1 +
 tools/perf/util/parse-events.l                |    3 +-
 18 files changed, 3314 insertions(+), 4 deletions(-)
 create mode 100644 tools/perf/pmu-events/arch/x86/meteorlake/metricgroups.json
 create mode 100644 tools/perf/pmu-events/arch/x86/meteorlake/mtl-metrics.json
 create mode 100755 tools/perf/tests/shell/test_stat_intel_tpebs.sh
 create mode 100644 tools/perf/util/intel-tpebs.c
 create mode 100644 tools/perf/util/intel-tpebs.h

--
2.43.0

reviewer
#21 lore raw
Quoted 191 lines · Namhyung Kim

Hello Weilin,

Quoted 177 lines · On Fri, Jul 19, 2024 at 11:21 PM <[email protected]> wrote:

From: Weilin Wang <[email protected]>

Change in v18:
- Update to exit 2 in TPEBS shell test when not on Intel platform.
- Several updates to use EVLIST_CTL_CMD_ENABLE_TAG, EVLIST_CTL_CMD_ACK_TAG, and etc.

Changes in v17:
- Add a poll on control fifo ack_fd to ensure program returns successfully when perf record failed for any reason.
- Add a check in the tpebs test to only run on Intel platforms.

Changes in v16:
- Update tpebs bash test code and variable name.
- Add a check to ensure only use "-C" option when cpumap is not "-1" when forking "perf record".

Changes in v15:
- Revert changes added for python import test failure in v14 because the code works correctly with the new python build code.
- Update the command line option to --record-tpebs.

Changes in v14:
- Fix the python import test failure. We cannot support PYTHON_PERF because it will trigger a chain of dependency issues if we add intel-tpebs.c to it. So, only enable tpebs functions in evsel and evlist when PYTHON_PERF is not defined.
- Fix shellcheck warning for the tpebs test.

Changes in v13:
- Add document for the command line option and fix build error in non-x86_64.
- Update example with non-zero retire_latency value when tpebs recording is enabled.
- Add tpebs_stop() back to tpebs_set_evsel() because in hybrid platform, when the forked perf record is not killed, the reader thread does not get any sampled data from the PIPE. As a result, tpebs_set_evesel() will always return zero on retire_latency values. This does not happen on my test GNR machine. Since -I is not supported yet, I think we should add tpebs_stop() to ensure correctness for now. More investigation is required here when we work on supporting -I mode.
- Rebase code on top of perf-tools-next.

Changes in v12:
- Update MTL metric JSON file to include E-Core TMA3.6 changes.
- Update comments and code for better code quality. Keep tpebs_start() and tpebs_delete() at evsel level for now and add comments on these functions with more details about potential future changes. Remove tpebs_stop() call from tpebs_set_evsel(). Simplify the tpebs_start() and tpebs_stop()/tpebs_delete() interfaces. Also fixed the bugs on not freed "new" pointer and the incorrect variable value assignment to val instead of counter->val.

Changes in v11:
- Make retire_latency evsels not opened for counting. This works correctly now with the code Namhyung suggested that adjusting group read size when retire_latency evsels included in the group.
- Update retire_latency value assignment using rint() to reduce precision loss while keeping code generic.
- Fix the build error caused by not used variable in the test.

Other changes in v10:
- Change perf record fork from perf stat to evsel. All the major operations like tpebs start, stop, read_evsel should directly work through evsel.
- Make intel-tpebs x86_64 only. This change is cross-compiled to arm64.
- Put tpebs code to intel-tepbs and simplify intel-tpebs APIs to minimum number
of functions and variables. Update funtion name and variable names to use consistent prefix. Also improve error handling.
- Integrate code patch from Ian for the :R parser.
- Update MTL metrics to TMA 4.8.

V9: https://lore.kernel.org/all/[email protected]/

Changes in v9:
- Update the retire_latency result print and metric calculation method. Plugin
the value to evsel so that no special code is required.
- Update --control:fifo to use pipe instead of named pipe.
- Add test for TPEBS counting mode.
- Update Document with more details.

Changes in v8:
- In this revision, the code is updated to base on Ian's patch on R modifier
parser https://lore.kernel.org/lkml/[email protected]/
After this change, there is no special code required for R modifier in metricgroup.c and metricgroup.h files.

Caveat of this change:
Ideally, we will need to add special handling to skip counting events with R
modifier in evsel. Currently, this is not implemented so the event with :R will be both counted and sampled. Usually, in a metric formula that uses retire_latency, it would already require to count the event. As a result, we will endup count the same event twice. This should be able to be handled properly when we finalize our design on evsel R modifier support.

- Move TPEBS specific code out from main perf stat code to separate files in
util/intel-tpebs.c and util/intel-tpebs.h. [Namhyung]
- Use --control:fifo to ack perf stat from forked perf record instead of sleep(2) [Namhyung]
- Add introductions about TPEBS and R modifier in Documents. [Namhyung]

Changes in v7:
- Update code and comments for better code quality [Namhyung]
- Add a separate commit for perf data [Namhyung]
- Update retire latency print function to improve alignment [Namhyung]

Changes in v6:
- Update code and add comments for better code quality [Namhyung]
- Remove the added fd var and directly pass the opened fd to data.file.fd [Namhyung]
- Add kill() to stop perf record when perf stat exists early [Namhyung]
- Add command opt check to ensure only start perf record when -a/-C given [Namhyung]
- Squash commits [Namhyung]

Changes in v5:
- Update code and add comments for better code quality [Ian]

Changes in v4:
- Remove uncessary debug print and update code and comments for better
readability and quality [Namhyung]
- Update mtl metric json file with consistent TmaL1 and TopdownL1 metricgroup

Changes in v3:
- Remove ':' when event name has '@' [Ian]
- Use 'R' as the modifier instead of "retire_latency" [Ian]

Changes in v2:
- Add MTL metric file
- Add more descriptions and example to the patch [Arnaldo]

Here is an example of running perf stat to collect a metric that uses retire_latency value of event MEM_INST_RETIRED.STLB_HIT_STORES on a MTL system.

In this simple example, there is no MEM_INST_RETIRED.STLB_HIT_STORES sample. Therefore, the MEM_INST_RETIRED.STLB_HIT_STORES:p count and retire_latency value are all 0.

./perf stat -M tma_dtlb_store -a -- sleep 1

[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]

Performance counter stats for 'system wide':

       181,047,168      cpu_core/TOPDOWN.SLOTS/          #      0.6 %  tma_dtlb_store
         3,195,608      cpu_core/topdown-retiring/
        40,156,649      cpu_core/topdown-mem-bound/
         3,550,925      cpu_core/topdown-bad-spec/
       117,571,818      cpu_core/topdown-fe-bound/
        57,118,087      cpu_core/topdown-be-bound/
            69,179      cpu_core/EXE_ACTIVITY.BOUND_ON_STORES/
             4,582      cpu_core/MEM_INST_RETIRED.STLB_HIT_STORES/
        30,183,104      cpu_core/CPU_CLK_UNHALTED.DISTRIBUTED/
        30,556,790      cpu_core/CPU_CLK_UNHALTED.THREAD/
           168,486      cpu_core/DTLB_STORE_MISSES.WALK_ACTIVE/

0.00 MEM_INST_RETIRED.STLB_HIT_STORES:p 0 0

1.003105924 seconds time elapsed

v1:
TPEBS is one of the features provided by the next generation of Intel PMU. Please refer to Section 8.4.1 of "Intel® Architecture Instruction Set Extensions Programming Reference" [1] for more details about this feature.

This set of patches supports TPEBS in counting mode. The code works in the following way: it forks a perf record process from perf stat when retire_latency of one or more events are used in a metric formula. Perf stat would send a SIGTERM signal to perf record before it needs the retire latency value for metric calculation. Perf stat will then process sample data to extract the retire latency data for metric calculations. Currently, the code uses the arithmetic average of retire latency values.

[1] https://www.intel.com/content/www/us/en/content-details/812218/intel-architecture-instruction-set-extensions-programming-reference.html?wapkw=future%20features

Ian Rogers (1):
perf parse-events: Add a retirement latency modifier

Quoted 9 lines

Weilin Wang (7):
perf data: Allow to use given fd in data->file.fd
perf stat: Fork and launch perf record when perf stat needs to get
retire latency value for a metric.
perf stat: Plugin retire_lat value from sampled data to evsel perf vendor events intel: Add MTL metric json files perf stat: Add command line option for enabling tpebs recording perf Document: Add TPEBS to Documents
perf test: Add test for Intel TPEBS counting mode

Quoted 3 lines

Thanks for your persistence!

Ping.

Thanks,
Ian

#22 lore raw
Quoted 192 lines · Ian Rogers
Quoted 191 lines · Namhyung Kim

Hello Weilin,

Quoted 186 lines · On Fri, Jul 19, 2024 at 11:21 PM <[email protected]> wrote:

From: Weilin Wang <[email protected]>

Change in v18:
- Update to exit 2 in TPEBS shell test when not on Intel platform.
- Several updates to use EVLIST_CTL_CMD_ENABLE_TAG, EVLIST_CTL_CMD_ACK_TAG, and etc.

Changes in v17:
- Add a poll on control fifo ack_fd to ensure program returns successfully when perf record failed for any reason.
- Add a check in the tpebs test to only run on Intel platforms.

Changes in v16:
- Update tpebs bash test code and variable name.
- Add a check to ensure only use "-C" option when cpumap is not "-1" when forking "perf record".

Changes in v15:
- Revert changes added for python import test failure in v14 because the code works correctly with the new python build code.
- Update the command line option to --record-tpebs.

Changes in v14:
- Fix the python import test failure. We cannot support PYTHON_PERF because it will trigger a chain of dependency issues if we add intel-tpebs.c to it. So, only enable tpebs functions in evsel and evlist when PYTHON_PERF is not defined.
- Fix shellcheck warning for the tpebs test.

Changes in v13:
- Add document for the command line option and fix build error in non-x86_64.
- Update example with non-zero retire_latency value when tpebs recording is enabled.
- Add tpebs_stop() back to tpebs_set_evsel() because in hybrid platform, when the forked perf record is not killed, the reader thread does not get any sampled data from the PIPE. As a result, tpebs_set_evesel() will always return zero on retire_latency values. This does not happen on my test GNR machine. Since -I is not supported yet, I think we should add tpebs_stop() to ensure correctness for now. More investigation is required here when we work on supporting -I mode.
- Rebase code on top of perf-tools-next.

Changes in v12:
- Update MTL metric JSON file to include E-Core TMA3.6 changes.
- Update comments and code for better code quality. Keep tpebs_start() and tpebs_delete() at evsel level for now and add comments on these functions with more details about potential future changes. Remove tpebs_stop() call from tpebs_set_evsel(). Simplify the tpebs_start() and tpebs_stop()/tpebs_delete() interfaces. Also fixed the bugs on not freed "new" pointer and the incorrect variable value assignment to val instead of counter->val.

Changes in v11:
- Make retire_latency evsels not opened for counting. This works correctly now with the code Namhyung suggested that adjusting group read size when retire_latency evsels included in the group.
- Update retire_latency value assignment using rint() to reduce precision loss while keeping code generic.
- Fix the build error caused by not used variable in the test.

Other changes in v10:
- Change perf record fork from perf stat to evsel. All the major operations like tpebs start, stop, read_evsel should directly work through evsel.
- Make intel-tpebs x86_64 only. This change is cross-compiled to arm64.
- Put tpebs code to intel-tepbs and simplify intel-tpebs APIs to minimum number
of functions and variables. Update funtion name and variable names to use consistent prefix. Also improve error handling.
- Integrate code patch from Ian for the :R parser.
- Update MTL metrics to TMA 4.8.

V9: https://lore.kernel.org/all/[email protected]/

Changes in v9:
- Update the retire_latency result print and metric calculation method. Plugin
the value to evsel so that no special code is required.
- Update --control:fifo to use pipe instead of named pipe.
- Add test for TPEBS counting mode.
- Update Document with more details.

Changes in v8:
- In this revision, the code is updated to base on Ian's patch on R modifier
parser https://lore.kernel.org/lkml/[email protected]/
After this change, there is no special code required for R modifier in metricgroup.c and metricgroup.h files.

Caveat of this change:
Ideally, we will need to add special handling to skip counting events with R
modifier in evsel. Currently, this is not implemented so the event with :R will be both counted and sampled. Usually, in a metric formula that uses retire_latency, it would already require to count the event. As a result, we will endup count the same event twice. This should be able to be handled properly when we finalize our design on evsel R modifier support.

- Move TPEBS specific code out from main perf stat code to separate files in
util/intel-tpebs.c and util/intel-tpebs.h. [Namhyung]
- Use --control:fifo to ack perf stat from forked perf record instead of sleep(2) [Namhyung]
- Add introductions about TPEBS and R modifier in Documents. [Namhyung]

Changes in v7:
- Update code and comments for better code quality [Namhyung]
- Add a separate commit for perf data [Namhyung]
- Update retire latency print function to improve alignment [Namhyung]

Changes in v6:
- Update code and add comments for better code quality [Namhyung]
- Remove the added fd var and directly pass the opened fd to data.file.fd [Namhyung]
- Add kill() to stop perf record when perf stat exists early [Namhyung]
- Add command opt check to ensure only start perf record when -a/-C given [Namhyung]
- Squash commits [Namhyung]

Changes in v5:
- Update code and add comments for better code quality [Ian]

Changes in v4:
- Remove uncessary debug print and update code and comments for better
readability and quality [Namhyung]
- Update mtl metric json file with consistent TmaL1 and TopdownL1 metricgroup

Changes in v3:
- Remove ':' when event name has '@' [Ian]
- Use 'R' as the modifier instead of "retire_latency" [Ian]

Changes in v2:
- Add MTL metric file
- Add more descriptions and example to the patch [Arnaldo]

Here is an example of running perf stat to collect a metric that uses retire_latency value of event MEM_INST_RETIRED.STLB_HIT_STORES on a MTL system.

In this simple example, there is no MEM_INST_RETIRED.STLB_HIT_STORES sample. Therefore, the MEM_INST_RETIRED.STLB_HIT_STORES:p count and retire_latency value are all 0.

./perf stat -M tma_dtlb_store -a -- sleep 1

[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]

Performance counter stats for 'system wide':

       181,047,168      cpu_core/TOPDOWN.SLOTS/          #      0.6 %  tma_dtlb_store
         3,195,608      cpu_core/topdown-retiring/
        40,156,649      cpu_core/topdown-mem-bound/
         3,550,925      cpu_core/topdown-bad-spec/
       117,571,818      cpu_core/topdown-fe-bound/
        57,118,087      cpu_core/topdown-be-bound/
            69,179      cpu_core/EXE_ACTIVITY.BOUND_ON_STORES/
             4,582      cpu_core/MEM_INST_RETIRED.STLB_HIT_STORES/
        30,183,104      cpu_core/CPU_CLK_UNHALTED.DISTRIBUTED/
        30,556,790      cpu_core/CPU_CLK_UNHALTED.THREAD/
           168,486      cpu_core/DTLB_STORE_MISSES.WALK_ACTIVE/

0.00 MEM_INST_RETIRED.STLB_HIT_STORES:p 0 0

1.003105924 seconds time elapsed

v1:
TPEBS is one of the features provided by the next generation of Intel PMU. Please refer to Section 8.4.1 of "Intel® Architecture Instruction Set Extensions Programming Reference" [1] for more details about this feature.

This set of patches supports TPEBS in counting mode. The code works in the following way: it forks a perf record process from perf stat when retire_latency of one or more events are used in a metric formula. Perf stat would send a SIGTERM signal to perf record before it needs the retire latency value for metric calculation. Perf stat will then process sample data to extract the retire latency data for metric calculations. Currently, the code uses the arithmetic average of retire latency values.

[1] https://www.intel.com/content/www/us/en/content-details/812218/intel-architecture-instruction-set-extensions-programming-reference.html?wapkw=future%20features

Ian Rogers (1):
perf parse-events: Add a retirement latency modifier

Weilin Wang (7):
perf data: Allow to use given fd in data->file.fd
perf stat: Fork and launch perf record when perf stat needs to get
retire latency value for a metric.
perf stat: Plugin retire_lat value from sampled data to evsel perf vendor events intel: Add MTL metric json files perf stat: Add command line option for enabling tpebs recording perf Document: Add TPEBS to Documents
perf test: Add test for Intel TPEBS counting mode

Quoted 5 lines
Quoted 3 lines

Thanks for your persistence!

Ping.

I guess Namhyung's reviewed-by should suffice, but since you're pinging and I saw previous comments about this serie, would it be possible to get your Reviewed-by as well?

Thanks,

- Arnaldo

reviewer
#23 lore raw
Quoted 196 lines · Arnaldo Carvalho de Melo
Quoted 194 lines · Ian Rogers
Quoted 193 lines · Namhyung Kim

Hello Weilin,

Quoted 177 lines · On Fri, Jul 19, 2024 at 11:21 PM <[email protected]> wrote:

From: Weilin Wang <[email protected]>

Change in v18:
- Update to exit 2 in TPEBS shell test when not on Intel platform.
- Several updates to use EVLIST_CTL_CMD_ENABLE_TAG, EVLIST_CTL_CMD_ACK_TAG, and etc.

Changes in v17:
- Add a poll on control fifo ack_fd to ensure program returns successfully when perf record failed for any reason.
- Add a check in the tpebs test to only run on Intel platforms.

Changes in v16:
- Update tpebs bash test code and variable name.
- Add a check to ensure only use "-C" option when cpumap is not "-1" when forking "perf record".

Changes in v15:
- Revert changes added for python import test failure in v14 because the code works correctly with the new python build code.
- Update the command line option to --record-tpebs.

Changes in v14:
- Fix the python import test failure. We cannot support PYTHON_PERF because it will trigger a chain of dependency issues if we add intel-tpebs.c to it. So, only enable tpebs functions in evsel and evlist when PYTHON_PERF is not defined.
- Fix shellcheck warning for the tpebs test.

Changes in v13:
- Add document for the command line option and fix build error in non-x86_64.
- Update example with non-zero retire_latency value when tpebs recording is enabled.
- Add tpebs_stop() back to tpebs_set_evsel() because in hybrid platform, when the forked perf record is not killed, the reader thread does not get any sampled data from the PIPE. As a result, tpebs_set_evesel() will always return zero on retire_latency values. This does not happen on my test GNR machine. Since -I is not supported yet, I think we should add tpebs_stop() to ensure correctness for now. More investigation is required here when we work on supporting -I mode.
- Rebase code on top of perf-tools-next.

Changes in v12:
- Update MTL metric JSON file to include E-Core TMA3.6 changes.
- Update comments and code for better code quality. Keep tpebs_start() and tpebs_delete() at evsel level for now and add comments on these functions with more details about potential future changes. Remove tpebs_stop() call from tpebs_set_evsel(). Simplify the tpebs_start() and tpebs_stop()/tpebs_delete() interfaces. Also fixed the bugs on not freed "new" pointer and the incorrect variable value assignment to val instead of counter->val.

Changes in v11:
- Make retire_latency evsels not opened for counting. This works correctly now with the code Namhyung suggested that adjusting group read size when retire_latency evsels included in the group.
- Update retire_latency value assignment using rint() to reduce precision loss while keeping code generic.
- Fix the build error caused by not used variable in the test.

Other changes in v10:
- Change perf record fork from perf stat to evsel. All the major operations like tpebs start, stop, read_evsel should directly work through evsel.
- Make intel-tpebs x86_64 only. This change is cross-compiled to arm64.
- Put tpebs code to intel-tepbs and simplify intel-tpebs APIs to minimum number
of functions and variables. Update funtion name and variable names to use consistent prefix. Also improve error handling.
- Integrate code patch from Ian for the :R parser.
- Update MTL metrics to TMA 4.8.

V9: https://lore.kernel.org/all/[email protected]/

Changes in v9:
- Update the retire_latency result print and metric calculation method. Plugin
the value to evsel so that no special code is required.
- Update --control:fifo to use pipe instead of named pipe.
- Add test for TPEBS counting mode.
- Update Document with more details.

Changes in v8:
- In this revision, the code is updated to base on Ian's patch on R modifier
parser https://lore.kernel.org/lkml/[email protected]/
After this change, there is no special code required for R modifier in metricgroup.c and metricgroup.h files.

Caveat of this change:
Ideally, we will need to add special handling to skip counting events with R
modifier in evsel. Currently, this is not implemented so the event with :R will be both counted and sampled. Usually, in a metric formula that uses retire_latency, it would already require to count the event. As a result, we will endup count the same event twice. This should be able to be handled properly when we finalize our design on evsel R modifier support.

- Move TPEBS specific code out from main perf stat code to separate files in
util/intel-tpebs.c and util/intel-tpebs.h. [Namhyung]
- Use --control:fifo to ack perf stat from forked perf record instead of sleep(2) [Namhyung]
- Add introductions about TPEBS and R modifier in Documents. [Namhyung]

Changes in v7:
- Update code and comments for better code quality [Namhyung]
- Add a separate commit for perf data [Namhyung]
- Update retire latency print function to improve alignment [Namhyung]

Changes in v6:
- Update code and add comments for better code quality [Namhyung]
- Remove the added fd var and directly pass the opened fd to data.file.fd [Namhyung]
- Add kill() to stop perf record when perf stat exists early [Namhyung]
- Add command opt check to ensure only start perf record when -a/-C given [Namhyung]
- Squash commits [Namhyung]

Changes in v5:
- Update code and add comments for better code quality [Ian]

Changes in v4:
- Remove uncessary debug print and update code and comments for better
readability and quality [Namhyung]
- Update mtl metric json file with consistent TmaL1 and TopdownL1 metricgroup

Changes in v3:
- Remove ':' when event name has '@' [Ian]
- Use 'R' as the modifier instead of "retire_latency" [Ian]

Changes in v2:
- Add MTL metric file
- Add more descriptions and example to the patch [Arnaldo]

Here is an example of running perf stat to collect a metric that uses retire_latency value of event MEM_INST_RETIRED.STLB_HIT_STORES on a MTL system.

In this simple example, there is no MEM_INST_RETIRED.STLB_HIT_STORES sample. Therefore, the MEM_INST_RETIRED.STLB_HIT_STORES:p count and retire_latency value are all 0.

./perf stat -M tma_dtlb_store -a -- sleep 1

[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]

Performance counter stats for 'system wide':

       181,047,168      cpu_core/TOPDOWN.SLOTS/          #      0.6 %  tma_dtlb_store
         3,195,608      cpu_core/topdown-retiring/
        40,156,649      cpu_core/topdown-mem-bound/
         3,550,925      cpu_core/topdown-bad-spec/
       117,571,818      cpu_core/topdown-fe-bound/
        57,118,087      cpu_core/topdown-be-bound/
            69,179      cpu_core/EXE_ACTIVITY.BOUND_ON_STORES/
             4,582      cpu_core/MEM_INST_RETIRED.STLB_HIT_STORES/
        30,183,104      cpu_core/CPU_CLK_UNHALTED.DISTRIBUTED/
        30,556,790      cpu_core/CPU_CLK_UNHALTED.THREAD/
           168,486      cpu_core/DTLB_STORE_MISSES.WALK_ACTIVE/

0.00 MEM_INST_RETIRED.STLB_HIT_STORES:p 0 0

1.003105924 seconds time elapsed

v1:
TPEBS is one of the features provided by the next generation of Intel PMU. Please refer to Section 8.4.1 of "Intel® Architecture Instruction Set Extensions Programming Reference" [1] for more details about this feature.

This set of patches supports TPEBS in counting mode. The code works in the following way: it forks a perf record process from perf stat when retire_latency of one or more events are used in a metric formula. Perf stat would send a SIGTERM signal to perf record before it needs the retire latency value for metric calculation. Perf stat will then process sample data to extract the retire latency data for metric calculations. Currently, the code uses the arithmetic average of retire latency values.

[1] https://www.intel.com/content/www/us/en/content-details/812218/intel-architecture-instruction-set-extensions-programming-reference.html?wapkw=future%20features

Ian Rogers (1):
perf parse-events: Add a retirement latency modifier

Quoted 9 lines

Weilin Wang (7):
perf data: Allow to use given fd in data->file.fd
perf stat: Fork and launch perf record when perf stat needs to get
retire latency value for a metric.
perf stat: Plugin retire_lat value from sampled data to evsel perf vendor events intel: Add MTL metric json files perf stat: Add command line option for enabling tpebs recording perf Document: Add TPEBS to Documents
perf test: Add test for Intel TPEBS counting mode

Thanks for your persistence!

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Ping.

I guess Namhyung's reviewed-by should suffice, but since you're pinging and I saw previous comments about this serie, would it be possible to get your Reviewed-by as well?

I'm happy with most of the changes and they can have my reviewed-by. I'm not happy with:
perf stat: Fork and launch 'perf record' when 'perf stat' needs to get retire latency value for a metric.
so please leave it off there.

Context: originally the patches aimed to abstract everything inside of the evsel, now builtin-stat is manually starting and ending the sub-process and has to be aware of TPEBS. There are ugly architectural dependencies. My reviewed-by was correct on the earlier version, as you could make a tpebs evsel just like any... other, open, close, read it, etc. This would be useful say in a python script. This version to my eyes is worse as all TPEBS dependencies are made explicit and the caller needs to be aware of TPEBS. I understand Weilin was asked to make some of the changes, and there was a desire for efficiency, but I think things were better in earlier versions.

Thanks,
Ian

#24 lore raw
Quoted 200 lines · Ian Rogers
Quoted 198 lines · Arnaldo Carvalho de Melo
Quoted 196 lines · Ian Rogers
Quoted 194 lines · Namhyung Kim

Hello Weilin,

Quoted 177 lines · On Fri, Jul 19, 2024 at 11:21 PM <[email protected]> wrote:

From: Weilin Wang <[email protected]>

Change in v18:
- Update to exit 2 in TPEBS shell test when not on Intel platform.
- Several updates to use EVLIST_CTL_CMD_ENABLE_TAG, EVLIST_CTL_CMD_ACK_TAG, and etc.

Changes in v17:
- Add a poll on control fifo ack_fd to ensure program returns successfully when perf record failed for any reason.
- Add a check in the tpebs test to only run on Intel platforms.

Changes in v16:
- Update tpebs bash test code and variable name.
- Add a check to ensure only use "-C" option when cpumap is not "-1" when forking "perf record".

Changes in v15:
- Revert changes added for python import test failure in v14 because the code works correctly with the new python build code.
- Update the command line option to --record-tpebs.

Changes in v14:
- Fix the python import test failure. We cannot support PYTHON_PERF because it will trigger a chain of dependency issues if we add intel-tpebs.c to it. So, only enable tpebs functions in evsel and evlist when PYTHON_PERF is not defined.
- Fix shellcheck warning for the tpebs test.

Changes in v13:
- Add document for the command line option and fix build error in non-x86_64.
- Update example with non-zero retire_latency value when tpebs recording is enabled.
- Add tpebs_stop() back to tpebs_set_evsel() because in hybrid platform, when the forked perf record is not killed, the reader thread does not get any sampled data from the PIPE. As a result, tpebs_set_evesel() will always return zero on retire_latency values. This does not happen on my test GNR machine. Since -I is not supported yet, I think we should add tpebs_stop() to ensure correctness for now. More investigation is required here when we work on supporting -I mode.
- Rebase code on top of perf-tools-next.

Changes in v12:
- Update MTL metric JSON file to include E-Core TMA3.6 changes.
- Update comments and code for better code quality. Keep tpebs_start() and tpebs_delete() at evsel level for now and add comments on these functions with more details about potential future changes. Remove tpebs_stop() call from tpebs_set_evsel(). Simplify the tpebs_start() and tpebs_stop()/tpebs_delete() interfaces. Also fixed the bugs on not freed "new" pointer and the incorrect variable value assignment to val instead of counter->val.

Changes in v11:
- Make retire_latency evsels not opened for counting. This works correctly now with the code Namhyung suggested that adjusting group read size when retire_latency evsels included in the group.
- Update retire_latency value assignment using rint() to reduce precision loss while keeping code generic.
- Fix the build error caused by not used variable in the test.

Other changes in v10:
- Change perf record fork from perf stat to evsel. All the major operations like tpebs start, stop, read_evsel should directly work through evsel.
- Make intel-tpebs x86_64 only. This change is cross-compiled to arm64.
- Put tpebs code to intel-tepbs and simplify intel-tpebs APIs to minimum number
of functions and variables. Update funtion name and variable names to use consistent prefix. Also improve error handling.
- Integrate code patch from Ian for the :R parser.
- Update MTL metrics to TMA 4.8.

V9: https://lore.kernel.org/all/[email protected]/

Changes in v9:
- Update the retire_latency result print and metric calculation method. Plugin
the value to evsel so that no special code is required.
- Update --control:fifo to use pipe instead of named pipe.
- Add test for TPEBS counting mode.
- Update Document with more details.

Changes in v8:
- In this revision, the code is updated to base on Ian's patch on R modifier
parser https://lore.kernel.org/lkml/[email protected]/
After this change, there is no special code required for R modifier in metricgroup.c and metricgroup.h files.

Caveat of this change:
Ideally, we will need to add special handling to skip counting events with R
modifier in evsel. Currently, this is not implemented so the event with :R will be both counted and sampled. Usually, in a metric formula that uses retire_latency, it would already require to count the event. As a result, we will endup count the same event twice. This should be able to be handled properly when we finalize our design on evsel R modifier support.

- Move TPEBS specific code out from main perf stat code to separate files in
util/intel-tpebs.c and util/intel-tpebs.h. [Namhyung]
- Use --control:fifo to ack perf stat from forked perf record instead of sleep(2) [Namhyung]
- Add introductions about TPEBS and R modifier in Documents. [Namhyung]

Changes in v7:
- Update code and comments for better code quality [Namhyung]
- Add a separate commit for perf data [Namhyung]
- Update retire latency print function to improve alignment [Namhyung]

Changes in v6:
- Update code and add comments for better code quality [Namhyung]
- Remove the added fd var and directly pass the opened fd to data.file.fd [Namhyung]
- Add kill() to stop perf record when perf stat exists early [Namhyung]
- Add command opt check to ensure only start perf record when -a/-C given [Namhyung]
- Squash commits [Namhyung]

Changes in v5:
- Update code and add comments for better code quality [Ian]

Changes in v4:
- Remove uncessary debug print and update code and comments for better
readability and quality [Namhyung]
- Update mtl metric json file with consistent TmaL1 and TopdownL1 metricgroup

Changes in v3:
- Remove ':' when event name has '@' [Ian]
- Use 'R' as the modifier instead of "retire_latency" [Ian]

Changes in v2:
- Add MTL metric file
- Add more descriptions and example to the patch [Arnaldo]

Here is an example of running perf stat to collect a metric that uses retire_latency value of event MEM_INST_RETIRED.STLB_HIT_STORES on a MTL system.

In this simple example, there is no MEM_INST_RETIRED.STLB_HIT_STORES sample. Therefore, the MEM_INST_RETIRED.STLB_HIT_STORES:p count and retire_latency value are all 0.

./perf stat -M tma_dtlb_store -a -- sleep 1

[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]

Performance counter stats for 'system wide':

       181,047,168      cpu_core/TOPDOWN.SLOTS/          #      0.6 %  tma_dtlb_store
         3,195,608      cpu_core/topdown-retiring/
        40,156,649      cpu_core/topdown-mem-bound/
         3,550,925      cpu_core/topdown-bad-spec/
       117,571,818      cpu_core/topdown-fe-bound/
        57,118,087      cpu_core/topdown-be-bound/
            69,179      cpu_core/EXE_ACTIVITY.BOUND_ON_STORES/
             4,582      cpu_core/MEM_INST_RETIRED.STLB_HIT_STORES/
        30,183,104      cpu_core/CPU_CLK_UNHALTED.DISTRIBUTED/
        30,556,790      cpu_core/CPU_CLK_UNHALTED.THREAD/
           168,486      cpu_core/DTLB_STORE_MISSES.WALK_ACTIVE/

0.00 MEM_INST_RETIRED.STLB_HIT_STORES:p 0 0

1.003105924 seconds time elapsed

v1:
TPEBS is one of the features provided by the next generation of Intel PMU. Please refer to Section 8.4.1 of "Intel® Architecture Instruction Set Extensions Programming Reference" [1] for more details about this feature.

This set of patches supports TPEBS in counting mode. The code works in the following way: it forks a perf record process from perf stat when retire_latency of one or more events are used in a metric formula. Perf stat would send a SIGTERM signal to perf record before it needs the retire latency value for metric calculation. Perf stat will then process sample data to extract the retire latency data for metric calculations. Currently, the code uses the arithmetic average of retire latency values.

[1] https://www.intel.com/content/www/us/en/content-details/812218/intel-architecture-instruction-set-extensions-programming-reference.html?wapkw=future%20features

Ian Rogers (1):
perf parse-events: Add a retirement latency modifier

Quoted 9 lines

Weilin Wang (7):
perf data: Allow to use given fd in data->file.fd
perf stat: Fork and launch perf record when perf stat needs to get
retire latency value for a metric.
perf stat: Plugin retire_lat value from sampled data to evsel perf vendor events intel: Add MTL metric json files perf stat: Add command line option for enabling tpebs recording perf Document: Add TPEBS to Documents
perf test: Add test for Intel TPEBS counting mode

Thanks for your persistence!

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Ping.

I guess Namhyung's reviewed-by should suffice, but since you're pinging and I saw previous comments about this serie, would it be possible to get your Reviewed-by as well?

I'm happy with most of the changes and they can have my reviewed-by.

Thanks.

Quoted 3 lines

I'm not happy with:
perf stat: Fork and launch 'perf record' when 'perf stat' needs to get retire latency value for a metric.

I don't like it either, but I couldn't find the time to engage in this discussion to try to offer an alternative patch and since Namhyung had provided his reviewed-by and you pinged me, I felt compelled to move forward on this.

Quoted 1 line

so please leave it off there.

So, what are you proposing, that we process up to some patch?

For now I'm removing the whole series from perf-tools-next.

- Arnaldo

Quoted 13 lines

Context: originally the patches aimed to abstract everything inside of the evsel, now builtin-stat is manually starting and ending the sub-process and has to be aware of TPEBS. There are ugly architectural dependencies. My reviewed-by was correct on the earlier version, as you could make a tpebs evsel just like any... other, open, close, read it, etc. This would be useful say in a python script. This version to my eyes is worse as all TPEBS dependencies are made explicit and the caller needs to be aware of TPEBS. I understand Weilin was asked to make some of the changes, and there was a desire for efficiency, but I think things were better in earlier versions.

Thanks,
Ian

reviewer
#25 lore raw
Quoted 212 lines · Arnaldo Carvalho de Melo
Quoted 200 lines · Ian Rogers
Quoted 198 lines · Arnaldo Carvalho de Melo
Quoted 196 lines · Ian Rogers
Quoted 194 lines · Namhyung Kim

Hello Weilin,

Quoted 177 lines · On Fri, Jul 19, 2024 at 11:21 PM <[email protected]> wrote:

From: Weilin Wang <[email protected]>

Change in v18:
- Update to exit 2 in TPEBS shell test when not on Intel platform.
- Several updates to use EVLIST_CTL_CMD_ENABLE_TAG, EVLIST_CTL_CMD_ACK_TAG, and etc.

Changes in v17:
- Add a poll on control fifo ack_fd to ensure program returns successfully when perf record failed for any reason.
- Add a check in the tpebs test to only run on Intel platforms.

Changes in v16:
- Update tpebs bash test code and variable name.
- Add a check to ensure only use "-C" option when cpumap is not "-1" when forking "perf record".

Changes in v15:
- Revert changes added for python import test failure in v14 because the code works correctly with the new python build code.
- Update the command line option to --record-tpebs.

Changes in v14:
- Fix the python import test failure. We cannot support PYTHON_PERF because it will trigger a chain of dependency issues if we add intel-tpebs.c to it. So, only enable tpebs functions in evsel and evlist when PYTHON_PERF is not defined.
- Fix shellcheck warning for the tpebs test.

Changes in v13:
- Add document for the command line option and fix build error in non-x86_64.
- Update example with non-zero retire_latency value when tpebs recording is enabled.
- Add tpebs_stop() back to tpebs_set_evsel() because in hybrid platform, when the forked perf record is not killed, the reader thread does not get any sampled data from the PIPE. As a result, tpebs_set_evesel() will always return zero on retire_latency values. This does not happen on my test GNR machine. Since -I is not supported yet, I think we should add tpebs_stop() to ensure correctness for now. More investigation is required here when we work on supporting -I mode.
- Rebase code on top of perf-tools-next.

Changes in v12:
- Update MTL metric JSON file to include E-Core TMA3.6 changes.
- Update comments and code for better code quality. Keep tpebs_start() and tpebs_delete() at evsel level for now and add comments on these functions with more details about potential future changes. Remove tpebs_stop() call from tpebs_set_evsel(). Simplify the tpebs_start() and tpebs_stop()/tpebs_delete() interfaces. Also fixed the bugs on not freed "new" pointer and the incorrect variable value assignment to val instead of counter->val.

Changes in v11:
- Make retire_latency evsels not opened for counting. This works correctly now with the code Namhyung suggested that adjusting group read size when retire_latency evsels included in the group.
- Update retire_latency value assignment using rint() to reduce precision loss while keeping code generic.
- Fix the build error caused by not used variable in the test.

Other changes in v10:
- Change perf record fork from perf stat to evsel. All the major operations like tpebs start, stop, read_evsel should directly work through evsel.
- Make intel-tpebs x86_64 only. This change is cross-compiled to arm64.
- Put tpebs code to intel-tepbs and simplify intel-tpebs APIs to minimum number
of functions and variables. Update funtion name and variable names to use consistent prefix. Also improve error handling.
- Integrate code patch from Ian for the :R parser.
- Update MTL metrics to TMA 4.8.

V9: https://lore.kernel.org/all/[email protected]/

Changes in v9:
- Update the retire_latency result print and metric calculation method. Plugin
the value to evsel so that no special code is required.
- Update --control:fifo to use pipe instead of named pipe.
- Add test for TPEBS counting mode.
- Update Document with more details.

Changes in v8:
- In this revision, the code is updated to base on Ian's patch on R modifier
parser https://lore.kernel.org/lkml/[email protected]/
After this change, there is no special code required for R modifier in metricgroup.c and metricgroup.h files.

Caveat of this change:
Ideally, we will need to add special handling to skip counting events with R
modifier in evsel. Currently, this is not implemented so the event with :R will be both counted and sampled. Usually, in a metric formula that uses retire_latency, it would already require to count the event. As a result, we will endup count the same event twice. This should be able to be handled properly when we finalize our design on evsel R modifier support.

- Move TPEBS specific code out from main perf stat code to separate files in
util/intel-tpebs.c and util/intel-tpebs.h. [Namhyung]
- Use --control:fifo to ack perf stat from forked perf record instead of sleep(2) [Namhyung]
- Add introductions about TPEBS and R modifier in Documents. [Namhyung]

Changes in v7:
- Update code and comments for better code quality [Namhyung]
- Add a separate commit for perf data [Namhyung]
- Update retire latency print function to improve alignment [Namhyung]

Changes in v6:
- Update code and add comments for better code quality [Namhyung]
- Remove the added fd var and directly pass the opened fd to data.file.fd [Namhyung]
- Add kill() to stop perf record when perf stat exists early [Namhyung]
- Add command opt check to ensure only start perf record when -a/-C given [Namhyung]
- Squash commits [Namhyung]

Changes in v5:
- Update code and add comments for better code quality [Ian]

Changes in v4:
- Remove uncessary debug print and update code and comments for better
readability and quality [Namhyung]
- Update mtl metric json file with consistent TmaL1 and TopdownL1 metricgroup

Changes in v3:
- Remove ':' when event name has '@' [Ian]
- Use 'R' as the modifier instead of "retire_latency" [Ian]

Changes in v2:
- Add MTL metric file
- Add more descriptions and example to the patch [Arnaldo]

Here is an example of running perf stat to collect a metric that uses retire_latency value of event MEM_INST_RETIRED.STLB_HIT_STORES on a MTL system.

In this simple example, there is no MEM_INST_RETIRED.STLB_HIT_STORES sample. Therefore, the MEM_INST_RETIRED.STLB_HIT_STORES:p count and retire_latency value are all 0.

./perf stat -M tma_dtlb_store -a -- sleep 1

[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]

Performance counter stats for 'system wide':

       181,047,168      cpu_core/TOPDOWN.SLOTS/          #      0.6 %  tma_dtlb_store
         3,195,608      cpu_core/topdown-retiring/
        40,156,649      cpu_core/topdown-mem-bound/
         3,550,925      cpu_core/topdown-bad-spec/
       117,571,818      cpu_core/topdown-fe-bound/
        57,118,087      cpu_core/topdown-be-bound/
            69,179      cpu_core/EXE_ACTIVITY.BOUND_ON_STORES/
             4,582      cpu_core/MEM_INST_RETIRED.STLB_HIT_STORES/
        30,183,104      cpu_core/CPU_CLK_UNHALTED.DISTRIBUTED/
        30,556,790      cpu_core/CPU_CLK_UNHALTED.THREAD/
           168,486      cpu_core/DTLB_STORE_MISSES.WALK_ACTIVE/

0.00 MEM_INST_RETIRED.STLB_HIT_STORES:p 0 0

1.003105924 seconds time elapsed

v1:
TPEBS is one of the features provided by the next generation of Intel PMU. Please refer to Section 8.4.1 of "Intel® Architecture Instruction Set Extensions Programming Reference" [1] for more details about this feature.

This set of patches supports TPEBS in counting mode. The code works in the following way: it forks a perf record process from perf stat when retire_latency of one or more events are used in a metric formula. Perf stat would send a SIGTERM signal to perf record before it needs the retire latency value for metric calculation. Perf stat will then process sample data to extract the retire latency data for metric calculations. Currently, the code uses the arithmetic average of retire latency values.

[1] https://www.intel.com/content/www/us/en/content-details/812218/intel-architecture-instruction-set-extensions-programming-reference.html?wapkw=future%20features

Ian Rogers (1):
perf parse-events: Add a retirement latency modifier

Quoted 9 lines

Weilin Wang (7):
perf data: Allow to use given fd in data->file.fd
perf stat: Fork and launch perf record when perf stat needs to get
retire latency value for a metric.
perf stat: Plugin retire_lat value from sampled data to evsel perf vendor events intel: Add MTL metric json files perf stat: Add command line option for enabling tpebs recording perf Document: Add TPEBS to Documents
perf test: Add test for Intel TPEBS counting mode

Thanks for your persistence!

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Ping.

I guess Namhyung's reviewed-by should suffice, but since you're pinging and I saw previous comments about this serie, would it be possible to get your Reviewed-by as well?

I'm happy with most of the changes and they can have my reviewed-by.

Thanks.

Quoted 8 lines
Quoted 3 lines

I'm not happy with:
perf stat: Fork and launch 'perf record' when 'perf stat' needs to get retire latency value for a metric.

I don't like it either, but I couldn't find the time to engage in this discussion to try to offer an alternative patch and since Namhyung had provided his reviewed-by and you pinged me, I felt compelled to move forward on this.

I think we should be moving forward on this. I think the series had my reviewed-by 9 months ago and this work is gating the bring up of Intel models like Granite Rapids, it also adds metrics for Intel Meteorlake which is Intel's laptop CPU of the day. After all fixes for the ARM breakages, this is the 2nd biggest nuts thing we don't have landed.

Quoted 3 lines
Quoted 1 line

so please leave it off there.

So, what are you proposing, that we process up to some patch?

I was proposing just not having my tag on that patch. Perfect isn't the enemy of good.

I don't want to be picky on other people's style, especially when it brings big value as here. A low value series blocked on a style issue due to 1 reviewer is:
https://lore.kernel.org/lkml/CAP-5=fW8YMivp1JW8vRKh=OZtGVLPQ4v88z_2ae+cAVnr7RXoQ@mail.gmail.com/
I'm happy to give style feedback but generally try to avoid it blocking merging. In this case I even wrote the patches doing what I'd suggested.

Quoted 1 line

For now I'm removing the whole series from perf-tools-next.

Ugh.

Thanks,
Ian

Quoted 15 lines

- Arnaldo

Quoted 13 lines

Context: originally the patches aimed to abstract everything inside of the evsel, now builtin-stat is manually starting and ending the sub-process and has to be aware of TPEBS. There are ugly architectural dependencies. My reviewed-by was correct on the earlier version, as you could make a tpebs evsel just like any... other, open, close, read it, etc. This would be useful say in a python script. This version to my eyes is worse as all TPEBS dependencies are made explicit and the caller needs to be aware of TPEBS. I understand Weilin was asked to make some of the changes, and there was a desire for efficiency, but I think things were better in earlier versions.

Thanks,
Ian

reviewer
#26 lore raw
Quoted 4 lines · Ian Rogers
Quoted 1 line · Arnaldo Carvalho de Melo

For now I'm removing the whole series from perf-tools-next.

Ugh.

Hi, what's the plan here? The topdown (aka TMA) metrics on recent Intel CPUs (client and server) are dependent on timed PEBS. I think we should land this series and move forward from there.

Thanks,
Ian

#27 lore raw
Quoted 9 lines · Ian Rogers
Quoted 4 lines · Ian Rogers
Quoted 1 line · Arnaldo Carvalho de Melo

For now I'm removing the whole series from perf-tools-next.

Ugh.

Hi, what's the plan here? The topdown (aka TMA) metrics on recent Intel CPUs (client and server) are dependent on timed PEBS. I think we should land this series and move forward from there.

I'm taking this as an Acked-by, merged the 3rd and 4th patches to keep bisectability and constified the process_sample_event() perf_tool pointer, test building with containers now.

Will push to tmp.perf-tools-next while that runs.

- Arnaldo