TPEBS counting mode support
v5 cover TPEBS counting mode support
From: Weilin Wang <[email protected]>
Changes in v5:
- Update code and add comments for better code quality [Ian]
v4: 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 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: Create another thread for sample data processing 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 | 211 +- .../arch/x86/meteorlake/metricgroups.json | 127 + .../arch/x86/meteorlake/mtl-metrics.json | 2551 +++++++++++++++++ tools/perf/util/data.c | 3 + tools/perf/util/data.h | 5 + tools/perf/util/metricgroup.c | 88 +- tools/perf/util/metricgroup.h | 22 +- tools/perf/util/stat-display.c | 65 + tools/perf/util/stat-shadow.c | 19 + tools/perf/util/stat.h | 4 + 10 files changed, 3076 insertions(+), 19 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 v5 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 :retire_latency keyword 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 | 38 +++++++++++++-- tools/perf/util/metricgroup.c | 88 +++++++++++++++++++++++++++++------ tools/perf/util/metricgroup.h | 10 +++- tools/perf/util/stat.h | 2 + 4 files changed, 119 insertions(+), 19 deletions(-)
tools/perf/builtin-stat.c +33 -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,16 @@ 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 +2123,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 +2158,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 +2194,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 +2237,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 +2761,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 +2774,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 +75 -13
173 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 v5 1/6] perf stat: Parse and find tpebs events when parsing metrics to prepare for perf record sampling
Quoted 10 lines · On Tue, Mar 26, 2024 at 1:29 PM <[email protected]> wrote:
From: Weilin Wang <[email protected]>
Metrics that use tpebs values would use the :retire_latency keyword in 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]>---
[SNIP]
tools/perf/util/metricgroup.c static int metricgroup__build_event_string(struct strbuf *events, · line 694
Quoted 11 lines
tools/perf/util/metricgroup.c +7
-0@@ -681,8 +685,56 @@ static int metricgroup__build_event_string(struct strbuf *events,hashmap__for_each_entry (ctx->ids, cur, bkt) {const char *sep, *rsep, *id = cur->pkey;enum perf_tool_event ev; +/* +* Parse and search for event name with retire_latency modifier. +* If found, put event name into the tpebs_events list. This list +* of events will be passed to perf record for sampling to get +* their reitre_latency value. +* Search for ":R" in event name without "@". Search for the +* last "@R" in event name with "@".
What is the retire_latency modifier exactly? Why do you search for :R and @R? What's the difference? Why don't you search for "retire_latency"?
Thanks,
Namhyung
Quoted 47 lines
tools/perf/util/metricgroup.c +42
-1+*/ +char *p =strstr (id,":R" ); +char *p1 =strstr (id,"@R" ); + +if (p ==NULL && p1) { + p =strstr (p1+1 ,"@R" ); +if (p ==NULL ) + p = p1; + p = p+1 ; + } + +if (p) { +char *name; +char *at; +struct tpebs_event *new_event =malloc (sizeof (struct tpebs_event )); -pr_debug ("found event %s\n" , id); +if (!new_event) +return -ENOMEM ; + + new_event->tpebs_name =strdup (id); + *p ='\0' ; + name =malloc (strlen (id) +2 ); +if (!name) +return -ENOMEM ; + + at =strchr (id,'@' ); +if (at !=NULL ) { + *at ='/' ; + at =strchr (id,'@' ); + *at ='/' ; +strcpy (name, id); +strcat (name,"p" ); + }else { +strcpy (name, id); +strcat (name,":p" ); + } + new_event->name = name; + *tpebs_event_size +=1 ; +pr_debug ("retire_latency required, tpebs_event_size=%lu, new_event=%s\n" , + *tpebs_event_size, new_event->name); +list_add_tail (&new_event->nd, tpebs_events); +continue ; + }/* Always move tool events outside of the group. */ ev =perf_tool_event__from_str (id);
RE: [RFC PATCH v5 1/6] perf stat: Parse and find tpebs events when parsing metrics to prepare for perf record sampling
Quoted 42 lines
-----Original Message-----
From: Namhyung Kim <[email protected]>
Sent: Thursday, March 28, 2024 10:46 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 v5 1/6] perf stat: Parse and find tpebs events when parsing metrics to prepare for perf record samplingQuoted 10 lines · On Tue, Mar 26, 2024 at 1:29 PM <[email protected]> wrote:
From: Weilin Wang <[email protected]>
Metrics that use tpebs values would use the :retire_latency keyword in 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]>---
[SNIP]
Review static int metricgroup__build_event_string(struct
Quoted 1 line
(quoted diff) +0
-0@@ -681,8 +685,56 @@ static int metricgroup__build_event_string(structstrbuf *events,
tools/perf/util/metricgroup.c static int metricgroup__build_event_string(struct strbuf *events, · line 694
Quoted 10 lines
tools/perf/util/metricgroup.c +7
-0hashmap__for_each_entry (ctx->ids, cur, bkt) {const char *sep, *rsep, *id = cur->pkey;enum perf_tool_event ev; +/* +* Parse and search for event name with retire_latency modifier. +* If found, put event name into the tpebs_events list. This list +* of events will be passed to perf record for sampling to get +* their reitre_latency value. +* Search for ":R" in event name without "@". Search for the +* last "@R" in event name with "@".
Quoted 3 lines
What is the
retire_latencymodifier exactly? Why do you search for :R and @R? What's the difference? Why don't you search for "retire_latency"?
We decided to use R as the modifier for retire_latency in one of the previous version of code review. Therefore, the code searches for R instead of "retire_latency".
It should search for :R in usual cases. But in hybrid platform, event name might be in format like cpu_core@event_name@R.
Thanks,
Weilin
Quoted 53 lines
Thanks,
NamhyungQuoted 5 lines
tools/perf/util/metricgroup.c +5
-0+*/ +char *p =strstr (id,":R" ); +char *p1 =strstr (id,"@R" ); + +if (p ==NULL && p1) {tools/perf/util/metricgroup.c static int metricgroup__build_event_string(struct strbuf *events,
Quoted 10 lines
tools/perf/util/metricgroup.c +10
-0+ p =strstr (p1+1 ,"@R" ); +if (p ==NULL ) + p = p1; + p = p+1 ; + } + +if (p) { +char *name; +char *at; + struct tpebs_event *new_event = malloc(sizeof(struct
tpebs_event));Quoted 15 lines
tools/perf/util/metricgroup.c +13
-1-pr_debug ("found event %s\n" , id); +if (!new_event) +return -ENOMEM ; + + new_event->tpebs_name =strdup (id); + *p ='\0' ; + name =malloc (strlen (id) +2 ); +if (!name) +return -ENOMEM ; + + at =strchr (id,'@' ); +if (at !=NULL ) { + *at ='/' ; + at =strchr (id,'@' );tools/perf/util/metricgroup.c static int metricgroup__build_event_string(struct strbuf *events,
Quoted 10 lines
tools/perf/util/metricgroup.c +10
-0+ *at ='/' ; +strcpy (name, id); +strcat (name,"p" ); + }else { +strcpy (name, id); +strcat (name,":p" ); + } + new_event->name = name; + *tpebs_event_size +=1 ; + pr_debug("retire_latency required, tpebs_event_size=%lu,new_event=%s\n",
Quoted 7 lines
tools/perf/util/metricgroup.c +4
-0+ *tpebs_event_size, new_event->name); +list_add_tail (&new_event->nd, tpebs_events); +continue ; + }/* Always move tool events outside of the group. */ ev =perf_tool_event__from_str (id);
Namhyung Kim
maintainerRe: [RFC PATCH v5 1/6] perf stat: Parse and find tpebs events when parsing metrics to prepare for perf record sampling
Quoted 47 lines · Weilin
Quoted 43 lines
-----Original Message-----
From: Namhyung Kim <[email protected]>
Sent: Thursday, March 28, 2024 10:46 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 v5 1/6] perf stat: Parse and find tpebs events when parsing metrics to prepare for perf record samplingQuoted 10 lines · On Tue, Mar 26, 2024 at 1:29 PM <[email protected]> wrote:
From: Weilin Wang <[email protected]>
Metrics that use tpebs values would use the :retire_latency keyword in 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]>---
[SNIP]
Review static int metricgroup__build_event_string(struct
Quoted 1 line
(quoted diff) +0
-0@@ -681,8 +685,56 @@ static int metricgroup__build_event_string(structstrbuf *events,
tools/perf/util/metricgroup.c static int metricgroup__build_event_string(struct strbuf *events, · line 694
Quoted 10 lines
tools/perf/util/metricgroup.c +7
-0hashmap__for_each_entry (ctx->ids, cur, bkt) {const char *sep, *rsep, *id = cur->pkey;enum perf_tool_event ev; +/* +* Parse and search for event name with retire_latency modifier. +* If found, put event name into the tpebs_events list. This list +* of events will be passed to perf record for sampling to get +* their reitre_latency value. +* Search for ":R" in event name without "@". Search for the +* last "@R" in event name with "@". Quoted 3 lines
What is the
retire_latencymodifier exactly? Why do you search for :R and @R? What's the difference? Why don't you search for "retire_latency"?
Quoted 5 lines
We decided to use R as the modifier for
retire_latencyin one of the previous version of code review. Therefore, the code searches for R instead of "retire_latency".It should search for :R in usual cases. But in hybrid platform, event name might be in format like cpu_core@event_name@R.
Ok, thanks for the explanation. Please update the commit message and the comment with this info.
Thanks,
Namhyung
RFC PATCH v5 2/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.
--- tools/perf/builtin-stat.c | 165 +++++++++++++++++++++++++++++++++- tools/perf/util/data.c | 3 + tools/perf/util/data.h | 5 ++ tools/perf/util/metricgroup.h | 8 ++ tools/perf/util/stat.h | 2 + 5 files changed, 181 insertions(+), 2 deletions(-)
tools/perf/builtin-stat.c +163 -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)
@@ -687,12 +694,155 @@ static enum counter_recovery stat_handle_error(struct evsel *counter)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" ; + +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; + + record_argv =calloc (10 +2 * stat_config.tpebs_event_size,sizeof (char *)); +if (!record_argv) +return -1 ; +__run_perf_record (record_argv); + +prepare_run_command (cmd, record_argv); +return start_command (cmd); +} + +struct perf_script { +struct perf_tool tool; +struct perf_session *session; +}; + +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); +free (r); + } +list_for_each_entry_safe (e, etmp, &stat_config.tpebs_events, nd) { +list_del_init (&e->nd); +free (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 int __cmd_script (struct child_process *cmd__maybe_unused ) +{ +int err =0 ; +struct perf_session *session; +struct perf_data data = { + .mode =PERF_DATA_MODE_READ , + .path =PERF_DATA , + .fd = cmd->out, + }; +struct perf_script script = { + .tool = { + .sample = process_sample_event, + .ordering_requires_timestamps = true, + .feature = process_feature_event, + .attr = perf_event__process_attr, + }, + }; +struct tpebs_event *e; + +list_for_each_entry (e, &stat_config.tpebs_events, nd) { +struct tpebs_retire_lat *new =malloc (sizeof (struct tpebs_retire_lat )); + +if (!new) +return -1 ; + new->event.name =strdup (e->name); + new->event.tpebs_name =strdup (e->tpebs_name); + new->count =0 ; + new->sum =0 ; +list_add_tail (&new->event.nd, &stat_config.tpebs_results); + } + +kill (cmd->pid,SIGTERM ); + session =perf_session__new (&data, &script.tool); +if (IS_ERR (session)) +return PTR_ERR (session); + script.session = session; + err =perf_session__process_events (session); +perf_session__delete (session); + +return err; +} +static int __run_perf_stat (int argc,const char **argv,int run_idx) {int interval = stat_config.interval;
@@ -709,13 +859,15 @@ 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;/* 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 (); +pr_debug ("perf stat pid = %d\n" ,getpid ()); + ret =prepare_perf_record (&cmd);if (ret)return ret; }
@@ -925,6 +1077,13 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) t1 =rdclock (); +if (stat_config.tpebs_event_size >0 ) { +int ret; + + ret =__cmd_script (&cmd); +close (cmd.out); + } +if (stat_config.walltime_run_table) stat_config.walltime_run[run_idx] = t1 - t0;
@@ -2972,5 +3131,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/data.c +3 -0
@@ -185,6 +185,9 @@ static bool check_pipe(struct perf_data *data)int fd =perf_data__is_read (data) ?STDIN_FILENO :STDOUT_FILENO ; +if (data->fd >0 ) + fd = data->fd; +if (!data->path) {if (!fstat (fd, &st) &&S_ISFIFO (st.st_mode)) is_pipe = true;
tools/perf/util/data.h +5 -0
@@ -28,6 +28,11 @@ struct perf_data_file {struct perf_data {const char *path; +/* +* When fd is given, use PIPE instead of file, use given fd instead of +* STDIN_FILENO or STDOUT_FILENO +*/ +int fd;struct perf_data_file file;bool is_pipe;bool is_dir;
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 TPEBS modifier */ 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 v5 2/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, Mar 26, 2024 at 1:29 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 4 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.
I'm afraid this requirement is too Intel specific. Maybe we need to move the code to somewhere under the arch directory.
Quoted 52 lines
Signed-off-by Weilin Wang <[email protected]>Reviewed-by Ian Rogers <[email protected]>--- tools/perf/builtin-stat.c | 165 +++++++++++++++++++++++++++++++++- tools/perf/util/data.c | 3 + tools/perf/util/data.h | 5 ++ tools/perf/util/metricgroup.h | 8 ++ tools/perf/util/stat.h | 2 + 5 files changed, 181 insertions(+), 2 deletions(-)tools/perf/builtin-stat.c +14
-1@@ -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)@@ -687,12 +694,155 @@ static enum counter_recovery stat_handle_error(struct evsel *counter)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" ;
tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter) · line 715
Quoted 10 lines
tools/perf/builtin-stat.c +10
-0+ 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" ;
What do you want to do if neither of -a nor -C is used? Maybe you can disable perf record in background.
Quoted 32 lines
tools/perf/builtin-stat.c +29
-0+ +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; + + record_argv =calloc (10 +2 * stat_config.tpebs_event_size,sizeof (char *)); +if (!record_argv) +return -1 ; +__run_perf_record (record_argv); + +prepare_run_command (cmd, record_argv); +return start_command (cmd); +}
tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter) · line 757
Quoted 10 lines
tools/perf/builtin-stat.c +10
-0+ +struct perf_script { +struct perf_tool tool; +struct perf_session *session; +}; + +static void tpebs_data__delete (void ) +{ +struct tpebs_retire_lat *r, *rtmp; +struct tpebs_event *e, *etmp;
A blank line please.
Quoted 44 lines
tools/perf/builtin-stat.c +44
-0+list_for_each_entry_safe (r, rtmp, &stat_config.tpebs_results, event.nd) { +list_del_init (&r->event.nd); +free (r); + } +list_for_each_entry_safe (e, etmp, &stat_config.tpebs_events, nd) { +list_del_init (&e->nd); +free (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 ;
tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter) · line 811
Quoted 10 lines
tools/perf/builtin-stat.c +10
-0+} + +static int __cmd_script (struct child_process *cmd__maybe_unused ) +{ +int err =0 ; +struct perf_session *session; +struct perf_data data = { + .mode =PERF_DATA_MODE_READ , + .path =PERF_DATA , + .fd = cmd->out,
I don't like this part as it added the fd field unnecessarily. I think we need a new session API that can pass a fd directly.
tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter) · line 816
Quoted 5 lines
tools/perf/builtin-stat.c +5
-0+ }; +struct perf_script script = { + .tool = { + .sample = process_sample_event, + .ordering_requires_timestamps = true,
Is this really needed? I don't think it needs ordering.
Quoted 9 lines
tools/perf/builtin-stat.c +9
-0+ .feature = process_feature_event, + .attr = perf_event__process_attr, + }, + }; +struct tpebs_event *e; + +list_for_each_entry (e, &stat_config.tpebs_events, nd) { +struct tpebs_retire_lat *new =malloc (sizeof (struct tpebs_retire_lat )); +
tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter) · line 835
Quoted 10 lines
tools/perf/builtin-stat.c +10
-0+if (!new) +return -1 ; + new->event.name =strdup (e->name); + new->event.tpebs_name =strdup (e->tpebs_name); + new->count =0 ; + new->sum =0 ; +list_add_tail (&new->event.nd, &stat_config.tpebs_results); + } + +kill (cmd->pid,SIGTERM );
Is this the only place to stop the perf record? What if perf stat exits before calling this function?
Quoted 71 lines
tools/perf/builtin-stat.c +22
-1+ session =perf_session__new (&data, &script.tool); +if (IS_ERR (session)) +return PTR_ERR (session); + script.session = session; + err =perf_session__process_events (session); +perf_session__delete (session); + +return err; +} +static int __run_perf_stat (int argc,const char **argv,int run_idx) {int interval = stat_config.interval;@@ -709,13 +859,15 @@ 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;/* 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 (); +pr_debug ("perf stat pid = %d\n" ,getpid ()); + ret =prepare_perf_record (&cmd);if (ret)return ret; }@@ -925,6 +1077,13 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) t1 =rdclock (); +if (stat_config.tpebs_event_size >0 ) { +int ret; + + ret =__cmd_script (&cmd); +close (cmd.out); + } +if (stat_config.walltime_run_table) stat_config.walltime_run[run_idx] = t1 - t0;@@ -2972,5 +3131,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/data.c +3
-0@@ -185,6 +185,9 @@ static bool check_pipe(struct perf_data *data)int fd =perf_data__is_read (data) ?STDIN_FILENO :STDOUT_FILENO ; +if (data->fd >0 ) + fd = data->fd; +if (!data->path) {if (!fstat (fd, &st) &&S_ISFIFO (st.st_mode)) is_pipe = true;tools/perf/util/data.h +0
-0
tools/perf/util/data.h struct perf_data_file { · line 35
Quoted 8 lines
tools/perf/util/data.h +5
-0@@ -28,6 +28,11 @@ struct perf_data_file {struct perf_data {const char *path; +/* +* When fd is given, use PIPE instead of file, use given fd instead of +* STDIN_FILENO or STDOUT_FILENO +*/ +int fd;
Maybe users can set data.file.fd directly instead of this.
Quoted 8 lines
tools/perf/util/data.h +0
-0struct perf_data_file file;bool is_pipe;bool is_dir;tools/perf/util/metricgroup.h +0
-0
tools/perf/util/metricgroup.h struct metric_expr { · line 73
Quoted 6 lines
tools/perf/util/metricgroup.h +2
-0@@ -68,10 +68,18 @@ struct metric_expr {struct tpebs_event {struct list_head nd; +/* Event name */ const char *name; +/* Event name with TPEBS modifier */
What is the TPEBS modifier?
Thanks,
Namhyung
Quoted 28 lines
tools/perf/util/metricgroup.h +6
-0const 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
RE: [RFC PATCH v5 2/6] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric.
Quoted 320 lines
-----Original Message-----
From: Namhyung Kim <[email protected]>
Sent: Thursday, March 28, 2024 11:43 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 v5 2/6] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric.Quoted 9 lines · On Tue, Mar 26, 2024 at 1:29 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.At the point of time that perf stat stops counting, it would send sigterm
signal
Quoted 1 line
to perf record process and receiving sampling data back from perf record
from a
Quoted 2 lines
pipe. Perf stat will then process the received data to get retire latency data and calculate metric result.
I'm afraid this requirement is too Intel specific. Maybe we need to move the code to somewhere under the arch directory.
Quoted 5 lines
Signed-off-by Weilin Wang <[email protected]>Reviewed-by Ian Rogers <[email protected]>--- tools/perf/builtin-stat.c | 165+++++++++++++++++++++++++++++++++-
tools/perf/builtin-stat.c static enum counter_recovery
Quoted 34 lines
tools/perf/util/data.c | 3 + tools/perf/util/data.h | 5 ++ tools/perf/util/metricgroup.h | 8 ++ tools/perf/util/stat.h | 2 + 5 files changed, 181 insertions(+), 2 deletions(-)tools/perf/builtin-stat.c +7
-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);@@ -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)@@ -687,12 +694,155 @@ static enum counter_recovery
stat_handle_error(struct evsel *counter)Quoted 13 lines
tools/perf/builtin-stat.c +7
-1return 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" ;tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter) · line 715
Quoted 10 lines
tools/perf/builtin-stat.c +10
-0+ 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" ;What do you want to do if neither of -a nor -C is used? Maybe you can disable perf record in background.
Quoted 15 lines
tools/perf/builtin-stat.c +12
-0+ +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) +{tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter)
Quoted 10 lines
tools/perf/builtin-stat.c +10
-0+memset (cmd,0 ,sizeof (*cmd)); + cmd->argv = argv; + cmd->out =-1 ; +} + +static int prepare_perf_record (struct child_process *cmd) +{ +const char **record_argv; + + record_argv = calloc(10 + 2 * stat_config.tpebs_event_size, sizeof(char*));
Quoted 7 lines
tools/perf/builtin-stat.c +7
-0+if (!record_argv) +return -1 ; +__run_perf_record (record_argv); + +prepare_run_command (cmd, record_argv); +return start_command (cmd); +}tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter) · line 757
Quoted 10 lines
tools/perf/builtin-stat.c +10
-0+ +struct perf_script { +struct perf_tool tool; +struct perf_session *session; +}; + +static void tpebs_data__delete (void ) +{ +struct tpebs_retire_lat *r, *rtmp; +struct tpebs_event *e, *etmp;A blank line please.
tools/perf/builtin-stat.c static enum counter_recovery · line 758
Quoted 1 line
tools/perf/builtin-stat.c +1
-0+list_for_each_entry_safe (r, rtmp, &stat_config.tpebs_results, event.nd){
Quoted 14 lines
tools/perf/builtin-stat.c +14
-0+list_del_init (&r->event.nd); +free (r); + } +list_for_each_entry_safe (e, etmp, &stat_config.tpebs_events, nd) { +list_del_init (&e->nd); +free (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 )tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter)
Quoted 10 lines
tools/perf/builtin-stat.c +10
-0+{ +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
Quoted 19 lines
tools/perf/builtin-stat.c +19
-0+* 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 ;tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter) · line 811
Quoted 10 lines
tools/perf/builtin-stat.c +10
-0+} + +static int __cmd_script (struct child_process *cmd__maybe_unused ) +{ +int err =0 ; +struct perf_session *session; +struct perf_data data = { + .mode =PERF_DATA_MODE_READ , + .path =PERF_DATA , + .fd = cmd->out,I don't like this part as it added the fd field unnecessarily. I think we need a new session API that can pass a fd directly.
tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter) · line 816
Quoted 5 lines
tools/perf/builtin-stat.c +5
-0+ }; +struct perf_script script = { + .tool = { + .sample = process_sample_event, + .ordering_requires_timestamps = true,Is this really needed? I don't think it needs ordering.
tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter)
Quoted 8 lines
tools/perf/builtin-stat.c +8
-0+ .feature = process_feature_event, + .attr = perf_event__process_attr, + }, + }; +struct tpebs_event *e; + +list_for_each_entry (e, &stat_config.tpebs_events, nd) { + struct tpebs_retire_lat *new = malloc(sizeof(struct
tpebs_retire_lat));tools/perf/builtin-stat.c static enum counter_recovery stat_handle_error(struct evsel *counter) · line 835
Quoted 11 lines
tools/perf/builtin-stat.c +11
-0+ +if (!new) +return -1 ; + new->event.name =strdup (e->name); + new->event.tpebs_name =strdup (e->tpebs_name); + new->count =0 ; + new->sum =0 ; +list_add_tail (&new->event.nd, &stat_config.tpebs_results); + } + +kill (cmd->pid,SIGTERM );Is this the only place to stop the perf record? What if perf stat exits before calling this function?
tools/perf/builtin-stat.c static int __run_perf_stat(int argc, const char
Quoted 14 lines
tools/perf/builtin-stat.c +10
-0+ session =perf_session__new (&data, &script.tool); +if (IS_ERR (session)) +return PTR_ERR (session); + script.session = session; + err =perf_session__process_events (session); +perf_session__delete (session); + +return err; +} +static int __run_perf_stat (int argc,const char **argv,int run_idx) {int interval = stat_config.interval;@@ -709,13 +859,15 @@ static int __run_perf_stat(int argc, const char**argv, int
run_idx)tools/perf/builtin-stat.c static int __run_perf_stat(int argc, const char
Quoted 17 lines
tools/perf/builtin-stat.c +3
-1struct affinity saved_affinity, *affinity =NULL ;int err;bool second_pass = false; +struct child_process cmd;/* 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 (); +pr_debug ("perf stat pid = %d\n" ,getpid ()); + ret =prepare_perf_record (&cmd);if (ret)return ret; }@@ -925,6 +1077,13 @@ static int __run_perf_stat(int argc, const char**argv, int
run_idx)Quoted 14 lines
tools/perf/builtin-stat.c +7
-0t1 =rdclock (); +if (stat_config.tpebs_event_size >0 ) { +int ret; + + ret =__cmd_script (&cmd); +close (cmd.out); + } +if (stat_config.walltime_run_table) stat_config.walltime_run[run_idx] = t1 - t0;tools/perf/builtin-stat.c int cmd_stat(int argc, const char **argv) · line 3132
Quoted 2 lines
tools/perf/builtin-stat.c +0
-0@@ -2972,5 +3131,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);
Quoted 25 lines
tools/perf/builtin-stat.c +2
-0+tpebs_data__delete (); +return status; }tools/perf/util/data.c +3
-0@@ -185,6 +185,9 @@ static bool check_pipe(struct perf_data *data)int fd =perf_data__is_read (data) ?STDIN_FILENO :STDOUT_FILENO ; +if (data->fd >0 ) + fd = data->fd; +if (!data->path) {if (!fstat (fd, &st) &&S_ISFIFO (st.st_mode)) is_pipe = true;tools/perf/util/data.h +0
-0@@ -28,6 +28,11 @@ struct perf_data_file {
Quoted 9 lines
tools/perf/util/data.h struct perf_data_file { · line 35
Quoted 7 lines
tools/perf/util/data.h +5
-0struct perf_data {const char *path; +/* +* When fd is given, use PIPE instead of file, use given fd instead of +* STDIN_FILENO or STDOUT_FILENO +*/ +int fd;Maybe users can set data.file.fd directly instead of this.
This will require a little code change in function check_pipe() in data.c. Do you want me to update that?
Thanks,
Weilin
Quoted 51 lines
Quoted 10 lines
tools/perf/util/data.h +0
-0struct perf_data_file file;bool is_pipe;bool is_dir;tools/perf/util/metricgroup.h +0
-0tools/perf/util/metricgroup.h struct metric_expr { · line 73
Quoted 6 lines
tools/perf/util/metricgroup.h +2
-0@@ -68,10 +68,18 @@ struct metric_expr {struct tpebs_event {struct list_head nd; +/* Event name */ const char *name; +/* Event name with TPEBS modifier */ What is the TPEBS modifier?
Thanks,
NamhyungQuoted 28 lines
tools/perf/util/metricgroup.h +6
-0const 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 v5 3/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
@@ -786,6 +786,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, nd) { + ret =expr__add_id_val (pctx,strdup (t->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 v5 4/6 perf stat: Create another thread for sample data processing
In reply to [email protected]From: Weilin Wang <[email protected]>
Another thread is required to synchronize between perf stat and perf record when we pass data through pipe.
--- tools/perf/builtin-stat.c | 51 +++++++++++++++++++++-------------- tools/perf/util/stat-shadow.c | 4 +-- 2 files changed, 33 insertions(+), 22 deletions(-)
tools/perf/builtin-stat.c +31 -20
@@ -802,9 +802,9 @@ static int process_feature_event(struct perf_session *session,return 0 ; } -static int __cmd_script (struct child_process *cmd__maybe_unused ) +static void *__cmd_script (void *arg__maybe_unused ) { -int err =0 ; +struct child_process *cmd = arg;struct perf_session *session;struct perf_data data = { .mode =PERF_DATA_MODE_READ ,
@@ -819,29 +819,15 @@ static int __cmd_script(struct child_process *cmd __maybe_unused) .attr = perf_event__process_attr, }, }; -struct tpebs_event *e; - -list_for_each_entry (e, &stat_config.tpebs_events, nd) { -struct tpebs_retire_lat *new =malloc (sizeof (struct tpebs_retire_lat )); -if (!new) -return -1 ; - new->event.name =strdup (e->name); - new->event.tpebs_name =strdup (e->tpebs_name); - new->count =0 ; - new->sum =0 ; -list_add_tail (&new->event.nd, &stat_config.tpebs_results); - } - -kill (cmd->pid,SIGTERM ); session =perf_session__new (&data, &script.tool);if (IS_ERR (session)) -return PTR_ERR (session); +return NULL ; script.session = session; - err =perf_session__process_events (session); +perf_session__process_events (session);perf_session__delete (session); -return err; +return NULL ; }static int __run_perf_stat (int argc,const char **argv,int run_idx)
@@ -861,16 +847,37 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)int err;bool second_pass = false;struct child_process cmd; +pthread_t thread_script;/* Prepare perf record for sampling event retire_latency before fork and * prepare workload */ 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 )); + +if (!new) +return -1 ; + new->event.name =strdup (e->name); + new->event.tpebs_name =strdup (e->tpebs_name); + 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 (&thread_script,NULL , __cmd_script, &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) {
@@ -1081,8 +1088,12 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)if (stat_config.tpebs_event_size >0 ) {int ret; - ret =__cmd_script (&cmd); +kill (cmd.pid,SIGTERM ); +pthread_join (thread_script,NULL );close (cmd.out); + ret =finish_command (&cmd); +if (ret != -ERR_RUN_COMMAND_WAITPID_SIGNAL ) +return ret; }if (stat_config.walltime_run_table)
tools/perf/util/stat-shadow.c +2 -2
@@ -361,8 +361,8 @@ static int prepare_retire_lat(struct expr_parse_ctx *pctx,int ret =0 ;struct tpebs_retire_lat *t; -list_for_each_entry (t, retire_lats, nd) { - ret =expr__add_id_val (pctx,strdup (t->tpebs_name), t->val); +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; }
Signature · 1 line
2.43.0
Namhyung Kim
maintainerRe: [RFC PATCH v5 4/6] perf stat: Create another thread for sample data processing
Quoted 5 lines · On Tue, Mar 26, 2024 at 1:29 PM <[email protected]> wrote:
From: Weilin Wang <[email protected]>
Another thread is required to synchronize between perf stat and perf record when we pass data through pipe.
It seems better if you can squash this commit to the patch 2/6.
Thanks,
Namhyung
Quoted 127 lines
Signed-off-by Weilin Wang <[email protected]>Reviewed-by Ian Rogers <[email protected]>--- tools/perf/builtin-stat.c | 51 +++++++++++++++++++++-------------- tools/perf/util/stat-shadow.c | 4 +-- 2 files changed, 33 insertions(+), 22 deletions(-)tools/perf/builtin-stat.c +31
-20@@ -802,9 +802,9 @@ static int process_feature_event(struct perf_session *session,return 0 ; } -static int __cmd_script (struct child_process *cmd__maybe_unused ) +static void *__cmd_script (void *arg__maybe_unused ) { -int err =0 ; +struct child_process *cmd = arg;struct perf_session *session;struct perf_data data = { .mode =PERF_DATA_MODE_READ ,@@ -819,29 +819,15 @@ static int __cmd_script(struct child_process *cmd __maybe_unused) .attr = perf_event__process_attr, }, }; -struct tpebs_event *e; - -list_for_each_entry (e, &stat_config.tpebs_events, nd) { -struct tpebs_retire_lat *new =malloc (sizeof (struct tpebs_retire_lat )); -if (!new) -return -1 ; - new->event.name =strdup (e->name); - new->event.tpebs_name =strdup (e->tpebs_name); - new->count =0 ; - new->sum =0 ; -list_add_tail (&new->event.nd, &stat_config.tpebs_results); - } - -kill (cmd->pid,SIGTERM ); session =perf_session__new (&data, &script.tool);if (IS_ERR (session)) -return PTR_ERR (session); +return NULL ; script.session = session; - err =perf_session__process_events (session); +perf_session__process_events (session);perf_session__delete (session); -return err; +return NULL ; }static int __run_perf_stat (int argc,const char **argv,int run_idx)@@ -861,16 +847,37 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)int err;bool second_pass = false;struct child_process cmd; +pthread_t thread_script;/* Prepare perf record for sampling event retire_latency before fork and * prepare workload */ 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 )); + +if (!new) +return -1 ; + new->event.name =strdup (e->name); + new->event.tpebs_name =strdup (e->tpebs_name); + 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 (&thread_script,NULL , __cmd_script, &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) {@@ -1081,8 +1088,12 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)if (stat_config.tpebs_event_size >0 ) {int ret; - ret =__cmd_script (&cmd); +kill (cmd.pid,SIGTERM ); +pthread_join (thread_script,NULL );close (cmd.out); + ret =finish_command (&cmd); +if (ret != -ERR_RUN_COMMAND_WAITPID_SIGNAL ) +return ret; }if (stat_config.walltime_run_table)tools/perf/util/stat-shadow.c +2
-3@@ -361,8 +361,8 @@ static int prepare_retire_lat(struct expr_parse_ctx *pctx,int ret =0 ;struct tpebs_retire_lat *t; -list_for_each_entry (t, retire_lats, nd) { - ret =expr__add_id_val (pctx,strdup (t->tpebs_name), t->val); +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; } --2.43.0
RFC PATCH v5 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:
In this simple example, there is no MEM_INST_RETIRED.STLB_HIT_STORES sample. Therefore, the MEM_INST_RETIRED.STLB_HIT_STORES:p retire_latency value, count and sum are all 0.
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
--- tools/perf/util/stat-display.c | 65 ++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
tools/perf/util/stat-display.c +65 -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,67 @@ 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 %-*s" ,COUNTS_LEN , t->val,EVNAME_LEN , t->event.name); +fprintf (out,"%*ld %*d\n" ,RETIRE_LEN , t->count, +RETIRE_LEN , t->sum); + } +} + +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 +1672,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
RFC PATCH v5 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
Quoted 20 lines · On Tue, Mar 26, 2024 at 1:29 PM <[email protected]> wrote:
From: Weilin Wang <[email protected]>
Changes in v5:
- Update code and add comments for better code quality [Ian]v4: 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 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: Create another thread for sample data processing 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
Quoted 13 lines
tools/perf/builtin-stat.c | 211 +- .../arch/x86/meteorlake/metricgroups.json | 127 + .../arch/x86/meteorlake/mtl-metrics.json | 2551 +++++++++++++++++ tools/perf/util/data.c | 3 + tools/perf/util/data.h | 5 + tools/perf/util/metricgroup.c | 88 +- tools/perf/util/metricgroup.h | 22 +- tools/perf/util/stat-display.c | 65 + tools/perf/util/stat-shadow.c | 19 + tools/perf/util/stat.h | 4 + 10 files changed, 3076 insertions(+), 19 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
Thanks Weilin,
I'm happy with this series, my Reviewed-by is on all the patches. Arnaldo/Namhyung, could we land this for the sake of Meteorlake metric enablement? For the sake of tools, for the series:
Thanks,
Ian
Quoted 3 lines
--
2.43.0
Namhyung Kim
maintainerHello,
Quoted 36 lines · Ian Rogers
Quoted 20 lines · On Tue, Mar 26, 2024 at 1:29 PM <[email protected]> wrote:
From: Weilin Wang <[email protected]>
Changes in v5:
- Update code and add comments for better code quality [Ian]v4: 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 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: Create another thread for sample data processing 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 13 lines
tools/perf/builtin-stat.c | 211 +- .../arch/x86/meteorlake/metricgroups.json | 127 + .../arch/x86/meteorlake/mtl-metrics.json | 2551 +++++++++++++++++ tools/perf/util/data.c | 3 + tools/perf/util/data.h | 5 + tools/perf/util/metricgroup.c | 88 +- tools/perf/util/metricgroup.h | 22 +- tools/perf/util/stat-display.c | 65 + tools/perf/util/stat-shadow.c | 19 + tools/perf/util/stat.h | 4 + 10 files changed, 3076 insertions(+), 19 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
Quoted 7 lines
Thanks Weilin,
I'm happy with this series, my Reviewed-by is on all the patches. Arnaldo/Namhyung, could we land this for the sake of Meteorlake metric enablement? For the sake of tools, for the series:
Reviewed-by Ian Rogers <[email protected]>
Let me review this series again.
Thanks,
Namhyung
Quoted 61 lines
-----Original Message-----
From: Namhyung Kim <[email protected]>
Sent: Thursday, March 28, 2024 12:43 PM
To: Ian Rogers <[email protected]>
Cc: Wang, Weilin <[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 v5 0/6] TPEBS counting mode supportHello,
Quoted 9 lines · Ian Rogers
Quoted 7 lines · On Tue, Mar 26, 2024 at 1:29 PM <[email protected]> wrote:
From: Weilin Wang <[email protected]>
Changes in v5:
- Update code and add comments for better code quality [Ian]Quoted 13 lines
Quoted 13 lines
Weilin Wang (6):
perf stat: Parse and find tpebs events when parsing metrics to prepare
for perf record sampling
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: Create another thread for sample data processing 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 3 lines
Quoted 3 lines
tools/perf/builtin-stat.c | 211 +- .../arch/x86/meteorlake/metricgroups.json | 127 + .../arch/x86/meteorlake/mtl-metrics.json | 2551+++++++++++++++++
Quoted 9 lines
Quoted 9 lines
tools/perf/util/data.c | 3 + tools/perf/util/data.h | 5 + tools/perf/util/metricgroup.c | 88 +- tools/perf/util/metricgroup.h | 22 +- tools/perf/util/stat-display.c | 65 + tools/perf/util/stat-shadow.c | 19 + tools/perf/util/stat.h | 4 + 10 files changed, 3076 insertions(+), 19 deletions(-) create mode 100644 tools/perf/pmu-
events/arch/x86/meteorlake/metricgroups.jsonQuoted 1 line
Quoted 1 line
create mode 100644 tools/perf/pmu-events/arch/x86/meteorlake/mtl-metrics.json
Quoted 3 lines
Thanks Weilin,
Quoted 7 lines
Quoted 5 lines
I'm happy with this series, my Reviewed-by is on all the patches. Arnaldo/Namhyung, could we land this for the sake of Meteorlake metric enablement? For the sake of tools, for the series:
Reviewed-by Ian Rogers <[email protected]>Let me review this series again.
Thanks a lot Ian and Namhyung!
Quoted 3 lines
Thanks,
Namhyung