perf stat: Introduce iostat mode to provide I/O performance metrics
v5 cover perf stat: Introduce iostat mode to provide I/O performance metrics
From: Alexander Antonov <[email protected]>
Resending V5 with added Acked-by: Namhyung Kim <[email protected]> tag.
Thanks,
Alexander
The previous version can be found at:
v4: https://lkml.kernel.org/r/[email protected]/
Changes in this revision are:
v4 -> v5:
- Addressed comments from Namhyung Kim:
1. Removed AGGR_PCIE_PORT aggregation mode
2. Added iostat_prepare() function
3. Moved implementation specific fprintf() calls to separate x86-related function
4. Fixed code-related issues
- Moved __weak iostat's functions to separate util/iostat.c file
The previous version can be found at:
v3: https://lkml.kernel.org/r/[email protected]/
Changes in this revision are:
v3 -> v4:
- Addressed comment from Namhyung Kim:
1. Removed NULL-termination of root ports list
The previous version can be found at:
v2: https://lkml.kernel.org/r/[email protected]
Changes in this revision are:
v2 -> v3:
- Addressed comments from Namhyung Kim:
1. Removed perf_device pointer from evsel structure. Use priv field instead
2. Renamed 'iiostat' to 'iostat'
3. Renamed 'show' mode to 'list' mode
4. Renamed iiostat_delete_root_ports() to iiostat_release() and iostat_show_root_ports() to iostat_list()
The previous version can be found at:
v1: https://lkml.kernel.org/r/[email protected]
Changes in this revision are:
v1 -> v2:
- Addressed comment from Arnaldo Carvalho de Melo:
1. Using 'perf iiostat' subcommand instead of 'perf stat --iiostat':
- Added perf-iiostat.sh script to use short command
- Updated manual pages to get help for 'perf iiostat'
- Added 'perf-iiostat' to perf's gitignore file
Mode is intended to provide four I/O performance metrics in MB per each root port:
- Inbound Read: I/O devices below root port read from the host memory - Inbound Write: I/O devices below root port write to the host memory - Outbound Read: CPU reads from I/O devices below root port
- Outbound Write: CPU writes to I/O devices below root port
Each metric requiries only one uncore event which increments at every 4B transfer in corresponding direction. The formulas to compute metrics are generic:
#EventCount * 4B / (1024 * 1024)
Note: iostat introduces new perf data aggregation mode - per PCIe root port hence -e and -M options are not supported.
Usage examples:
1. List all PCIe root ports (example for 2-S platform):
$ perf iostat list S0-uncore_iio_0<0000:00> S1-uncore_iio_0<0000:80> S0-uncore_iio_1<0000:17> S1-uncore_iio_1<0000:85> S0-uncore_iio_2<0000:3a> S1-uncore_iio_2<0000:ae> S0-uncore_iio_3<0000:5d> S1-uncore_iio_3<0000:d7>
2. Collect metrics for all PCIe root ports:
$ perf iostat -- dd if=/dev/zero of=/dev/nvme0n1 bs=1M oflag=direct 357708+0 records in 357707+0 records out 375083606016 bytes (375 GB, 349 GiB) copied, 215.974 s, 1.7 GB/s
Performance counter stats for 'system wide':
port Inbound Read(MB) Inbound Write(MB) Outbound Read(MB) Outbound Write(MB)
0000:00 1 0 2 3 0000:80 0 0 0 0 0000:17 352552 43 0 21 0000:85 0 0 0 0 0000:3a 3 0 0 0 0000:ae 0 0 0 0 0000:5d 0 0 0 0 0000:d7 0 0 0 0
3. Collect metrics for comma separated list of PCIe root ports:
$ perf iostat 0000:17,0:3a -- dd if=/dev/zero of=/dev/nvme0n1 bs=1M oflag=direct 357708+0 records in 357707+0 records out 375083606016 bytes (375 GB, 349 GiB) copied, 197.08 s, 1.9 GB/s
Performance counter stats for 'system wide':
port Inbound Read(MB) Inbound Write(MB) Outbound Read(MB) Outbound Write(MB)
0000:17 358559 44 0 22
0000:3a 3 2 0 0
197.081983474 seconds time elapsed
Alexander Antonov (4):
perf stat: Basic support for iostat in perf
perf stat: Helper functions for PCIe root ports list in iostat mode perf stat: Enable iostat mode for x86 platforms
perf: Update .gitignore file
tools/perf/.gitignore | 1 + tools/perf/Documentation/perf-iostat.txt | 88 +++++ tools/perf/Makefile.perf | 5 +- tools/perf/arch/x86/util/Build | 1 + tools/perf/arch/x86/util/iostat.c | 470 +++++++++++++++++++++++ tools/perf/builtin-stat.c | 21 +- tools/perf/command-list.txt | 1 + tools/perf/perf-iostat.sh | 12 + tools/perf/util/Build | 1 + tools/perf/util/iostat.c | 53 +++ tools/perf/util/iostat.h | 47 +++ tools/perf/util/stat-display.c | 40 +- tools/perf/util/stat-shadow.c | 5 +- tools/perf/util/stat.h | 1 + 14 files changed, 733 insertions(+), 13 deletions(-) create mode 100644 tools/perf/Documentation/perf-iostat.txt create mode 100644 tools/perf/arch/x86/util/iostat.c create mode 100644 tools/perf/perf-iostat.sh create mode 100644 tools/perf/util/iostat.c create mode 100644 tools/perf/util/iostat.h
base-commit: 4c391ea001cb2e7bd9a691a886c0dcb030c1791c
Signature · 1 line
2.21.3
PATCH RESEND v5 1/4 perf stat: Basic support for iostat in perf
From: Alexander Antonov <[email protected]>
Add basic flow for a new iostat mode in perf. Mode is intended to provide four I/O performance metrics per each PCIe root port: Inbound Read, Inbound Write, Outbound Read, Outbound Write.
The actual code to compute the metrics and attribute it to root port is in follow-on patches.
--- tools/perf/builtin-stat.c | 21 +++++++++++++- tools/perf/util/Build | 1 + tools/perf/util/iostat.c | 53 ++++++++++++++++++++++++++++++++++ tools/perf/util/iostat.h | 47 ++++++++++++++++++++++++++++++ tools/perf/util/stat-display.c | 40 ++++++++++++++++++------- tools/perf/util/stat-shadow.c | 5 +++- tools/perf/util/stat.h | 1 + 7 files changed, 156 insertions(+), 12 deletions(-) create mode 100644 tools/perf/util/iostat.c create mode 100644 tools/perf/util/iostat.h
tools/perf/builtin-stat.c +20 -1
@@ -68,6 +68,7 @@#include "util/affinity.h" #include "util/pfm.h" #include "util/bpf_counter.h" +#include "util/iostat.h" #include "asm/bug.h" #include <linux/time64.h>
@@ -212,7 +213,8 @@ static struct perf_stat_config stat_config = { .walltime_nsecs_stats = &walltime_nsecs_stats, .big_num = true, .ctl_fd = -1, - .ctl_fd_ack = -1 + .ctl_fd_ack = -1, + .iostat_run = false, };static bool cpus_map_matched (struct evsel *a,struct evsel *b)
@@ -1268,6 +1270,9 @@ static struct option stat_options[] = { "\t\t\t Optionally send control command completion ('ack\\n') to ack-fd descriptor.\n" "\t\t\t Alternatively, ctl-fifo / ack-fifo will be opened and used as ctl-fd / ack-fd.", parse_control_option), + OPT_CALLBACK_OPTARG(0, "iostat", &evsel_list, &stat_config, "default", + "measure I/O performance metrics provided by arch/platform", + iostat_parse), OPT_END() };
@@ -2341,6 +2346,17 @@ int cmd_stat(int argc, const char **argv) goto out; } +if (stat_config.iostat_run) { + status =iostat_prepare (evsel_list, &stat_config); +if (status) + goto out; +if (iostat_mode ==IOSTAT_LIST ) { +iostat_list (evsel_list, &stat_config); + goto out; + }else if (verbose) +iostat_list (evsel_list, &stat_config); + } +if (add_default_attributes ()) goto out;
@@ -2516,6 +2532,9 @@ int cmd_stat(int argc, const char **argv)perf_stat__exit_aggr_mode ();evlist__free_stats (evsel_list); out: +if (stat_config.iostat_run) +iostat_release (evsel_list); +zfree (&stat_config.walltime_run);if (smi_cost && smi_reset)
tools/perf/util/Build +1 -0
@@ -102,6 +102,7 @@ perf-y += rwsem.o perf-y += thread-stack.o perf-y += spark.o perf-y += topdown.o +perf-y += iostat.o perf-y += stream.o perf-$(CONFIG_AUXTRACE) += auxtrace.o perf-$(CONFIG_AUXTRACE) += intel-pt-decoder/
tools/perf/util/iostat.c new file +53 -0
53 lines not on this page · raw message
tools/perf/util/iostat.h new file +47 -0
47 lines not on this page · raw message
tools/perf/util/stat-display.c +30 -10
@@ -17,6 +17,7 @@#include "cgroup.h" #include <api/fs/fs.h> #include "util.h" +#include "iostat.h" #define CNTR_NOT_SUPPORTED "<not supported>"#define CNTR_NOT_COUNTED "<not counted>"
@@ -310,6 +311,11 @@ static void print_metric_header(struct perf_stat_config *config,struct outstate *os = ctx;char tbuf[1024 ]; +/* In case of iostat, print metric header for first root port only */ +if (config->iostat_run && + os->evsel->priv != os->evsel->evlist->selected->priv) +return ; +if (!valid_only_metric (unit))return ; unit =fixunit (tbuf, os->evsel, unit);
@@ -958,8 +964,11 @@ static void print_metric_headers(struct perf_stat_config *config,if (config->csv_output) {if (config->interval)fputs ("time," , config->output); -fputs (aggr_header_csv[config->aggr_mode], config->output); +if (!config->iostat_run) +fputs (aggr_header_csv[config->aggr_mode], config->output); } +if (config->iostat_run) +iostat_print_header_prefix (config);/* Print metrics headers only */ evlist__for_each_entry (evlist, counter) {
@@ -989,7 +998,8 @@ static void print_interval(struct perf_stat_config *config,if (config->interval_clear)puts (CONSOLE_CLEAR ); -sprintf (prefix,"%6lu.%09lu%s" , (unsigned long ) ts->tv_sec, ts->tv_nsec, config->csv_sep); +if (!config->iostat_run) +sprintf (prefix,"%6lu.%09lu%s" , (unsigned long ) ts->tv_sec, ts->tv_nsec, config->csv_sep);if ((num_print_interval ==0 && !config->csv_output) || config->interval_clear) {switch (config->aggr_mode) {
@@ -1025,9 +1035,11 @@ static void print_interval(struct perf_stat_config *config,break ;case AGGR_GLOBAL :default : -fprintf (output,"# time" ); -if (!metric_only) -fprintf (output," counts %*s events\n" , unit_width,"unit" ); +if (!config->iostat_run) { +fprintf (output,"# time" ); +if (!metric_only) +fprintf (output," counts %*s events\n" , unit_width,"unit" ); + }case AGGR_UNSET :break ; }
@@ -1220,6 +1232,9 @@ void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *confstruct evsel *counter;char buf[64 ], *prefix =NULL ; +if (config->iostat_run) + evlist->selected =evlist__first (evlist); +if (interval)print_interval (config, evlist, prefix = buf, ts);else
@@ -1232,7 +1247,7 @@ void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *confprint_metric_headers (config, evlist, prefix, false);if (num_print_iv++ ==25 ) num_print_iv =0 ; -if (config->aggr_mode ==AGGR_GLOBAL && prefix) +if (config->aggr_mode ==AGGR_GLOBAL && prefix && !config->iostat_run)fprintf (config->output,"%s" , prefix); }
@@ -1249,11 +1264,16 @@ void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *conf }break ;case AGGR_GLOBAL : -evlist__for_each_entry (evlist, counter) { -print_counter_aggr (config, counter, prefix); +if (config->iostat_run) +iostat_print_counters (evlist, config, ts, prefix = buf, + print_counter_aggr); +else { +evlist__for_each_entry (evlist, counter) { +print_counter_aggr (config, counter, prefix); + } +if (metric_only) +fputc ('\n' , config->output); } -if (metric_only) -fputc ('\n' , config->output);break ;case AGGR_NONE :if (metric_only)
tools/perf/util/stat-shadow.c +4 -1
@@ -11,6 +11,7 @@#include "cgroup.h" #include "units.h" #include <linux/zalloc.h> +#include "iostat.h" /* * AGGR_GLOBAL: Use CPU 0
@@ -962,7 +963,9 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,struct metric_event *me;int num =1 ; -if (evsel__match (evsel,HARDWARE ,HW_INSTRUCTIONS )) { +if (config->iostat_run) { +iostat_print_metric (config, evsel, out); + }else if (evsel__match (evsel,HARDWARE ,HW_INSTRUCTIONS )) { total =runtime_stat_avg (st,STAT_CYCLES , cpu, &rsd);if (total) {
tools/perf/util/stat.h +1 -0
@@ -133,6 +133,7 @@ struct perf_stat_config {bool metric_no_merge;bool stop_read_counter;bool quiet; +bool iostat_run;FILE *output;unsigned int interval;unsigned int timeout;
Signature · 1 line
2.21.3
PATCH RESEND v5 2/4 perf stat: Helper functions for PCIe root ports list in iostat mode
In reply to [email protected]From: Alexander Antonov <[email protected]>
Introduce helper functions to control PCIe root ports list. These helpers will be used in the follow-up patch.
--- tools/perf/arch/x86/util/iostat.c | 110 ++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 tools/perf/arch/x86/util/iostat.c
tools/perf/arch/x86/util/iostat.c new file +110 -0
@@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* perf iostat +* +* Copyright (C) 2020, Intel Corporation +* +* Authors: Alexander Antonov <[email protected]> +*/ + +#include <api/fs/fs.h> +#include <linux/kernel.h> +#include <linux/err.h> +#include <limits.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <dirent.h> +#include <unistd.h> +#include <stdlib.h> +#include <regex.h> +#include "util/cpumap.h" +#include "util/debug.h" +#include "util/iostat.h" +#include "util/counts.h" +#include "path.h" + +struct iio_root_port { +u32 domain; +u8 bus; +u8 die; +u8 pmu_idx; +int idx; +}; + +struct iio_root_ports_list { +struct iio_root_port **rps; +int nr_entries; +}; + +static void iio_root_port_show (FILE *output, +const struct iio_root_port *const rp) +{ +if (output && rp) +fprintf (output,"S%d-uncore_iio_%d<%04x:%02x>\n" , + rp->die, rp->pmu_idx, rp->domain, rp->bus); +} + +static struct iio_root_port *iio_root_port_new (u32 domain,u8 bus, +u8 die,u8 pmu_idx) +{ +struct iio_root_port *p =calloc (1 ,sizeof (*p)); + +if (p) { + p->domain = domain; + p->bus = bus; + p->die = die; + p->pmu_idx = pmu_idx; + } +return p; +} + +static void iio_root_ports_list_free (struct iio_root_ports_list *list) +{ +int idx; + +if (list) { +for (idx =0 ; idx < list->nr_entries; idx++) +free (list->rps[idx]); +free (list->rps); +free (list); + } +} + +static struct iio_root_port *iio_root_port_find_by_notation ( +const struct iio_root_ports_list *const list,u32 domain,u8 bus) +{ +int idx; +struct iio_root_port *rp; + +if (list) { +for (idx =0 ; idx < list->nr_entries; idx++) { + rp = list->rps[idx]; +if (rp && rp->domain == domain && rp->bus == bus) +return rp; + } + } +return NULL ; +} + +static int iio_root_ports_list_insert (struct iio_root_ports_list *list, +struct iio_root_port *const rp) +{ +struct iio_root_port **tmp_buf; + +if (list && rp) { + rp->idx = list->nr_entries++; + tmp_buf =realloc (list->rps, + list->nr_entries *sizeof (*list->rps)); +if (!tmp_buf) { +pr_err ("Failed to realloc memory\n" ); +return -ENOMEM ; + } + tmp_buf[rp->idx] = rp; + list->rps = tmp_buf; + } +return 0 ; +}
Signature · 1 line
2.21.3
PATCH RESEND v5 3/4 perf stat: Enable iostat mode for x86 platforms
In reply to [email protected]From: Alexander Antonov <[email protected]>
This functionality is based on recently introduced sysfs attributes for Intel® Xeon® Scalable processor family (code name Skylake-SP):
Commit bb42b3d39781 ("perf/x86/intel/uncore: Expose an Uncore unit to IIO PMON mapping")
Mode is intended to provide four I/O performance metrics in MB per each PCIe root port:
- Inbound Read: I/O devices below root port read from the host memory
- Inbound Write: I/O devices below root port write to the host memory
- Outbound Read: CPU reads from I/O devices below root port
- Outbound Write: CPU writes to I/O devices below root port
Each metric requiries only one uncore event which increments at every 4B transfer in corresponding direction. The formulas to compute metrics are generic:
#EventCount * 4B / (1024 * 1024)
--- tools/perf/Documentation/perf-iostat.txt | 88 ++++++ tools/perf/Makefile.perf | 5 +- tools/perf/arch/x86/util/Build | 1 + tools/perf/arch/x86/util/iostat.c | 360 +++++++++++++++++++++++ tools/perf/command-list.txt | 1 + tools/perf/perf-iostat.sh | 12 + 6 files changed, 466 insertions(+), 1 deletion(-) create mode 100644 tools/perf/Documentation/perf-iostat.txt create mode 100644 tools/perf/perf-iostat.sh
tools/perf/Documentation/perf-iostat.txt new file +88 -0
@@ -0,0 +1,88 @@ +perf-iostat(1) +=============== + +NAME +---- +perf-iostat - Show I/O performance metrics + +SYNOPSIS +-------- +[verse] +'perf iostat' list +'perf iostat' <ports> -- <command> [<options>] + +DESCRIPTION +----------- +Mode is intended to provide four I/O performance metrics per each PCIe root port: + +- Inbound Read - I/O devices below root port read from the host memory, in MB + +- Inbound Write - I/O devices below root port write to the host memory, in MB + +- Outbound Read - CPU reads from I/O devices below root port, in MB + +- Outbound Write - CPU writes to I/O devices below root port, in MB + +OPTIONS +------- +<command>...:: + Any command you can specify in a shell. + +list:: + List all PCIe root ports. + +<ports>:: + Select the root ports for monitoring. Comma-separated list is supported. + +EXAMPLES +-------- + +1. List all PCIe root ports (example for 2-S platform): + + $ perf iostat list + S0-uncore_iio_0<0000:00> + S1-uncore_iio_0<0000:80> + S0-uncore_iio_1<0000:17> + S1-uncore_iio_1<0000:85> + S0-uncore_iio_2<0000:3a> + S1-uncore_iio_2<0000:ae> + S0-uncore_iio_3<0000:5d> + S1-uncore_iio_3<0000:d7> + +2. Collect metrics for all PCIe root ports: + + $ perf iostat -- dd if=/dev/zero of=/dev/nvme0n1 bs=1M oflag=direct + 357708+0 records in + 357707+0 records out + 375083606016 bytes (375 GB, 349 GiB) copied, 215.974 s, 1.7 GB/s + + Performance counter stats for 'system wide': + + port Inbound Read(MB) Inbound Write(MB) Outbound Read(MB) Outbound Write(MB) + 0000:00 1 0 2 3 + 0000:80 0 0 0 0 + 0000:17 352552 43 0 21 + 0000:85 0 0 0 0 + 0000:3a 3 0 0 0 + 0000:ae 0 0 0 0 + 0000:5d 0 0 0 0 + 0000:d7 0 0 0 0 + +3. Collect metrics for comma-separated list of PCIe root ports: + + $ perf iostat 0000:17,0:3a -- dd if=/dev/zero of=/dev/nvme0n1 bs=1M oflag=direct + 357708+0 records in + 357707+0 records out + 375083606016 bytes (375 GB, 349 GiB) copied, 197.08 s, 1.9 GB/s + + Performance counter stats for 'system wide': + + port Inbound Read(MB) Inbound Write(MB) Outbound Read(MB) Outbound Write(MB) + 0000:17 358559 44 0 22 + 0000:3a 3 2 0 0 + + 197.081983474 seconds time elapsed + +SEE ALSO +-------- +linkperf:perf-stat[1]
tools/perf/Makefile.perf +4 -1
@@ -283,6 +283,7 @@ SCRIPT_SH = SCRIPT_SH += perf-archive.sh SCRIPT_SH += perf-with-kcore.sh +SCRIPT_SH += perf-iostat.sh grep-libs = $(filter -l%,$(1)) strip-libs = $(filter-out -l%,$(1))
@@ -948,6 +949,8 @@ endif $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' $(call QUIET_INSTALL, perf-with-kcore) \ $(INSTALL) $(OUTPUT)perf-with-kcore -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' + $(call QUIET_INSTALL, perf-iostat) \ + $(INSTALL) $(OUTPUT)perf-iostat -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' ifndef NO_LIBAUDIT $(call QUIET_INSTALL, strace/groups) \ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(STRACE_GROUPS_INSTDIR_SQ)'; \
@@ -1042,7 +1045,7 @@ bpf-skel-clean: $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS) clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean - $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS) + $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(OUTPUT)perf-iostat $(LANG_BINDINGS) $(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)$(RM) $(OUTPUT).config-detected $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents $(OUTPUT)$(LIBJVMTI).so
tools/perf/arch/x86/util/Build +1 -0
@@ -9,6 +9,7 @@ perf-y += event.o perf-y += evlist.o perf-y += mem-events.o perf-y += evsel.o +perf-y += iostat.o perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_BPF_PROLOGUE) += dwarf-regs.o
tools/perf/arch/x86/util/iostat.c +360 -0
375 lines not on this page · raw message
tools/perf/command-list.txt +1 -0
@@ -14,6 +14,7 @@ perf-config mainporcelain common perf-evlist mainporcelain common perf-ftrace mainporcelain common perf-inject mainporcelain common +perf-iostat mainporcelain common perf-kallsyms mainporcelain common perf-kmem mainporcelain common perf-kvm mainporcelain common
tools/perf/perf-iostat.sh new file +12 -0
@@ -0,0 +1,12 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# perf iostat +# Alexander Antonov <[email protected]> + +if [[ "$1" == "list" ]] || [[ "$1" =~ ([a-f0-9A-F]{1,}):([a-f0-9A-F]{1,2})(,)? ]]; then + DELIMITER="=" +else + DELIMITER=" " +fi + +perf stat --iostat$DELIMITER$*
Signature · 1 line
2.21.3
PATCH RESEND v5 4/4 perf: Update .gitignore file
In reply to [email protected]From: Alexander Antonov <[email protected]>
After a "make -C tools/perf", git reports the following untracked file:
perf-iostat
Add this generated file to perf's .gitignore file.
--- tools/perf/.gitignore | 1 + 1 file changed, 1 insertion(+)
tools/perf/.gitignore +1 -0
@@ -20,6 +20,7 @@ perf.data.old output.svg perf-archive perf-with-kcore +perf-iostat tags TAGS cscope*
Signature · 1 line
2.21.3
Em Mon, Apr 19, 2021 at 12:41:43PM +0300, [email protected] escreveu:
Quoted 3 lines
From: Alexander Antonov <[email protected]>
Resending V5 with added Acked-by: Namhyung Kim <[email protected]> tag.
Thanks, applied.
- Arnaldo
Quoted 136 lines
Thanks,
AlexanderThe previous version can be found at:
v4: https://lkml.kernel.org/r/[email protected]/
Changes in this revision are:
v4 -> v5:
- Addressed comments from Namhyung Kim:
1. RemovedAGGR_PCIE_PORTaggregation mode
2. Addediostat_prepare()function
3. Moved implementation specificfprintf()calls to separate x86-related function
4. Fixed code-related issues
- Moved__weakiostat's functions to separateutil/iostat.cfileThe previous version can be found at:
v3: https://lkml.kernel.org/r/[email protected]/
Changes in this revision are:
v3 -> v4:
- Addressed comment from Namhyung Kim:
1. Removed NULL-termination of root ports listThe previous version can be found at:
v2: https://lkml.kernel.org/r/[email protected]Changes in this revision are:
v2 -> v3:
- Addressed comments from Namhyung Kim:
1. Removedperf_devicepointer from evsel structure. Use priv field instead
2. Renamed 'iiostat' to 'iostat'
3. Renamed 'show' mode to 'list' mode
4. Renamediiostat_delete_root_ports()toiiostat_release()andiostat_show_root_ports()toiostat_list()The previous version can be found at:
v1: https://lkml.kernel.org/r/[email protected]Changes in this revision are:
v1 -> v2:
- Addressed comment from Arnaldo Carvalho de Melo:
1. Using 'perf iiostat' subcommand instead of 'perf stat --iiostat':
- Addedperf-iiostat.shscript to use short command
- Updated manual pages to get help for 'perf iiostat'
- Added 'perf-iiostat' to perf's gitignore fileMode is intended to provide four I/O performance metrics in MB per each root port:
- Inbound Read: I/O devices below root port read from the host memory - Inbound Write: I/O devices below root port write to the host memory - Outbound Read: CPU reads from I/O devices below root port- Outbound Write: CPU writes to I/O devices below root port
Each metric requiries only one uncore event which increments at every 4B transfer in corresponding direction. The formulas to compute metrics are generic:
#EventCount * 4B / (1024 * 1024)Note: iostat introduces new perf data aggregation mode - per PCIe root port hence -e and -M options are not supported.
Usage examples:
1. List all PCIe root ports (example for 2-S platform):
$ perf iostat list S0-uncore_iio_0<0000:00> S1-uncore_iio_0<0000:80> S0-uncore_iio_1<0000:17> S1-uncore_iio_1<0000:85> S0-uncore_iio_2<0000:3a> S1-uncore_iio_2<0000:ae> S0-uncore_iio_3<0000:5d> S1-uncore_iio_3<0000:d7>2. Collect metrics for all PCIe root ports:
$ perf iostat -- dd if=/dev/zero of=/dev/nvme0n1 bs=1M oflag=direct 357708+0 records in 357707+0 records out 375083606016 bytes (375 GB, 349 GiB) copied, 215.974 s, 1.7 GB/sPerformance counter stats for 'system wide':
port Inbound Read(MB) Inbound Write(MB) Outbound Read(MB) Outbound Write(MB)
0000:00 1 0 2 3 0000:80 0 0 0 0 0000:17 352552 43 0 21 0000:85 0 0 0 0 0000:3a 3 0 0 0 0000:ae 0 0 0 0 0000:5d 0 0 0 0 0000:d7 0 0 0 03. Collect metrics for comma separated list of PCIe root ports:
$ perf iostat 0000:17,0:3a -- dd if=/dev/zero of=/dev/nvme0n1 bs=1M oflag=direct 357708+0 records in 357707+0 records out 375083606016 bytes (375 GB, 349 GiB) copied, 197.08 s, 1.9 GB/sPerformance counter stats for 'system wide':
port Inbound Read(MB) Inbound Write(MB) Outbound Read(MB) Outbound Write(MB)
0000:17 358559 44 0 22
0000:3a 3 2 0 0197.081983474 seconds time elapsedAlexander Antonov (4):
perf stat: Basic support for iostat in perf
perf stat: Helper functions for PCIe root ports list in iostat mode perf stat: Enable iostat mode for x86 platforms
perf: Update .gitignore filetools/perf/.gitignore | 1 + tools/perf/Documentation/perf-iostat.txt | 88 +++++ tools/perf/Makefile.perf | 5 +- tools/perf/arch/x86/util/Build | 1 + tools/perf/arch/x86/util/iostat.c | 470 +++++++++++++++++++++++ tools/perf/builtin-stat.c | 21 +- tools/perf/command-list.txt | 1 + tools/perf/perf-iostat.sh | 12 + tools/perf/util/Build | 1 + tools/perf/util/iostat.c | 53 +++ tools/perf/util/iostat.h | 47 +++ tools/perf/util/stat-display.c | 40 +- tools/perf/util/stat-shadow.c | 5 +- tools/perf/util/stat.h | 1 + 14 files changed, 733 insertions(+), 13 deletions(-) create mode 100644 tools/perf/Documentation/perf-iostat.txt create mode 100644 tools/perf/arch/x86/util/iostat.c create mode 100644 tools/perf/perf-iostat.sh create mode 100644 tools/perf/util/iostat.c create mode 100644 tools/perf/util/iostat.hbase-commit:
4c391ea001cb2e7bd9a691a886c0dcb030c1791cSignature · 1 line
2.21.3
Signature · 1 line
- Arnaldo