TPEBS counting mode support
v7 cover TPEBS counting mode support
From: Weilin Wang <[email protected]>
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]
v6: https://lore.kernel.org/all/[email protected]/
Weilin Wang (6):
perf stat: Parse and find tpebs events when parsing metrics to prepare
for perf record sampling
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: Add retire latency values into the expr_parse_ctx to
prepare for final metric calculation
perf stat: Add retire latency print functions to print out at the very
end of print out
perf vendor events intel: Add MTL metric json files
tools/perf/builtin-stat.c | 249 +- .../arch/x86/meteorlake/metricgroups.json | 127 + .../arch/x86/meteorlake/mtl-metrics.json | 2551 +++++++++++++++++ tools/perf/util/data.c | 7 +- tools/perf/util/metricgroup.c | 87 +- tools/perf/util/metricgroup.h | 22 +- tools/perf/util/stat-display.c | 69 + tools/perf/util/stat-shadow.c | 19 + tools/perf/util/stat.h | 4 + 9 files changed, 3115 insertions(+), 20 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
--
2.43.0
RFC PATCH v7 1/6 perf stat: Parse and find tpebs events when parsing metrics to prepare for perf record sampling
From: Weilin Wang <[email protected]>
Metrics that use tpebs values would use the R as retire_latency modifier in formulas. We put all these events into a list and pass the list to perf record to collect their retire latency value.
--- tools/perf/builtin-stat.c | 40 ++++++++++++++-- tools/perf/util/metricgroup.c | 87 +++++++++++++++++++++++++++++------ tools/perf/util/metricgroup.h | 10 +++- tools/perf/util/stat.h | 2 + 4 files changed, 120 insertions(+), 19 deletions(-)
tools/perf/builtin-stat.c +35 -5
@@ -162,6 +162,7 @@ static struct perf_stat_config stat_config = { .ctl_fd = -1, .ctl_fd_ack = -1, .iostat_run = false, + .tpebs_events = LIST_HEAD_INIT(stat_config.tpebs_events), };static bool cpus_map_matched (struct evsel *a,struct evsel *b)
@@ -686,6 +687,12 @@ static enum counter_recovery stat_handle_error(struct evsel *counter)return COUNTER_FATAL ; } +static int __run_perf_record (void ) +{ +pr_debug ("Prepare perf record for retire_latency\n" ); +return 0 ; +} +static int __run_perf_stat (int argc,const char **argv,int run_idx) {int interval = stat_config.interval;
@@ -703,6 +710,18 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)int err;bool second_pass = false; +/* +* Prepare perf record for sampling event retire_latency before fork and +* prepare workload +*/ +if (stat_config.tpebs_event_size >0 ) { +int ret; + + ret =__run_perf_record (); +if (ret) +return ret; + } +if (forks) {if (evlist__prepare_workload (evsel_list, &target, argv, is_pipe, workload_exec_failed_signal) <0 ) {perror ("failed to prepare workload" );
@@ -2106,7 +2125,9 @@ static int add_default_attributes(void) stat_config.metric_no_threshold, stat_config.user_requested_cpu_list, stat_config.system_wide, - &stat_config.metric_events); + &stat_config.metric_events, + &stat_config.tpebs_events, + &stat_config.tpebs_event_size); }if (smi_cost) {
@@ -2139,7 +2160,9 @@ static int add_default_attributes(void) stat_config.metric_no_threshold, stat_config.user_requested_cpu_list, stat_config.system_wide, - &stat_config.metric_events); + &stat_config.metric_events, + &stat_config.tpebs_events, + &stat_config.tpebs_event_size); }if (topdown_run) {
@@ -2173,7 +2196,9 @@ static int add_default_attributes(void)/*metric_no_threshold=*/ true, stat_config.user_requested_cpu_list, stat_config.system_wide, - &stat_config.metric_events) < 0) + &stat_config.metric_events, + &stat_config.tpebs_events, + &stat_config.tpebs_event_size) < 0) return -1; }
@@ -2214,7 +2239,9 @@ static int add_default_attributes(void)/*metric_no_threshold=*/ true, stat_config.user_requested_cpu_list, stat_config.system_wide, - &stat_config.metric_events) < 0) + &stat_config.metric_events, +/*&stat_config.tpebs_events=*/ NULL , + /*stat_config.tpebs_event_size=*/0) < 0) return -1;evlist__for_each_entry (metric_evlist, metric_evsel) {
@@ -2736,6 +2763,7 @@ int cmd_stat(int argc, const char **argv) } } +/* * Metric parsing needs to be delayed as metrics may optimize events * knowing the target is system-wide.
@@ -2748,7 +2776,9 @@ int cmd_stat(int argc, const char **argv) stat_config.metric_no_threshold, stat_config.user_requested_cpu_list, stat_config.system_wide, - &stat_config.metric_events); + &stat_config.metric_events, + &stat_config.tpebs_events, + &stat_config.tpebs_event_size);zfree (&metrics);if (ret) {
tools/perf/util/metricgroup.c +74 -13
172 lines not on this page · raw message
tools/perf/util/metricgroup.h +9 -1
@@ -66,6 +66,12 @@ struct metric_expr {int runtime; }; +struct tpebs_event { +struct list_head nd; +const char *name; +const char *tpebs_name; +}; +struct metric_event *metricgroup__lookup (struct rblist *metric_events,struct evsel *evsel,bool create);
@@ -77,7 +83,9 @@ int metricgroup__parse_groups(struct evlist *perf_evlist,bool metric_no_threshold, const char *user_requested_cpu_list, bool system_wide, - struct rblist *metric_events); + struct rblist *metric_events, + struct list_head *tpebs_events, + size_t *tpebs_event_size); int metricgroup__parse_groups_test(struct evlist *evlist, const struct pmu_metrics_table *table, const char *str,
tools/perf/util/stat.h +2 -0
@@ -109,6 +109,8 @@ struct perf_stat_config {struct cpu_aggr_map *cpus_aggr_map;u64 *walltime_run;struct rblist metric_events; +struct list_head tpebs_events; +size_t tpebs_event_size;int ctl_fd;int ctl_fd_ack;bool ctl_fd_close;
Signature · 1 line
2.43.0
Namhyung Kim
maintainerRe: [RFC PATCH v7 1/6] perf stat: Parse and find tpebs events when parsing metrics to prepare for perf record sampling
Quoted 4 lines · On Tue, Apr 2, 2024 at 2:45 PM <[email protected]> wrote:
From: Weilin Wang <[email protected]>
Metrics that use tpebs values would use the R as
retire_latencymodifier in
Can you please add this to documentation so that others can refer? I'm not sure if we have a doc for the JSON metric format.
Thanks,
Namhyung
Quoted 5 lines
formulas. We put all these events into a list and pass the list to perf record to collect their retire latency value.
Signed-off-by Weilin Wang <[email protected]>Reviewed-by Ian Rogers <[email protected]>
RFC PATCH v7 2/6 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
@@ -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
RFC PATCH v7 3/6 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, perf stat 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, it would send sigterm signal to perf record process and receiving sampling data back from perf record from a pipe. Perf stat will then process the received data to get retire latency data and calculate metric result.
Another thread is required to synchronize between perf stat and perf record when we pass data through pipe.
--- tools/perf/builtin-stat.c | 212 +++++++++++++++++++++++++++++++++- tools/perf/util/metricgroup.h | 8 ++ tools/perf/util/stat.h | 2 + 3 files changed, 220 insertions(+), 2 deletions(-)
tools/perf/builtin-stat.c +210 -2
@@ -94,8 +94,13 @@#include <perf/evlist.h> #include <internal/threadmap.h> +#include "util/sample.h" +#include <sys/param.h> +#include <subcmd/run-command.h> +#define DEFAULT_SEPARATOR " "#define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi" +#define PERF_DATA "-"static void print_counters (struct timespec *ts,int argc,const char **argv);
@@ -163,6 +168,8 @@ static struct perf_stat_config stat_config = { .ctl_fd_ack = -1, .iostat_run = false, .tpebs_events = LIST_HEAD_INIT(stat_config.tpebs_events), + .tpebs_results = LIST_HEAD_INIT(stat_config.tpebs_results), + .tpebs_pid = -1, };static bool cpus_map_matched (struct evsel *a,struct evsel *b)
@@ -684,15 +691,173 @@ static enum counter_recovery stat_handle_error(struct evsel *counter)if (child_pid !=-1 )kill (child_pid,SIGTERM ); +if (stat_config.tpebs_pid !=-1 ) +kill (stat_config.tpebs_pid,SIGTERM );return COUNTER_FATAL ; } -static int __run_perf_record (void ) +static int __run_perf_record (const char **record_argv) { +int i =0 ; +struct tpebs_event *e; +pr_debug ("Prepare perf record for retire_latency\n" ); + + record_argv[i++] ="perf" ; + record_argv[i++] ="record" ; + record_argv[i++] ="-W" ; + record_argv[i++] ="--synth=no" ; + +if (stat_config.user_requested_cpu_list) { + record_argv[i++] ="-C" ; + record_argv[i++] = stat_config.user_requested_cpu_list; + } + +if (stat_config.system_wide) + record_argv[i++] ="-a" ; + +if (!stat_config.system_wide && !stat_config.user_requested_cpu_list) { +pr_err ("Require -a or -C option to run sampling.\n" ); +return -ECANCELED ; + } + +list_for_each_entry (e, &stat_config.tpebs_events, nd) { + record_argv[i++] ="-e" ; + record_argv[i++] = e->name; + } + + record_argv[i++] ="-o" ; + record_argv[i++] =PERF_DATA ; + +return 0 ; +} + +static void prepare_run_command (struct child_process *cmd, +const char **argv) +{ +memset (cmd,0 ,sizeof (*cmd)); + cmd->argv = argv; + cmd->out =-1 ; +} + +static int prepare_perf_record (struct child_process *cmd) +{ +const char **record_argv; +int ret; + + record_argv =calloc (10 +2 * stat_config.tpebs_event_size,sizeof (char *)); +if (!record_argv) +return -1 ; + + ret =__run_perf_record (record_argv); +if (ret) +return ret; + +prepare_run_command (cmd, record_argv); +return start_command (cmd); +} + +struct perf_script { +struct perf_tool tool; +struct perf_session *session; +}; + +static void tpebs_event_name__delete (struct tpebs_event *e) +{ +zfree (&e->name); +zfree (&e->tpebs_name); +} + +static void tpebs_event__delete (struct tpebs_event *e) +{ +tpebs_event_name__delete (e); +free (e); +} + +static void tpebs_retire_lat__delete (struct tpebs_retire_lat *r) +{ +tpebs_event_name__delete (&r->event); +free (r); +} + +static void tpebs_data__delete (void ) +{ +struct tpebs_retire_lat *r, *rtmp; +struct tpebs_event *e, *etmp; + +list_for_each_entry_safe (r, rtmp, &stat_config.tpebs_results, event.nd) { +list_del_init (&r->event.nd); +tpebs_retire_lat__delete (r); + } +list_for_each_entry_safe (e, etmp, &stat_config.tpebs_events, nd) { +list_del_init (&e->nd); +tpebs_event__delete (e); + } +} + +static int process_sample_event (struct perf_tool *tool__maybe_unused , +union perf_event *event__maybe_unused , +struct perf_sample *sample, +struct evsel *evsel, +struct machine *machine__maybe_unused ) +{ +int ret =0 ; +const char *evname; +struct tpebs_retire_lat *t; + + evname =evsel__name (evsel); + +/* +* Need to handle per core results? We are assuming average retire +* latency value will be used. Save the number of samples and the sum of +* retire latency value for each event. +*/ +list_for_each_entry (t, &stat_config.tpebs_results, event.nd) { +if (!strcmp (evname, t->event.name)) { + t->count +=1 ; + t->sum += sample->retire_lat; +break ; + } + } + +return ret; +} + +static int process_feature_event (struct perf_session *session, +union perf_event *event) +{ +if (event->feat.feat_id <HEADER_LAST_FEATURE ) +return perf_event__process_feature (session, event);return 0 ; } +static void *__sample_reader (void *arg) +{ +struct child_process *cmd = arg; +struct perf_session *session; +struct perf_data data = { + .mode =PERF_DATA_MODE_READ , + .path =PERF_DATA , + .file.fd = cmd->out, + }; +struct perf_script script = { + .tool = { + .sample = process_sample_event, + .feature = process_feature_event, + .attr = perf_event__process_attr, + }, + }; + + session =perf_session__new (&data, &script.tool); +if (IS_ERR (session)) +return NULL ; + script.session = session; +perf_session__process_events (session); +perf_session__delete (session); + +return NULL ; +} +static int __run_perf_stat (int argc,const char **argv,int run_idx) {int interval = stat_config.interval;
@@ -709,6 +874,8 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)struct affinity saved_affinity, *affinity =NULL ;int err;bool second_pass = false; +struct child_process cmd; +pthread_t reader_thread;/* * Prepare perf record for sampling event retire_latency before fork and
@@ -716,10 +883,35 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)*/ if (stat_config.tpebs_event_size >0 ) {int ret; +struct tpebs_event *e; + +pr_debug ("perf stat pid = %d\n" ,getpid ()); +list_for_each_entry (e, &stat_config.tpebs_events, nd) { +struct tpebs_retire_lat *new =malloc (sizeof (struct tpebs_retire_lat )); - ret =__run_perf_record (); +if (!new) +return -1 ; + new->event.name =strdup (e->name); +if (!new->event.name) +return -ENOMEM ; + new->event.tpebs_name =strdup (e->tpebs_name); +if (!new->event.tpebs_name) +return -ENOMEM ; + new->count =0 ; + new->sum =0 ; +list_add_tail (&new->event.nd, &stat_config.tpebs_results); + } + ret =prepare_perf_record (&cmd);if (ret)return ret; +if (pthread_create (&reader_thread,NULL , __sample_reader, &cmd)) { +kill (cmd.pid,SIGTERM ); +close (cmd.out); +pr_err ("Could not create thread to process sample data.\n" ); +return -1 ; + } +/* Wait for perf record initialization a little bit.*/ +sleep (2 ); }if (forks) {
@@ -927,6 +1119,17 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) t1 =rdclock (); +if (stat_config.tpebs_event_size >0 ) { +int ret; + +kill (cmd.pid,SIGTERM ); +pthread_join (reader_thread,NULL ); +close (cmd.out); + ret =finish_command (&cmd); +if (ret != -ERR_RUN_COMMAND_WAITPID_SIGNAL ) +return ret; + } +if (stat_config.walltime_run_table) stat_config.walltime_run[run_idx] = t1 - t0;
@@ -1034,6 +1237,9 @@ static void sig_atexit(void)if (child_pid !=-1 )kill (child_pid,SIGTERM ); +if (stat_config.tpebs_pid !=-1 ) +kill (stat_config.tpebs_pid,SIGTERM ); +sigprocmask (SIG_SETMASK , &oset,NULL );if (signr ==-1 )
@@ -2974,5 +3180,7 @@ int cmd_stat(int argc, const char **argv)metricgroup__rblist_exit (&stat_config.metric_events);evlist__close_control (stat_config.ctl_fd, stat_config.ctl_fd_ack, &stat_config.ctl_fd_close); +tpebs_data__delete (); +return status; }
tools/perf/util/metricgroup.h +8 -0
@@ -68,10 +68,18 @@ struct metric_expr {struct tpebs_event {struct list_head nd; +/* Event name */ const char *name; +/* Event name with the TPEBS modifier R */ const char *tpebs_name; }; +struct tpebs_retire_lat { +struct tpebs_event event; +size_t count; +int sum; +}; +struct metric_event *metricgroup__lookup (struct rblist *metric_events,struct evsel *evsel,bool create);
tools/perf/util/stat.h +2 -0
@@ -111,6 +111,8 @@ struct perf_stat_config {struct rblist metric_events;struct list_head tpebs_events;size_t tpebs_event_size; +struct list_head tpebs_results; +pid_t tpebs_pid;int ctl_fd;int ctl_fd_ack;bool ctl_fd_close;
Signature · 1 line
2.43.0
Namhyung Kim
maintainerRe: [RFC PATCH v7 3/6] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric.
Quoted 8 lines · On Tue, Apr 2, 2024 at 2:46 PM <[email protected]> wrote:
From: Weilin Wang <[email protected]>
When
retire_latencyvalue is used in a metric formula, perf stat would fork a perf record process with "-e" and "-W" options. Perf record will collect requiredretire_latencyvalues in parallel while perf stat is collecting counting values.
Quoted 7 lines
At the point of time that perf stat stops counting, it would send sigterm signal to perf record process and receiving sampling data back from perf record from a pipe. Perf stat will then process the received data to get retire latency data and calculate metric result.
Another thread is required to synchronize between perf stat and perf record when we pass data through pipe.
I feel like I'm repeating some of the precious review comments..
Still I think it's better to split these special case handling routines from the normal perf stat code.
Quoted 28 lines
Signed-off-by Weilin Wang <[email protected]>Reviewed-by Ian Rogers <[email protected]>--- tools/perf/builtin-stat.c | 212 +++++++++++++++++++++++++++++++++- tools/perf/util/metricgroup.h | 8 ++ tools/perf/util/stat.h | 2 + 3 files changed, 220 insertions(+), 2 deletions(-)tools/perf/builtin-stat.c +5
-0@@ -94,8 +94,13 @@#include <perf/evlist.h> #include <internal/threadmap.h> +#include "util/sample.h" +#include <sys/param.h> +#include <subcmd/run-command.h> +#define DEFAULT_SEPARATOR " "#define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi" +#define PERF_DATA "-"static void print_counters (struct timespec *ts,int argc,const char **argv);
tools/perf/builtin-stat.c static struct perf_stat_config stat_config = { · line 171
Quoted 4 lines
tools/perf/builtin-stat.c +1
-0@@ -163,6 +168,8 @@ static struct perf_stat_config stat_config = { .ctl_fd_ack = -1, .iostat_run = false, .tpebs_events = LIST_HEAD_INIT(stat_config.tpebs_events), + .tpebs_results = LIST_HEAD_INIT(stat_config.tpebs_results),
Can we combine these two lists? Why not move the result fields to tpebs_events?
Quoted 60 lines
tools/perf/builtin-stat.c +47
-1+ .tpebs_pid = -1, };static bool cpus_map_matched (struct evsel *a,struct evsel *b)@@ -684,15 +691,173 @@ static enum counter_recovery stat_handle_error(struct evsel *counter)if (child_pid !=-1 )kill (child_pid,SIGTERM ); +if (stat_config.tpebs_pid !=-1 ) +kill (stat_config.tpebs_pid,SIGTERM );return COUNTER_FATAL ; } -static int __run_perf_record (void ) +static int __run_perf_record (const char **record_argv) { +int i =0 ; +struct tpebs_event *e; +pr_debug ("Prepare perf record for retire_latency\n" ); + + record_argv[i++] ="perf" ; + record_argv[i++] ="record" ; + record_argv[i++] ="-W" ; + record_argv[i++] ="--synth=no" ; + +if (stat_config.user_requested_cpu_list) { + record_argv[i++] ="-C" ; + record_argv[i++] = stat_config.user_requested_cpu_list; + } + +if (stat_config.system_wide) + record_argv[i++] ="-a" ; + +if (!stat_config.system_wide && !stat_config.user_requested_cpu_list) { +pr_err ("Require -a or -C option to run sampling.\n" ); +return -ECANCELED ; + } + +list_for_each_entry (e, &stat_config.tpebs_events, nd) { + record_argv[i++] ="-e" ; + record_argv[i++] = e->name; + } + + record_argv[i++] ="-o" ; + record_argv[i++] =PERF_DATA ; + +return 0 ; +} + +static void prepare_run_command (struct child_process *cmd, +const char **argv) +{ +memset (cmd,0 ,sizeof (*cmd)); + cmd->argv = argv; + cmd->out =-1 ; +} + +static int prepare_perf_record (struct child_process *cmd) +{
tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter) · line 754
Quoted 10 lines
tools/perf/builtin-stat.c +10
-0+const char **record_argv; +int ret; + + record_argv =calloc (10 +2 * stat_config.tpebs_event_size,sizeof (char *)); +if (!record_argv) +return -1 ; + + ret =__run_perf_record (record_argv); +if (ret) +return ret;
free(record_argv) before return.
Quoted 95 lines
tools/perf/builtin-stat.c +92
-0+ +prepare_run_command (cmd, record_argv); +return start_command (cmd); +} + +struct perf_script { +struct perf_tool tool; +struct perf_session *session; +}; + +static void tpebs_event_name__delete (struct tpebs_event *e) +{ +zfree (&e->name); +zfree (&e->tpebs_name); +} + +static void tpebs_event__delete (struct tpebs_event *e) +{ +tpebs_event_name__delete (e); +free (e); +} + +static void tpebs_retire_lat__delete (struct tpebs_retire_lat *r) +{ +tpebs_event_name__delete (&r->event); +free (r); +} + +static void tpebs_data__delete (void ) +{ +struct tpebs_retire_lat *r, *rtmp; +struct tpebs_event *e, *etmp; + +list_for_each_entry_safe (r, rtmp, &stat_config.tpebs_results, event.nd) { +list_del_init (&r->event.nd); +tpebs_retire_lat__delete (r); + } +list_for_each_entry_safe (e, etmp, &stat_config.tpebs_events, nd) { +list_del_init (&e->nd); +tpebs_event__delete (e); + } +} + +static int process_sample_event (struct perf_tool *tool__maybe_unused , +union perf_event *event__maybe_unused , +struct perf_sample *sample, +struct evsel *evsel, +struct machine *machine__maybe_unused ) +{ +int ret =0 ; +const char *evname; +struct tpebs_retire_lat *t; + + evname =evsel__name (evsel); + +/* +* Need to handle per core results? We are assuming average retire +* latency value will be used. Save the number of samples and the sum of +* retire latency value for each event. +*/ +list_for_each_entry (t, &stat_config.tpebs_results, event.nd) { +if (!strcmp (evname, t->event.name)) { + t->count +=1 ; + t->sum += sample->retire_lat; +break ; + } + } + +return ret; +} + +static int process_feature_event (struct perf_session *session, +union perf_event *event) +{ +if (event->feat.feat_id <HEADER_LAST_FEATURE ) +return perf_event__process_feature (session, event);return 0 ; } +static void *__sample_reader (void *arg) +{ +struct child_process *cmd = arg; +struct perf_session *session; +struct perf_data data = { + .mode =PERF_DATA_MODE_READ , + .path =PERF_DATA , + .file.fd = cmd->out, + }; +struct perf_script script = { + .tool = { + .sample = process_sample_event, + .feature = process_feature_event, + .attr = perf_event__process_attr, + }, + };
tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter) · line 859
Quoted 10 lines
tools/perf/builtin-stat.c +10
-0+ + session =perf_session__new (&data, &script.tool); +if (IS_ERR (session)) +return NULL ; + script.session = session; +perf_session__process_events (session); +perf_session__delete (session); + +return NULL ; +}
Now we have weight[123] fields to show the average weight. Can we simply use it like below?
$ perf mem record -t load -o- timeout 1 perf test -w datasym | \
perf report -i- -q -F weight1
[ perf record: Woken up 3 times to write data ]
[ perf record: Captured and wrote 0.614 MB - ]
92.2 <--- thisQuoted 37 lines
tools/perf/builtin-stat.c +21
-1+static int __run_perf_stat (int argc,const char **argv,int run_idx) {int interval = stat_config.interval;@@ -709,6 +874,8 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)struct affinity saved_affinity, *affinity =NULL ;int err;bool second_pass = false; +struct child_process cmd; +pthread_t reader_thread;/* * Prepare perf record for sampling event retire_latency before fork and @@ -716,10 +883,35 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)*/ if (stat_config.tpebs_event_size >0 ) {int ret; +struct tpebs_event *e; + +pr_debug ("perf stat pid = %d\n" ,getpid ()); +list_for_each_entry (e, &stat_config.tpebs_events, nd) { +struct tpebs_retire_lat *new =malloc (sizeof (struct tpebs_retire_lat )); - ret =__run_perf_record (); +if (!new) +return -1 ; + new->event.name =strdup (e->name); +if (!new->event.name) +return -ENOMEM ; + new->event.tpebs_name =strdup (e->tpebs_name); +if (!new->event.tpebs_name) +return -ENOMEM ; + new->count =0 ; + new->sum =0 ; +list_add_tail (&new->event.nd, &stat_config.tpebs_results); + } + ret =prepare_perf_record (&cmd);
tools/perf/builtin-stat.c static int __run_perf_stat(int argc, const char **argv, int run_idx) · line 914
Quoted 10 lines
tools/perf/builtin-stat.c +8
-0if (ret)return ret; +if (pthread_create (&reader_thread,NULL , __sample_reader, &cmd)) { +kill (cmd.pid,SIGTERM ); +close (cmd.out); +pr_err ("Could not create thread to process sample data.\n" ); +return -1 ; + } +/* Wait for perf record initialization a little bit.*/ +sleep (2 );
This won't guarantee anything and just slows down the normal case. You'd better make the record process wait until the reader is ready.
Thanks,
Namhyung
Quoted 78 lines
tools/perf/builtin-stat.c +16
-0}if (forks) {@@ -927,6 +1119,17 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) t1 =rdclock (); +if (stat_config.tpebs_event_size >0 ) { +int ret; + +kill (cmd.pid,SIGTERM ); +pthread_join (reader_thread,NULL ); +close (cmd.out); + ret =finish_command (&cmd); +if (ret != -ERR_RUN_COMMAND_WAITPID_SIGNAL ) +return ret; + } +if (stat_config.walltime_run_table) stat_config.walltime_run[run_idx] = t1 - t0;@@ -1034,6 +1237,9 @@ static void sig_atexit(void)if (child_pid !=-1 )kill (child_pid,SIGTERM ); +if (stat_config.tpebs_pid !=-1 ) +kill (stat_config.tpebs_pid,SIGTERM ); +sigprocmask (SIG_SETMASK , &oset,NULL );if (signr ==-1 )@@ -2974,5 +3180,7 @@ int cmd_stat(int argc, const char **argv)metricgroup__rblist_exit (&stat_config.metric_events);evlist__close_control (stat_config.ctl_fd, stat_config.ctl_fd_ack, &stat_config.ctl_fd_close); +tpebs_data__delete (); +return status; }tools/perf/util/metricgroup.h +8
-0@@ -68,10 +68,18 @@ struct metric_expr {struct tpebs_event {struct list_head nd; +/* Event name */ const char *name; +/* Event name with the TPEBS modifier R */ const char *tpebs_name; }; +struct tpebs_retire_lat { +struct tpebs_event event; +size_t count; +int sum; +}; +struct metric_event *metricgroup__lookup (struct rblist *metric_events,struct evsel *evsel,bool create);tools/perf/util/stat.h +2
-1@@ -111,6 +111,8 @@ struct perf_stat_config {struct rblist metric_events;struct list_head tpebs_events;size_t tpebs_event_size; +struct list_head tpebs_results; +pid_t tpebs_pid;int ctl_fd;int ctl_fd_ack;bool ctl_fd_close; --2.43.0
RFC PATCH v7 4/6 perf stat: Add retire latency values into the expr_parse_ctx to prepare for final metric calculation
In reply to [email protected]From: Weilin Wang <[email protected]>
Retire latency values of events are used in metric formulas. This update adds code to process data from perf record for required retire latency values.
--- tools/perf/builtin-stat.c | 1 + tools/perf/util/metricgroup.h | 4 ++++ tools/perf/util/stat-shadow.c | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+)
tools/perf/builtin-stat.c +1 -0
@@ -816,6 +816,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,if (!strcmp (evname, t->event.name)) { t->count +=1 ; t->sum += sample->retire_lat; + t->val = (double ) t->sum / t->count;break ; } }
tools/perf/util/metricgroup.h +4 -0
@@ -76,8 +76,12 @@ struct tpebs_event {struct tpebs_retire_lat {struct tpebs_event event; +/* Count of retire_latency values found in sample data */ size_t count; +/* Sum of all the retire_latency values in sample data */ int sum; +/* Average of retire_latency, val = sum / count */ +double val; }; struct metric_event *metricgroup__lookup(struct rblist *metric_events,
tools/perf/util/stat-shadow.c +19 -0
@@ -355,6 +355,20 @@ static void print_nsecs(struct perf_stat_config *config,print_metric (config, ctxp,NULL ,NULL ,"CPUs utilized" ,0 ); } +static int prepare_retire_lat (struct expr_parse_ctx *pctx, +struct list_head *retire_lats) +{ +int ret =0 ; +struct tpebs_retire_lat *t; + +list_for_each_entry (t, retire_lats, event.nd) { + ret =expr__add_id_val (pctx,strdup (t->event.tpebs_name), t->val); +if (ret <0 ) +return ret; + } +return ret; +} + static int prepare_metric(const struct metric_expr *mexp, const struct evsel *evsel, struct expr_parse_ctx *pctx,
@@ -486,6 +500,11 @@ static void generic_metric(struct perf_stat_config *config, pctx->sctx.user_requested_cpu_list =strdup (config->user_requested_cpu_list); pctx->sctx.runtime = runtime; pctx->sctx.system_wide = config->system_wide; + i =prepare_retire_lat (pctx, &config->tpebs_results); +if (i <0 ) { +expr__ctx_free (pctx); +return ; + } i =prepare_metric (mexp, evsel, pctx, aggr_idx);if (i <0 ) {expr__ctx_free (pctx);
Signature · 1 line
2.43.0
RFC PATCH v7 5/6 perf stat: Add retire latency print functions to print out at the very end of print out
In reply to [email protected]From: Weilin Wang <[email protected]>
Add print out functions so that users could read retire latency values.
Example output:
Performance counter stats for 'system wide':
25,717 MEM_INST_RETIRED.SPLIT_STORES # 2.2 % tma_split_stores
28,365,080 CPU_CLK_UNHALTED.THREAD
24.00 MEM_INST_RETIRED.SPLIT_STORES:p # 96 42.054365083 seconds time elapsed
This output of retire latency data is in format:
<val> <event-name> # <sum> <count>.
--- tools/perf/util/stat-display.c | 69 ++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+)
tools/perf/util/stat-display.c +69 -0
@@ -21,6 +21,7 @@#include "iostat.h" #include "pmu.h" #include "pmus.h" +#include "metricgroup.h" #define CNTR_NOT_SUPPORTED "<not supported>"#define CNTR_NOT_COUNTED "<not counted>"
@@ -34,6 +35,7 @@#define COMM_LEN 16#define PID_LEN 7#define CPUS_LEN 4 +#define RETIRE_LEN 8static int aggr_header_lens[] = { [AGGR_CORE ] =18 ,
@@ -426,6 +428,71 @@ static void print_metric_std(struct perf_stat_config *config,fprintf (out," %-*s" ,METRIC_LEN - n -1 , unit); } +static void print_retire_lat_std (struct perf_stat_config *config, +struct outstate *os) +{ +FILE *out = os->fh; +bool newline = os->newline; +struct tpebs_retire_lat *t; +struct list_head *retire_lats = &config->tpebs_results; + +list_for_each_entry (t, retire_lats, event.nd) { +if (newline) +do_new_line_std (config, os); +fprintf (out,"%'*.2f " ,COUNTS_LEN , t->val); +/* For print alignment */ +fprintf (out,"%-*s " , config->unit_width,"" ); +fprintf (out,"%-*s" ,EVNAME_LEN , t->event.name); +fprintf (out," # " ); +fprintf (out,"%*d %*ld\n" ,RETIRE_LEN , t->sum, +RETIRE_LEN , t->count); + } +} + +static void print_retire_lat_csv (struct perf_stat_config *config, +struct outstate *os) +{ +FILE *out = os->fh; +struct tpebs_retire_lat *t; +struct list_head *retire_lats = &config->tpebs_results; +const char *sep = config->csv_sep; + +list_for_each_entry (t, retire_lats, event.nd) { +fprintf (out,"%f%s%s%s%s%ld%s%d\n" , t->val, sep, sep, t->event.name, sep, + t->count, sep, t->sum); + } +} + +static void print_retire_lat_json (struct perf_stat_config *config, +struct outstate *os) +{ +FILE *out = os->fh; +struct tpebs_retire_lat *t; +struct list_head *retire_lats = &config->tpebs_results; + +fprintf (out,"{" ); +list_for_each_entry (t, retire_lats, event.nd) { +fprintf (out,"\"retire_latency-value\" : \"%f\", " , t->val); +fprintf (out,"\"event-name\" : \"%s\"" , t->event.name); +fprintf (out,"\"sample-counts\" : \"%ld\"" , t->count); +fprintf (out,"\"retire_latency-sum\" : \"%d\"" , t->sum); + } +fprintf (out,"}" ); +} + +static void print_retire_lat (struct perf_stat_config *config, +struct outstate *os) +{ +if (!&config->tpebs_results) +return ; +if (config->json_output) +print_retire_lat_json (config, os); +else if (config->csv_output) +print_retire_lat_csv (config, os); +else +print_retire_lat_std (config, os); +} +static void new_line_csv (struct perf_stat_config *config,void *ctx) {struct outstate *os = ctx;
@@ -1609,6 +1676,8 @@ void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *confbreak ; } +print_retire_lat (config, &os); +print_footer (config);fflush (config->output);
Signature · 1 line
2.43.0
Namhyung Kim
maintainerRe: [RFC PATCH v7 5/6] perf stat: Add retire latency print functions to print out at the very end of print out
Quoted 9 lines · On Tue, Apr 2, 2024 at 2:46 PM <[email protected]> wrote:
From: Weilin Wang <[email protected]>
Add print out functions so that users could read retire latency values.
Example output:
Performance counter stats for 'system wide':
Quoted 8 lines
25,717 MEM_INST_RETIRED.SPLIT_STORES # 2.2 % tma_split_stores 28,365,080 CPU_CLK_UNHALTED.THREAD 24.00 MEM_INST_RETIRED.SPLIT_STORES:p # 96 42.054365083 seconds time elapsedThis output of retire latency data is in format:
<val> <event-name> # <sum> <count>.
Nop, please follow the perf stat output format. It'd be
<sum> <event-name> # ...
Hmm.. maybe you don't need this at all as it'll have the event anyway (probably without the 'p' modifier like in the example above).
Then I think you can just add a metric value saying the average latency in the comment area.
Performance counter stats for 'system wide':
25,717 MEM_INST_RETIRED.SPLIT_STORES # 2.2 %
tma_split_stores
#
24.0 average latency
28,365,080 CPU_CLK_UNHALTED.THREADThanks,
Namhyung
Quoted 3 lines
Signed-off-by Weilin Wang <[email protected]>Reviewed-by Ian Rogers <[email protected]>
Namhyung Kim
maintainerRe: [RFC PATCH v7 5/6] perf stat: Add retire latency print functions to print out at the very end of print out
Quoted 31 lines · Namhyung Kim
Quoted 9 lines · On Tue, Apr 2, 2024 at 2:46 PM <[email protected]> wrote:
From: Weilin Wang <[email protected]>
Add print out functions so that users could read retire latency values.
Example output:
Performance counter stats for 'system wide':
Quoted 8 lines
25,717 MEM_INST_RETIRED.SPLIT_STORES # 2.2 % tma_split_stores 28,365,080 CPU_CLK_UNHALTED.THREAD 24.00 MEM_INST_RETIRED.SPLIT_STORES:p # 96 42.054365083 seconds time elapsedThis output of retire latency data is in format:
<val> <event-name> # <sum> <count>.Nop, please follow the perf stat output format. It'd be
<sum> <event-name> # ...
Hmm.. maybe you don't need this at all as it'll have the event anyway (probably without the 'p' modifier like in the example above).
Then I think you can just add a metric value saying the average latency in the comment area.
Quoted 6 lines
Performance counter stats for 'system wide':
25,717 MEM_INST_RETIRED.SPLIT_STORES # 2.2 %
tma_split_stores
#
24.0 average latency
Sorry for the line wrapping. They should be in the same line.
Thanks,
Namhyung
RFC PATCH v7 6/6 perf vendor events intel: Add MTL metric json files
In reply to [email protected]From: Weilin Wang <[email protected]>
Add MTL metric json file at TMA4.7 [1]. Some of the metrics' formulas use TPEBS retire_latency in MTL.
[1] https://lore.kernel.org/all/[email protected]/
--- .../arch/x86/meteorlake/metricgroups.json | 127 + .../arch/x86/meteorlake/mtl-metrics.json | 2551 +++++++++++++++++ 2 files changed, 2678 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 +127 -0
@@ -0,0 +1,127 @@ +{ + "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", + "C0Wait": "Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet", + "CacheHits": "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", + "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", + "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", + "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", + "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_aux_group": "Metrics contributing to tma_backend_bound_aux category", + "tma_backend_bound_group": "Metrics contributing to tma_backend_bound category", + "tma_bad_speculation_group": "Metrics contributing to tma_bad_speculation category", + "tma_base_group": "Metrics contributing to tma_base 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_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_mem_scheduler_group": "Metrics contributing to tma_mem_scheduler 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_nuke_group": "Metrics contributing to tma_nuke 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 +2551 -0
2,551 lines not on this page · raw message
Signature · 1 line
2.43.0
Namhyung Kim
maintainerHello Weilin,
Quoted 9 lines · On Tue, Apr 2, 2024 at 2:45 PM <[email protected]> wrote:
From: Weilin Wang <[email protected]>
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]
In general, I think you need to explain what exactly TPEBS is and why you want to do this for TPEBS. Maybe somewhere in the documentation.
Thanks,
Namhyung
Quoted 30 lines
Weilin Wang (6):
perf stat: Parse and find tpebs events when parsing metrics to prepare
for perf record sampling
perf data: Allow to use given fd indata->file.fd
perf stat: Fork and launch perf record when perf stat needs to get
retire latency value for a metric.
perf stat: Add retire latency values into theexpr_parse_ctxto
prepare for final metric calculation
perf stat: Add retire latency print functions to print out at the very
end of print out
perf vendor events intel: Add MTL metric json filestools/perf/builtin-stat.c | 249 +- .../arch/x86/meteorlake/metricgroups.json | 127 + .../arch/x86/meteorlake/mtl-metrics.json | 2551 +++++++++++++++++ tools/perf/util/data.c | 7 +- tools/perf/util/metricgroup.c | 87 +- tools/perf/util/metricgroup.h | 22 +- tools/perf/util/stat-display.c | 69 + tools/perf/util/stat-shadow.c | 19 + tools/perf/util/stat.h | 4 + 9 files changed, 3115 insertions(+), 20 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--
2.43.0
Quoted 27 lines
-----Original Message-----
From: Namhyung Kim <[email protected]>
Sent: Monday, April 22, 2024 12:10 PM
To: Wang, Weilin <[email protected]>
Cc: Ian Rogers <[email protected]>; Arnaldo Carvalho de Melo <[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 v7 0/6] TPEBS counting mode supportHello Weilin,
Quoted 8 lines · On Tue, Apr 2, 2024 at 2:45 PM <[email protected]> wrote:
From: Weilin Wang <[email protected]>
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]
Quoted 6 lines
Quoted 1 line
In general, I think you need to explain what exactly TPEBS is and why you want to do this for TPEBS. Maybe somewhere in the documentation.
Hi Namhyung,
Ok, I will work on this. I had explanations in about TPEBS in the first version of the code patch. I will add that in a more propriate place.
Thanks,
Weilin
Quoted 36 lines
Thanks,
NamhyungQuoted 13 lines
Weilin Wang (6):
perf stat: Parse and find tpebs events when parsing metrics to prepare
for perf record sampling
perf data: Allow to use given fd indata->file.fd
perf stat: Fork and launch perf record when perf stat needs to get
retire latency value for a metric.
perf stat: Add retire latency values into theexpr_parse_ctxto
prepare for final metric calculation
perf stat: Add retire latency print functions to print out at the very
end of print out
perf vendor events intel: Add MTL metric json filesQuoted 11 lines
tools/perf/builtin-stat.c | 249 +- .../arch/x86/meteorlake/metricgroups.json | 127 + .../arch/x86/meteorlake/mtl-metrics.json | 2551 +++++++++++++++++ tools/perf/util/data.c | 7 +- tools/perf/util/metricgroup.c | 87 +- tools/perf/util/metricgroup.h | 22 +- tools/perf/util/stat-display.c | 69 + tools/perf/util/stat-shadow.c | 19 + tools/perf/util/stat.h | 4 + 9 files changed, 3115 insertions(+), 20 deletions(-) create mode 100644 tools/perf/pmu-
events/arch/x86/meteorlake/metricgroups.jsonQuoted 1 line
create mode 100644 tools/perf/pmu-events/arch/x86/meteorlake/mtl-metrics.json
Quoted 5 lines
--
2.43.0