perf/core improvements and fixes
Arnaldo Carvalho de Melo
maintainerFrom: Arnaldo Carvalho de Melo <[email protected]>
Hi Ingo,
Please consider pulling,
- Arnaldo
The following changes since commit 89f1c2c59c4aef8e26edbc7db5175e6ffb0e9ec7:
Merge tag 'perf-core-for-mingo-20160920' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2016-09-20 23:32:02 +0200)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-20160922
for you to fetch changes up to 2d831454140f28fa643b78deede4511b9e2c9e5f:
perf hists: Make hists__fprintf_headers function global (2016-09-22 13:08:59 -0300)
----------------------------------------------------------------
perf/core improvements:
New features:
- Add support for interacting with Coresight PMU ETMs/PTMs, that are IP blocks to perform hardware assisted tracing on a ARM CPU core (Mathieu Poirier)
Infrastructure:
- Histogram prep work for the upcoming c2c tool (Jiri Olsa)
----------------------------------------------------------------
Jiri Olsa (9):
perf evsel: Remove superfluous initialization of weight perf hists: Use bigger buffer for stdio headers
perf hists: Add __hist_entry__snprintf function
perf tools: Make reset_dimensions global
perf tools: Make output_field_add and sort_dimension__add global perf tools: Make several sorting functions global perf tools: Make several display functions global perf hists: Make __hist_entry__snprintf function global perf hists: Make hists__fprintf_headers function global
Mathieu Poirier (6):
perf tools: Confine __get_cpuid() to x86 architecture perf tools: Make coresight PMU listable
perf tools: Add coresight etm PMU record capabilities perf pmu: Push configuration down to PMU driver perf tools: Add PMU configuration to tools perf tools: Add sink configuration for cs_etm PMU
MAINTAINERS | 5 + tools/perf/Makefile.config | 11 +- tools/perf/arch/arm/util/Build | 2 + tools/perf/arch/arm/util/auxtrace.c | 54 ++++ tools/perf/arch/arm/util/cs-etm.c | 617 ++++++++++++++++++++++++++++++++++++ tools/perf/arch/arm/util/cs-etm.h | 26 ++ tools/perf/arch/arm/util/pmu.c | 36 +++ tools/perf/arch/arm64/util/Build | 4 + tools/perf/builtin-record.c | 10 + tools/perf/builtin-stat.c | 9 + tools/perf/builtin-top.c | 13 + tools/perf/ui/browsers/hists.c | 2 +- tools/perf/ui/hist.c | 2 +- tools/perf/ui/stdio/hist.c | 14 +- tools/perf/util/Build | 1 + tools/perf/util/auxtrace.c | 1 + tools/perf/util/auxtrace.h | 1 + tools/perf/util/cs-etm.h | 74 +++++ tools/perf/util/drv_configs.c | 77 +++++ tools/perf/util/drv_configs.h | 26 ++ tools/perf/util/evsel.c | 2 - tools/perf/util/hist.h | 5 + tools/perf/util/pmu.h | 2 + tools/perf/util/sort.c | 16 +- tools/perf/util/sort.h | 11 + 25 files changed, 1001 insertions(+), 20 deletions(-) create mode 100644 tools/perf/arch/arm/util/auxtrace.c create mode 100644 tools/perf/arch/arm/util/cs-etm.c create mode 100644 tools/perf/arch/arm/util/cs-etm.h create mode 100644 tools/perf/arch/arm/util/pmu.c create mode 100644 tools/perf/util/cs-etm.h create mode 100644 tools/perf/util/drv_configs.c create mode 100644 tools/perf/util/drv_configs.h
[root at zoo ~]# time dm
1 73.911 alpine:3.4: Ok 2 26.890 android-ndk:r12b-arm: Ok 3 77.833 archlinux:latest: Ok 4 40.814 centos:5: Ok 5 64.151 centos:6: Ok 6 75.720 centos:7: Ok 7 68.960 debian:7: Ok 8 75.606 debian:8: Ok 9 75.127 fedora:20: Ok 10 80.186 fedora:21: Ok 11 80.157 fedora:22: Ok 12 83.273 fedora:23: Ok 13 91.566 fedora:24: Ok 14 37.720 fedora:24-x-ARC-uClibc: Ok 15 98.492 fedora:rawhide: Ok 16 100.555 mageia:5: Ok 17 94.140 opensuse:13.2: Ok 18 95.476 opensuse:42.1: Ok 19 106.037 opensuse:tumbleweed: Ok 20 75.951 ubuntu:12.04.5: Ok 21 52.138 ubuntu:14.04: Ok 22 94.814 ubuntu:14.04.4: Ok 23 100.525 ubuntu:15.10: Ok 24 93.813 ubuntu:16.04: Ok 25 85.214 ubuntu:16.04-x-arm: Ok 26 83.487 ubuntu:16.04-x-arm64: Ok 27 82.918 ubuntu:16.04-x-powerpc64: Ok 28 84.189 ubuntu:16.04-x-powerpc64el: Ok 29 93.162 ubuntu:16.10: Ok
real 38m13.568s
user 0m2.379s
sys 0m2.402s
[root at zoo ~]#
[root at jouet ~]# perf test
1: vmlinux symtab matches kallsyms : Ok 2: detect openat syscall event : Ok 3: detect openat syscall event on all cpus : Ok 4: read samples using the mmap interface : Ok 5: parse events tests : Ok 6: Validate PERF_RECORD_* events & perf_sample fields : Ok 7: Test perf pmu format parsing : Ok 8: Test dso data read : Ok 9: Test dso data cache : Ok 10: Test dso data reopen : Ok 11: roundtrip evsel->name check : Ok 12: Check parsing of sched tracepoints fields : Ok 13: Generate and check syscalls:sys_enter_openat event fields: Ok 14: struct perf_event_attr setup : Ok 15: Test matching and linking multiple hists : Ok 16: Try 'import perf' in python, checking link problems : Ok 17: Test breakpoint overflow signal handler : Ok 18: Test breakpoint overflow sampling : Ok 19: Test number of exit event of a simple workload : Ok 20: Test software clock events have valid period values : Ok 21: Test object code reading : Ok 22: Test sample parsing : Ok 23: Test using a dummy software event to keep tracking : Ok 24: Test parsing with no sample_id_all bit set : Ok 25: Test filtering hist entries : Ok 26: Test mmap thread lookup : Ok 27: Test thread mg sharing : Ok 28: Test output sorting of hist entries : Ok 29: Test cumulation of child hist entries : Ok 30: Test tracking with sched_switch : Ok 31: Filter fds with revents mask in a fdarray : Ok 32: Add fd to a fdarray, making it autogrow : Ok 33: Test kmod_path__parse function : Ok 34: Test thread map : Ok 35: Test LLVM searching and compiling : 35.1: Basic BPF llvm compiling test : Ok 35.2: Test kbuild searching : Ok 35.3: Compile source for BPF prologue generation test : Ok 35.4: Compile source for BPF relocation test : Ok 36: Test topology in session : Ok 37: Test BPF filter : 37.1: Test basic BPF filtering : Ok 37.2: Test BPF prologue generation : Ok 37.3: Test BPF relocation checker : Ok 38: Test thread map synthesize : Ok 39: Test cpu map synthesize : Ok 40: Test stat config synthesize : Ok 41: Test stat synthesize : Ok 42: Test stat round synthesize : Ok 43: Test attr update synthesize : Ok 44: Test events times : Ok 45: Test backward reading from ring buffer : Ok 46: Test cpu map print : Ok 47: Test SDT event probing : Ok 48: Test is_printable_array function : Ok 49: Test bitmap print : Ok 50: x86 rdpmc test : Ok 51: Test converting perf time to TSC : Ok 52: Test dwarf unwind : Ok 53: Test x86 instruction decoder - new instructions : Ok 54: Test intel cqm nmi context read : Skip
[root at jouet ~]#
Arnaldo Carvalho de Melo
maintainerPATCH 1/15 perf evsel: Remove superfluous initialization of weight
From: Jiri Olsa <[email protected]>
Removing superfluous initialization of weight, it's already set to 0 via memset.
--- tools/perf/util/evsel.c | 2 -- 1 file changed, 2 deletions(-)
tools/perf/util/evsel.c +0 -2
@@ -1728,7 +1728,6 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, data->cpu = data->pid = data->tid =-1 ; data->stream_id = data->id = data->time =-1ULL ; data->period = evsel->attr.sample_period; - data->weight =0 ; data->cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ;if (event->header.type !=PERF_RECORD_SAMPLE ) {
@@ -1935,7 +1934,6 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, } } - data->weight =0 ;if (type &PERF_SAMPLE_WEIGHT ) {OVERFLOW_CHECK_u64 (array); data->weight = *array;
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 2/15 perf hists: Use bigger buffer for stdio headers
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
With node column on big CPUs servers we can run out of stdio header space quite soon. Enlarging header buffer.
--- tools/perf/ui/stdio/hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/ui/stdio/hist.c +1 -1
@@ -698,7 +698,7 @@ hists__fprintf_standard_headers(struct hists *hists,static int hists__fprintf_headers (struct hists *hists,FILE *fp) { -char bf[96 ]; +char bf[1024 ];struct perf_hpp dummy_hpp = { .buf = bf, .size =sizeof (bf),
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 3/15 perf tools: Confine __get_cpuid() to x86 architecture
In reply to Arnaldo Carvalho de MeloFrom: Mathieu Poirier <[email protected]>
The __get_cpuid() test is only valid when compiling for x86. When compiling for other architectures like ARM/ARM64 the test fails event if the functionality is not required.
This patch isolate the build-in feature check to x86 platform, allowing the compilation and usage of PMUs that use the AUXTRACE infrastructure on other architectures (i.e ARM CoreSight).
--- tools/perf/Makefile.config | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/perf/Makefile.config +7 -4
@@ -746,10 +746,13 @@ ifdef LIBBABELTRACE endif ifndef NO_AUXTRACE - ifeq ($(feature-get_cpuid), 0) - msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc); - NO_AUXTRACE := 1 - else + ifeq ($(ARCH),x86) + ifeq ($(feature-get_cpuid), 0) + msg := $(warning Your gcc lacks the __get_cpuid() builtin, disables support for auxtrace/Intel PT, please install a newer gcc); + NO_AUXTRACE := 1 + endif + endif + ifndef NO_AUXTRACE $(call detected,CONFIG_AUXTRACE) CFLAGS += -DHAVE_AUXTRACE_SUPPORT endif
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 4/15 perf tools: Make coresight PMU listable
In reply to Arnaldo Carvalho de MeloFrom: Mathieu Poirier <[email protected]>
Adding the required mechanic allowing 'perf list pmu' to discover coresight ETM/PTM tracers.
--- MAINTAINERS | 1 + tools/perf/arch/arm/util/Build | 2 ++ tools/perf/arch/arm/util/pmu.c | 34 ++++++++++++++++++++++++++++++++++ tools/perf/arch/arm64/util/Build | 2 ++ 4 files changed, 39 insertions(+) create mode 100644 tools/perf/arch/arm/util/pmu.c
MAINTAINERS +1 -0
@@ -1123,6 +1123,7 @@ F: drivers/hwtracing/coresight/* F: Documentation/trace/coresight.txt F: Documentation/devicetree/bindings/arm/coresight.txt F: Documentation/ABI/testing/sysfs-bus-coresight-devices-* +F: tools/perf/arch/arm/util/pmu.c ARM/CORGI MACHINE SUPPORT M: Richard Purdie <[email protected]>
tools/perf/arch/arm/util/Build +2 -0
@@ -2,3 +2,5 @@ libperf-$(CONFIG_DWARF) += dwarf-regs.o libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o + +libperf-$(CONFIG_AUXTRACE) += pmu.o
tools/perf/arch/arm/util/pmu.c new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright(C) 2015 Linaro Limited. All rights reserved. +* Author: Mathieu Poirier <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published by +* the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <string.h> +#include <linux/coresight-pmu.h> +#include <linux/perf_event.h> + +#include "../../util/pmu.h" + +struct perf_event_attr +*perf_pmu__get_default_config (struct perf_pmu *pmu__maybe_unused ) +{ +#ifdef HAVE_AUXTRACE_SUPPORT +if (!strcmp (pmu->name,CORESIGHT_ETM_PMU_NAME )) { +/* add ETM default config here */ + pmu->selectable = true; + } +#endif +return NULL ; +}
tools/perf/arch/arm64/util/Build +2 -0
@@ -1,2 +1,4 @@ libperf-$(CONFIG_DWARF) += dwarf-regs.o libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o + +libperf-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 5/15 perf tools: Add coresight etm PMU record capabilities
In reply to Arnaldo Carvalho de MeloFrom: Mathieu Poirier <[email protected]>
Coresight ETMs are IP blocks used to perform HW assisted tracing on a CPU core. This patch introduce the required auxiliary API functions allowing the perf core to interact with a tracer.
--- MAINTAINERS | 4 + tools/perf/arch/arm/util/Build | 2 +- tools/perf/arch/arm/util/auxtrace.c | 54 ++++ tools/perf/arch/arm/util/cs-etm.c | 559 ++++++++++++++++++++++++++++++++++++ tools/perf/arch/arm/util/cs-etm.h | 23 ++ tools/perf/arch/arm64/util/Build | 4 +- tools/perf/util/auxtrace.c | 1 + tools/perf/util/auxtrace.h | 1 + tools/perf/util/cs-etm.h | 74 +++++ 9 files changed, 720 insertions(+), 2 deletions(-) create mode 100644 tools/perf/arch/arm/util/auxtrace.c create mode 100644 tools/perf/arch/arm/util/cs-etm.c create mode 100644 tools/perf/arch/arm/util/cs-etm.h create mode 100644 tools/perf/util/cs-etm.h
MAINTAINERS +4 -0
@@ -1124,6 +1124,10 @@ F: Documentation/trace/coresight.txt F: Documentation/devicetree/bindings/arm/coresight.txt F: Documentation/ABI/testing/sysfs-bus-coresight-devices-* F: tools/perf/arch/arm/util/pmu.c +F: tools/perf/arch/arm/util/auxtrace.c +F: tools/perf/arch/arm/util/cs-etm.c +F: tools/perf/arch/arm/util/cs-etm.h +F: tools/perf/util/cs-etm.h ARM/CORGI MACHINE SUPPORT M: Richard Purdie <[email protected]>
tools/perf/arch/arm/util/Build +1 -1
@@ -3,4 +3,4 @@ libperf-$(CONFIG_DWARF) += dwarf-regs.o libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o -libperf-$(CONFIG_AUXTRACE) += pmu.o +libperf-$(CONFIG_AUXTRACE) += pmu.o auxtrace.o cs-etm.o
tools/perf/arch/arm/util/auxtrace.c new file +54 -0
54 lines not on this page · raw message
tools/perf/arch/arm/util/cs-etm.c new file +559 -0
559 lines not on this page · raw message
tools/perf/arch/arm/util/cs-etm.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Copyright(C) 2015 Linaro Limited. All rights reserved. +* Author: Mathieu Poirier <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published by +* the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef INCLUDE__PERF_CS_ETM_H__ +#define INCLUDE__PERF_CS_ETM_H__ + +struct auxtrace_record *cs_etm_record_init (int *err); + +#endif
tools/perf/arch/arm64/util/Build +3 -1
@@ -1,4 +1,6 @@ libperf-$(CONFIG_DWARF) += dwarf-regs.o libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o -libperf-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o +libperf-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o \ + ../../arm/util/auxtrace.o \ + ../../arm/util/cs-etm.o
tools/perf/util/auxtrace.c +1 -0
@@ -892,6 +892,7 @@ int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused,return intel_pt_process_auxtrace_info (event, session);case PERF_AUXTRACE_INTEL_BTS :return intel_bts_process_auxtrace_info (event, session); +case PERF_AUXTRACE_CS_ETM :case PERF_AUXTRACE_UNKNOWN :default :return -EINVAL ;
tools/perf/util/auxtrace.h +1 -0
@@ -41,6 +41,7 @@ enum auxtrace_type {PERF_AUXTRACE_UNKNOWN ,PERF_AUXTRACE_INTEL_PT ,PERF_AUXTRACE_INTEL_BTS , + PERF_AUXTRACE_CS_ETM, }; enum itrace_period_type {
tools/perf/util/cs-etm.h new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 6/15 perf pmu: Push configuration down to PMU driver
In reply to Arnaldo Carvalho de MeloFrom: Mathieu Poirier <[email protected]>
This patch adds a PMU callback and the required mechanic so that drivers can process the command line configuration elements found in evsel::config_terms.
--- tools/perf/util/Build | 1 + tools/perf/util/drv_configs.c | 77 +++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/drv_configs.h | 26 +++++++++++++++ tools/perf/util/pmu.h | 2 ++ 4 files changed, 106 insertions(+) create mode 100644 tools/perf/util/drv_configs.c create mode 100644 tools/perf/util/drv_configs.h
tools/perf/util/Build +1 -0
@@ -86,6 +86,7 @@ libperf-y += term.o libperf-y += help-unknown-cmd.o libperf-y += mem-events.o libperf-y += vsprintf.o +libperf-y += drv_configs.o libperf-$(CONFIG_LIBBPF) += bpf-loader.o libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
tools/perf/util/drv_configs.c new file +77 -0
77 lines not on this page · raw message
tools/perf/util/drv_configs.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* drv_configs.h: Interface to apply PMU specific configuration +* Copyright (c) 2016-2018, Linaro Ltd. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +*/ + +#ifndef __PERF_DRV_CONFIGS_H +#define __PERF_DRV_CONFIGS_H + +#include "drv_configs.h" +#include "evlist.h" +#include "evsel.h" + +int perf_evlist__apply_drv_configs (struct perf_evlist *evlist, +struct perf_evsel **err_evsel, +struct perf_evsel_config_term **term); +#endif
tools/perf/util/pmu.h +2 -0
@@ -4,6 +4,7 @@#include <linux/bitmap.h> #include <linux/perf_event.h> #include <stdbool.h> +#include "evsel.h" #include "parse-events.h" enum {
@@ -25,6 +26,7 @@ struct perf_pmu {struct list_head format;/* HEAD struct perf_pmu_format -> list */ struct list_head aliases;/* HEAD struct perf_pmu_alias -> list */ struct list_head list;/* ELEM */ +int (*set_drv_config) (struct perf_evsel_config_term *term); };struct perf_pmu_info {
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 7/15 perf tools: Add PMU configuration to tools
In reply to Arnaldo Carvalho de MeloFrom: Mathieu Poirier <[email protected]>
Now that the required mechanic is there to deal with PMU specific configuration, add the functionality to the tools where events can be selected.
--- tools/perf/builtin-record.c | 10 ++++++++++ tools/perf/builtin-stat.c | 9 +++++++++ tools/perf/builtin-top.c | 13 +++++++++++++ 3 files changed, 32 insertions(+)
tools/perf/builtin-record.c +10 -0
@@ -22,6 +22,7 @@#include "util/evlist.h" #include "util/evsel.h" #include "util/debug.h" +#include "util/drv_configs.h" #include "util/session.h" #include "util/tool.h" #include "util/symbol.h"
@@ -383,6 +384,7 @@ static int record__open(struct record *rec)struct perf_evlist *evlist = rec->evlist;struct perf_session *session = rec->session;struct record_opts *opts = &rec->opts; +struct perf_evsel_config_term *err_term;int rc =0 ;perf_evlist__config (evlist, opts, &callchain_param);
@@ -412,6 +414,14 @@ try_again: goto out; } +if (perf_evlist__apply_drv_configs (evlist, &pos, &err_term)) { +error ("failed to set config \"%s\" on event %s with %d (%s)\n" , + err_term->val.drv_cfg,perf_evsel__name (pos), errno, +str_error_r (errno, msg,sizeof (msg))); + rc =-1 ; + goto out; + } + rc =record__mmap (rec);if (rc) goto out;
tools/perf/builtin-stat.c +9 -0
@@ -52,6 +52,7 @@#include "util/evlist.h" #include "util/evsel.h" #include "util/debug.h" +#include "util/drv_configs.h" #include "util/color.h" #include "util/stat.h" #include "util/header.h"
@@ -540,6 +541,7 @@ static int __run_perf_stat(int argc, const char **argv)int status =0 ;const bool forks = (argc >0 );bool is_pipe =STAT_RECORD ? perf_stat.file.is_pipe : false; +struct perf_evsel_config_term *err_term;if (interval) { ts.tv_sec = interval /USEC_PER_MSEC ;
@@ -611,6 +613,13 @@ try_again:return -1 ; } +if (perf_evlist__apply_drv_configs (evsel_list, &counter, &err_term)) { +error ("failed to set config \"%s\" on event %s with %d (%s)\n" , + err_term->val.drv_cfg,perf_evsel__name (counter), errno, +str_error_r (errno, msg,sizeof (msg))); +return -1 ; + } +if (STAT_RECORD ) {int err, fd =perf_data_file__fd (&perf_stat.file);
tools/perf/builtin-top.c +13 -0
@@ -24,6 +24,7 @@#include "util/annotate.h" #include "util/config.h" #include "util/color.h" +#include "util/drv_configs.h" #include "util/evlist.h" #include "util/evsel.h" #include "util/machine.h"
@@ -913,6 +914,10 @@ static int callchain_param__setup_sample_type(struct callchain_param *callchain)static int __cmd_top (struct perf_top *top) { +char msg[512 ]; +struct perf_evsel *pos; +struct perf_evsel_config_term *err_term; +struct perf_evlist *evlist = top->evlist;struct record_opts *opts = &top->record_opts;pthread_t thread;int ret;
@@ -947,6 +952,14 @@ static int __cmd_top(struct perf_top *top)if (ret) goto out_delete; + ret =perf_evlist__apply_drv_configs (evlist, &pos, &err_term); +if (ret) { +error ("failed to set config \"%s\" on event %s with %d (%s)\n" , + err_term->val.drv_cfg,perf_evsel__name (pos), errno, +str_error_r (errno, msg,sizeof (msg))); + goto out_delete; + } + top->session->evlist = top->evlist;perf_session__set_id_hdr_size (top->session);
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 8/15 perf tools: Add sink configuration for cs_etm PMU
In reply to Arnaldo Carvalho de MeloFrom: Mathieu Poirier <[email protected]>
Using the PMU::set_drv_config() callback to enable the CoreSight sink that will be used for the trace session.
--- tools/perf/arch/arm/util/cs-etm.c | 58 +++++++++++++++++++++++++++++++++++++++ tools/perf/arch/arm/util/cs-etm.h | 3 ++ tools/perf/arch/arm/util/pmu.c | 2 ++ 3 files changed, 63 insertions(+)
tools/perf/arch/arm/util/cs-etm.c +58 -0
@@ -27,12 +27,16 @@#include "../../util/auxtrace.h" #include "../../util/cpumap.h" #include "../../util/evlist.h" +#include "../../util/evsel.h" #include "../../util/pmu.h" #include "../../util/thread_map.h" #include "../../util/cs-etm.h" #include <stdlib.h> +#define ENABLE_SINK_MAX 128 +#define CS_BUS_DEVICE_PATH "/bus/coresight/devices/" +struct cs_etm_recording {struct auxtrace_record itr;struct perf_pmu *cs_etm_pmu;
@@ -557,3 +561,57 @@ struct auxtrace_record *cs_etm_record_init(int *err) out:return NULL ; } + +static FILE *cs_device__open_file (const char *name) +{ +struct stat st; +char path[PATH_MAX ]; +const char *sysfs; + + sysfs =sysfs__mountpoint (); +if (!sysfs) +return NULL ; + +snprintf (path,PATH_MAX , +"%s" CS_BUS_DEVICE_PATH "%s" , sysfs, name); + +printf ("path: %s\n" , path); + +if (stat (path, &st) <0 ) +return NULL ; + +return fopen (path,"w" ); + +} + +static __attribute__((format (printf,2 ,3 ))) +int cs_device__print_file (const char *name,const char *fmt, ...) +{ +va_list args; +FILE *file; +int ret = -EINVAL ; + +va_start (args, fmt); + file =cs_device__open_file (name); +if (file) { + ret =vfprintf (file, fmt, args); +fclose (file); + } +va_end (args); +return ret; +} + +int cs_etm_set_drv_config (struct perf_evsel_config_term *term) +{ +int ret; +char enable_sink[ENABLE_SINK_MAX ]; + +snprintf (enable_sink,ENABLE_SINK_MAX ,"%s/%s" , + term->val.drv_cfg,"enable_sink" ); + + ret =cs_device__print_file (enable_sink,"%d" ,1 ); +if (ret <0 ) +return ret; + +return 0 ; +}
tools/perf/arch/arm/util/cs-etm.h +3 -0
@@ -18,6 +18,9 @@#ifndef INCLUDE__PERF_CS_ETM_H__ #define INCLUDE__PERF_CS_ETM_H__ +#include "../../util/evsel.h" +struct auxtrace_record *cs_etm_record_init (int *err); +int cs_etm_set_drv_config (struct perf_evsel_config_term *term);#endif
tools/perf/arch/arm/util/pmu.c +2 -0
@@ -19,6 +19,7 @@#include <linux/coresight-pmu.h> #include <linux/perf_event.h> +#include "cs-etm.h" #include "../../util/pmu.h" struct perf_event_attr
@@ -28,6 +29,7 @@ struct perf_event_attrif (!strcmp (pmu->name,CORESIGHT_ETM_PMU_NAME )) {/* add ETM default config here */ pmu->selectable = true; + pmu->set_drv_config = cs_etm_set_drv_config; }#endif return NULL ;
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 9/15 perf hists: Add __hist_entry__snprintf function
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Add __hist_entry__snprintf() to take a perf_hpp_list as an argument instead of using he->hists->hpp_list.
This way we can display arbitrary list of entries regardless of the hists setup, which will be useful in the upcoming c2c patch series.
--- tools/perf/ui/stdio/hist.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
tools/perf/ui/stdio/hist.c +8 -2
@@ -373,7 +373,8 @@ static size_t hist_entry_callchain__fprintf(struct hist_entry *he,return 0 ; } -static int hist_entry__snprintf (struct hist_entry *he,struct perf_hpp *hpp) +static int __hist_entry__snprintf (struct hist_entry *he,struct perf_hpp *hpp, +struct perf_hpp_list *hpp_list) {const char *sep = symbol_conf.field_sep;struct perf_hpp_fmt *fmt;
@@ -384,7 +385,7 @@ static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp)if (symbol_conf.exclude_other && !he->parent)return 0 ; -hists__for_each_format (he->hists, fmt) { +perf_hpp_list__for_each_format (hpp_list, fmt) {if (perf_hpp__should_skip (fmt, he->hists))continue ;
@@ -410,6 +411,11 @@ static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp)return hpp->buf - start; } +static int hist_entry__snprintf (struct hist_entry *he,struct perf_hpp *hpp) +{ +return __hist_entry__snprintf (he, hpp, he->hists->hpp_list); +} + static int hist_entry__hierarchy_fprintf(struct hist_entry *he, struct perf_hpp *hpp, struct hists *hists,
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 10/15 perf tools: Make reset_dimensions global
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Will be used from external places in the upcoming c2c patch series.
--- tools/perf/util/sort.c | 2 +- tools/perf/util/sort.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/sort.c +1 -1
@@ -2748,7 +2748,7 @@ static int setup_output_list(struct perf_hpp_list *list, char *str)return ret; } -static void reset_dimensions (void ) +void reset_dimensions (void ) {unsigned int i;
tools/perf/util/sort.h +1 -0
@@ -269,4 +269,5 @@ int report_parse_ignore_callees_opt(const struct option *opt, const char *arg, ibool is_strict_order (const char *order);int hpp_dimension__add_output (unsigned col); +void reset_dimensions (void );#endif /* __PERF_SORT_H */
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 11/15 perf tools: Make output_field_add and sort_dimension__add global
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Will be used from external places in the upcoming c2c patch series.
--- tools/perf/util/sort.c | 8 ++++---- tools/perf/util/sort.h | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-)
tools/perf/util/sort.c +4 -4
@@ -2308,9 +2308,9 @@ int hpp_dimension__add_output(unsigned col)return __hpp_dimension__add_output (&perf_hpp_list, &hpp_sort_dimensions[col]); } -static int sort_dimension__add (struct perf_hpp_list *list,const char *tok, -struct perf_evlist *evlist, -int level) +int sort_dimension__add (struct perf_hpp_list *list,const char *tok, +struct perf_evlist *evlist, +int level) {unsigned int i;
@@ -2685,7 +2685,7 @@ void sort__setup_elide(FILE *output) } } -static int output_field_add (struct perf_hpp_list *list,char *tok) +int output_field_add (struct perf_hpp_list *list,char *tok) {unsigned int i;
tools/perf/util/sort.h +4 -0
@@ -270,4 +270,8 @@ bool is_strict_order(const char *order);int hpp_dimension__add_output (unsigned col);void reset_dimensions (void ); +int sort_dimension__add (struct perf_hpp_list *list,const char *tok, +struct perf_evlist *evlist, +int level); +int output_field_add (struct perf_hpp_list *list,char *tok);#endif /* __PERF_SORT_H */
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 12/15 perf tools: Make several sorting functions global
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Will be used from external places in the upcoming c2c patch series.
--- tools/perf/util/sort.c | 6 +++--- tools/perf/util/sort.h | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-)
tools/perf/util/sort.c +3 -3
@@ -867,7 +867,7 @@ struct sort_entry sort_cycles = { };/* --sort daddr_sym */ -static int64_t +int64_t sort__daddr_cmp (struct hist_entry *left,struct hist_entry *right) {uint64_t l =0 , r =0 ;
@@ -896,7 +896,7 @@ static int hist_entry__daddr_snprintf(struct hist_entry *he, char *bf, width); } -static int64_t +int64_t sort__iaddr_cmp (struct hist_entry *left,struct hist_entry *right) {uint64_t l =0 , r =0 ;
@@ -1062,7 +1062,7 @@ static int hist_entry__snoop_snprintf(struct hist_entry *he, char *bf,return repsep_snprintf (bf, size,"%-*s" , width, out); } -static int64_t +int64_t sort__dcacheline_cmp (struct hist_entry *left,struct hist_entry *right) {u64 l, r;
tools/perf/util/sort.h +6 -0
@@ -274,4 +274,10 @@ int sort_dimension__add(struct perf_hpp_list *list, const char *tok,struct perf_evlist *evlist, int level);int output_field_add (struct perf_hpp_list *list,char *tok); +int64_t +sort__iaddr_cmp (struct hist_entry *left,struct hist_entry *right); +int64_t +sort__daddr_cmp (struct hist_entry *left,struct hist_entry *right); +int64_t +sort__dcacheline_cmp (struct hist_entry *left,struct hist_entry *right);#endif /* __PERF_SORT_H */
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 13/15 perf tools: Make several display functions global
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Will be used from external places in the upcoming c2c patch series.
--- tools/perf/ui/browsers/hists.c | 2 +- tools/perf/ui/hist.c | 2 +- tools/perf/util/hist.h | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-)
tools/perf/ui/browsers/hists.c +1 -1
@@ -1080,7 +1080,7 @@ struct hpp_arg {bool current_entry; }; -static int __hpp__slsmg_color_printf (struct perf_hpp *hpp,const char *fmt, ...) +int __hpp__slsmg_color_printf (struct perf_hpp *hpp,const char *fmt, ...) {struct hpp_arg *arg = hpp->ptr;int ret, len;
tools/perf/ui/hist.c +1 -1
@@ -237,7 +237,7 @@ static int hpp__header_fn(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,return scnprintf (hpp->buf, hpp->size,"%*s" , len, fmt->name); } -static int hpp_color_scnprintf (struct perf_hpp *hpp,const char *fmt, ...) +int hpp_color_scnprintf (struct perf_hpp *hpp,const char *fmt, ...) {va_list args;ssize_t ssize = hpp->size;
tools/perf/util/hist.h +2 -0
@@ -485,5 +485,7 @@ static inline struct rb_node *rb_hierarchy_next(struct rb_node *node)#define HIERARCHY_INDENT 3bool hist_entry__has_hierarchy_children (struct hist_entry *he,float limit); +int hpp_color_scnprintf (struct perf_hpp *hpp,const char *fmt, ...); +int __hpp__slsmg_color_printf (struct perf_hpp *hpp,const char *fmt, ...);#endif /* __PERF_HIST_H */
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 14/15 perf hists: Make __hist_entry__snprintf function global
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Will be used from external places in the upcoming c2c patch series.
--- tools/perf/ui/stdio/hist.c | 4 ++-- tools/perf/util/hist.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
tools/perf/ui/stdio/hist.c +2 -2
@@ -373,8 +373,8 @@ static size_t hist_entry_callchain__fprintf(struct hist_entry *he,return 0 ; } -static int __hist_entry__snprintf (struct hist_entry *he,struct perf_hpp *hpp, -struct perf_hpp_list *hpp_list) +int __hist_entry__snprintf (struct hist_entry *he,struct perf_hpp *hpp, +struct perf_hpp_list *hpp_list) {const char *sep = symbol_conf.field_sep;struct perf_hpp_fmt *fmt;
tools/perf/util/hist.h +2 -0
@@ -487,5 +487,7 @@ static inline struct rb_node *rb_hierarchy_next(struct rb_node *node)bool hist_entry__has_hierarchy_children (struct hist_entry *he,float limit);int hpp_color_scnprintf (struct perf_hpp *hpp,const char *fmt, ...);int __hpp__slsmg_color_printf (struct perf_hpp *hpp,const char *fmt, ...); +int __hist_entry__snprintf (struct hist_entry *he,struct perf_hpp *hpp, +struct perf_hpp_list *hpp_list);#endif /* __PERF_HIST_H */
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 15/15 perf hists: Make hists__fprintf_headers function global
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Will be used from external places in the upcoming c2c patch series.
--- tools/perf/ui/stdio/hist.c | 2 +- tools/perf/util/hist.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
tools/perf/ui/stdio/hist.c +1 -1
@@ -702,7 +702,7 @@ hists__fprintf_standard_headers(struct hists *hists,return hpp_list->nr_header_lines +2 ; } -static int hists__fprintf_headers (struct hists *hists,FILE *fp) +int hists__fprintf_headers (struct hists *hists,FILE *fp) {char bf[1024 ];struct perf_hpp dummy_hpp = {
tools/perf/util/hist.h +1 -0
@@ -489,5 +489,6 @@ int hpp_color_scnprintf(struct perf_hpp *hpp, const char *fmt, ...);int __hpp__slsmg_color_printf (struct perf_hpp *hpp,const char *fmt, ...);int __hist_entry__snprintf (struct hist_entry *he,struct perf_hpp *hpp,struct perf_hpp_list *hpp_list); +int hists__fprintf_headers (struct hists *hists,FILE *fp);#endif /* __PERF_HIST_H */
Signature · 1 line
2.7.4
Quoted 186 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
Hi Ingo,
Please consider pulling,
- Arnaldo
The following changes since commit
89f1c2c59c4aef8e26edbc7db5175e6ffb0e9ec7:Merge tag 'perf-core-for-mingo-20160920' of
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linuxinto perf/core (2016-09-20 23:32:02 +0200)are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingo-20160922for you to fetch changes up to
2d831454140f28fa643b78deede4511b9e2c9e5f:perf hists: Make
hists__fprintf_headersfunction global (2016-09-22 13:08:59 -0300)----------------------------------------------------------------
perf/core improvements:New features:
- Add support for interacting with Coresight PMU ETMs/PTMs, that are IP blocks to perform hardware assisted tracing on a ARM CPU core (Mathieu Poirier)
Infrastructure:
- Histogram prep work for the upcoming c2c tool (Jiri Olsa)
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>----------------------------------------------------------------
Jiri Olsa (9):
perf evsel: Remove superfluous initialization of weight perf hists: Use bigger buffer for stdio headers
perf hists: Add__hist_entry__snprintffunction
perf tools: Makereset_dimensionsglobal
perf tools: Makeoutput_field_addandsort_dimension__addglobal perf tools: Make several sorting functions global perf tools: Make several display functions global perf hists: Make__hist_entry__snprintffunction global perf hists: Makehists__fprintf_headersfunction globalMathieu Poirier (6):
perf tools: Confine__get_cpuid()to x86 architecture perf tools: Make coresight PMU listable
perf tools: Add coresight etm PMU record capabilities perf pmu: Push configuration down to PMU driver perf tools: Add PMU configuration to tools perf tools: Add sink configuration forcs_etmPMUMAINTAINERS | 5 + tools/perf/Makefile.config | 11 +- tools/perf/arch/arm/util/Build | 2 + tools/perf/arch/arm/util/auxtrace.c | 54 ++++ tools/perf/arch/arm/util/cs-etm.c | 617 ++++++++++++++++++++++++++++++++++++ tools/perf/arch/arm/util/cs-etm.h | 26 ++ tools/perf/arch/arm/util/pmu.c | 36 +++ tools/perf/arch/arm64/util/Build | 4 + tools/perf/builtin-record.c | 10 + tools/perf/builtin-stat.c | 9 + tools/perf/builtin-top.c | 13 + tools/perf/ui/browsers/hists.c | 2 +- tools/perf/ui/hist.c | 2 +- tools/perf/ui/stdio/hist.c | 14 +- tools/perf/util/Build | 1 + tools/perf/util/auxtrace.c | 1 + tools/perf/util/auxtrace.h | 1 + tools/perf/util/cs-etm.h | 74 +++++ tools/perf/util/drv_configs.c | 77 +++++ tools/perf/util/drv_configs.h | 26 ++ tools/perf/util/evsel.c | 2 - tools/perf/util/hist.h | 5 + tools/perf/util/pmu.h | 2 + tools/perf/util/sort.c | 16 +- tools/perf/util/sort.h | 11 + 25 files changed, 1001 insertions(+), 20 deletions(-) create mode 100644 tools/perf/arch/arm/util/auxtrace.c create mode 100644 tools/perf/arch/arm/util/cs-etm.c create mode 100644 tools/perf/arch/arm/util/cs-etm.h create mode 100644 tools/perf/arch/arm/util/pmu.c create mode 100644 tools/perf/util/cs-etm.h create mode 100644 tools/perf/util/drv_configs.c create mode 100644 tools/perf/util/drv_configs.h[root at zoo ~]# time dm
1 73.911 alpine:3.4: Ok 2 26.890 android-ndk:r12b-arm: Ok 3 77.833 archlinux:latest: Ok 4 40.814 centos:5: Ok 5 64.151 centos:6: Ok 6 75.720 centos:7: Ok 7 68.960 debian:7: Ok 8 75.606 debian:8: Ok 9 75.127 fedora:20: Ok 10 80.186 fedora:21: Ok 11 80.157 fedora:22: Ok 12 83.273 fedora:23: Ok 13 91.566 fedora:24: Ok 14 37.720 fedora:24-x-ARC-uClibc: Ok 15 98.492 fedora:rawhide: Ok 16 100.555 mageia:5: Ok 17 94.140 opensuse:13.2: Ok 18 95.476 opensuse:42.1: Ok 19 106.037 opensuse:tumbleweed: Ok 20 75.951 ubuntu:12.04.5: Ok 21 52.138 ubuntu:14.04: Ok 22 94.814 ubuntu:14.04.4: Ok 23 100.525 ubuntu:15.10: Ok 24 93.813 ubuntu:16.04: Ok 25 85.214 ubuntu:16.04-x-arm: Ok 26 83.487 ubuntu:16.04-x-arm64: Ok 27 82.918 ubuntu:16.04-x-powerpc64: Ok 28 84.189 ubuntu:16.04-x-powerpc64el: Ok 29 93.162 ubuntu:16.10: Okreal 38m13.568s
user 0m2.379s
sys 0m2.402s
[root at zoo ~]#[root at jouet ~]# perf test
1: vmlinux symtab matches kallsyms : Ok 2: detect openat syscall event : Ok 3: detect openat syscall event on all cpus : Ok 4: read samples using the mmap interface : Ok 5: parse events tests : Ok 6: Validate PERF_RECORD_* events & perf_sample fields : Ok 7: Test perf pmu format parsing : Ok 8: Test dso data read : Ok 9: Test dso data cache : Ok 10: Test dso data reopen : Ok 11: roundtrip evsel->name check : Ok 12: Check parsing of sched tracepoints fields : Ok 13: Generate and check syscalls:sys_enter_openat event fields: Ok 14: struct perf_event_attr setup : Ok 15: Test matching and linking multiple hists : Ok 16: Try 'import perf' in python, checking link problems : Ok 17: Test breakpoint overflow signal handler : Ok 18: Test breakpoint overflow sampling : Ok 19: Test number of exit event of a simple workload : Ok 20: Test software clock events have valid period values : Ok 21: Test object code reading : Ok 22: Test sample parsing : Ok 23: Test using a dummy software event to keep tracking : Ok 24: Test parsing with no sample_id_all bit set : Ok 25: Test filtering hist entries : Ok 26: Test mmap thread lookup : Ok 27: Test thread mg sharing : Ok 28: Test output sorting of hist entries : Ok 29: Test cumulation of child hist entries : Ok 30: Test tracking with sched_switch : Ok 31: Filter fds with revents mask in a fdarray : Ok 32: Add fd to a fdarray, making it autogrow : Ok 33: Test kmod_path__parse function : Ok 34: Test thread map : Ok 35: Test LLVM searching and compiling : 35.1: Basic BPF llvm compiling test : Ok 35.2: Test kbuild searching : Ok 35.3: Compile source for BPF prologue generation test : Ok 35.4: Compile source for BPF relocation test : Ok 36: Test topology in session : Ok 37: Test BPF filter : 37.1: Test basic BPF filtering : Ok 37.2: Test BPF prologue generation : Ok 37.3: Test BPF relocation checker : Ok 38: Test thread map synthesize : Ok 39: Test cpu map synthesize : Ok 40: Test stat config synthesize : Ok 41: Test stat synthesize : Ok 42: Test stat round synthesize : Ok 43: Test attr update synthesize : Ok 44: Test events times : Ok 45: Test backward reading from ring buffer : Ok 46: Test cpu map print : Ok 47: Test SDT event probing : Ok 48: Test is_printable_array function : Ok 49: Test bitmap print : Ok 50: x86 rdpmc test : Ok 51: Test converting perf time to TSC : Ok 52: Test dwarf unwind : Ok 53: Test x86 instruction decoder - new instructions : Ok 54: Test intel cqm nmi context read : Skip
Quoted 1 line
[root at jouet ~]#
Pulled, thanks a lot Arnaldo!
Ingo