summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2014-04-07 23:49:35 (GMT)
committerScott Wood <scottwood@freescale.com>2014-04-07 23:49:35 (GMT)
commit62b8c978ee6b8d135d9e7953221de58000dba986 (patch)
tree683b04b2e627f6710c22c151b23c8cc9a165315e /tools
parent78fd82238d0e5716578c326404184a27ba67fd6e (diff)
downloadlinux-fsl-qoriq-62b8c978ee6b8d135d9e7953221de58000dba986.tar.xz
Rewind v3.13-rc3+ (78fd82238d0e5716) to v3.12
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile15
-rw-r--r--tools/hv/hv_kvp_daemon.c29
-rw-r--r--tools/hv/hv_vss_daemon.c8
-rw-r--r--tools/lib/traceevent/Makefile18
-rw-r--r--tools/lib/traceevent/event-parse.c201
-rw-r--r--tools/lib/traceevent/event-parse.h14
-rw-r--r--tools/perf/.gitignore1
-rw-r--r--tools/perf/Documentation/Makefile79
-rw-r--r--tools/perf/Documentation/perf-buildid-cache.txt13
-rw-r--r--tools/perf/Documentation/perf-kvm.txt4
-rw-r--r--tools/perf/Documentation/perf-lock.txt2
-rw-r--r--tools/perf/Documentation/perf-record.txt17
-rw-r--r--tools/perf/Documentation/perf-report.txt16
-rw-r--r--tools/perf/Documentation/perf-stat.txt5
-rw-r--r--tools/perf/Documentation/perf-timechart.txt15
-rw-r--r--tools/perf/Documentation/perf-top.txt15
-rw-r--r--tools/perf/Documentation/perf-trace.txt37
-rw-r--r--tools/perf/Makefile848
-rw-r--r--tools/perf/Makefile.perf892
-rw-r--r--tools/perf/arch/arm/Makefile3
-rw-r--r--tools/perf/arch/arm/include/perf_regs.h54
-rw-r--r--tools/perf/arch/arm/util/unwind.c48
-rw-r--r--tools/perf/arch/x86/include/perf_regs.h6
-rw-r--r--tools/perf/arch/x86/util/unwind.c4
-rw-r--r--tools/perf/bash_completion106
-rw-r--r--tools/perf/bench/mem-memcpy-arch.h2
-rw-r--r--tools/perf/bench/mem-memcpy.c2
-rw-r--r--tools/perf/bench/mem-memset-arch.h2
-rw-r--r--tools/perf/bench/mem-memset.c2
-rw-r--r--tools/perf/bench/numa.c38
-rw-r--r--tools/perf/bench/sched-pipe.c115
-rw-r--r--tools/perf/builtin-annotate.c45
-rw-r--r--tools/perf/builtin-bench.c245
-rw-r--r--tools/perf/builtin-buildid-cache.c156
-rw-r--r--tools/perf/builtin-buildid-list.c11
-rw-r--r--tools/perf/builtin-diff.c31
-rw-r--r--tools/perf/builtin-evlist.c7
-rw-r--r--tools/perf/builtin-inject.c46
-rw-r--r--tools/perf/builtin-kmem.c13
-rw-r--r--tools/perf/builtin-kvm.c50
-rw-r--r--tools/perf/builtin-list.c84
-rw-r--r--tools/perf/builtin-lock.c137
-rw-r--r--tools/perf/builtin-mem.c9
-rw-r--r--tools/perf/builtin-probe.c16
-rw-r--r--tools/perf/builtin-record.c201
-rw-r--r--tools/perf/builtin-report.c124
-rw-r--r--tools/perf/builtin-sched.c70
-rw-r--r--tools/perf/builtin-script.c127
-rw-r--r--tools/perf/builtin-stat.c224
-rw-r--r--tools/perf/builtin-timechart.c14
-rw-r--r--tools/perf/builtin-top.c89
-rw-r--r--tools/perf/builtin-trace.c1480
-rw-r--r--tools/perf/config/Makefile389
-rw-r--r--tools/perf/config/feature-checks/Makefile152
-rw-r--r--tools/perf/config/feature-checks/test-all.c111
-rw-r--r--tools/perf/config/feature-checks/test-backtrace.c13
-rw-r--r--tools/perf/config/feature-checks/test-bionic.c6
-rw-r--r--tools/perf/config/feature-checks/test-cplus-demangle.c14
-rw-r--r--tools/perf/config/feature-checks/test-dwarf.c10
-rw-r--r--tools/perf/config/feature-checks/test-fortify-source.c6
-rw-r--r--tools/perf/config/feature-checks/test-glibc.c8
-rw-r--r--tools/perf/config/feature-checks/test-gtk2-infobar.c11
-rw-r--r--tools/perf/config/feature-checks/test-gtk2.c10
-rw-r--r--tools/perf/config/feature-checks/test-hello.c6
-rw-r--r--tools/perf/config/feature-checks/test-libaudit.c10
-rw-r--r--tools/perf/config/feature-checks/test-libbfd.c15
-rw-r--r--tools/perf/config/feature-checks/test-libelf-getphdrnum.c8
-rw-r--r--tools/perf/config/feature-checks/test-libelf-mmap.c8
-rw-r--r--tools/perf/config/feature-checks/test-libelf.c8
-rw-r--r--tools/perf/config/feature-checks/test-libnuma.c9
-rw-r--r--tools/perf/config/feature-checks/test-libperl.c9
-rw-r--r--tools/perf/config/feature-checks/test-libpython-version.c10
-rw-r--r--tools/perf/config/feature-checks/test-libpython.c8
-rw-r--r--tools/perf/config/feature-checks/test-libslang.c6
-rw-r--r--tools/perf/config/feature-checks/test-libunwind-debug-frame.c16
-rw-r--r--tools/perf/config/feature-checks/test-libunwind.c27
-rw-r--r--tools/perf/config/feature-checks/test-on-exit.c16
-rw-r--r--tools/perf/config/feature-checks/test-stackprotector-all.c6
-rw-r--r--tools/perf/config/feature-checks/test-stackprotector.c6
-rw-r--r--tools/perf/config/feature-checks/test-timerfd.c18
-rw-r--r--tools/perf/config/feature-checks/test-volatile-register-var.c6
-rw-r--r--tools/perf/config/feature-tests.mak246
-rw-r--r--tools/perf/config/utilities.mak17
-rw-r--r--tools/perf/perf.c14
-rw-r--r--tools/perf/perf.h67
-rw-r--r--tools/perf/scripts/python/Perf-Trace-Util/Context.c6
-rw-r--r--tools/perf/tests/attr/README6
-rw-r--r--tools/perf/tests/attr/test-record-graph-default2
-rw-r--r--tools/perf/tests/attr/test-record-graph-dwarf2
-rw-r--r--tools/perf/tests/attr/test-record-graph-fp2
-rw-r--r--tools/perf/tests/code-reading.c17
-rw-r--r--tools/perf/tests/dso-data.c1
-rw-r--r--tools/perf/tests/evsel-tp-sched.c4
-rw-r--r--tools/perf/tests/hists_link.c14
-rw-r--r--tools/perf/tests/mmap-basic.c2
-rw-r--r--tools/perf/tests/open-syscall-all-cpus.c2
-rw-r--r--tools/perf/tests/open-syscall-tp-fields.c2
-rw-r--r--tools/perf/tests/open-syscall.c2
-rw-r--r--tools/perf/tests/parse-events.c9
-rw-r--r--tools/perf/tests/perf-record.c12
-rw-r--r--tools/perf/tests/rdpmc.c2
-rw-r--r--tools/perf/tests/sample-parsing.c11
-rw-r--r--tools/perf/tests/sw-clock.c15
-rw-r--r--tools/perf/tests/task-exit.c16
-rw-r--r--tools/perf/ui/browser.c4
-rw-r--r--tools/perf/ui/browser.h32
-rw-r--r--tools/perf/ui/browsers/annotate.c24
-rw-r--r--tools/perf/ui/browsers/hists.c23
-rw-r--r--tools/perf/ui/browsers/map.c40
-rw-r--r--tools/perf/ui/browsers/map.h2
-rw-r--r--tools/perf/ui/browsers/scripts.c8
-rw-r--r--tools/perf/ui/gtk/annotate.c13
-rw-r--r--tools/perf/ui/gtk/browser.c2
-rw-r--r--tools/perf/ui/gtk/gtk.h22
-rw-r--r--tools/perf/ui/gtk/progress.c20
-rw-r--r--tools/perf/ui/gtk/setup.c2
-rw-r--r--tools/perf/ui/gtk/util.c4
-rw-r--r--tools/perf/ui/hist.c2
-rw-r--r--tools/perf/ui/progress.c32
-rw-r--r--tools/perf/ui/progress.h19
-rw-r--r--tools/perf/ui/setup.c61
-rw-r--r--tools/perf/ui/stdio/hist.c14
-rw-r--r--tools/perf/ui/tui/progress.c18
-rw-r--r--tools/perf/ui/tui/setup.c3
-rw-r--r--tools/perf/ui/tui/tui.h6
-rw-r--r--tools/perf/ui/ui.h14
-rwxr-xr-xtools/perf/util/PERF-VERSION-GEN5
-rw-r--r--tools/perf/util/annotate.c76
-rw-r--r--tools/perf/util/annotate.h26
-rw-r--r--tools/perf/util/build-id.c6
-rw-r--r--tools/perf/util/build-id.h3
-rw-r--r--tools/perf/util/cache.h3
-rw-r--r--tools/perf/util/callchain.c147
-rw-r--r--tools/perf/util/callchain.h11
-rw-r--r--tools/perf/util/color.c11
-rw-r--r--tools/perf/util/color.h2
-rw-r--r--tools/perf/util/comm.c121
-rw-r--r--tools/perf/util/comm.h21
-rw-r--r--tools/perf/util/cpumap.c6
-rw-r--r--tools/perf/util/data.c120
-rw-r--r--tools/perf/util/data.h48
-rw-r--r--tools/perf/util/dso.c50
-rw-r--r--tools/perf/util/dso.h3
-rw-r--r--tools/perf/util/event.c94
-rw-r--r--tools/perf/util/event.h18
-rw-r--r--tools/perf/util/evlist.c288
-rw-r--r--tools/perf/util/evlist.h24
-rw-r--r--tools/perf/util/evsel.c42
-rw-r--r--tools/perf/util/evsel.h34
-rw-r--r--tools/perf/util/fs.c119
-rw-r--r--tools/perf/util/fs.h7
-rwxr-xr-xtools/perf/util/generate-cmdlist.sh4
-rw-r--r--tools/perf/util/header.c32
-rw-r--r--tools/perf/util/hist.c95
-rw-r--r--tools/perf/util/hist.h75
-rw-r--r--tools/perf/util/include/dwarf-regs.h2
-rw-r--r--tools/perf/util/include/linux/compiler.h19
-rw-r--r--tools/perf/util/include/linux/magic.h4
-rw-r--r--tools/perf/util/intlist.c23
-rw-r--r--tools/perf/util/intlist.h2
-rw-r--r--tools/perf/util/machine.c180
-rw-r--r--tools/perf/util/machine.h41
-rw-r--r--tools/perf/util/map.c50
-rw-r--r--tools/perf/util/map.h7
-rw-r--r--tools/perf/util/parse-events.c10
-rw-r--r--tools/perf/util/parse-events.l63
-rw-r--r--tools/perf/util/parse-options.c218
-rw-r--r--tools/perf/util/parse-options.h4
-rw-r--r--tools/perf/util/path.c10
-rw-r--r--tools/perf/util/perf_regs.h4
-rw-r--r--tools/perf/util/pmu.c33
-rw-r--r--tools/perf/util/pmu.h1
-rw-r--r--tools/perf/util/probe-event.c5
-rw-r--r--tools/perf/util/probe-finder.c248
-rw-r--r--tools/perf/util/probe-finder.h15
-rw-r--r--tools/perf/util/pstack.h10
-rw-r--r--tools/perf/util/python-ext-sources2
-rw-r--r--tools/perf/util/python.c8
-rw-r--r--tools/perf/util/rblist.c27
-rw-r--r--tools/perf/util/rblist.h1
-rw-r--r--tools/perf/util/record.c71
-rw-r--r--tools/perf/util/scripting-engines/trace-event-perl.c2
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c4
-rw-r--r--tools/perf/util/session.c278
-rw-r--r--tools/perf/util/session.h38
-rw-r--r--tools/perf/util/sort.c331
-rw-r--r--tools/perf/util/sort.h8
-rw-r--r--tools/perf/util/srcline.c265
-rw-r--r--tools/perf/util/strfilter.c72
-rw-r--r--tools/perf/util/strfilter.h12
-rw-r--r--tools/perf/util/symbol-elf.c607
-rw-r--r--tools/perf/util/symbol-minimal.c15
-rw-r--r--tools/perf/util/symbol.c449
-rw-r--r--tools/perf/util/symbol.h29
-rw-r--r--tools/perf/util/sysfs.c60
-rw-r--r--tools/perf/util/sysfs.h6
-rw-r--r--tools/perf/util/target.c54
-rw-r--r--tools/perf/util/target.h45
-rw-r--r--tools/perf/util/thread.c136
-rw-r--r--tools/perf/util/thread.h20
-rw-r--r--tools/perf/util/top.c2
-rw-r--r--tools/perf/util/top.h1
-rw-r--r--tools/perf/util/trace-event-parse.c36
-rw-r--r--tools/perf/util/trace-event.h9
-rw-r--r--tools/perf/util/unwind.c84
-rw-r--r--tools/perf/util/unwind.h9
-rw-r--r--tools/perf/util/util.c66
-rw-r--r--tools/perf/util/util.h26
-rw-r--r--tools/power/cpupower/man/cpupower-idle-info.13
-rw-r--r--tools/power/cpupower/man/cpupower-idle-set.171
-rw-r--r--tools/power/cpupower/utils/helpers/sysfs.c4
-rw-r--r--tools/power/x86/turbostat/turbostat.c197
-rw-r--r--tools/scripts/Makefile.include23
-rw-r--r--tools/testing/ktest/examples/crosstests.conf6
-rw-r--r--tools/thermal/tmon/Makefile47
-rw-r--r--tools/thermal/tmon/README50
-rw-r--r--tools/thermal/tmon/pid.c131
-rw-r--r--tools/thermal/tmon/sysfs.c596
-rw-r--r--tools/thermal/tmon/tmon.8142
-rw-r--r--tools/thermal/tmon/tmon.c352
-rw-r--r--tools/thermal/tmon/tmon.h204
-rw-r--r--tools/thermal/tmon/tui.c638
-rw-r--r--tools/usb/Makefile5
-rw-r--r--tools/virtio/virtio_test.c6
-rw-r--r--tools/virtio/vringh_test.c13
-rw-r--r--tools/vm/page-types.c32
226 files changed, 3903 insertions, 11378 deletions
diff --git a/tools/Makefile b/tools/Makefile
index a9b0200..41067f3 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -15,7 +15,6 @@ help:
@echo ' net - misc networking tools'
@echo ' vm - misc vm tools'
@echo ' x86_energy_perf_policy - Intel energy policy tool'
- @echo ' tmon - thermal monitoring and tuning tool'
@echo ''
@echo 'You can do:'
@echo ' $$ make -C tools/ <tool>_install'
@@ -51,9 +50,6 @@ selftests: FORCE
turbostat x86_energy_perf_policy: FORCE
$(call descend,power/x86/$@)
-tmon: FORCE
- $(call descend,thermal/$@)
-
cpupower_install:
$(call descend,power/$(@:_install=),install)
@@ -66,13 +62,9 @@ selftests_install:
turbostat_install x86_energy_perf_policy_install:
$(call descend,power/x86/$(@:_install=),install)
-tmon_install:
- $(call descend,thermal/$(@:_install=),install)
-
install: cgroup_install cpupower_install firewire_install lguest_install \
perf_install selftests_install turbostat_install usb_install \
- virtio_install vm_install net_install x86_energy_perf_policy_install \
- tmon
+ virtio_install vm_install net_install x86_energy_perf_policy_install
cpupower_clean:
$(call descend,power/cpupower,clean)
@@ -92,11 +84,8 @@ selftests_clean:
turbostat_clean x86_energy_perf_policy_clean:
$(call descend,power/x86/$(@:_clean=),clean)
-tmon_clean:
- $(call descend,thermal/tmon,clean)
-
clean: cgroup_clean cpupower_clean firewire_clean lguest_clean perf_clean \
selftests_clean turbostat_clean usb_clean virtio_clean \
- vm_clean net_clean x86_energy_perf_policy_clean tmon_clean
+ vm_clean net_clean x86_energy_perf_policy_clean
.PHONY: FORCE
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index b8d6d54..8fd9ec6 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -89,7 +89,6 @@ static char *processor_arch;
static char *os_build;
static char *os_version;
static char *lic_version = "Unknown version";
-static char full_domain_name[HV_KVP_EXCHANGE_MAX_VALUE_SIZE];
static struct utsname uts_buf;
/*
@@ -1368,7 +1367,7 @@ setval_error:
}
-static void
+static int
kvp_get_domain_name(char *buffer, int length)
{
struct addrinfo hints, *info ;
@@ -1382,12 +1381,12 @@ kvp_get_domain_name(char *buffer, int length)
error = getaddrinfo(buffer, NULL, &hints, &info);
if (error != 0) {
- snprintf(buffer, length, "getaddrinfo failed: 0x%x %s",
- error, gai_strerror(error));
- return;
+ strcpy(buffer, "getaddrinfo failed\n");
+ return error;
}
- snprintf(buffer, length, "%s", info->ai_canonname);
+ strcpy(buffer, info->ai_canonname);
freeaddrinfo(info);
+ return error;
}
static int
@@ -1434,6 +1433,7 @@ int main(void)
int pool;
char *if_name;
struct hv_kvp_ipaddr_value *kvp_ip_val;
+ char *kvp_send_buffer;
char *kvp_recv_buffer;
size_t kvp_recv_buffer_len;
@@ -1442,21 +1442,17 @@ int main(void)
openlog("KVP", 0, LOG_USER);
syslog(LOG_INFO, "KVP starting; pid is:%d", getpid());
- kvp_recv_buffer_len = NLMSG_LENGTH(0) + sizeof(struct cn_msg) + sizeof(struct hv_kvp_msg);
+ kvp_recv_buffer_len = NLMSG_HDRLEN + sizeof(struct cn_msg) + sizeof(struct hv_kvp_msg);
+ kvp_send_buffer = calloc(1, kvp_recv_buffer_len);
kvp_recv_buffer = calloc(1, kvp_recv_buffer_len);
- if (!kvp_recv_buffer) {
- syslog(LOG_ERR, "Failed to allocate netlink buffer");
+ if (!(kvp_send_buffer && kvp_recv_buffer)) {
+ syslog(LOG_ERR, "Failed to allocate netlink buffers");
exit(EXIT_FAILURE);
}
/*
* Retrieve OS release information.
*/
kvp_get_os_info();
- /*
- * Cache Fully Qualified Domain Name because getaddrinfo takes an
- * unpredictable amount of time to finish.
- */
- kvp_get_domain_name(full_domain_name, sizeof(full_domain_name));
if (kvp_file_init()) {
syslog(LOG_ERR, "Failed to initialize the pools");
@@ -1492,7 +1488,7 @@ int main(void)
/*
* Register ourselves with the kernel.
*/
- message = (struct cn_msg *)kvp_recv_buffer;
+ message = (struct cn_msg *)kvp_send_buffer;
message->id.idx = CN_KVP_IDX;
message->id.val = CN_KVP_VAL;
@@ -1675,7 +1671,8 @@ int main(void)
switch (hv_msg->body.kvp_enum_data.index) {
case FullyQualifiedDomainName:
- strcpy(key_value, full_domain_name);
+ kvp_get_domain_name(key_value,
+ HV_KVP_EXCHANGE_MAX_VALUE_SIZE);
strcpy(key_name, "FullyQualifiedDomainName");
break;
case IntegrationServicesVersion:
diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index 8bcb040..8611962 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -140,6 +140,7 @@ int main(void)
struct cn_msg *incoming_cn_msg;
int op;
struct hv_vss_msg *vss_msg;
+ char *vss_send_buffer;
char *vss_recv_buffer;
size_t vss_recv_buffer_len;
@@ -149,9 +150,10 @@ int main(void)
openlog("Hyper-V VSS", 0, LOG_USER);
syslog(LOG_INFO, "VSS starting; pid is:%d", getpid());
- vss_recv_buffer_len = NLMSG_LENGTH(0) + sizeof(struct cn_msg) + sizeof(struct hv_vss_msg);
+ vss_recv_buffer_len = NLMSG_HDRLEN + sizeof(struct cn_msg) + sizeof(struct hv_vss_msg);
+ vss_send_buffer = calloc(1, vss_recv_buffer_len);
vss_recv_buffer = calloc(1, vss_recv_buffer_len);
- if (!vss_recv_buffer) {
+ if (!(vss_send_buffer && vss_recv_buffer)) {
syslog(LOG_ERR, "Failed to allocate netlink buffers");
exit(EXIT_FAILURE);
}
@@ -183,7 +185,7 @@ int main(void)
/*
* Register ourselves with the kernel.
*/
- message = (struct cn_msg *)vss_recv_buffer;
+ message = (struct cn_msg *)vss_send_buffer;
message->id.idx = CN_VSS_IDX;
message->id.val = CN_VSS_VAL;
message->ack = 0;
diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index fc15020..ca6cb77 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -134,14 +134,14 @@ ifeq ($(VERBOSE),1)
print_install =
else
Q = @
- print_compile = echo ' CC '$(OBJ);
- print_app_build = echo ' BUILD '$(OBJ);
- print_fpic_compile = echo ' CC FPIC '$(OBJ);
- print_shared_lib_compile = echo ' BUILD SHARED LIB '$(OBJ);
- print_plugin_obj_compile = echo ' BUILD PLUGIN OBJ '$(OBJ);
- print_plugin_build = echo ' BUILD PLUGIN '$(OBJ);
- print_static_lib_build = echo ' BUILD STATIC LIB '$(OBJ);
- print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2';
+ print_compile = echo ' CC '$(OBJ);
+ print_app_build = echo ' BUILD '$(OBJ);
+ print_fpic_compile = echo ' CC FPIC '$(OBJ);
+ print_shared_lib_compile = echo ' BUILD SHARED LIB '$(OBJ);
+ print_plugin_obj_compile = echo ' CC PLUGIN OBJ '$(OBJ);
+ print_plugin_build = echo ' CC PLUGI '$(OBJ);
+ print_static_lib_build = echo ' BUILD STATIC LIB '$(OBJ);
+ print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2';
endif
do_fpic_compile = \
@@ -268,7 +268,7 @@ TRACK_CFLAGS = $(subst ','\'',$(CFLAGS)):$(ARCH):$(CROSS_COMPILE)
TRACEEVENT-CFLAGS: force
@FLAGS='$(TRACK_CFLAGS)'; \
if test x"$$FLAGS" != x"`cat TRACEEVENT-CFLAGS 2>/dev/null`" ; then \
- echo 1>&2 " FLAGS: * new build flags or cross compiler"; \
+ echo 1>&2 " * new build flags or cross compiler"; \
echo "$$FLAGS" >TRACEEVENT-CFLAGS; \
fi
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 217c82e..d1c2a6a 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -305,11 +305,6 @@ int pevent_register_comm(struct pevent *pevent, const char *comm, int pid)
return 0;
}
-void pevent_register_trace_clock(struct pevent *pevent, char *trace_clock)
-{
- pevent->trace_clock = trace_clock;
-}
-
struct func_map {
unsigned long long addr;
char *func;
@@ -604,11 +599,10 @@ find_printk(struct pevent *pevent, unsigned long long addr)
* This registers a string by the address it was stored in the kernel.
* The @fmt passed in is duplicated.
*/
-int pevent_register_print_string(struct pevent *pevent, const char *fmt,
+int pevent_register_print_string(struct pevent *pevent, char *fmt,
unsigned long long addr)
{
struct printk_list *item = malloc(sizeof(*item));
- char *p;
if (!item)
return -1;
@@ -616,21 +610,10 @@ int pevent_register_print_string(struct pevent *pevent, const char *fmt,
item->next = pevent->printklist;
item->addr = addr;
- /* Strip off quotes and '\n' from the end */
- if (fmt[0] == '"')
- fmt++;
item->printk = strdup(fmt);
if (!item->printk)
goto out_free;
- p = item->printk + strlen(item->printk) - 1;
- if (*p == '"')
- *p = 0;
-
- p -= 2;
- if (strcmp(p, "\\n") == 0)
- *p = 0;
-
pevent->printklist = item;
pevent->printk_count++;
@@ -1606,24 +1589,6 @@ process_arg(struct event_format *event, struct print_arg *arg, char **tok)
static enum event_type
process_op(struct event_format *event, struct print_arg *arg, char **tok);
-/*
- * For __print_symbolic() and __print_flags, we need to completely
- * evaluate the first argument, which defines what to print next.
- */
-static enum event_type
-process_field_arg(struct event_format *event, struct print_arg *arg, char **tok)
-{
- enum event_type type;
-
- type = process_arg(event, arg, tok);
-
- while (type == EVENT_OP) {
- type = process_op(event, arg, tok);
- }
-
- return type;
-}
-
static enum event_type
process_cond(struct event_format *event, struct print_arg *top, char **tok)
{
@@ -2389,7 +2354,7 @@ process_flags(struct event_format *event, struct print_arg *arg, char **tok)
goto out_free;
}
- type = process_field_arg(event, field, &token);
+ type = process_arg(event, field, &token);
/* Handle operations in the first argument */
while (type == EVENT_OP)
@@ -2442,8 +2407,7 @@ process_symbols(struct event_format *event, struct print_arg *arg, char **tok)
goto out_free;
}
- type = process_field_arg(event, field, &token);
-
+ type = process_arg(event, field, &token);
if (test_type_token(type, token, EVENT_DELIM, ","))
goto out_free_field;
@@ -3454,19 +3418,6 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
goto out_warning_op;
}
break;
- case PRINT_DYNAMIC_ARRAY:
- /* Without [], we pass the address to the dynamic data */
- offset = pevent_read_number(pevent,
- data + arg->dynarray.field->offset,
- arg->dynarray.field->size);
- /*
- * The actual length of the dynamic array is stored
- * in the top half of the field, and the offset
- * is in the bottom half of the 32 bit field.
- */
- offset &= 0xffff;
- val = (unsigned long long)((unsigned long)data + offset);
- break;
default: /* not sure what to do there */
return 0;
}
@@ -3537,7 +3488,6 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
struct pevent *pevent = event->pevent;
struct print_flag_sym *flag;
struct format_field *field;
- struct printk_map *printk;
unsigned long long val, fval;
unsigned long addr;
char *str;
@@ -3573,12 +3523,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
if (!(field->flags & FIELD_IS_ARRAY) &&
field->size == pevent->long_size) {
addr = *(unsigned long *)(data + field->offset);
- /* Check if it matches a print format */
- printk = find_printk(pevent, addr);
- if (printk)
- trace_seq_puts(s, printk->printk);
- else
- trace_seq_printf(s, "%lx", addr);
+ trace_seq_printf(s, "%lx", addr);
break;
}
str = malloc(len + 1);
@@ -3620,23 +3565,15 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
}
break;
case PRINT_HEX:
- if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) {
- unsigned long offset;
- offset = pevent_read_number(pevent,
- data + arg->hex.field->dynarray.field->offset,
- arg->hex.field->dynarray.field->size);
- hex = data + (offset & 0xffff);
- } else {
- field = arg->hex.field->field.field;
- if (!field) {
- str = arg->hex.field->field.name;
- field = pevent_find_any_field(event, str);
- if (!field)
- goto out_warning_field;
- arg->hex.field->field.field = field;
- }
- hex = data + field->offset;
+ field = arg->hex.field->field.field;
+ if (!field) {
+ str = arg->hex.field->field.name;
+ field = pevent_find_any_field(event, str);
+ if (!field)
+ goto out_warning_field;
+ arg->hex.field->field.field = field;
}
+ hex = data + field->offset;
len = eval_num_arg(data, size, event, arg->hex.size);
for (i = 0; i < len; i++) {
if (i)
@@ -3834,8 +3771,8 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
if (asprintf(&arg->atom.atom, "%lld", ip) < 0)
goto out_free;
- /* skip the first "%pf: " */
- for (ptr = fmt + 5, bptr = data + field->offset;
+ /* skip the first "%pf : " */
+ for (ptr = fmt + 6, bptr = data + field->offset;
bptr < data + size && *ptr; ptr++) {
int ls = 0;
@@ -3945,6 +3882,7 @@ get_bprint_format(void *data, int size __maybe_unused,
struct format_field *field;
struct printk_map *printk;
char *format;
+ char *p;
field = pevent->bprint_fmt_field;
@@ -3961,13 +3899,25 @@ get_bprint_format(void *data, int size __maybe_unused,
printk = find_printk(pevent, addr);
if (!printk) {
- if (asprintf(&format, "%%pf: (NO FORMAT FOUND at %llx)\n", addr) < 0)
+ if (asprintf(&format, "%%pf : (NO FORMAT FOUND at %llx)\n", addr) < 0)
return NULL;
return format;
}
- if (asprintf(&format, "%s: %s", "%pf", printk->printk) < 0)
+ p = printk->printk;
+ /* Remove any quotes. */
+ if (*p == '"')
+ p++;
+ if (asprintf(&format, "%s : %s", "%pf", p) < 0)
return NULL;
+ /* remove ending quotes and new line since we will add one too */
+ p = format + strlen(format) - 1;
+ if (*p == '"')
+ *p = 0;
+
+ p -= 2;
+ if (strcmp(p, "\\n") == 0)
+ *p = 0;
return format;
}
@@ -4013,7 +3963,7 @@ static int is_printable_array(char *p, unsigned int len)
unsigned int i;
for (i = 0; i < len && p[i]; i++)
- if (!isprint(p[i]) && !isspace(p[i]))
+ if (!isprint(p[i]))
return 0;
return 1;
}
@@ -4478,11 +4428,11 @@ void pevent_event_info(struct trace_seq *s, struct event_format *event,
{
int print_pretty = 1;
- if (event->pevent->print_raw || (event->flags & EVENT_FL_PRINTRAW))
+ if (event->pevent->print_raw)
print_event_fields(s, record->data, record->size, event);
else {
- if (event->handler && !(event->flags & EVENT_FL_NOHANDLE))
+ if (event->handler)
print_pretty = event->handler(s, record, event,
event->context);
@@ -4493,21 +4443,8 @@ void pevent_event_info(struct trace_seq *s, struct event_format *event,
trace_seq_terminate(s);
}
-static bool is_timestamp_in_us(char *trace_clock, bool use_trace_clock)
-{
- if (!use_trace_clock)
- return true;
-
- if (!strcmp(trace_clock, "local") || !strcmp(trace_clock, "global")
- || !strcmp(trace_clock, "uptime") || !strcmp(trace_clock, "perf"))
- return true;
-
- /* trace_clock is setting in tsc or counter mode */
- return false;
-}
-
void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
- struct pevent_record *record, bool use_trace_clock)
+ struct pevent_record *record)
{
static const char *spaces = " "; /* 20 spaces */
struct event_format *event;
@@ -4520,14 +4457,9 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
int pid;
int len;
int p;
- bool use_usec_format;
- use_usec_format = is_timestamp_in_us(pevent->trace_clock,
- use_trace_clock);
- if (use_usec_format) {
- secs = record->ts / NSECS_PER_SEC;
- nsecs = record->ts - secs * NSECS_PER_SEC;
- }
+ secs = record->ts / NSECS_PER_SEC;
+ nsecs = record->ts - secs * NSECS_PER_SEC;
if (record->size < 0) {
do_warning("ug! negative record size %d", record->size);
@@ -4552,20 +4484,15 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
} else
trace_seq_printf(s, "%16s-%-5d [%03d]", comm, pid, record->cpu);
- if (use_usec_format) {
- if (pevent->flags & PEVENT_NSEC_OUTPUT) {
- usecs = nsecs;
- p = 9;
- } else {
- usecs = (nsecs + 500) / NSECS_PER_USEC;
- p = 6;
- }
+ if (pevent->flags & PEVENT_NSEC_OUTPUT) {
+ usecs = nsecs;
+ p = 9;
+ } else {
+ usecs = (nsecs + 500) / NSECS_PER_USEC;
+ p = 6;
+ }
- trace_seq_printf(s, " %5lu.%0*lu: %s: ",
- secs, p, usecs, event->name);
- } else
- trace_seq_printf(s, " %12llu: %s: ",
- record->ts, event->name);
+ trace_seq_printf(s, " %5lu.%0*lu: %s: ", secs, p, usecs, event->name);
/* Space out the event names evenly. */
len = strlen(event->name);
@@ -5399,48 +5326,6 @@ int pevent_print_num_field(struct trace_seq *s, const char *fmt,
return -1;
}
-/**
- * pevent_print_func_field - print a field and a format for function pointers
- * @s: The seq to print to
- * @fmt: The printf format to print the field with.
- * @event: the event that the field is for
- * @name: The name of the field
- * @record: The record with the field name.
- * @err: print default error if failed.
- *
- * Returns: 0 on success, -1 field not found, or 1 if buffer is full.
- */
-int pevent_print_func_field(struct trace_seq *s, const char *fmt,
- struct event_format *event, const char *name,
- struct pevent_record *record, int err)
-{
- struct format_field *field = pevent_find_field(event, name);
- struct pevent *pevent = event->pevent;
- unsigned long long val;
- struct func_map *func;
- char tmp[128];
-
- if (!field)
- goto failed;
-
- if (pevent_read_number_field(field, record->data, &val))
- goto failed;
-
- func = find_func(pevent, val);
-
- if (func)
- snprintf(tmp, 128, "%s/0x%llx", func->func, func->addr - val);
- else
- sprintf(tmp, "0x%08llx", val);
-
- return trace_seq_printf(s, fmt, tmp);
-
- failed:
- if (err)
- trace_seq_printf(s, "CAN'T FIND FIELD \"%s\"", name);
- return -1;
-}
-
static void free_func_handle(struct pevent_function_handler *func)
{
struct pevent_func_params *params;
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 8d73d25..c37b202 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -20,7 +20,6 @@
#ifndef _PARSE_EVENTS_H
#define _PARSE_EVENTS_H
-#include <stdbool.h>
#include <stdarg.h>
#include <regex.h>
@@ -308,8 +307,6 @@ enum {
EVENT_FL_ISBPRINT = 0x04,
EVENT_FL_ISFUNCENT = 0x10,
EVENT_FL_ISFUNCRET = 0x20,
- EVENT_FL_NOHANDLE = 0x40,
- EVENT_FL_PRINTRAW = 0x80,
EVENT_FL_FAILED = 0x80000000
};
@@ -453,8 +450,6 @@ struct pevent {
/* cache */
struct event_format *last_event;
-
- char *trace_clock;
};
static inline void pevent_set_flag(struct pevent *pevent, int flag)
@@ -532,15 +527,14 @@ enum trace_flag_type {
};
int pevent_register_comm(struct pevent *pevent, const char *comm, int pid);
-void pevent_register_trace_clock(struct pevent *pevent, char *trace_clock);
int pevent_register_function(struct pevent *pevent, char *name,
unsigned long long addr, char *mod);
-int pevent_register_print_string(struct pevent *pevent, const char *fmt,
+int pevent_register_print_string(struct pevent *pevent, char *fmt,
unsigned long long addr);
int pevent_pid_is_registered(struct pevent *pevent, int pid);
void pevent_print_event(struct pevent *pevent, struct trace_seq *s,
- struct pevent_record *record, bool use_trace_clock);
+ struct pevent_record *record);
int pevent_parse_header_page(struct pevent *pevent, char *buf, unsigned long size,
int long_size);
@@ -569,10 +563,6 @@ int pevent_print_num_field(struct trace_seq *s, const char *fmt,
struct event_format *event, const char *name,
struct pevent_record *record, int err);
-int pevent_print_func_field(struct trace_seq *s, const char *fmt,
- struct event_format *event, const char *name,
- struct pevent_record *record, int err);
-
int pevent_register_event_handler(struct pevent *pevent, int id,
const char *sys_name, const char *event_name,
pevent_event_handler_func func, void *context);
diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore
index 782d86e..8f8fbc2 100644
--- a/tools/perf/.gitignore
+++ b/tools/perf/.gitignore
@@ -13,7 +13,6 @@ perf*.html
common-cmds.h
perf.data
perf.data.old
-output.svg
perf-archive
tags
TAGS
diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile
index 3ba1c0b..5a37a7c 100644
--- a/tools/perf/Documentation/Makefile
+++ b/tools/perf/Documentation/Makefile
@@ -145,17 +145,16 @@ endif
ifneq ($(findstring $(MAKEFLAGS),s),s)
ifneq ($(V),1)
- QUIET_ASCIIDOC = @echo ' ASCIIDOC '$@;
- QUIET_XMLTO = @echo ' XMLTO '$@;
- QUIET_DB2TEXI = @echo ' DB2TEXI '$@;
- QUIET_MAKEINFO = @echo ' MAKEINFO '$@;
- QUIET_DBLATEX = @echo ' DBLATEX '$@;
- QUIET_XSLTPROC = @echo ' XSLTPROC '$@;
- QUIET_GEN = @echo ' GEN '$@;
+ QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
+ QUIET_XMLTO = @echo ' ' XMLTO $@;
+ QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
+ QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
+ QUIET_DBLATEX = @echo ' ' DBLATEX $@;
+ QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
+ QUIET_GEN = @echo ' ' GEN $@;
QUIET_STDERR = 2> /dev/null
QUIET_SUBDIR0 = +@subdir=
- QUIET_SUBDIR1 = ;$(NO_SUBDIR) \
- echo ' SUBDIR ' $$subdir; \
+ QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
$(MAKE) $(PRINT_DIR) -C $$subdir
export V
endif
@@ -184,43 +183,47 @@ ifdef missing_tools
endif
do-install-man: man
- $(call QUIET_INSTALL, Documentation-man) \
- $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir); \
-# $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir); \
-# $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir); \
- $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir); \
-# $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir); \
-# $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
+ $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
+# $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
+# $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
+ $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
+# $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
+# $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
install-man: check-man-tools man
+try-install-man:
ifdef missing_tools
- DO_INSTALL_MAN = $(warning Please install $(missing_tools) to have the man pages installed)
+ $(warning Please install $(missing_tools) to have the man pages installed)
else
- DO_INSTALL_MAN = do-install-man
+ $(MAKE) do-install-man
endif
-try-install-man: $(DO_INSTALL_MAN)
-
install-info: info
- $(call QUIET_INSTALL, Documentation-info) \
- $(INSTALL) -d -m 755 $(DESTDIR)$(infodir); \
- $(INSTALL) -m 644 $(OUTPUT)perf.info $(OUTPUT)perfman.info $(DESTDIR)$(infodir); \
+ $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
+ $(INSTALL) -m 644 $(OUTPUT)perf.info $(OUTPUT)perfman.info $(DESTDIR)$(infodir)
if test -r $(DESTDIR)$(infodir)/dir; then \
- $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perf.info ;\
- $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perfman.info ;\
+ $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perf.info ;\
+ $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perfman.info ;\
else \
echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
fi
install-pdf: pdf
- $(call QUIET_INSTALL, Documentation-pdf) \
- $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir); \
- $(INSTALL) -m 644 $(OUTPUT)user-manual.pdf $(DESTDIR)$(pdfdir)
+ $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
+ $(INSTALL) -m 644 $(OUTPUT)user-manual.pdf $(DESTDIR)$(pdfdir)
#install-html: html
# '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(MAKECMDGOALS),tags)
+$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
+ $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) $(OUTPUT)PERF-VERSION-FILE
+
+-include $(OUTPUT)PERF-VERSION-FILE
+endif
+endif
#
# Determine "include::" file references in asciidoc files.
@@ -250,17 +253,15 @@ $(OUTPUT)cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
$(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
date >$@
-CLEAN_FILES = \
- $(MAN_XML) $(addsuffix +,$(MAN_XML)) \
- $(MAN_HTML) $(addsuffix +,$(MAN_HTML)) \
- $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7) \
- $(OUTPUT)*.texi $(OUTPUT)*.texi+ $(OUTPUT)*.texi++ \
- $(OUTPUT)perf.info $(OUTPUT)perfman.info \
- $(OUTPUT)howto-index.txt $(OUTPUT)howto/*.html $(OUTPUT)doc.dep \
- $(OUTPUT)technical/api-*.html $(OUTPUT)technical/api-index.txt \
- $(cmds_txt) $(OUTPUT)*.made
clean:
- $(call QUIET_CLEAN, Documentation) $(RM) $(CLEAN_FILES)
+ $(RM) $(MAN_XML) $(addsuffix +,$(MAN_XML))
+ $(RM) $(MAN_HTML) $(addsuffix +,$(MAN_HTML))
+ $(RM) $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7)
+ $(RM) $(OUTPUT)*.texi $(OUTPUT)*.texi+ $(OUTPUT)*.texi++
+ $(RM) $(OUTPUT)perf.info $(OUTPUT)perfman.info
+ $(RM) $(OUTPUT)howto-index.txt $(OUTPUT)howto/*.html $(OUTPUT)doc.dep
+ $(RM) $(OUTPUT)technical/api-*.html $(OUTPUT)technical/api-index.txt
+ $(RM) $(cmds_txt) $(OUTPUT)*.made
$(MAN_HTML): $(OUTPUT)%.html : %.txt
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
@@ -341,3 +342,5 @@ $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
#quick-install-html:
# '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)
+
+.PHONY: .FORCE-PERF-VERSION-FILE
diff --git a/tools/perf/Documentation/perf-buildid-cache.txt b/tools/perf/Documentation/perf-buildid-cache.txt
index fd77d81..e9a8349 100644
--- a/tools/perf/Documentation/perf-buildid-cache.txt
+++ b/tools/perf/Documentation/perf-buildid-cache.txt
@@ -21,19 +21,6 @@ OPTIONS
-a::
--add=::
Add specified file to the cache.
--k::
---kcore::
- Add specified kcore file to the cache. For the current host that is
- /proc/kcore which requires root permissions to read. Be aware that
- running 'perf buildid-cache' as root may update root's build-id cache
- not the user's. Use the -v option to see where the file is created.
- Note that the copied file contains only code sections not the whole core
- image. Note also that files "kallsyms" and "modules" must also be in the
- same directory and are also copied. All 3 files are created with read
- permissions for root only. kcore will not be added if there is already a
- kcore in the cache (with the same build-id) that has the same modules at
- the same addresses. Use the -v option to see if a copy of kcore is
- actually made.
-r::
--remove=::
Remove specified file from the cache.
diff --git a/tools/perf/Documentation/perf-kvm.txt b/tools/perf/Documentation/perf-kvm.txt
index 6a06cef..ac84db2 100644
--- a/tools/perf/Documentation/perf-kvm.txt
+++ b/tools/perf/Documentation/perf-kvm.txt
@@ -109,9 +109,7 @@ STAT LIVE OPTIONS
-m::
--mmap-pages=::
- Number of mmap data pages (must be a power of two) or size
- specification with appended unit character - B/K/M/G. The
- size is rounded up to have nearest pages power of two value.
+ Number of mmap data pages. Must be a power of two.
-a::
--all-cpus::
diff --git a/tools/perf/Documentation/perf-lock.txt b/tools/perf/Documentation/perf-lock.txt
index ab25be2..c7f5f55 100644
--- a/tools/perf/Documentation/perf-lock.txt
+++ b/tools/perf/Documentation/perf-lock.txt
@@ -48,7 +48,7 @@ REPORT OPTIONS
-k::
--key=<value>::
Sorting key. Possible values: acquired (default), contended,
- avg_wait, wait_total, wait_max, wait_min.
+ wait_total, wait_max, wait_min.
INFO OPTIONS
------------
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 43b42c4..ca0d3d9 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -87,9 +87,7 @@ OPTIONS
-m::
--mmap-pages=::
- Number of mmap data pages (must be a power of two) or size
- specification with appended unit character - B/K/M/G. The
- size is rounded up to have nearest pages power of two value.
+ Number of mmap data pages. Must be a power of two.
-g::
Enables call-graph (stack chain/backtrace) recording.
@@ -180,9 +178,6 @@ following filters are defined:
- u: only when the branch target is at the user level
- k: only when the branch target is in the kernel
- hv: only when the target is at the hypervisor level
- - in_tx: only when the target is in a hardware transaction
- - no_tx: only when the target is not in a hardware transaction
- - abort_tx: only when the target is a hardware transaction abort
+
The option requires at least one branch type among any, any_call, any_ret, ind_call.
@@ -193,20 +188,12 @@ is enabled for all the sampling events. The sampled branch type is the same for
The various filters must be specified as a comma separated list: --branch-filter any_ret,u,k
Note that this feature may not be available on all processors.
+-W::
--weight::
Enable weightened sampling. An additional weight is recorded per sample and can be
displayed with the weight and local_weight sort keys. This currently works for TSX
abort events and some memory events in precise mode on modern Intel CPUs.
---transaction::
-Record transaction flags for transaction related events.
-
---force-per-cpu::
-Force the use of per-cpu mmaps. By default, when tasks are specified (i.e. -p,
--t or -u options) per-thread mmaps are created. This option overrides that and
-forces per-cpu mmaps. A side-effect of that is that inheritance is
-automatically enabled. Add the -i option also to disable inheritance.
-
SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-list[1]
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 10a2798..2b8097e 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -71,11 +71,7 @@ OPTIONS
entries are displayed as "[other]".
- cpu: cpu number the task ran at the time of sample
- srcline: filename and line number executed at the time of sample. The
- DWARF debugging info must be provided.
- - weight: Event specific weight, e.g. memory latency or transaction
- abort cost. This is the global weight.
- - local_weight: Local weight version of the weight above.
- - transaction: Transaction abort flags.
+ DWARF debuggin info must be provided.
By default, comm, dso and symbol keys are used.
(i.e. --sort comm,dso,symbol)
@@ -89,8 +85,6 @@ OPTIONS
- symbol_from: name of function branched from
- symbol_to: name of function branched to
- mispredict: "N" for predicted branch, "Y" for mispredicted branch
- - in_tx: branch in TSX transaction
- - abort: TSX transaction abort.
And default sort keys are changed to comm, dso_from, symbol_from, dso_to
and symbol_to, see '--branch-stack'.
@@ -141,14 +135,6 @@ OPTIONS
Default: fractal,0.5,callee,function.
---max-stack::
- Set the stack depth limit when parsing the callchain, anything
- beyond the specified depth will be ignored. This is a trade-off
- between information loss and faster processing especially for
- workloads that can have a very long callchain stack.
-
- Default: 127
-
-G::
--inverted::
alias for inverted caller based call graph.
diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index 80c7da6..73c9759 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -137,11 +137,6 @@ core number and the number of online logical processors on that physical process
After starting the program, wait msecs before measuring. This is useful to
filter out the startup phase of the program, which is often very different.
--T::
---transaction::
-
-Print statistics of transactional execution if supported.
-
EXAMPLES
--------
diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt
index 3ff8bd4..1632b0e 100644
--- a/tools/perf/Documentation/perf-timechart.txt
+++ b/tools/perf/Documentation/perf-timechart.txt
@@ -8,8 +8,7 @@ perf-timechart - Tool to visualize total system behavior during a workload
SYNOPSIS
--------
[verse]
-'perf timechart' record <command>
-'perf timechart' [<options>]
+'perf timechart' {record}
DESCRIPTION
-----------
@@ -42,18 +41,6 @@ OPTIONS
--symfs=<directory>::
Look for files with symbols relative to this directory.
-EXAMPLES
---------
-
-$ perf timechart record git pull
-
- [ perf record: Woken up 13 times to write data ]
- [ perf record: Captured and wrote 4.253 MB perf.data (~185801 samples) ]
-
-$ perf timechart
-
- Written 10.2 seconds of trace to output.svg.
-
SEE ALSO
--------
linkperf:perf-record[1]
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index 7de01dd..6a118e7 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -68,9 +68,7 @@ Default is to monitor all CPUS.
-m <pages>::
--mmap-pages=<pages>::
- Number of mmap data pages (must be a power of two) or size
- specification with appended unit character - B/K/M/G. The
- size is rounded up to have nearest pages power of two value.
+ Number of mmapped data pages.
-p <pid>::
--pid=<pid>::
@@ -114,8 +112,7 @@ Default is to monitor all CPUS.
-s::
--sort::
- Sort by key(s): pid, comm, dso, symbol, parent, srcline, weight,
- local_weight, abort, in_tx, transaction
+ Sort by key(s): pid, comm, dso, symbol, parent, srcline, weight, local_weight.
-n::
--show-nr-samples::
@@ -150,14 +147,6 @@ Default is to monitor all CPUS.
Setup and enable call-graph (stack chain/backtrace) recording,
implies -G.
---max-stack::
- Set the stack depth limit when parsing the callchain, anything
- beyond the specified depth will be ignored. This is a trade-off
- between information loss and faster processing especially for
- workloads that can have a very long callchain stack.
-
- Default: 127
-
--ignore-callees=<regex>::
Ignore callees of the function(s) matching the given regex.
This has the effect of collecting the callers of each such
diff --git a/tools/perf/Documentation/perf-trace.txt b/tools/perf/Documentation/perf-trace.txt
index fae38d9..daccd2c 100644
--- a/tools/perf/Documentation/perf-trace.txt
+++ b/tools/perf/Documentation/perf-trace.txt
@@ -9,7 +9,6 @@ SYNOPSIS
--------
[verse]
'perf trace'
-'perf trace record'
DESCRIPTION
-----------
@@ -17,14 +16,9 @@ This command will show the events associated with the target, initially
syscalls, but other system events like pagefaults, task lifetime events,
scheduling events, etc.
-This is a live mode tool in addition to working with perf.data files like
-the other perf tools. Files can be generated using the 'perf record' command
-but the session needs to include the raw_syscalls events (-e 'raw_syscalls:*').
-Alernatively, the 'perf trace record' can be used as a shortcut to
-automatically include the raw_syscalls events when writing events to a file.
-
-The following options apply to perf trace; options to perf trace record are
-found in the perf record man page.
+Initially this is a live mode only tool, but eventually will work with
+perf.data files like the other tools, allowing a detached 'record' from
+analysis phases.
OPTIONS
-------
@@ -65,9 +59,7 @@ OPTIONS
-m::
--mmap-pages=::
- Number of mmap data pages (must be a power of two) or size
- specification with appended unit character - B/K/M/G. The
- size is rounded up to have nearest pages power of two value.
+ Number of mmap data pages. Must be a power of two.
-C::
--cpu::
@@ -86,27 +78,6 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs.
--input
Process events from a given perf data file.
--T
---time
- Print full timestamp rather time relative to first sample.
-
---comm::
- Show process COMM right beside its ID, on by default, disable with --no-comm.
-
--s::
---summary::
- Show only a summary of syscalls by thread with min, max, and average times
- (in msec) and relative stddev.
-
--S::
---with-summary::
- Show all syscalls followed by a summary by thread with min, max, and
- average times (in msec) and relative stddev.
-
---tool_stats::
- Show tool stats such as number of times fd->pathname was discovered thru
- hooking the open syscall return + vfs_getname or via reading /proc/pid/fd, etc.
-
SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-script[1]
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 4835618..64c043b 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -1,79 +1,819 @@
+include ../scripts/Makefile.include
+
+# The default target of this Makefile is...
+all:
+
+include config/utilities.mak
+
+# Define V to have a more verbose compile.
#
-# This is a simple wrapper Makefile that calls the main Makefile.perf
-# with a -j option to do parallel builds
+# Define O to save output files in a separate directory.
#
-# If you want to invoke the perf build in some non-standard way then
-# you can use the 'make -f Makefile.perf' method to invoke it.
+# Define ARCH as name of target architecture if you want cross-builds.
#
-
+# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.
#
-# Clear out the built-in rules GNU make defines by default (such as .o targets),
-# so that we pass through all targets to Makefile.perf:
+# Define NO_LIBPERL to disable perl script extension.
#
-.SUFFIXES:
-
+# Define NO_LIBPYTHON to disable python script extension.
#
-# We don't want to pass along options like -j:
+# Define PYTHON to point to the python binary if the default
+# `python' is not correct; for example: PYTHON=python2
#
-unexport MAKEFLAGS
-
+# Define PYTHON_CONFIG to point to the python-config binary if
+# the default `$(PYTHON)-config' is not correct.
#
-# Do a parallel build with multiple jobs, based on the number of CPUs online
-# in this system: 'make -j8' on a 8-CPU system, etc.
+# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
#
-# (To override it, run 'make JOBS=1' and similar.)
+# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
#
-ifeq ($(JOBS),)
- JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
- ifeq ($(JOBS),)
- JOBS := 1
- endif
-endif
-
+# Define LDFLAGS=-static to build a static binary.
#
-# Only pass canonical directory names as the output directory:
+# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
#
-ifneq ($(O),)
- FULL_O := $(shell readlink -f $(O) || echo $(O))
-endif
-
+# Define NO_DWARF if you do not want debug-info analysis feature at all.
#
-# Only accept the 'DEBUG' variable from the command line:
+# Define WERROR=0 to disable treating any warnings as errors.
#
-ifeq ("$(origin DEBUG)", "command line")
- ifeq ($(DEBUG),)
- override DEBUG = 0
- else
- SET_DEBUG = "DEBUG=$(DEBUG)"
- endif
+# Define NO_NEWT if you do not want TUI support. (deprecated)
+#
+# Define NO_SLANG if you do not want TUI support.
+#
+# Define NO_GTK2 if you do not want GTK+ GUI support.
+#
+# Define NO_DEMANGLE if you do not want C++ symbol demangling.
+#
+# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)
+#
+# Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf
+# backtrace post unwind.
+#
+# Define NO_BACKTRACE if you do not want stack backtrace debug feature
+#
+# Define NO_LIBNUMA if you do not want numa perf benchmark
+#
+# Define NO_LIBAUDIT if you do not want libaudit support
+#
+# Define NO_LIBBIONIC if you do not want bionic support
+
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(shell pwd)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+#$(info Determined 'srctree' to be $(srctree))
+endif
+
+ifneq ($(objtree),)
+#$(info Determined 'objtree' to be $(objtree))
+endif
+
+ifneq ($(OUTPUT),)
+#$(info Determined 'OUTPUT' to be $(OUTPUT))
+endif
+
+$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
+ @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
+
+CC = $(CROSS_COMPILE)gcc
+AR = $(CROSS_COMPILE)ar
+
+RM = rm -f
+MKDIR = mkdir
+FIND = find
+INSTALL = install
+FLEX = flex
+BISON = bison
+STRIP = strip
+
+LK_DIR = $(srctree)/tools/lib/lk/
+TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
+
+# include config/Makefile by default and rule out
+# non-config cases
+config := 1
+
+NON_CONFIG_TARGETS := clean TAGS tags cscope help
+
+ifdef MAKECMDGOALS
+ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
+ config := 0
+endif
+endif
+
+ifeq ($(config),1)
+include config/Makefile
+endif
+
+export prefix bindir sharedir sysconfdir
+
+# sparse is architecture-neutral, which means that we need to tell it
+# explicitly what architecture to check for. Fix this up for yours..
+SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
+
+# Guard against environment variables
+BUILTIN_OBJS =
+LIB_H =
+LIB_OBJS =
+PYRF_OBJS =
+SCRIPT_SH =
+
+SCRIPT_SH += perf-archive.sh
+
+grep-libs = $(filter -l%,$(1))
+strip-libs = $(filter-out -l%,$(1))
+
+ifneq ($(OUTPUT),)
+ TE_PATH=$(OUTPUT)
+ifneq ($(subdir),)
+ LK_PATH=$(OUTPUT)/../lib/lk/
+else
+ LK_PATH=$(OUTPUT)
+endif
else
- override DEBUG = 0
+ TE_PATH=$(TRACE_EVENT_DIR)
+ LK_PATH=$(LK_DIR)
endif
-define print_msg
- @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
-endef
+LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
+export LIBTRACEEVENT
-define make
- @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@
-endef
+LIBLK = $(LK_PATH)liblk.a
+export LIBLK
-#
-# Needed if no target specified:
-#
-all:
- $(print_msg)
- $(make)
+# python extension build directories
+PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
+PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
+PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
+export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
+
+python-clean := rm -rf $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so
+
+PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
+PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBLK)
+$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
+ $(QUIET_GEN)CFLAGS='$(CFLAGS)' $(PYTHON_WORD) util/setup.py \
+ --quiet build_ext; \
+ mkdir -p $(OUTPUT)python && \
+ cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/
#
-# The clean target is not really parallel, don't print the jobs info:
+# No Perl scripts right now:
#
-clean:
- $(make)
+
+SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
#
-# All other targets get passed through:
+# Single 'perf' binary right now:
#
-%:
- $(print_msg)
- $(make)
+PROGRAMS += $(OUTPUT)perf
+
+# what 'all' will build and 'install' will install, in perfexecdir
+ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
+
+# what 'all' will build but not install in perfexecdir
+OTHER_PROGRAMS = $(OUTPUT)perf
+
+# Set paths to tools early so that they can be used for version tests.
+ifndef SHELL_PATH
+ SHELL_PATH = /bin/sh
+endif
+ifndef PERL_PATH
+ PERL_PATH = /usr/bin/perl
+endif
+
+export PERL_PATH
+
+$(OUTPUT)util/parse-events-flex.c: util/parse-events.l $(OUTPUT)util/parse-events-bison.c
+ $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c
+
+$(OUTPUT)util/parse-events-bison.c: util/parse-events.y
+ $(QUIET_BISON)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/parse-events-bison.c -p parse_events_
+
+$(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c
+ $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/pmu-flex.h -t util/pmu.l > $(OUTPUT)util/pmu-flex.c
+
+$(OUTPUT)util/pmu-bison.c: util/pmu.y
+ $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c -p perf_pmu_
+
+$(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c
+$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
+
+LIB_FILE=$(OUTPUT)libperf.a
+
+LIB_H += ../../include/uapi/linux/perf_event.h
+LIB_H += ../../include/linux/rbtree.h
+LIB_H += ../../include/linux/list.h
+LIB_H += ../../include/uapi/linux/const.h
+LIB_H += ../../include/linux/hash.h
+LIB_H += ../../include/linux/stringify.h
+LIB_H += util/include/linux/bitmap.h
+LIB_H += util/include/linux/bitops.h
+LIB_H += util/include/linux/compiler.h
+LIB_H += util/include/linux/const.h
+LIB_H += util/include/linux/ctype.h
+LIB_H += util/include/linux/kernel.h
+LIB_H += util/include/linux/list.h
+LIB_H += util/include/linux/export.h
+LIB_H += util/include/linux/magic.h
+LIB_H += util/include/linux/poison.h
+LIB_H += util/include/linux/prefetch.h
+LIB_H += util/include/linux/rbtree.h
+LIB_H += util/include/linux/rbtree_augmented.h
+LIB_H += util/include/linux/string.h
+LIB_H += util/include/linux/types.h
+LIB_H += util/include/linux/linkage.h
+LIB_H += util/include/asm/asm-offsets.h
+LIB_H += util/include/asm/bug.h
+LIB_H += util/include/asm/byteorder.h
+LIB_H += util/include/asm/hweight.h
+LIB_H += util/include/asm/swab.h
+LIB_H += util/include/asm/system.h
+LIB_H += util/include/asm/uaccess.h
+LIB_H += util/include/dwarf-regs.h
+LIB_H += util/include/asm/dwarf2.h
+LIB_H += util/include/asm/cpufeature.h
+LIB_H += util/include/asm/unistd_32.h
+LIB_H += util/include/asm/unistd_64.h
+LIB_H += perf.h
+LIB_H += util/annotate.h
+LIB_H += util/cache.h
+LIB_H += util/callchain.h
+LIB_H += util/build-id.h
+LIB_H += util/debug.h
+LIB_H += util/sysfs.h
+LIB_H += util/pmu.h
+LIB_H += util/event.h
+LIB_H += util/evsel.h
+LIB_H += util/evlist.h
+LIB_H += util/exec_cmd.h
+LIB_H += util/types.h
+LIB_H += util/levenshtein.h
+LIB_H += util/machine.h
+LIB_H += util/map.h
+LIB_H += util/parse-options.h
+LIB_H += util/parse-events.h
+LIB_H += util/quote.h
+LIB_H += util/util.h
+LIB_H += util/xyarray.h
+LIB_H += util/header.h
+LIB_H += util/help.h
+LIB_H += util/session.h
+LIB_H += util/strbuf.h
+LIB_H += util/strlist.h
+LIB_H += util/strfilter.h
+LIB_H += util/svghelper.h
+LIB_H += util/tool.h
+LIB_H += util/run-command.h
+LIB_H += util/sigchain.h
+LIB_H += util/dso.h
+LIB_H += util/symbol.h
+LIB_H += util/color.h
+LIB_H += util/values.h
+LIB_H += util/sort.h
+LIB_H += util/hist.h
+LIB_H += util/thread.h
+LIB_H += util/thread_map.h
+LIB_H += util/trace-event.h
+LIB_H += util/probe-finder.h
+LIB_H += util/dwarf-aux.h
+LIB_H += util/probe-event.h
+LIB_H += util/pstack.h
+LIB_H += util/cpumap.h
+LIB_H += util/top.h
+LIB_H += $(ARCH_INCLUDE)
+LIB_H += util/cgroup.h
+LIB_H += $(LIB_INCLUDE)traceevent/event-parse.h
+LIB_H += util/target.h
+LIB_H += util/rblist.h
+LIB_H += util/intlist.h
+LIB_H += util/perf_regs.h
+LIB_H += util/unwind.h
+LIB_H += util/vdso.h
+LIB_H += ui/helpline.h
+LIB_H += ui/progress.h
+LIB_H += ui/util.h
+LIB_H += ui/ui.h
+
+LIB_OBJS += $(OUTPUT)util/abspath.o
+LIB_OBJS += $(OUTPUT)util/alias.o
+LIB_OBJS += $(OUTPUT)util/annotate.o
+LIB_OBJS += $(OUTPUT)util/build-id.o
+LIB_OBJS += $(OUTPUT)util/config.o
+LIB_OBJS += $(OUTPUT)util/ctype.o
+LIB_OBJS += $(OUTPUT)util/sysfs.o
+LIB_OBJS += $(OUTPUT)util/pmu.o
+LIB_OBJS += $(OUTPUT)util/environment.o
+LIB_OBJS += $(OUTPUT)util/event.o
+LIB_OBJS += $(OUTPUT)util/evlist.o
+LIB_OBJS += $(OUTPUT)util/evsel.o
+LIB_OBJS += $(OUTPUT)util/exec_cmd.o
+LIB_OBJS += $(OUTPUT)util/help.o
+LIB_OBJS += $(OUTPUT)util/levenshtein.o
+LIB_OBJS += $(OUTPUT)util/parse-options.o
+LIB_OBJS += $(OUTPUT)util/parse-events.o
+LIB_OBJS += $(OUTPUT)util/path.o
+LIB_OBJS += $(OUTPUT)util/rbtree.o
+LIB_OBJS += $(OUTPUT)util/bitmap.o
+LIB_OBJS += $(OUTPUT)util/hweight.o
+LIB_OBJS += $(OUTPUT)util/run-command.o
+LIB_OBJS += $(OUTPUT)util/quote.o
+LIB_OBJS += $(OUTPUT)util/strbuf.o
+LIB_OBJS += $(OUTPUT)util/string.o
+LIB_OBJS += $(OUTPUT)util/strlist.o
+LIB_OBJS += $(OUTPUT)util/strfilter.o
+LIB_OBJS += $(OUTPUT)util/top.o
+LIB_OBJS += $(OUTPUT)util/usage.o
+LIB_OBJS += $(OUTPUT)util/wrapper.o
+LIB_OBJS += $(OUTPUT)util/sigchain.o
+LIB_OBJS += $(OUTPUT)util/dso.o
+LIB_OBJS += $(OUTPUT)util/symbol.o
+LIB_OBJS += $(OUTPUT)util/symbol-elf.o
+LIB_OBJS += $(OUTPUT)util/color.o
+LIB_OBJS += $(OUTPUT)util/pager.o
+LIB_OBJS += $(OUTPUT)util/header.o
+LIB_OBJS += $(OUTPUT)util/callchain.o
+LIB_OBJS += $(OUTPUT)util/values.o
+LIB_OBJS += $(OUTPUT)util/debug.o
+LIB_OBJS += $(OUTPUT)util/machine.o
+LIB_OBJS += $(OUTPUT)util/map.o
+LIB_OBJS += $(OUTPUT)util/pstack.o
+LIB_OBJS += $(OUTPUT)util/session.o
+LIB_OBJS += $(OUTPUT)util/thread.o
+LIB_OBJS += $(OUTPUT)util/thread_map.o
+LIB_OBJS += $(OUTPUT)util/trace-event-parse.o
+LIB_OBJS += $(OUTPUT)util/parse-events-flex.o
+LIB_OBJS += $(OUTPUT)util/parse-events-bison.o
+LIB_OBJS += $(OUTPUT)util/pmu-flex.o
+LIB_OBJS += $(OUTPUT)util/pmu-bison.o
+LIB_OBJS += $(OUTPUT)util/trace-event-read.o
+LIB_OBJS += $(OUTPUT)util/trace-event-info.o
+LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
+LIB_OBJS += $(OUTPUT)util/svghelper.o
+LIB_OBJS += $(OUTPUT)util/sort.o
+LIB_OBJS += $(OUTPUT)util/hist.o
+LIB_OBJS += $(OUTPUT)util/probe-event.o
+LIB_OBJS += $(OUTPUT)util/util.o
+LIB_OBJS += $(OUTPUT)util/xyarray.o
+LIB_OBJS += $(OUTPUT)util/cpumap.o
+LIB_OBJS += $(OUTPUT)util/cgroup.o
+LIB_OBJS += $(OUTPUT)util/target.o
+LIB_OBJS += $(OUTPUT)util/rblist.o
+LIB_OBJS += $(OUTPUT)util/intlist.o
+LIB_OBJS += $(OUTPUT)util/vdso.o
+LIB_OBJS += $(OUTPUT)util/stat.o
+LIB_OBJS += $(OUTPUT)util/record.o
+
+LIB_OBJS += $(OUTPUT)ui/setup.o
+LIB_OBJS += $(OUTPUT)ui/helpline.o
+LIB_OBJS += $(OUTPUT)ui/progress.o
+LIB_OBJS += $(OUTPUT)ui/util.o
+LIB_OBJS += $(OUTPUT)ui/hist.o
+LIB_OBJS += $(OUTPUT)ui/stdio/hist.o
+
+LIB_OBJS += $(OUTPUT)arch/common.o
+
+LIB_OBJS += $(OUTPUT)tests/parse-events.o
+LIB_OBJS += $(OUTPUT)tests/dso-data.o
+LIB_OBJS += $(OUTPUT)tests/attr.o
+LIB_OBJS += $(OUTPUT)tests/vmlinux-kallsyms.o
+LIB_OBJS += $(OUTPUT)tests/open-syscall.o
+LIB_OBJS += $(OUTPUT)tests/open-syscall-all-cpus.o
+LIB_OBJS += $(OUTPUT)tests/open-syscall-tp-fields.o
+LIB_OBJS += $(OUTPUT)tests/mmap-basic.o
+LIB_OBJS += $(OUTPUT)tests/perf-record.o
+LIB_OBJS += $(OUTPUT)tests/rdpmc.o
+LIB_OBJS += $(OUTPUT)tests/evsel-roundtrip-name.o
+LIB_OBJS += $(OUTPUT)tests/evsel-tp-sched.o
+LIB_OBJS += $(OUTPUT)tests/pmu.o
+LIB_OBJS += $(OUTPUT)tests/hists_link.o
+LIB_OBJS += $(OUTPUT)tests/python-use.o
+LIB_OBJS += $(OUTPUT)tests/bp_signal.o
+LIB_OBJS += $(OUTPUT)tests/bp_signal_overflow.o
+LIB_OBJS += $(OUTPUT)tests/task-exit.o
+LIB_OBJS += $(OUTPUT)tests/sw-clock.o
+ifeq ($(ARCH),x86)
+LIB_OBJS += $(OUTPUT)tests/perf-time-to-tsc.o
+endif
+LIB_OBJS += $(OUTPUT)tests/code-reading.o
+LIB_OBJS += $(OUTPUT)tests/sample-parsing.o
+LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o
+
+BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
+BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
+# Benchmark modules
+BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
+BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
+ifeq ($(RAW_ARCH),x86_64)
+BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
+BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
+endif
+BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
+BUILTIN_OBJS += $(OUTPUT)bench/mem-memset.o
+
+BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
+BUILTIN_OBJS += $(OUTPUT)builtin-evlist.o
+BUILTIN_OBJS += $(OUTPUT)builtin-help.o
+BUILTIN_OBJS += $(OUTPUT)builtin-sched.o
+BUILTIN_OBJS += $(OUTPUT)builtin-buildid-list.o
+BUILTIN_OBJS += $(OUTPUT)builtin-buildid-cache.o
+BUILTIN_OBJS += $(OUTPUT)builtin-list.o
+BUILTIN_OBJS += $(OUTPUT)builtin-record.o
+BUILTIN_OBJS += $(OUTPUT)builtin-report.o
+BUILTIN_OBJS += $(OUTPUT)builtin-stat.o
+BUILTIN_OBJS += $(OUTPUT)builtin-timechart.o
+BUILTIN_OBJS += $(OUTPUT)builtin-top.o
+BUILTIN_OBJS += $(OUTPUT)builtin-script.o
+BUILTIN_OBJS += $(OUTPUT)builtin-probe.o
+BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o
+BUILTIN_OBJS += $(OUTPUT)builtin-lock.o
+BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o
+BUILTIN_OBJS += $(OUTPUT)builtin-inject.o
+BUILTIN_OBJS += $(OUTPUT)tests/builtin-test.o
+BUILTIN_OBJS += $(OUTPUT)builtin-mem.o
+
+PERFLIBS = $(LIB_FILE) $(LIBLK) $(LIBTRACEEVENT)
+
+# We choose to avoid "if .. else if .. else .. endif endif"
+# because maintaining the nesting to match is a pain. If
+# we had "elif" things would have been much nicer...
+
+-include arch/$(ARCH)/Makefile
+
+ifneq ($(OUTPUT),)
+ CFLAGS += -I$(OUTPUT)
+endif
+
+ifdef NO_LIBELF
+EXTLIBS := $(filter-out -lelf,$(EXTLIBS))
+
+# Remove ELF/DWARF dependent codes
+LIB_OBJS := $(filter-out $(OUTPUT)util/symbol-elf.o,$(LIB_OBJS))
+LIB_OBJS := $(filter-out $(OUTPUT)util/dwarf-aux.o,$(LIB_OBJS))
+LIB_OBJS := $(filter-out $(OUTPUT)util/probe-event.o,$(LIB_OBJS))
+LIB_OBJS := $(filter-out $(OUTPUT)util/probe-finder.o,$(LIB_OBJS))
+
+BUILTIN_OBJS := $(filter-out $(OUTPUT)builtin-probe.o,$(BUILTIN_OBJS))
+
+# Use minimal symbol handling
+LIB_OBJS += $(OUTPUT)util/symbol-minimal.o
+
+else # NO_LIBELF
+ifndef NO_DWARF
+ LIB_OBJS += $(OUTPUT)util/probe-finder.o
+ LIB_OBJS += $(OUTPUT)util/dwarf-aux.o
+endif # NO_DWARF
+endif # NO_LIBELF
+
+ifndef NO_LIBUNWIND
+ LIB_OBJS += $(OUTPUT)util/unwind.o
+endif
+LIB_OBJS += $(OUTPUT)tests/keep-tracking.o
+
+ifndef NO_LIBAUDIT
+ BUILTIN_OBJS += $(OUTPUT)builtin-trace.o
+endif
+
+ifndef NO_SLANG
+ LIB_OBJS += $(OUTPUT)ui/browser.o
+ LIB_OBJS += $(OUTPUT)ui/browsers/annotate.o
+ LIB_OBJS += $(OUTPUT)ui/browsers/hists.o
+ LIB_OBJS += $(OUTPUT)ui/browsers/map.o
+ LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o
+ LIB_OBJS += $(OUTPUT)ui/tui/setup.o
+ LIB_OBJS += $(OUTPUT)ui/tui/util.o
+ LIB_OBJS += $(OUTPUT)ui/tui/helpline.o
+ LIB_OBJS += $(OUTPUT)ui/tui/progress.o
+ LIB_H += ui/browser.h
+ LIB_H += ui/browsers/map.h
+ LIB_H += ui/keysyms.h
+ LIB_H += ui/libslang.h
+endif
+
+ifndef NO_GTK2
+ LIB_OBJS += $(OUTPUT)ui/gtk/browser.o
+ LIB_OBJS += $(OUTPUT)ui/gtk/hists.o
+ LIB_OBJS += $(OUTPUT)ui/gtk/setup.o
+ LIB_OBJS += $(OUTPUT)ui/gtk/util.o
+ LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o
+ LIB_OBJS += $(OUTPUT)ui/gtk/progress.o
+ LIB_OBJS += $(OUTPUT)ui/gtk/annotate.o
+endif
+
+ifndef NO_LIBPERL
+ LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o
+ LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o
+endif
+
+ifndef NO_LIBPYTHON
+ LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
+ LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
+endif
+
+ifeq ($(NO_PERF_REGS),0)
+ ifeq ($(ARCH),x86)
+ LIB_H += arch/x86/include/perf_regs.h
+ endif
+endif
+
+ifndef NO_LIBNUMA
+ BUILTIN_OBJS += $(OUTPUT)bench/numa.o
+endif
+
+ifdef ASCIIDOC8
+ export ASCIIDOC8
+endif
+
+LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
+
+export INSTALL SHELL_PATH
+
+### Build rules
+
+SHELL = $(SHELL_PATH)
+
+all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
+
+please_set_SHELL_PATH_to_a_more_modern_shell:
+ @$$(:)
+
+shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
+
+strip: $(PROGRAMS) $(OUTPUT)perf
+ $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
+
+$(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -include $(OUTPUT)PERF-VERSION-FILE \
+ '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
+ $(CFLAGS) -c $(filter %.c,$^) -o $@
+
+$(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
+ $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(OUTPUT)perf.o \
+ $(BUILTIN_OBJS) $(LIBS) -o $@
+
+$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \
+ '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
+ '-DPERF_MAN_PATH="$(mandir_SQ)"' \
+ '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
+
+$(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \
+ '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
+ '-DPERF_MAN_PATH="$(mandir_SQ)"' \
+ '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
+
+$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
+
+$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
+ $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
+
+$(SCRIPTS) : % : %.sh
+ $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
+
+# These can record PERF_VERSION
+$(OUTPUT)perf.o perf.spec \
+ $(SCRIPTS) \
+ : $(OUTPUT)PERF-VERSION-FILE
+
+.SUFFIXES:
+.SUFFIXES: .o .c .S .s
+
+# These two need to be here so that when O= is not used they take precedence
+# over the general rule for .o
+
+$(OUTPUT)util/%-flex.o: $(OUTPUT)util/%-flex.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(CFLAGS) -w $<
+
+$(OUTPUT)util/%-bison.o: $(OUTPUT)util/%-bison.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(CFLAGS) -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w $<
+
+$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
+$(OUTPUT)%.i: %.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -E $(CFLAGS) $<
+$(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -S $(CFLAGS) $<
+$(OUTPUT)%.o: %.S
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
+$(OUTPUT)%.s: %.S
+ $(QUIET_CC)$(CC) -o $@ -E $(CFLAGS) $<
+
+$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \
+ '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
+ '-DPREFIX="$(prefix_SQ)"' \
+ $<
+
+$(OUTPUT)tests/attr.o: tests/attr.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \
+ '-DBINDIR="$(bindir_SQ)"' -DPYTHON='"$(PYTHON_WORD)"' \
+ $<
+
+$(OUTPUT)tests/python-use.o: tests/python-use.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \
+ -DPYTHONPATH='"$(OUTPUT)python"' \
+ -DPYTHON='"$(PYTHON_WORD)"' \
+ $<
+
+$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
+
+$(OUTPUT)ui/browser.o: ui/browser.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $<
+
+$(OUTPUT)ui/browsers/annotate.o: ui/browsers/annotate.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $<
+
+$(OUTPUT)ui/browsers/hists.o: ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $<
+
+$(OUTPUT)ui/browsers/map.o: ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $<
+
+$(OUTPUT)ui/browsers/scripts.o: ui/browsers/scripts.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $<
+
+$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-unused-parameter -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
+
+$(OUTPUT)util/parse-events.o: util/parse-events.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-redundant-decls $<
+
+$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-undef -Wno-switch-default $<
+
+$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs -Wno-undef -Wno-switch-default $<
+
+$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
+
+$(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
+ $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
+
+$(OUTPUT)perf-%: %.o $(PERFLIBS)
+ $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS)
+
+$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
+$(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
+
+# we compile into subdirectories. if the target directory is not the source directory, they might not exists. So
+# we depend the various files onto their directories.
+DIRECTORY_DEPS = $(LIB_OBJS) $(BUILTIN_OBJS) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h
+$(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS)))
+# In the second step, we make a rule to actually create these directories
+$(sort $(dir $(DIRECTORY_DEPS))):
+ $(QUIET_MKDIR)$(MKDIR) -p $@ 2>/dev/null
+
+$(LIB_FILE): $(LIB_OBJS)
+ $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
+
+# libtraceevent.a
+$(LIBTRACEEVENT):
+ $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) libtraceevent.a
+
+$(LIBTRACEEVENT)-clean:
+ $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) clean
+
+# if subdir is set, we've been called from above so target has been built
+# already
+$(LIBLK):
+ifeq ($(subdir),)
+ $(QUIET_SUBDIR0)$(LK_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) liblk.a
+endif
+
+$(LIBLK)-clean:
+ifeq ($(subdir),)
+ $(QUIET_SUBDIR0)$(LK_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) clean
+endif
+
+help:
+ @echo 'Perf make targets:'
+ @echo ' doc - make *all* documentation (see below)'
+ @echo ' man - make manpage documentation (access with man <foo>)'
+ @echo ' html - make html documentation'
+ @echo ' info - make GNU info documentation (access with info <foo>)'
+ @echo ' pdf - make pdf documentation'
+ @echo ' TAGS - use etags to make tag information for source browsing'
+ @echo ' tags - use ctags to make tag information for source browsing'
+ @echo ' cscope - use cscope to make interactive browsing database'
+ @echo ''
+ @echo 'Perf install targets:'
+ @echo ' NOTE: documentation build requires asciidoc, xmlto packages to be installed'
+ @echo ' HINT: use "make prefix=<path> <install target>" to install to a particular'
+ @echo ' path like make prefix=/usr/local install install-doc'
+ @echo ' install - install compiled binaries'
+ @echo ' install-doc - install *all* documentation'
+ @echo ' install-man - install manpage documentation'
+ @echo ' install-html - install html documentation'
+ @echo ' install-info - install GNU info documentation'
+ @echo ' install-pdf - install pdf documentation'
+ @echo ''
+ @echo ' quick-install-doc - alias for quick-install-man'
+ @echo ' quick-install-man - install the documentation quickly'
+ @echo ' quick-install-html - install the html documentation quickly'
+ @echo ''
+ @echo 'Perf maintainer targets:'
+ @echo ' clean - clean all binary objects and build output'
+
+
+DOC_TARGETS := doc man html info pdf
+
+INSTALL_DOC_TARGETS := $(patsubst %,install-%,$(DOC_TARGETS)) try-install-man
+INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html
+
+# 'make doc' should call 'make -C Documentation all'
+$(DOC_TARGETS):
+ $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:doc=all)
+
+TAGS:
+ $(RM) TAGS
+ $(FIND) . -name '*.[hcS]' -print | xargs etags -a
+
+tags:
+ $(RM) tags
+ $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
+
+cscope:
+ $(RM) cscope*
+ $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
+
+### Detect prefix changes
+TRACK_CFLAGS = $(subst ','\'',$(CFLAGS)):\
+ $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
+
+$(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS
+ @FLAGS='$(TRACK_CFLAGS)'; \
+ if test x"$$FLAGS" != x"`cat $(OUTPUT)PERF-CFLAGS 2>/dev/null`" ; then \
+ echo 1>&2 " * new build flags or prefix"; \
+ echo "$$FLAGS" >$(OUTPUT)PERF-CFLAGS; \
+ fi
+
+### Testing rules
+
+# GNU make supports exporting all variables by "export" without parameters.
+# However, the environment gets quite big, and some programs have problems
+# with that.
+
+check: $(OUTPUT)common-cmds.h
+ if sparse; \
+ then \
+ for i in *.c */*.c; \
+ do \
+ sparse $(CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
+ done; \
+ else \
+ exit 1; \
+ fi
+
+### Installation rules
+
+install-bin: all
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
+ $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
+ $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
+ifndef NO_LIBPERL
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
+ $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
+ $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'
+ $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
+endif
+ifndef NO_LIBPYTHON
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
+ $(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'
+ $(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'
+ $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
+endif
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'
+ $(INSTALL) bash_completion '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'
+ $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'
+ $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'
+
+install: install-bin try-install-man
+
+install-python_ext:
+ $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
+
+# 'make install-doc' should call 'make -C Documentation install'
+$(INSTALL_DOC_TARGETS):
+ $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:-doc=)
+
+### Cleaning rules
+
+clean: $(LIBTRACEEVENT)-clean $(LIBLK)-clean
+ $(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS)
+ $(RM) $(ALL_PROGRAMS) perf
+ $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
+ $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
+ $(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS
+ $(RM) $(OUTPUT)util/*-bison*
+ $(RM) $(OUTPUT)util/*-flex*
+ $(python-clean)
+
+.PHONY: all install clean strip $(LIBTRACEEVENT) $(LIBLK)
+.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
+.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
deleted file mode 100644
index 7fc8f17..0000000
--- a/tools/perf/Makefile.perf
+++ /dev/null
@@ -1,892 +0,0 @@
-include ../scripts/Makefile.include
-
-# The default target of this Makefile is...
-all:
-
-include config/utilities.mak
-
-# Define V to have a more verbose compile.
-#
-# Define O to save output files in a separate directory.
-#
-# Define ARCH as name of target architecture if you want cross-builds.
-#
-# Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.
-#
-# Define NO_LIBPERL to disable perl script extension.
-#
-# Define NO_LIBPYTHON to disable python script extension.
-#
-# Define PYTHON to point to the python binary if the default
-# `python' is not correct; for example: PYTHON=python2
-#
-# Define PYTHON_CONFIG to point to the python-config binary if
-# the default `$(PYTHON)-config' is not correct.
-#
-# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
-#
-# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
-#
-# Define LDFLAGS=-static to build a static binary.
-#
-# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
-#
-# Define NO_DWARF if you do not want debug-info analysis feature at all.
-#
-# Define WERROR=0 to disable treating any warnings as errors.
-#
-# Define NO_NEWT if you do not want TUI support. (deprecated)
-#
-# Define NO_SLANG if you do not want TUI support.
-#
-# Define NO_GTK2 if you do not want GTK+ GUI support.
-#
-# Define NO_DEMANGLE if you do not want C++ symbol demangling.
-#
-# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)
-#
-# Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf
-# backtrace post unwind.
-#
-# Define NO_BACKTRACE if you do not want stack backtrace debug feature
-#
-# Define NO_LIBNUMA if you do not want numa perf benchmark
-#
-# Define NO_LIBAUDIT if you do not want libaudit support
-#
-# Define NO_LIBBIONIC if you do not want bionic support
-
-ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(shell pwd)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-#$(info Determined 'srctree' to be $(srctree))
-endif
-
-ifneq ($(objtree),)
-#$(info Determined 'objtree' to be $(objtree))
-endif
-
-ifneq ($(OUTPUT),)
-#$(info Determined 'OUTPUT' to be $(OUTPUT))
-endif
-
-$(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD
- @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
- @touch $(OUTPUT)PERF-VERSION-FILE
-
-CC = $(CROSS_COMPILE)gcc
-AR = $(CROSS_COMPILE)ar
-
-RM = rm -f
-LN = ln -f
-MKDIR = mkdir
-FIND = find
-INSTALL = install
-FLEX = flex
-BISON = bison
-STRIP = strip
-
-LK_DIR = $(srctree)/tools/lib/lk/
-TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/
-
-# include config/Makefile by default and rule out
-# non-config cases
-config := 1
-
-NON_CONFIG_TARGETS := clean TAGS tags cscope help
-
-ifdef MAKECMDGOALS
-ifeq ($(filter-out $(NON_CONFIG_TARGETS),$(MAKECMDGOALS)),)
- config := 0
-endif
-endif
-
-ifeq ($(config),1)
-include config/Makefile
-endif
-
-export prefix bindir sharedir sysconfdir
-
-# sparse is architecture-neutral, which means that we need to tell it
-# explicitly what architecture to check for. Fix this up for yours..
-SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
-
-# Guard against environment variables
-BUILTIN_OBJS =
-LIB_H =
-LIB_OBJS =
-GTK_OBJS =
-PYRF_OBJS =
-SCRIPT_SH =
-
-SCRIPT_SH += perf-archive.sh
-
-grep-libs = $(filter -l%,$(1))
-strip-libs = $(filter-out -l%,$(1))
-
-ifneq ($(OUTPUT),)
- TE_PATH=$(OUTPUT)
-ifneq ($(subdir),)
- LK_PATH=$(OUTPUT)/../lib/lk/
-else
- LK_PATH=$(OUTPUT)
-endif
-else
- TE_PATH=$(TRACE_EVENT_DIR)
- LK_PATH=$(LK_DIR)
-endif
-
-LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
-export LIBTRACEEVENT
-
-LIBLK = $(LK_PATH)liblk.a
-export LIBLK
-
-# python extension build directories
-PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/
-PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
-PYTHON_EXTBUILD_TMP := $(PYTHON_EXTBUILD)tmp/
-export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
-
-python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf.so
-
-PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
-PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBLK)
-
-$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
- $(QUIET_GEN)CFLAGS='$(CFLAGS)' $(PYTHON_WORD) util/setup.py \
- --quiet build_ext; \
- mkdir -p $(OUTPUT)python && \
- cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/
-#
-# No Perl scripts right now:
-#
-
-SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
-
-#
-# Single 'perf' binary right now:
-#
-PROGRAMS += $(OUTPUT)perf
-
-# what 'all' will build and 'install' will install, in perfexecdir
-ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
-
-# what 'all' will build but not install in perfexecdir
-OTHER_PROGRAMS = $(OUTPUT)perf
-
-# Set paths to tools early so that they can be used for version tests.
-ifndef SHELL_PATH
- SHELL_PATH = /bin/sh
-endif
-ifndef PERL_PATH
- PERL_PATH = /usr/bin/perl
-endif
-
-export PERL_PATH
-
-$(OUTPUT)util/parse-events-flex.c: util/parse-events.l $(OUTPUT)util/parse-events-bison.c
- $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c
-
-$(OUTPUT)util/parse-events-bison.c: util/parse-events.y
- $(QUIET_BISON)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/parse-events-bison.c -p parse_events_
-
-$(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c
- $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/pmu-flex.h -t util/pmu.l > $(OUTPUT)util/pmu-flex.c
-
-$(OUTPUT)util/pmu-bison.c: util/pmu.y
- $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c -p perf_pmu_
-
-$(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c
-$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
-
-LIB_FILE=$(OUTPUT)libperf.a
-
-LIB_H += ../../include/uapi/linux/perf_event.h
-LIB_H += ../../include/linux/rbtree.h
-LIB_H += ../../include/linux/list.h
-LIB_H += ../../include/uapi/linux/const.h
-LIB_H += ../../include/linux/hash.h
-LIB_H += ../../include/linux/stringify.h
-LIB_H += util/include/linux/bitmap.h
-LIB_H += util/include/linux/bitops.h
-LIB_H += util/include/linux/compiler.h
-LIB_H += util/include/linux/const.h
-LIB_H += util/include/linux/ctype.h
-LIB_H += util/include/linux/kernel.h
-LIB_H += util/include/linux/list.h
-LIB_H += util/include/linux/export.h
-LIB_H += util/include/linux/magic.h
-LIB_H += util/include/linux/poison.h
-LIB_H += util/include/linux/prefetch.h
-LIB_H += util/include/linux/rbtree.h
-LIB_H += util/include/linux/rbtree_augmented.h
-LIB_H += util/include/linux/string.h
-LIB_H += util/include/linux/types.h
-LIB_H += util/include/linux/linkage.h
-LIB_H += util/include/asm/asm-offsets.h
-LIB_H += util/include/asm/bug.h
-LIB_H += util/include/asm/byteorder.h
-LIB_H += util/include/asm/hweight.h
-LIB_H += util/include/asm/swab.h
-LIB_H += util/include/asm/system.h
-LIB_H += util/include/asm/uaccess.h
-LIB_H += util/include/dwarf-regs.h
-LIB_H += util/include/asm/dwarf2.h
-LIB_H += util/include/asm/cpufeature.h
-LIB_H += util/include/asm/unistd_32.h
-LIB_H += util/include/asm/unistd_64.h
-LIB_H += perf.h
-LIB_H += util/annotate.h
-LIB_H += util/cache.h
-LIB_H += util/callchain.h
-LIB_H += util/build-id.h
-LIB_H += util/debug.h
-LIB_H += util/fs.h
-LIB_H += util/pmu.h
-LIB_H += util/event.h
-LIB_H += util/evsel.h
-LIB_H += util/evlist.h
-LIB_H += util/exec_cmd.h
-LIB_H += util/types.h
-LIB_H += util/levenshtein.h
-LIB_H += util/machine.h
-LIB_H += util/map.h
-LIB_H += util/parse-options.h
-LIB_H += util/parse-events.h
-LIB_H += util/quote.h
-LIB_H += util/util.h
-LIB_H += util/xyarray.h
-LIB_H += util/header.h
-LIB_H += util/help.h
-LIB_H += util/session.h
-LIB_H += util/strbuf.h
-LIB_H += util/strlist.h
-LIB_H += util/strfilter.h
-LIB_H += util/svghelper.h
-LIB_H += util/tool.h
-LIB_H += util/run-command.h
-LIB_H += util/sigchain.h
-LIB_H += util/dso.h
-LIB_H += util/symbol.h
-LIB_H += util/color.h
-LIB_H += util/values.h
-LIB_H += util/sort.h
-LIB_H += util/hist.h
-LIB_H += util/comm.h
-LIB_H += util/thread.h
-LIB_H += util/thread_map.h
-LIB_H += util/trace-event.h
-LIB_H += util/probe-finder.h
-LIB_H += util/dwarf-aux.h
-LIB_H += util/probe-event.h
-LIB_H += util/pstack.h
-LIB_H += util/cpumap.h
-LIB_H += util/top.h
-LIB_H += $(ARCH_INCLUDE)
-LIB_H += util/cgroup.h
-LIB_H += $(LIB_INCLUDE)traceevent/event-parse.h
-LIB_H += util/target.h
-LIB_H += util/rblist.h
-LIB_H += util/intlist.h
-LIB_H += util/perf_regs.h
-LIB_H += util/unwind.h
-LIB_H += util/vdso.h
-LIB_H += ui/helpline.h
-LIB_H += ui/progress.h
-LIB_H += ui/util.h
-LIB_H += ui/ui.h
-LIB_H += util/data.h
-
-LIB_OBJS += $(OUTPUT)util/abspath.o
-LIB_OBJS += $(OUTPUT)util/alias.o
-LIB_OBJS += $(OUTPUT)util/annotate.o
-LIB_OBJS += $(OUTPUT)util/build-id.o
-LIB_OBJS += $(OUTPUT)util/config.o
-LIB_OBJS += $(OUTPUT)util/ctype.o
-LIB_OBJS += $(OUTPUT)util/fs.o
-LIB_OBJS += $(OUTPUT)util/pmu.o
-LIB_OBJS += $(OUTPUT)util/environment.o
-LIB_OBJS += $(OUTPUT)util/event.o
-LIB_OBJS += $(OUTPUT)util/evlist.o
-LIB_OBJS += $(OUTPUT)util/evsel.o
-LIB_OBJS += $(OUTPUT)util/exec_cmd.o
-LIB_OBJS += $(OUTPUT)util/help.o
-LIB_OBJS += $(OUTPUT)util/levenshtein.o
-LIB_OBJS += $(OUTPUT)util/parse-options.o
-LIB_OBJS += $(OUTPUT)util/parse-events.o
-LIB_OBJS += $(OUTPUT)util/path.o
-LIB_OBJS += $(OUTPUT)util/rbtree.o
-LIB_OBJS += $(OUTPUT)util/bitmap.o
-LIB_OBJS += $(OUTPUT)util/hweight.o
-LIB_OBJS += $(OUTPUT)util/run-command.o
-LIB_OBJS += $(OUTPUT)util/quote.o
-LIB_OBJS += $(OUTPUT)util/strbuf.o
-LIB_OBJS += $(OUTPUT)util/string.o
-LIB_OBJS += $(OUTPUT)util/strlist.o
-LIB_OBJS += $(OUTPUT)util/strfilter.o
-LIB_OBJS += $(OUTPUT)util/top.o
-LIB_OBJS += $(OUTPUT)util/usage.o
-LIB_OBJS += $(OUTPUT)util/wrapper.o
-LIB_OBJS += $(OUTPUT)util/sigchain.o
-LIB_OBJS += $(OUTPUT)util/dso.o
-LIB_OBJS += $(OUTPUT)util/symbol.o
-LIB_OBJS += $(OUTPUT)util/symbol-elf.o
-LIB_OBJS += $(OUTPUT)util/color.o
-LIB_OBJS += $(OUTPUT)util/pager.o
-LIB_OBJS += $(OUTPUT)util/header.o
-LIB_OBJS += $(OUTPUT)util/callchain.o
-LIB_OBJS += $(OUTPUT)util/values.o
-LIB_OBJS += $(OUTPUT)util/debug.o
-LIB_OBJS += $(OUTPUT)util/machine.o
-LIB_OBJS += $(OUTPUT)util/map.o
-LIB_OBJS += $(OUTPUT)util/pstack.o
-LIB_OBJS += $(OUTPUT)util/session.o
-LIB_OBJS += $(OUTPUT)util/comm.o
-LIB_OBJS += $(OUTPUT)util/thread.o
-LIB_OBJS += $(OUTPUT)util/thread_map.o
-LIB_OBJS += $(OUTPUT)util/trace-event-parse.o
-LIB_OBJS += $(OUTPUT)util/parse-events-flex.o
-LIB_OBJS += $(OUTPUT)util/parse-events-bison.o
-LIB_OBJS += $(OUTPUT)util/pmu-flex.o
-LIB_OBJS += $(OUTPUT)util/pmu-bison.o
-LIB_OBJS += $(OUTPUT)util/trace-event-read.o
-LIB_OBJS += $(OUTPUT)util/trace-event-info.o
-LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o
-LIB_OBJS += $(OUTPUT)util/svghelper.o
-LIB_OBJS += $(OUTPUT)util/sort.o
-LIB_OBJS += $(OUTPUT)util/hist.o
-LIB_OBJS += $(OUTPUT)util/probe-event.o
-LIB_OBJS += $(OUTPUT)util/util.o
-LIB_OBJS += $(OUTPUT)util/xyarray.o
-LIB_OBJS += $(OUTPUT)util/cpumap.o
-LIB_OBJS += $(OUTPUT)util/cgroup.o
-LIB_OBJS += $(OUTPUT)util/target.o
-LIB_OBJS += $(OUTPUT)util/rblist.o
-LIB_OBJS += $(OUTPUT)util/intlist.o
-LIB_OBJS += $(OUTPUT)util/vdso.o
-LIB_OBJS += $(OUTPUT)util/stat.o
-LIB_OBJS += $(OUTPUT)util/record.o
-LIB_OBJS += $(OUTPUT)util/srcline.o
-LIB_OBJS += $(OUTPUT)util/data.o
-
-LIB_OBJS += $(OUTPUT)ui/setup.o
-LIB_OBJS += $(OUTPUT)ui/helpline.o
-LIB_OBJS += $(OUTPUT)ui/progress.o
-LIB_OBJS += $(OUTPUT)ui/util.o
-LIB_OBJS += $(OUTPUT)ui/hist.o
-LIB_OBJS += $(OUTPUT)ui/stdio/hist.o
-
-LIB_OBJS += $(OUTPUT)arch/common.o
-
-LIB_OBJS += $(OUTPUT)tests/parse-events.o
-LIB_OBJS += $(OUTPUT)tests/dso-data.o
-LIB_OBJS += $(OUTPUT)tests/attr.o
-LIB_OBJS += $(OUTPUT)tests/vmlinux-kallsyms.o
-LIB_OBJS += $(OUTPUT)tests/open-syscall.o
-LIB_OBJS += $(OUTPUT)tests/open-syscall-all-cpus.o
-LIB_OBJS += $(OUTPUT)tests/open-syscall-tp-fields.o
-LIB_OBJS += $(OUTPUT)tests/mmap-basic.o
-LIB_OBJS += $(OUTPUT)tests/perf-record.o
-LIB_OBJS += $(OUTPUT)tests/rdpmc.o
-LIB_OBJS += $(OUTPUT)tests/evsel-roundtrip-name.o
-LIB_OBJS += $(OUTPUT)tests/evsel-tp-sched.o
-LIB_OBJS += $(OUTPUT)tests/pmu.o
-LIB_OBJS += $(OUTPUT)tests/hists_link.o
-LIB_OBJS += $(OUTPUT)tests/python-use.o
-LIB_OBJS += $(OUTPUT)tests/bp_signal.o
-LIB_OBJS += $(OUTPUT)tests/bp_signal_overflow.o
-LIB_OBJS += $(OUTPUT)tests/task-exit.o
-LIB_OBJS += $(OUTPUT)tests/sw-clock.o
-ifeq ($(ARCH),x86)
-LIB_OBJS += $(OUTPUT)tests/perf-time-to-tsc.o
-endif
-LIB_OBJS += $(OUTPUT)tests/code-reading.o
-LIB_OBJS += $(OUTPUT)tests/sample-parsing.o
-LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o
-
-BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
-BUILTIN_OBJS += $(OUTPUT)builtin-bench.o
-# Benchmark modules
-BUILTIN_OBJS += $(OUTPUT)bench/sched-messaging.o
-BUILTIN_OBJS += $(OUTPUT)bench/sched-pipe.o
-ifeq ($(RAW_ARCH),x86_64)
-BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy-x86-64-asm.o
-BUILTIN_OBJS += $(OUTPUT)bench/mem-memset-x86-64-asm.o
-endif
-BUILTIN_OBJS += $(OUTPUT)bench/mem-memcpy.o
-BUILTIN_OBJS += $(OUTPUT)bench/mem-memset.o
-
-BUILTIN_OBJS += $(OUTPUT)builtin-diff.o
-BUILTIN_OBJS += $(OUTPUT)builtin-evlist.o
-BUILTIN_OBJS += $(OUTPUT)builtin-help.o
-BUILTIN_OBJS += $(OUTPUT)builtin-sched.o
-BUILTIN_OBJS += $(OUTPUT)builtin-buildid-list.o
-BUILTIN_OBJS += $(OUTPUT)builtin-buildid-cache.o
-BUILTIN_OBJS += $(OUTPUT)builtin-list.o
-BUILTIN_OBJS += $(OUTPUT)builtin-record.o
-BUILTIN_OBJS += $(OUTPUT)builtin-report.o
-BUILTIN_OBJS += $(OUTPUT)builtin-stat.o
-BUILTIN_OBJS += $(OUTPUT)builtin-timechart.o
-BUILTIN_OBJS += $(OUTPUT)builtin-top.o
-BUILTIN_OBJS += $(OUTPUT)builtin-script.o
-BUILTIN_OBJS += $(OUTPUT)builtin-probe.o
-BUILTIN_OBJS += $(OUTPUT)builtin-kmem.o
-BUILTIN_OBJS += $(OUTPUT)builtin-lock.o
-BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o
-BUILTIN_OBJS += $(OUTPUT)builtin-inject.o
-BUILTIN_OBJS += $(OUTPUT)tests/builtin-test.o
-BUILTIN_OBJS += $(OUTPUT)builtin-mem.o
-
-PERFLIBS = $(LIB_FILE) $(LIBLK) $(LIBTRACEEVENT)
-
-# We choose to avoid "if .. else if .. else .. endif endif"
-# because maintaining the nesting to match is a pain. If
-# we had "elif" things would have been much nicer...
-
--include arch/$(ARCH)/Makefile
-
-ifneq ($(OUTPUT),)
- CFLAGS += -I$(OUTPUT)
-endif
-
-ifdef NO_LIBELF
-EXTLIBS := $(filter-out -lelf,$(EXTLIBS))
-
-# Remove ELF/DWARF dependent codes
-LIB_OBJS := $(filter-out $(OUTPUT)util/symbol-elf.o,$(LIB_OBJS))
-LIB_OBJS := $(filter-out $(OUTPUT)util/dwarf-aux.o,$(LIB_OBJS))
-LIB_OBJS := $(filter-out $(OUTPUT)util/probe-event.o,$(LIB_OBJS))
-LIB_OBJS := $(filter-out $(OUTPUT)util/probe-finder.o,$(LIB_OBJS))
-
-BUILTIN_OBJS := $(filter-out $(OUTPUT)builtin-probe.o,$(BUILTIN_OBJS))
-
-# Use minimal symbol handling
-LIB_OBJS += $(OUTPUT)util/symbol-minimal.o
-
-else # NO_LIBELF
-ifndef NO_DWARF
- LIB_OBJS += $(OUTPUT)util/probe-finder.o
- LIB_OBJS += $(OUTPUT)util/dwarf-aux.o
-endif # NO_DWARF
-endif # NO_LIBELF
-
-ifndef NO_LIBUNWIND
- LIB_OBJS += $(OUTPUT)util/unwind.o
-endif
-LIB_OBJS += $(OUTPUT)tests/keep-tracking.o
-
-ifndef NO_LIBAUDIT
- BUILTIN_OBJS += $(OUTPUT)builtin-trace.o
-endif
-
-ifndef NO_SLANG
- LIB_OBJS += $(OUTPUT)ui/browser.o
- LIB_OBJS += $(OUTPUT)ui/browsers/annotate.o
- LIB_OBJS += $(OUTPUT)ui/browsers/hists.o
- LIB_OBJS += $(OUTPUT)ui/browsers/map.o
- LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o
- LIB_OBJS += $(OUTPUT)ui/tui/setup.o
- LIB_OBJS += $(OUTPUT)ui/tui/util.o
- LIB_OBJS += $(OUTPUT)ui/tui/helpline.o
- LIB_OBJS += $(OUTPUT)ui/tui/progress.o
- LIB_H += ui/tui/tui.h
- LIB_H += ui/browser.h
- LIB_H += ui/browsers/map.h
- LIB_H += ui/keysyms.h
- LIB_H += ui/libslang.h
-endif
-
-ifndef NO_GTK2
- ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so
-
- GTK_OBJS += $(OUTPUT)ui/gtk/browser.o
- GTK_OBJS += $(OUTPUT)ui/gtk/hists.o
- GTK_OBJS += $(OUTPUT)ui/gtk/setup.o
- GTK_OBJS += $(OUTPUT)ui/gtk/util.o
- GTK_OBJS += $(OUTPUT)ui/gtk/helpline.o
- GTK_OBJS += $(OUTPUT)ui/gtk/progress.o
- GTK_OBJS += $(OUTPUT)ui/gtk/annotate.o
-
-install-gtk: $(OUTPUT)libperf-gtk.so
- $(call QUIET_INSTALL, 'GTK UI') \
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'; \
- $(INSTALL) $(OUTPUT)libperf-gtk.so '$(DESTDIR_SQ)$(libdir_SQ)'
-endif
-
-ifndef NO_LIBPERL
- LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o
- LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o
-endif
-
-ifndef NO_LIBPYTHON
- LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
- LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
-endif
-
-ifeq ($(NO_PERF_REGS),0)
- ifeq ($(ARCH),x86)
- LIB_H += arch/x86/include/perf_regs.h
- endif
-endif
-
-ifndef NO_LIBNUMA
- BUILTIN_OBJS += $(OUTPUT)bench/numa.o
-endif
-
-ifdef ASCIIDOC8
- export ASCIIDOC8
-endif
-
-LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group
-
-export INSTALL SHELL_PATH
-
-### Build rules
-
-SHELL = $(SHELL_PATH)
-
-all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
-
-please_set_SHELL_PATH_to_a_more_modern_shell:
- @$$(:)
-
-shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
-
-strip: $(PROGRAMS) $(OUTPUT)perf
- $(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
-
-$(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -include $(OUTPUT)PERF-VERSION-FILE \
- '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
- $(CFLAGS) -c $(filter %.c,$^) -o $@
-
-$(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
- $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(OUTPUT)perf.o \
- $(BUILTIN_OBJS) $(LIBS) -o $@
-
-$(GTK_OBJS): $(OUTPUT)%.o: %.c $(LIB_H)
- $(QUIET_CC)$(CC) -o $@ -c -fPIC $(CFLAGS) $(GTK_CFLAGS) $<
-
-$(OUTPUT)libperf-gtk.so: $(GTK_OBJS) $(PERFLIBS)
- $(QUIET_LINK)$(CC) -o $@ -shared $(ALL_LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)
-
-$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \
- '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
- '-DPERF_MAN_PATH="$(mandir_SQ)"' \
- '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
-
-$(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \
- '-DPERF_HTML_PATH="$(htmldir_SQ)"' \
- '-DPERF_MAN_PATH="$(mandir_SQ)"' \
- '-DPERF_INFO_PATH="$(infodir_SQ)"' $<
-
-$(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
-
-$(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
- $(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
-
-$(SCRIPTS) : % : %.sh
- $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
-
-# These can record PERF_VERSION
-$(OUTPUT)perf.o perf.spec \
- $(SCRIPTS) \
- : $(OUTPUT)PERF-VERSION-FILE
-
-.SUFFIXES:
-
-#
-# If a target does not match any of the later rules then prefix it by $(OUTPUT)
-# This makes targets like 'make O=/tmp/perf perf.o' work in a natural way.
-#
-ifneq ($(OUTPUT),)
-%.o: $(OUTPUT)%.o
- @echo " # Redirected target $@ => $(OUTPUT)$@"
-util/%.o: $(OUTPUT)util/%.o
- @echo " # Redirected target $@ => $(OUTPUT)$@"
-bench/%.o: $(OUTPUT)bench/%.o
- @echo " # Redirected target $@ => $(OUTPUT)$@"
-tests/%.o: $(OUTPUT)tests/%.o
- @echo " # Redirected target $@ => $(OUTPUT)$@"
-endif
-
-# These two need to be here so that when O= is not used they take precedence
-# over the general rule for .o
-
-$(OUTPUT)util/%-flex.o: $(OUTPUT)util/%-flex.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(CFLAGS) -w $<
-
-$(OUTPUT)util/%-bison.o: $(OUTPUT)util/%-bison.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(CFLAGS) -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w $<
-
-$(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
-$(OUTPUT)%.i: %.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -E $(CFLAGS) $<
-$(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -S $(CFLAGS) $<
-$(OUTPUT)%.o: %.S
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
-$(OUTPUT)%.s: %.S
- $(QUIET_CC)$(CC) -o $@ -E $(CFLAGS) $<
-
-$(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \
- '-DPERF_EXEC_PATH="$(perfexecdir_SQ)"' \
- '-DPREFIX="$(prefix_SQ)"' \
- $<
-
-$(OUTPUT)tests/attr.o: tests/attr.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \
- '-DBINDIR="$(bindir_SQ)"' -DPYTHON='"$(PYTHON_WORD)"' \
- $<
-
-$(OUTPUT)tests/python-use.o: tests/python-use.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \
- -DPYTHONPATH='"$(OUTPUT)python"' \
- -DPYTHON='"$(PYTHON_WORD)"' \
- $<
-
-$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
-
-$(OUTPUT)ui/setup.o: ui/setup.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DLIBDIR='"$(libdir_SQ)"' $<
-
-$(OUTPUT)ui/browser.o: ui/browser.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $<
-
-$(OUTPUT)ui/browsers/annotate.o: ui/browsers/annotate.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $<
-
-$(OUTPUT)ui/browsers/hists.o: ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $<
-
-$(OUTPUT)ui/browsers/map.o: ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $<
-
-$(OUTPUT)ui/browsers/scripts.o: ui/browsers/scripts.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $<
-
-$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-unused-parameter -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<
-
-$(OUTPUT)util/parse-events.o: util/parse-events.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -Wno-redundant-decls $<
-
-$(OUTPUT)util/scripting-engines/trace-event-perl.o: util/scripting-engines/trace-event-perl.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-undef -Wno-switch-default $<
-
-$(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o: scripts/perl/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs -Wno-undef -Wno-switch-default $<
-
-$(OUTPUT)util/scripting-engines/trace-event-python.o: util/scripting-engines/trace-event-python.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow $<
-
-$(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Util/Context.c $(OUTPUT)PERF-CFLAGS
- $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $<
-
-$(OUTPUT)perf-%: %.o $(PERFLIBS)
- $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS)
-
-$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
-$(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
-
-# we compile into subdirectories. if the target directory is not the source directory, they might not exists. So
-# we depend the various files onto their directories.
-DIRECTORY_DEPS = $(LIB_OBJS) $(BUILTIN_OBJS) $(GTK_OBJS)
-DIRECTORY_DEPS += $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h
-$(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS)))
-# In the second step, we make a rule to actually create these directories
-$(sort $(dir $(DIRECTORY_DEPS))):
- $(QUIET_MKDIR)$(MKDIR) -p $@ 2>/dev/null
-
-$(LIB_FILE): $(LIB_OBJS)
- $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
-
-# libtraceevent.a
-TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch])
-
-$(LIBTRACEEVENT): $(TE_SOURCES)
- $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS)" libtraceevent.a
-
-$(LIBTRACEEVENT)-clean:
- $(call QUIET_CLEAN, libtraceevent)
- @$(MAKE) -C $(TRACE_EVENT_DIR) O=$(OUTPUT) clean >/dev/null
-
-LIBLK_SOURCES = $(wildcard $(LK_PATH)*.[ch])
-
-# if subdir is set, we've been called from above so target has been built
-# already
-$(LIBLK): $(LIBLK_SOURCES)
-ifeq ($(subdir),)
- $(QUIET_SUBDIR0)$(LK_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) liblk.a
-endif
-
-$(LIBLK)-clean:
-ifeq ($(subdir),)
- $(call QUIET_CLEAN, liblk)
- @$(MAKE) -C $(LK_DIR) O=$(OUTPUT) clean >/dev/null
-endif
-
-help:
- @echo 'Perf make targets:'
- @echo ' doc - make *all* documentation (see below)'
- @echo ' man - make manpage documentation (access with man <foo>)'
- @echo ' html - make html documentation'
- @echo ' info - make GNU info documentation (access with info <foo>)'
- @echo ' pdf - make pdf documentation'
- @echo ' TAGS - use etags to make tag information for source browsing'
- @echo ' tags - use ctags to make tag information for source browsing'
- @echo ' cscope - use cscope to make interactive browsing database'
- @echo ''
- @echo 'Perf install targets:'
- @echo ' NOTE: documentation build requires asciidoc, xmlto packages to be installed'
- @echo ' HINT: use "make prefix=<path> <install target>" to install to a particular'
- @echo ' path like make prefix=/usr/local install install-doc'
- @echo ' install - install compiled binaries'
- @echo ' install-doc - install *all* documentation'
- @echo ' install-man - install manpage documentation'
- @echo ' install-html - install html documentation'
- @echo ' install-info - install GNU info documentation'
- @echo ' install-pdf - install pdf documentation'
- @echo ''
- @echo ' quick-install-doc - alias for quick-install-man'
- @echo ' quick-install-man - install the documentation quickly'
- @echo ' quick-install-html - install the html documentation quickly'
- @echo ''
- @echo 'Perf maintainer targets:'
- @echo ' clean - clean all binary objects and build output'
-
-
-DOC_TARGETS := doc man html info pdf
-
-INSTALL_DOC_TARGETS := $(patsubst %,install-%,$(DOC_TARGETS)) try-install-man
-INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html
-
-# 'make doc' should call 'make -C Documentation all'
-$(DOC_TARGETS):
- $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:doc=all)
-
-TAGS:
- $(RM) TAGS
- $(FIND) . -name '*.[hcS]' -print | xargs etags -a
-
-tags:
- $(RM) tags
- $(FIND) . -name '*.[hcS]' -print | xargs ctags -a
-
-cscope:
- $(RM) cscope*
- $(FIND) . -name '*.[hcS]' -print | xargs cscope -b
-
-### Detect prefix changes
-TRACK_CFLAGS = $(subst ','\'',$(CFLAGS)):\
- $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
-
-$(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS
- @FLAGS='$(TRACK_CFLAGS)'; \
- if test x"$$FLAGS" != x"`cat $(OUTPUT)PERF-CFLAGS 2>/dev/null`" ; then \
- echo 1>&2 " FLAGS: * new build flags or prefix"; \
- echo "$$FLAGS" >$(OUTPUT)PERF-CFLAGS; \
- fi
-
-### Testing rules
-
-# GNU make supports exporting all variables by "export" without parameters.
-# However, the environment gets quite big, and some programs have problems
-# with that.
-
-check: $(OUTPUT)common-cmds.h
- if sparse; \
- then \
- for i in *.c */*.c; \
- do \
- sparse $(CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
- done; \
- else \
- exit 1; \
- fi
-
-### Installation rules
-
-install-gtk:
-
-install-bin: all install-gtk
- $(call QUIET_INSTALL, binaries) \
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'; \
- $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'; \
- $(LN) '$(DESTDIR_SQ)$(bindir_SQ)/perf' '$(DESTDIR_SQ)$(bindir_SQ)/trace'
- $(call QUIET_INSTALL, libexec) \
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
- $(call QUIET_INSTALL, perf-archive) \
- $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
-ifndef NO_LIBPERL
- $(call QUIET_INSTALL, perl-scripts) \
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
- $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
- $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
- $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
-endif
-ifndef NO_LIBPYTHON
- $(call QUIET_INSTALL, python-scripts) \
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'; \
- $(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
- $(INSTALL) scripts/python/*.py -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
- $(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
-endif
- $(call QUIET_INSTALL, bash_completion-script) \
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d'; \
- $(INSTALL) bash_completion '$(DESTDIR_SQ)$(sysconfdir_SQ)/bash_completion.d/perf'
- $(call QUIET_INSTALL, tests) \
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
- $(INSTALL) tests/attr.py '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \
- $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'
-
-install: install-bin try-install-man
-
-install-python_ext:
- $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
-
-# 'make install-doc' should call 'make -C Documentation install'
-$(INSTALL_DOC_TARGETS):
- $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:-doc=)
-
-### Cleaning rules
-
-#
-# This is here, not in config/Makefile, because config/Makefile does
-# not get included for the clean target:
-#
-config-clean:
- $(call QUIET_CLEAN, config)
- @$(MAKE) -C config/feature-checks clean >/dev/null
-
-clean: $(LIBTRACEEVENT)-clean $(LIBLK)-clean config-clean
- $(call QUIET_CLEAN, core-objs) $(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS) $(GTK_OBJS)
- $(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf
- $(call QUIET_CLEAN, core-gen) $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex*
- $(call QUIET_CLEAN, Documentation)
- @$(MAKE) -C Documentation O=$(OUTPUT) clean >/dev/null
- $(python-clean)
-
-#
-# Trick: if ../../.git does not exist - we are building out of tree for example,
-# then force version regeneration:
-#
-ifeq ($(wildcard ../../.git/HEAD),)
- GIT-HEAD-PHONY = ../../.git/HEAD
-else
- GIT-HEAD-PHONY =
-endif
-
-.PHONY: all install clean config-clean strip install-gtk
-.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
-.PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope .FORCE-PERF-CFLAGS
-
diff --git a/tools/perf/arch/arm/Makefile b/tools/perf/arch/arm/Makefile
index fe9b61e..15130b5 100644
--- a/tools/perf/arch/arm/Makefile
+++ b/tools/perf/arch/arm/Makefile
@@ -2,6 +2,3 @@ ifndef NO_DWARF
PERF_HAVE_DWARF_REGS := 1
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
endif
-ifndef NO_LIBUNWIND
-LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o
-endif
diff --git a/tools/perf/arch/arm/include/perf_regs.h b/tools/perf/arch/arm/include/perf_regs.h
deleted file mode 100644
index 2a1cfde..0000000
--- a/tools/perf/arch/arm/include/perf_regs.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef ARCH_PERF_REGS_H
-#define ARCH_PERF_REGS_H
-
-#include <stdlib.h>
-#include "../../util/types.h"
-#include <asm/perf_regs.h>
-
-#define PERF_REGS_MASK ((1ULL << PERF_REG_ARM_MAX) - 1)
-#define PERF_REG_IP PERF_REG_ARM_PC
-#define PERF_REG_SP PERF_REG_ARM_SP
-
-static inline const char *perf_reg_name(int id)
-{
- switch (id) {
- case PERF_REG_ARM_R0:
- return "r0";
- case PERF_REG_ARM_R1:
- return "r1";
- case PERF_REG_ARM_R2:
- return "r2";
- case PERF_REG_ARM_R3:
- return "r3";
- case PERF_REG_ARM_R4:
- return "r4";
- case PERF_REG_ARM_R5:
- return "r5";
- case PERF_REG_ARM_R6:
- return "r6";
- case PERF_REG_ARM_R7:
- return "r7";
- case PERF_REG_ARM_R8:
- return "r8";
- case PERF_REG_ARM_R9:
- return "r9";
- case PERF_REG_ARM_R10:
- return "r10";
- case PERF_REG_ARM_FP:
- return "fp";
- case PERF_REG_ARM_IP:
- return "ip";
- case PERF_REG_ARM_SP:
- return "sp";
- case PERF_REG_ARM_LR:
- return "lr";
- case PERF_REG_ARM_PC:
- return "pc";
- default:
- return NULL;
- }
-
- return NULL;
-}
-
-#endif /* ARCH_PERF_REGS_H */
diff --git a/tools/perf/arch/arm/util/unwind.c b/tools/perf/arch/arm/util/unwind.c
deleted file mode 100644
index da3dc95..0000000
--- a/tools/perf/arch/arm/util/unwind.c
+++ /dev/null
@@ -1,48 +0,0 @@
-
-#include <errno.h>
-#include <libunwind.h>
-#include "perf_regs.h"
-#include "../../util/unwind.h"
-
-int unwind__arch_reg_id(int regnum)
-{
- switch (regnum) {
- case UNW_ARM_R0:
- return PERF_REG_ARM_R0;
- case UNW_ARM_R1:
- return PERF_REG_ARM_R1;
- case UNW_ARM_R2:
- return PERF_REG_ARM_R2;
- case UNW_ARM_R3:
- return PERF_REG_ARM_R3;
- case UNW_ARM_R4:
- return PERF_REG_ARM_R4;
- case UNW_ARM_R5:
- return PERF_REG_ARM_R5;
- case UNW_ARM_R6:
- return PERF_REG_ARM_R6;
- case UNW_ARM_R7:
- return PERF_REG_ARM_R7;
- case UNW_ARM_R8:
- return PERF_REG_ARM_R8;
- case UNW_ARM_R9:
- return PERF_REG_ARM_R9;
- case UNW_ARM_R10:
- return PERF_REG_ARM_R10;
- case UNW_ARM_R11:
- return PERF_REG_ARM_FP;
- case UNW_ARM_R12:
- return PERF_REG_ARM_IP;
- case UNW_ARM_R13:
- return PERF_REG_ARM_SP;
- case UNW_ARM_R14:
- return PERF_REG_ARM_LR;
- case UNW_ARM_R15:
- return PERF_REG_ARM_PC;
- default:
- pr_err("unwind: invalid reg id %d\n", regnum);
- return -EINVAL;
- }
-
- return -EINVAL;
-}
diff --git a/tools/perf/arch/x86/include/perf_regs.h b/tools/perf/arch/x86/include/perf_regs.h
index e84ca76..7fcdcdb 100644
--- a/tools/perf/arch/x86/include/perf_regs.h
+++ b/tools/perf/arch/x86/include/perf_regs.h
@@ -5,7 +5,7 @@
#include "../../util/types.h"
#include <asm/perf_regs.h>
-#ifndef HAVE_ARCH_X86_64_SUPPORT
+#ifndef ARCH_X86_64
#define PERF_REGS_MASK ((1ULL << PERF_REG_X86_32_MAX) - 1)
#else
#define REG_NOSUPPORT ((1ULL << PERF_REG_X86_DS) | \
@@ -52,7 +52,7 @@ static inline const char *perf_reg_name(int id)
return "FS";
case PERF_REG_X86_GS:
return "GS";
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#ifdef ARCH_X86_64
case PERF_REG_X86_R8:
return "R8";
case PERF_REG_X86_R9:
@@ -69,7 +69,7 @@ static inline const char *perf_reg_name(int id)
return "R14";
case PERF_REG_X86_R15:
return "R15";
-#endif /* HAVE_ARCH_X86_64_SUPPORT */
+#endif /* ARCH_X86_64 */
default:
return NULL;
}
diff --git a/tools/perf/arch/x86/util/unwind.c b/tools/perf/arch/x86/util/unwind.c
index 456a88c..78d956e 100644
--- a/tools/perf/arch/x86/util/unwind.c
+++ b/tools/perf/arch/x86/util/unwind.c
@@ -4,7 +4,7 @@
#include "perf_regs.h"
#include "../../util/unwind.h"
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#ifdef ARCH_X86_64
int unwind__arch_reg_id(int regnum)
{
int id;
@@ -108,4 +108,4 @@ int unwind__arch_reg_id(int regnum)
return id;
}
-#endif /* HAVE_ARCH_X86_64_SUPPORT */
+#endif /* ARCH_X86_64 */
diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 62e157db..56e6a12 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -1,87 +1,17 @@
# perf completion
-# Taken from git.git's completion script.
-__my_reassemble_comp_words_by_ref()
+function_exists()
{
- local exclude i j first
- # Which word separators to exclude?
- exclude="${1//[^$COMP_WORDBREAKS]}"
- cword_=$COMP_CWORD
- if [ -z "$exclude" ]; then
- words_=("${COMP_WORDS[@]}")
- return
- fi
- # List of word completion separators has shrunk;
- # re-assemble words to complete.
- for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do
- # Append each nonempty word consisting of just
- # word separator characters to the current word.
- first=t
- while
- [ $i -gt 0 ] &&
- [ -n "${COMP_WORDS[$i]}" ] &&
- # word consists of excluded word separators
- [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]
- do
- # Attach to the previous token,
- # unless the previous token is the command name.
- if [ $j -ge 2 ] && [ -n "$first" ]; then
- ((j--))
- fi
- first=
- words_[$j]=${words_[j]}${COMP_WORDS[i]}
- if [ $i = $COMP_CWORD ]; then
- cword_=$j
- fi
- if (($i < ${#COMP_WORDS[@]} - 1)); then
- ((i++))
- else
- # Done.
- return
- fi
- done
- words_[$j]=${words_[j]}${COMP_WORDS[i]}
- if [ $i = $COMP_CWORD ]; then
- cword_=$j
- fi
- done
+ declare -F $1 > /dev/null
+ return $?
}
-type _get_comp_words_by_ref &>/dev/null ||
-_get_comp_words_by_ref()
-{
- local exclude cur_ words_ cword_
- if [ "$1" = "-n" ]; then
- exclude=$2
- shift 2
- fi
- __my_reassemble_comp_words_by_ref "$exclude"
- cur_=${words_[cword_]}
- while [ $# -gt 0 ]; do
- case "$1" in
- cur)
- cur=$cur_
- ;;
- prev)
- prev=${words_[$cword_-1]}
- ;;
- words)
- words=("${words_[@]}")
- ;;
- cword)
- cword=$cword_
- ;;
- esac
- shift
- done
-}
-
-type __ltrim_colon_completions &>/dev/null ||
+function_exists __ltrim_colon_completions ||
__ltrim_colon_completions()
{
if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then
# Remove colon-word prefix from COMPREPLY items
- local colon_word=${1%"${1##*:}"}
+ local colon_word=${1%${1##*:}}
local i=${#COMPREPLY[*]}
while [[ $((--i)) -ge 0 ]]; do
COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}
@@ -89,18 +19,23 @@ __ltrim_colon_completions()
fi
}
-type perf &>/dev/null &&
+have perf &&
_perf()
{
- local cur words cword prev cmd
+ local cur prev cmd
COMPREPLY=()
- _get_comp_words_by_ref -n =: cur words cword prev
+ if function_exists _get_comp_words_by_ref; then
+ _get_comp_words_by_ref -n : cur prev
+ else
+ cur=$(_get_cword :)
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+ fi
- cmd=${words[0]}
+ cmd=${COMP_WORDS[0]}
# List perf subcommands or long options
- if [ $cword -eq 1 ]; then
+ if [ $COMP_CWORD -eq 1 ]; then
if [[ $cur == --* ]]; then
COMPREPLY=( $( compgen -W '--help --version \
--exec-path --html-path --paginate --no-pager \
@@ -110,17 +45,18 @@ _perf()
COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) )
fi
# List possible events for -e option
- elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then
+ elif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; then
evts=$($cmd list --raw-dump)
COMPREPLY=( $( compgen -W '$evts' -- "$cur" ) )
__ltrim_colon_completions $cur
# List long option names
elif [[ $cur == --* ]]; then
- subcmd=${words[1]}
+ subcmd=${COMP_WORDS[1]}
opts=$($cmd $subcmd --list-opts)
COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) )
+ # Fall down to list regular files
+ else
+ _filedir
fi
} &&
-
-complete -o bashdefault -o default -o nospace -F _perf perf 2>/dev/null \
- || complete -o default -o nospace -F _perf perf
+complete -F _perf perf
diff --git a/tools/perf/bench/mem-memcpy-arch.h b/tools/perf/bench/mem-memcpy-arch.h
index 57b4ed8..a72e36c 100644
--- a/tools/perf/bench/mem-memcpy-arch.h
+++ b/tools/perf/bench/mem-memcpy-arch.h
@@ -1,5 +1,5 @@
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#ifdef ARCH_X86_64
#define MEMCPY_FN(fn, name, desc) \
extern void *fn(void *, const void *, size_t);
diff --git a/tools/perf/bench/mem-memcpy.c b/tools/perf/bench/mem-memcpy.c
index 5ce71d3..8cdca43 100644
--- a/tools/perf/bench/mem-memcpy.c
+++ b/tools/perf/bench/mem-memcpy.c
@@ -58,7 +58,7 @@ struct routine routines[] = {
{ "default",
"Default memcpy() provided by glibc",
memcpy },
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#ifdef ARCH_X86_64
#define MEMCPY_FN(fn, name, desc) { name, desc, fn },
#include "mem-memcpy-x86-64-asm-def.h"
diff --git a/tools/perf/bench/mem-memset-arch.h b/tools/perf/bench/mem-memset-arch.h
index 633800c..a040fa7 100644
--- a/tools/perf/bench/mem-memset-arch.h
+++ b/tools/perf/bench/mem-memset-arch.h
@@ -1,5 +1,5 @@
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#ifdef ARCH_X86_64
#define MEMSET_FN(fn, name, desc) \
extern void *fn(void *, int, size_t);
diff --git a/tools/perf/bench/mem-memset.c b/tools/perf/bench/mem-memset.c
index 9af79d2..4a2f120 100644
--- a/tools/perf/bench/mem-memset.c
+++ b/tools/perf/bench/mem-memset.c
@@ -58,7 +58,7 @@ static const struct routine routines[] = {
{ "default",
"Default memset() provided by glibc",
memset },
-#ifdef HAVE_ARCH_X86_64_SUPPORT
+#ifdef ARCH_X86_64
#define MEMSET_FN(fn, name, desc) { name, desc, fn },
#include "mem-memset-x86-64-asm-def.h"
diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index d4c83c6..30d1c32 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -429,14 +429,14 @@ static int parse_cpu_list(const char *arg)
return 0;
}
-static int parse_setup_cpu_list(void)
+static void parse_setup_cpu_list(void)
{
struct thread_data *td;
char *str0, *str;
int t;
if (!g->p.cpu_list_str)
- return 0;
+ return;
dprintf("g->p.nr_tasks: %d\n", g->p.nr_tasks);
@@ -500,12 +500,8 @@ static int parse_setup_cpu_list(void)
dprintf("CPUs: %d_%d-%d#%dx%d\n", bind_cpu_0, bind_len, bind_cpu_1, step, mul);
- if (bind_cpu_0 >= g->p.nr_cpus || bind_cpu_1 >= g->p.nr_cpus) {
- printf("\nTest not applicable, system has only %d CPUs.\n", g->p.nr_cpus);
- return -1;
- }
-
- BUG_ON(bind_cpu_0 < 0 || bind_cpu_1 < 0);
+ BUG_ON(bind_cpu_0 < 0 || bind_cpu_0 >= g->p.nr_cpus);
+ BUG_ON(bind_cpu_1 < 0 || bind_cpu_1 >= g->p.nr_cpus);
BUG_ON(bind_cpu_0 > bind_cpu_1);
for (bind_cpu = bind_cpu_0; bind_cpu <= bind_cpu_1; bind_cpu += step) {
@@ -545,7 +541,6 @@ out:
printf("# NOTE: %d tasks bound, %d tasks unbound\n", t, g->p.nr_tasks - t);
free(str0);
- return 0;
}
static int parse_cpus_opt(const struct option *opt __maybe_unused,
@@ -566,14 +561,14 @@ static int parse_node_list(const char *arg)
return 0;
}
-static int parse_setup_node_list(void)
+static void parse_setup_node_list(void)
{
struct thread_data *td;
char *str0, *str;
int t;
if (!g->p.node_list_str)
- return 0;
+ return;
dprintf("g->p.nr_tasks: %d\n", g->p.nr_tasks);
@@ -624,12 +619,8 @@ static int parse_setup_node_list(void)
dprintf("NODEs: %d-%d #%d\n", bind_node_0, bind_node_1, step);
- if (bind_node_0 >= g->p.nr_nodes || bind_node_1 >= g->p.nr_nodes) {
- printf("\nTest not applicable, system has only %d nodes.\n", g->p.nr_nodes);
- return -1;
- }
-
- BUG_ON(bind_node_0 < 0 || bind_node_1 < 0);
+ BUG_ON(bind_node_0 < 0 || bind_node_0 >= g->p.nr_nodes);
+ BUG_ON(bind_node_1 < 0 || bind_node_1 >= g->p.nr_nodes);
BUG_ON(bind_node_0 > bind_node_1);
for (bind_node = bind_node_0; bind_node <= bind_node_1; bind_node += step) {
@@ -660,7 +651,6 @@ out:
printf("# NOTE: %d tasks mem-bound, %d tasks unbound\n", t, g->p.nr_tasks - t);
free(str0);
- return 0;
}
static int parse_nodes_opt(const struct option *opt __maybe_unused,
@@ -1120,7 +1110,7 @@ static void *worker_thread(void *__tdata)
/* Check whether our max runtime timed out: */
if (g->p.nr_secs) {
timersub(&stop, &start0, &diff);
- if ((u32)diff.tv_sec >= g->p.nr_secs) {
+ if (diff.tv_sec >= g->p.nr_secs) {
g->stop_work = true;
break;
}
@@ -1167,7 +1157,7 @@ static void *worker_thread(void *__tdata)
runtime_ns_max += diff.tv_usec * 1000;
if (details >= 0) {
- printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016"PRIx64"]\n",
+ printf(" #%2d / %2d: %14.2lf nsecs/op [val: %016lx]\n",
process_nr, thread_nr, runtime_ns_max / bytes_done, val);
}
fflush(stdout);
@@ -1366,8 +1356,8 @@ static int init(void)
init_thread_data();
tprintf("#\n");
- if (parse_setup_cpu_list() || parse_setup_node_list())
- return -1;
+ parse_setup_cpu_list();
+ parse_setup_node_list();
tprintf("#\n");
print_summary();
@@ -1610,6 +1600,7 @@ static int run_bench_numa(const char *name, const char **argv)
return 0;
err:
+ usage_with_options(numa_usage, options);
return -1;
}
@@ -1710,7 +1701,8 @@ static int bench_all(void)
BUG_ON(ret < 0);
for (i = 0; i < nr; i++) {
- run_bench_numa(tests[i][0], tests[i] + 1);
+ if (run_bench_numa(tests[i][0], tests[i] + 1))
+ return -1;
}
printf("\n");
diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c
index 07a8d76..69cfba8 100644
--- a/tools/perf/bench/sched-pipe.c
+++ b/tools/perf/bench/sched-pipe.c
@@ -7,7 +7,9 @@
* Based on pipe-test-1m.c by Ingo Molnar <mingo@redhat.com>
* http://people.redhat.com/mingo/cfs-scheduler/tools/pipe-test-1m.c
* Ported to perf by Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
+ *
*/
+
#include "../perf.h"
#include "../util/util.h"
#include "../util/parse-options.h"
@@ -26,24 +28,12 @@
#include <sys/time.h>
#include <sys/types.h>
-#include <pthread.h>
-
-struct thread_data {
- int nr;
- int pipe_read;
- int pipe_write;
- pthread_t pthread;
-};
-
#define LOOPS_DEFAULT 1000000
-static int loops = LOOPS_DEFAULT;
-
-/* Use processes by default: */
-static bool threaded;
+static int loops = LOOPS_DEFAULT;
static const struct option options[] = {
- OPT_INTEGER('l', "loop", &loops, "Specify number of loops"),
- OPT_BOOLEAN('T', "threaded", &threaded, "Specify threads/process based task setup"),
+ OPT_INTEGER('l', "loop", &loops,
+ "Specify number of loops"),
OPT_END()
};
@@ -52,37 +42,13 @@ static const char * const bench_sched_pipe_usage[] = {
NULL
};
-static void *worker_thread(void *__tdata)
-{
- struct thread_data *td = __tdata;
- int m = 0, i;
- int ret;
-
- for (i = 0; i < loops; i++) {
- if (!td->nr) {
- ret = read(td->pipe_read, &m, sizeof(int));
- BUG_ON(ret != sizeof(int));
- ret = write(td->pipe_write, &m, sizeof(int));
- BUG_ON(ret != sizeof(int));
- } else {
- ret = write(td->pipe_write, &m, sizeof(int));
- BUG_ON(ret != sizeof(int));
- ret = read(td->pipe_read, &m, sizeof(int));
- BUG_ON(ret != sizeof(int));
- }
- }
-
- return NULL;
-}
-
-int bench_sched_pipe(int argc, const char **argv, const char *prefix __maybe_unused)
+int bench_sched_pipe(int argc, const char **argv,
+ const char *prefix __maybe_unused)
{
- struct thread_data threads[2], *td;
int pipe_1[2], pipe_2[2];
+ int m = 0, i;
struct timeval start, stop, diff;
unsigned long long result_usec = 0;
- int nr_threads = 2;
- int t;
/*
* why does "ret" exist?
@@ -92,66 +58,43 @@ int bench_sched_pipe(int argc, const char **argv, const char *prefix __maybe_unu
int __maybe_unused ret, wait_stat;
pid_t pid, retpid __maybe_unused;
- argc = parse_options(argc, argv, options, bench_sched_pipe_usage, 0);
+ argc = parse_options(argc, argv, options,
+ bench_sched_pipe_usage, 0);
BUG_ON(pipe(pipe_1));
BUG_ON(pipe(pipe_2));
- gettimeofday(&start, NULL);
-
- for (t = 0; t < nr_threads; t++) {
- td = threads + t;
+ pid = fork();
+ assert(pid >= 0);
- td->nr = t;
-
- if (t == 0) {
- td->pipe_read = pipe_1[0];
- td->pipe_write = pipe_2[1];
- } else {
- td->pipe_write = pipe_1[1];
- td->pipe_read = pipe_2[0];
- }
- }
-
-
- if (threaded) {
-
- for (t = 0; t < nr_threads; t++) {
- td = threads + t;
-
- ret = pthread_create(&td->pthread, NULL, worker_thread, td);
- BUG_ON(ret);
- }
-
- for (t = 0; t < nr_threads; t++) {
- td = threads + t;
+ gettimeofday(&start, NULL);
- ret = pthread_join(td->pthread, NULL);
- BUG_ON(ret);
+ if (!pid) {
+ for (i = 0; i < loops; i++) {
+ ret = read(pipe_1[0], &m, sizeof(int));
+ ret = write(pipe_2[1], &m, sizeof(int));
}
-
} else {
- pid = fork();
- assert(pid >= 0);
-
- if (!pid) {
- worker_thread(threads + 0);
- exit(0);
- } else {
- worker_thread(threads + 1);
+ for (i = 0; i < loops; i++) {
+ ret = write(pipe_1[1], &m, sizeof(int));
+ ret = read(pipe_2[0], &m, sizeof(int));
}
-
- retpid = waitpid(pid, &wait_stat, 0);
- assert((retpid == pid) && WIFEXITED(wait_stat));
}
gettimeofday(&stop, NULL);
timersub(&stop, &start, &diff);
+ if (pid) {
+ retpid = waitpid(pid, &wait_stat, 0);
+ assert((retpid == pid) && WIFEXITED(wait_stat));
+ } else {
+ exit(0);
+ }
+
switch (bench_format) {
case BENCH_FORMAT_DEFAULT:
- printf("# Executed %d pipe operations between two %s\n\n",
- loops, threaded ? "threads" : "processes");
+ printf("# Executed %d pipe operations between two tasks\n\n",
+ loops);
result_usec = diff.tv_sec * 1000000;
result_usec += diff.tv_usec;
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 4087ab1..5ebd0c3 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -28,10 +28,8 @@
#include "util/hist.h"
#include "util/session.h"
#include "util/tool.h"
-#include "util/data.h"
#include "arch/common.h"
-#include <dlfcn.h>
#include <linux/bitmap.h>
struct perf_annotate {
@@ -65,7 +63,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
return 0;
}
- he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, 1, 1, 0);
+ he = __hists__add_entry(&evsel->hists, al, NULL, 1, 1);
if (he == NULL)
return -ENOMEM;
@@ -118,11 +116,11 @@ static int hist_entry__tty_annotate(struct hist_entry *he,
ann->print_line, ann->full_paths, 0, 0);
}
-static void hists__find_annotations(struct hists *hists,
+static void hists__find_annotations(struct hists *self,
struct perf_evsel *evsel,
struct perf_annotate *ann)
{
- struct rb_node *nd = rb_first(&hists->entries), *next;
+ struct rb_node *nd = rb_first(&self->entries), *next;
int key = K_RIGHT;
while (nd) {
@@ -144,18 +142,8 @@ find_next:
if (use_browser == 2) {
int ret;
- int (*annotate)(struct hist_entry *he,
- struct perf_evsel *evsel,
- struct hist_browser_timer *hbt);
-
- annotate = dlsym(perf_gtk_handle,
- "hist_entry__gtk_annotate");
- if (annotate == NULL) {
- ui__error("GTK browser not found!\n");
- return;
- }
- ret = annotate(he, evsel, NULL);
+ ret = hist_entry__gtk_annotate(he, evsel, NULL);
if (!ret || !ann->skip_missing)
return;
@@ -200,13 +188,9 @@ static int __cmd_annotate(struct perf_annotate *ann)
struct perf_session *session;
struct perf_evsel *pos;
u64 total_nr_samples;
- struct perf_data_file file = {
- .path = input_name,
- .mode = PERF_DATA_MODE_READ,
- .force = ann->force,
- };
- session = perf_session__new(&file, false, &ann->tool);
+ session = perf_session__new(input_name, O_RDONLY,
+ ann->force, false, &ann->tool);
if (session == NULL)
return -ENOMEM;
@@ -247,7 +231,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
if (nr_samples > 0) {
total_nr_samples += nr_samples;
- hists__collapse_resort(hists, NULL);
+ hists__collapse_resort(hists);
hists__output_resort(hists);
if (symbol_conf.event_group &&
@@ -259,21 +243,12 @@ static int __cmd_annotate(struct perf_annotate *ann)
}
if (total_nr_samples == 0) {
- ui__error("The %s file has no samples!\n", file.path);
+ ui__error("The %s file has no samples!\n", session->filename);
goto out_delete;
}
- if (use_browser == 2) {
- void (*show_annotations)(void);
-
- show_annotations = dlsym(perf_gtk_handle,
- "perf_gtk__show_annotations");
- if (show_annotations == NULL) {
- ui__error("GTK browser not found!\n");
- goto out_delete;
- }
- show_annotations();
- }
+ if (use_browser == 2)
+ perf_gtk__show_annotations();
out_delete:
/*
diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index e47f90c..77298bf 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -1,18 +1,21 @@
/*
+ *
* builtin-bench.c
*
- * General benchmarking collections provided by perf
+ * General benchmarking subsystem provided by perf
*
* Copyright (C) 2009, Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
+ *
*/
/*
- * Available benchmark collection list:
*
- * sched ... scheduler and IPC performance
+ * Available subsystem list:
+ * sched ... scheduler and IPC mechanism
* mem ... memory access performance
- * numa ... NUMA scheduling and MM performance
+ *
*/
+
#include "perf.h"
#include "util/util.h"
#include "util/parse-options.h"
@@ -22,92 +25,112 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/prctl.h>
-typedef int (*bench_fn_t)(int argc, const char **argv, const char *prefix);
-
-struct bench {
- const char *name;
- const char *summary;
- bench_fn_t fn;
+struct bench_suite {
+ const char *name;
+ const char *summary;
+ int (*fn)(int, const char **, const char *);
};
-
-#ifdef HAVE_LIBNUMA_SUPPORT
-static struct bench numa_benchmarks[] = {
- { "mem", "Benchmark for NUMA workloads", bench_numa },
- { "all", "Test all NUMA benchmarks", NULL },
- { NULL, NULL, NULL }
+ \
+/* sentinel: easy for help */
+#define suite_all { "all", "Test all benchmark suites", NULL }
+
+#ifdef LIBNUMA_SUPPORT
+static struct bench_suite numa_suites[] = {
+ { "mem",
+ "Benchmark for NUMA workloads",
+ bench_numa },
+ suite_all,
+ { NULL,
+ NULL,
+ NULL }
};
#endif
-static struct bench sched_benchmarks[] = {
- { "messaging", "Benchmark for scheduling and IPC", bench_sched_messaging },
- { "pipe", "Benchmark for pipe() between two processes", bench_sched_pipe },
- { "all", "Test all scheduler benchmarks", NULL },
- { NULL, NULL, NULL }
+static struct bench_suite sched_suites[] = {
+ { "messaging",
+ "Benchmark for scheduler and IPC mechanisms",
+ bench_sched_messaging },
+ { "pipe",
+ "Flood of communication over pipe() between two processes",
+ bench_sched_pipe },
+ suite_all,
+ { NULL,
+ NULL,
+ NULL }
};
-static struct bench mem_benchmarks[] = {
- { "memcpy", "Benchmark for memcpy()", bench_mem_memcpy },
- { "memset", "Benchmark for memset() tests", bench_mem_memset },
- { "all", "Test all memory benchmarks", NULL },
- { NULL, NULL, NULL }
+static struct bench_suite mem_suites[] = {
+ { "memcpy",
+ "Simple memory copy in various ways",
+ bench_mem_memcpy },
+ { "memset",
+ "Simple memory set in various ways",
+ bench_mem_memset },
+ suite_all,
+ { NULL,
+ NULL,
+ NULL }
};
-struct collection {
- const char *name;
- const char *summary;
- struct bench *benchmarks;
+struct bench_subsys {
+ const char *name;
+ const char *summary;
+ struct bench_suite *suites;
};
-static struct collection collections[] = {
- { "sched", "Scheduler and IPC benchmarks", sched_benchmarks },
- { "mem", "Memory access benchmarks", mem_benchmarks },
-#ifdef HAVE_LIBNUMA_SUPPORT
- { "numa", "NUMA scheduling and MM benchmarks", numa_benchmarks },
+static struct bench_subsys subsystems[] = {
+#ifdef LIBNUMA_SUPPORT
+ { "numa",
+ "NUMA scheduling and MM behavior",
+ numa_suites },
#endif
- { "all", "All benchmarks", NULL },
- { NULL, NULL, NULL }
+ { "sched",
+ "scheduler and IPC mechanism",
+ sched_suites },
+ { "mem",
+ "memory access performance",
+ mem_suites },
+ { "all", /* sentinel: easy for help */
+ "all benchmark subsystem",
+ NULL },
+ { NULL,
+ NULL,
+ NULL }
};
-/* Iterate over all benchmark collections: */
-#define for_each_collection(coll) \
- for (coll = collections; coll->name; coll++)
-
-/* Iterate over all benchmarks within a collection: */
-#define for_each_bench(coll, bench) \
- for (bench = coll->benchmarks; bench->name; bench++)
-
-static void dump_benchmarks(struct collection *coll)
+static void dump_suites(int subsys_index)
{
- struct bench *bench;
+ int i;
- printf("\n # List of available benchmarks for collection '%s':\n\n", coll->name);
+ printf("# List of available suites for %s...\n\n",
+ subsystems[subsys_index].name);
- for_each_bench(coll, bench)
- printf("%14s: %s\n", bench->name, bench->summary);
+ for (i = 0; subsystems[subsys_index].suites[i].name; i++)
+ printf("%14s: %s\n",
+ subsystems[subsys_index].suites[i].name,
+ subsystems[subsys_index].suites[i].summary);
printf("\n");
+ return;
}
static const char *bench_format_str;
-
-/* Output/formatting style, exported to benchmark modules: */
int bench_format = BENCH_FORMAT_DEFAULT;
static const struct option bench_options[] = {
- OPT_STRING('f', "format", &bench_format_str, "default", "Specify format style"),
+ OPT_STRING('f', "format", &bench_format_str, "default",
+ "Specify format style"),
OPT_END()
};
static const char * const bench_usage[] = {
- "perf bench [<common options>] <collection> <benchmark> [<options>]",
+ "perf bench [<common options>] <subsystem> <suite> [<options>]",
NULL
};
static void print_usage(void)
{
- struct collection *coll;
int i;
printf("Usage: \n");
@@ -115,10 +138,11 @@ static void print_usage(void)
printf("\t%s\n", bench_usage[i]);
printf("\n");
- printf(" # List of all available benchmark collections:\n\n");
+ printf("# List of available subsystems...\n\n");
- for_each_collection(coll)
- printf("%14s: %s\n", coll->name, coll->summary);
+ for (i = 0; subsystems[i].name; i++)
+ printf("%14s: %s\n",
+ subsystems[i].name, subsystems[i].summary);
printf("\n");
}
@@ -135,74 +159,44 @@ static int bench_str2int(const char *str)
return BENCH_FORMAT_UNKNOWN;
}
-/*
- * Run a specific benchmark but first rename the running task's ->comm[]
- * to something meaningful:
- */
-static int run_bench(const char *coll_name, const char *bench_name, bench_fn_t fn,
- int argc, const char **argv, const char *prefix)
-{
- int size;
- char *name;
- int ret;
-
- size = strlen(coll_name) + 1 + strlen(bench_name) + 1;
-
- name = zalloc(size);
- BUG_ON(!name);
-
- scnprintf(name, size, "%s-%s", coll_name, bench_name);
-
- prctl(PR_SET_NAME, name);
- argv[0] = name;
-
- ret = fn(argc, argv, prefix);
-
- free(name);
-
- return ret;
-}
-
-static void run_collection(struct collection *coll)
+static void all_suite(struct bench_subsys *subsys) /* FROM HERE */
{
- struct bench *bench;
+ int i;
const char *argv[2];
+ struct bench_suite *suites = subsys->suites;
argv[1] = NULL;
/*
* TODO:
- *
- * Preparing preset parameters for
+ * preparing preset parameters for
* embedded, ordinary PC, HPC, etc...
- * would be helpful.
+ * will be helpful
*/
- for_each_bench(coll, bench) {
- if (!bench->fn)
- break;
- printf("# Running %s/%s benchmark...\n", coll->name, bench->name);
+ for (i = 0; suites[i].fn; i++) {
+ printf("# Running %s/%s benchmark...\n",
+ subsys->name,
+ suites[i].name);
fflush(stdout);
- argv[1] = bench->name;
- run_bench(coll->name, bench->name, bench->fn, 1, argv, NULL);
+ argv[1] = suites[i].name;
+ suites[i].fn(1, argv, NULL);
printf("\n");
}
}
-static void run_all_collections(void)
+static void all_subsystem(void)
{
- struct collection *coll;
-
- for_each_collection(coll)
- run_collection(coll);
+ int i;
+ for (i = 0; subsystems[i].suites; i++)
+ all_suite(&subsystems[i]);
}
int cmd_bench(int argc, const char **argv, const char *prefix __maybe_unused)
{
- struct collection *coll;
- int ret = 0;
+ int i, j, status = 0;
if (argc < 2) {
- /* No collection specified. */
+ /* No subsystem specified. */
print_usage();
goto end;
}
@@ -212,7 +206,7 @@ int cmd_bench(int argc, const char **argv, const char *prefix __maybe_unused)
bench_format = bench_str2int(bench_format_str);
if (bench_format == BENCH_FORMAT_UNKNOWN) {
- printf("Unknown format descriptor: '%s'\n", bench_format_str);
+ printf("Unknown format descriptor:%s\n", bench_format_str);
goto end;
}
@@ -222,51 +216,52 @@ int cmd_bench(int argc, const char **argv, const char *prefix __maybe_unused)
}
if (!strcmp(argv[0], "all")) {
- run_all_collections();
+ all_subsystem();
goto end;
}
- for_each_collection(coll) {
- struct bench *bench;
-
- if (strcmp(coll->name, argv[0]))
+ for (i = 0; subsystems[i].name; i++) {
+ if (strcmp(subsystems[i].name, argv[0]))
continue;
if (argc < 2) {
- /* No bench specified. */
- dump_benchmarks(coll);
+ /* No suite specified. */
+ dump_suites(i);
goto end;
}
if (!strcmp(argv[1], "all")) {
- run_collection(coll);
+ all_suite(&subsystems[i]);
goto end;
}
- for_each_bench(coll, bench) {
- if (strcmp(bench->name, argv[1]))
+ for (j = 0; subsystems[i].suites[j].name; j++) {
+ if (strcmp(subsystems[i].suites[j].name, argv[1]))
continue;
if (bench_format == BENCH_FORMAT_DEFAULT)
- printf("# Running '%s/%s' benchmark:\n", coll->name, bench->name);
+ printf("# Running %s/%s benchmark...\n",
+ subsystems[i].name,
+ subsystems[i].suites[j].name);
fflush(stdout);
- ret = run_bench(coll->name, bench->name, bench->fn, argc-1, argv+1, prefix);
+ status = subsystems[i].suites[j].fn(argc - 1,
+ argv + 1, prefix);
goto end;
}
if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
- dump_benchmarks(coll);
+ dump_suites(i);
goto end;
}
- printf("Unknown benchmark: '%s' for collection '%s'\n", argv[1], argv[0]);
- ret = 1;
+ printf("Unknown suite:%s for %s\n", argv[1], argv[0]);
+ status = 1;
goto end;
}
- printf("Unknown collection: '%s'\n", argv[0]);
- ret = 1;
+ printf("Unknown subsystem:%s\n", argv[0]);
+ status = 1;
end:
- return ret;
+ return status;
}
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index cfede86..c96c8fa 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -6,11 +6,6 @@
* Copyright (C) 2010, Red Hat Inc.
* Copyright (C) 2010, Arnaldo Carvalho de Melo <acme@redhat.com>
*/
-#include <sys/types.h>
-#include <sys/time.h>
-#include <time.h>
-#include <dirent.h>
-#include <unistd.h>
#include "builtin.h"
#include "perf.h"
#include "util/cache.h"
@@ -22,140 +17,6 @@
#include "util/session.h"
#include "util/symbol.h"
-static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid)
-{
- char root_dir[PATH_MAX];
- char notes[PATH_MAX];
- u8 build_id[BUILD_ID_SIZE];
- char *p;
-
- strlcpy(root_dir, proc_dir, sizeof(root_dir));
-
- p = strrchr(root_dir, '/');
- if (!p)
- return -1;
- *p = '\0';
-
- scnprintf(notes, sizeof(notes), "%s/sys/kernel/notes", root_dir);
-
- if (sysfs__read_build_id(notes, build_id, sizeof(build_id)))
- return -1;
-
- build_id__sprintf(build_id, sizeof(build_id), sbuildid);
-
- return 0;
-}
-
-static int build_id_cache__kcore_dir(char *dir, size_t sz)
-{
- struct timeval tv;
- struct tm tm;
- char dt[32];
-
- if (gettimeofday(&tv, NULL) || !localtime_r(&tv.tv_sec, &tm))
- return -1;
-
- if (!strftime(dt, sizeof(dt), "%Y%m%d%H%M%S", &tm))
- return -1;
-
- scnprintf(dir, sz, "%s%02u", dt, (unsigned)tv.tv_usec / 10000);
-
- return 0;
-}
-
-static int build_id_cache__kcore_existing(const char *from_dir, char *to_dir,
- size_t to_dir_sz)
-{
- char from[PATH_MAX];
- char to[PATH_MAX];
- struct dirent *dent;
- int ret = -1;
- DIR *d;
-
- d = opendir(to_dir);
- if (!d)
- return -1;
-
- scnprintf(from, sizeof(from), "%s/modules", from_dir);
-
- while (1) {
- dent = readdir(d);
- if (!dent)
- break;
- if (dent->d_type != DT_DIR)
- continue;
- scnprintf(to, sizeof(to), "%s/%s/modules", to_dir,
- dent->d_name);
- if (!compare_proc_modules(from, to)) {
- scnprintf(to, sizeof(to), "%s/%s", to_dir,
- dent->d_name);
- strlcpy(to_dir, to, to_dir_sz);
- ret = 0;
- break;
- }
- }
-
- closedir(d);
-
- return ret;
-}
-
-static int build_id_cache__add_kcore(const char *filename, const char *debugdir)
-{
- char dir[32], sbuildid[BUILD_ID_SIZE * 2 + 1];
- char from_dir[PATH_MAX], to_dir[PATH_MAX];
- char *p;
-
- strlcpy(from_dir, filename, sizeof(from_dir));
-
- p = strrchr(from_dir, '/');
- if (!p || strcmp(p + 1, "kcore"))
- return -1;
- *p = '\0';
-
- if (build_id_cache__kcore_buildid(from_dir, sbuildid))
- return -1;
-
- scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s",
- debugdir, sbuildid);
-
- if (!build_id_cache__kcore_existing(from_dir, to_dir, sizeof(to_dir))) {
- pr_debug("same kcore found in %s\n", to_dir);
- return 0;
- }
-
- if (build_id_cache__kcore_dir(dir, sizeof(dir)))
- return -1;
-
- scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s/%s",
- debugdir, sbuildid, dir);
-
- if (mkdir_p(to_dir, 0755))
- return -1;
-
- if (kcore_copy(from_dir, to_dir)) {
- /* Remove YYYYmmddHHMMSShh directory */
- if (!rmdir(to_dir)) {
- p = strrchr(to_dir, '/');
- if (p)
- *p = '\0';
- /* Try to remove buildid directory */
- if (!rmdir(to_dir)) {
- p = strrchr(to_dir, '/');
- if (p)
- *p = '\0';
- /* Try to remove [kernel.kcore] directory */
- rmdir(to_dir);
- }
- }
- return -1;
- }
-
- pr_debug("kcore added to build-id cache directory %s\n", to_dir);
-
- return 0;
-}
-
static int build_id_cache__add_file(const char *filename, const char *debugdir)
{
char sbuild_id[BUILD_ID_SIZE * 2 + 1];
@@ -221,12 +82,8 @@ static bool dso__missing_buildid_cache(struct dso *dso, int parm __maybe_unused)
static int build_id_cache__fprintf_missing(const char *filename, bool force, FILE *fp)
{
- struct perf_data_file file = {
- .path = filename,
- .mode = PERF_DATA_MODE_READ,
- .force = force,
- };
- struct perf_session *session = perf_session__new(&file, false, NULL);
+ struct perf_session *session = perf_session__new(filename, O_RDONLY,
+ force, false, NULL);
if (session == NULL)
return -1;
@@ -273,14 +130,11 @@ int cmd_buildid_cache(int argc, const char **argv,
char const *add_name_list_str = NULL,
*remove_name_list_str = NULL,
*missing_filename = NULL,
- *update_name_list_str = NULL,
- *kcore_filename;
+ *update_name_list_str = NULL;
const struct option buildid_cache_options[] = {
OPT_STRING('a', "add", &add_name_list_str,
"file list", "file(s) to add"),
- OPT_STRING('k', "kcore", &kcore_filename,
- "file", "kcore file to add"),
OPT_STRING('r', "remove", &remove_name_list_str, "file list",
"file(s) to remove"),
OPT_STRING('M', "missing", &missing_filename, "file",
@@ -363,9 +217,5 @@ int cmd_buildid_cache(int argc, const char **argv,
}
}
- if (kcore_filename &&
- build_id_cache__add_kcore(kcore_filename, debugdir))
- pr_warning("Couldn't add %s\n", kcore_filename);
-
return ret;
}
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c
index ed3873b..e74366a 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -15,7 +15,6 @@
#include "util/parse-options.h"
#include "util/session.h"
#include "util/symbol.h"
-#include "util/data.h"
static int sysfs__fprintf_build_id(FILE *fp)
{
@@ -53,11 +52,6 @@ static bool dso__skip_buildid(struct dso *dso, int with_hits)
static int perf_session__list_build_ids(bool force, bool with_hits)
{
struct perf_session *session;
- struct perf_data_file file = {
- .path = input_name,
- .mode = PERF_DATA_MODE_READ,
- .force = force,
- };
symbol__elf_init();
/*
@@ -66,14 +60,15 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
if (filename__fprintf_build_id(input_name, stdout))
goto out;
- session = perf_session__new(&file, false, &build_id__mark_dso_hit_ops);
+ session = perf_session__new(input_name, O_RDONLY, force, false,
+ &build_id__mark_dso_hit_ops);
if (session == NULL)
return -1;
/*
* in pipe-mode, the only way to get the buildids is to parse
* the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID
*/
- if (with_hits || perf_data_file__is_pipe(&file))
+ if (with_hits || session->fd_pipe)
perf_session__process_events(session, &build_id__mark_dso_hit_ops);
perf_session__fprintf_dsos_buildid(session, stdout, dso__skip_buildid, with_hits);
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 3b67ea2..f28799e 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -16,7 +16,6 @@
#include "util/sort.h"
#include "util/symbol.h"
#include "util/util.h"
-#include "util/data.h"
#include <stdlib.h>
#include <math.h>
@@ -43,7 +42,7 @@ struct diff_hpp_fmt {
struct data__file {
struct perf_session *session;
- struct perf_data_file file;
+ const char *file;
int idx;
struct hists *hists;
struct diff_hpp_fmt fmt[PERF_HPP_DIFF__MAX_INDEX];
@@ -303,12 +302,11 @@ static int formula_fprintf(struct hist_entry *he, struct hist_entry *pair,
return -1;
}
-static int hists__add_entry(struct hists *hists,
+static int hists__add_entry(struct hists *self,
struct addr_location *al, u64 period,
- u64 weight, u64 transaction)
+ u64 weight)
{
- if (__hists__add_entry(hists, al, NULL, NULL, NULL, period, weight,
- transaction) != NULL)
+ if (__hists__add_entry(self, al, NULL, period, weight) != NULL)
return 0;
return -ENOMEM;
}
@@ -330,8 +328,7 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
if (al.filtered)
return 0;
- if (hists__add_entry(&evsel->hists, &al, sample->period,
- sample->weight, sample->transaction)) {
+ if (hists__add_entry(&evsel->hists, &al, sample->period, sample->weight)) {
pr_warning("problem incrementing symbol period, skipping event\n");
return -1;
}
@@ -370,7 +367,7 @@ static void perf_evlist__collapse_resort(struct perf_evlist *evlist)
list_for_each_entry(evsel, &evlist->entries, node) {
struct hists *hists = &evsel->hists;
- hists__collapse_resort(hists, NULL);
+ hists__collapse_resort(hists);
}
}
@@ -602,7 +599,7 @@ static void data__fprintf(void)
data__for_each_file(i, d)
fprintf(stdout, "# [%d] %s %s\n",
- d->idx, d->file.path,
+ d->idx, d->file,
!d->idx ? "(Baseline)" : "");
fprintf(stdout, "#\n");
@@ -664,16 +661,17 @@ static int __cmd_diff(void)
int ret = -EINVAL, i;
data__for_each_file(i, d) {
- d->session = perf_session__new(&d->file, false, &tool);
+ d->session = perf_session__new(d->file, O_RDONLY, force,
+ false, &tool);
if (!d->session) {
- pr_err("Failed to open %s\n", d->file.path);
+ pr_err("Failed to open %s\n", d->file);
ret = -ENOMEM;
goto out_delete;
}
ret = perf_session__process_events(d->session, &tool);
if (ret) {
- pr_err("Failed to process %s\n", d->file.path);
+ pr_err("Failed to process %s\n", d->file);
goto out_delete;
}
@@ -1016,12 +1014,7 @@ static int data_init(int argc, const char **argv)
return -ENOMEM;
data__for_each_file(i, d) {
- struct perf_data_file *file = &d->file;
-
- file->path = use_default ? defaults[i] : argv[i];
- file->mode = PERF_DATA_MODE_READ,
- file->force = force,
-
+ d->file = use_default ? defaults[i] : argv[i];
d->idx = i;
}
diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
index 20b0f12..05bd9df 100644
--- a/tools/perf/builtin-evlist.c
+++ b/tools/perf/builtin-evlist.c
@@ -14,18 +14,13 @@
#include "util/parse-events.h"
#include "util/parse-options.h"
#include "util/session.h"
-#include "util/data.h"
static int __cmd_evlist(const char *file_name, struct perf_attr_details *details)
{
struct perf_session *session;
struct perf_evsel *pos;
- struct perf_data_file file = {
- .path = file_name,
- .mode = PERF_DATA_MODE_READ,
- };
- session = perf_session__new(&file, 0, NULL);
+ session = perf_session__new(file_name, O_RDONLY, 0, false, NULL);
if (session == NULL)
return -ENOMEM;
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 6a25085..afe377b 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -15,7 +15,6 @@
#include "util/tool.h"
#include "util/debug.h"
#include "util/build-id.h"
-#include "util/data.h"
#include "util/parse-options.h"
@@ -72,17 +71,12 @@ static int perf_event__repipe_attr(struct perf_tool *tool,
union perf_event *event,
struct perf_evlist **pevlist)
{
- struct perf_inject *inject = container_of(tool, struct perf_inject,
- tool);
int ret;
ret = perf_event__process_attr(tool, event, pevlist);
if (ret)
return ret;
- if (!inject->pipe_output)
- return 0;
-
return perf_event__repipe_synth(tool, event);
}
@@ -106,8 +100,8 @@ static int perf_event__repipe_sample(struct perf_tool *tool,
struct perf_evsel *evsel,
struct machine *machine)
{
- if (evsel->handler) {
- inject_handler f = evsel->handler;
+ if (evsel->handler.func) {
+ inject_handler f = evsel->handler.func;
return f(tool, event, sample, evsel, machine);
}
@@ -167,38 +161,38 @@ static int perf_event__repipe_tracing_data(struct perf_tool *tool,
return err;
}
-static int dso__read_build_id(struct dso *dso)
+static int dso__read_build_id(struct dso *self)
{
- if (dso->has_build_id)
+ if (self->has_build_id)
return 0;
- if (filename__read_build_id(dso->long_name, dso->build_id,
- sizeof(dso->build_id)) > 0) {
- dso->has_build_id = true;
+ if (filename__read_build_id(self->long_name, self->build_id,
+ sizeof(self->build_id)) > 0) {
+ self->has_build_id = true;
return 0;
}
return -1;
}
-static int dso__inject_build_id(struct dso *dso, struct perf_tool *tool,
+static int dso__inject_build_id(struct dso *self, struct perf_tool *tool,
struct machine *machine)
{
u16 misc = PERF_RECORD_MISC_USER;
int err;
- if (dso__read_build_id(dso) < 0) {
- pr_debug("no build_id found for %s\n", dso->long_name);
+ if (dso__read_build_id(self) < 0) {
+ pr_debug("no build_id found for %s\n", self->long_name);
return -1;
}
- if (dso->kernel)
+ if (self->kernel)
misc = PERF_RECORD_MISC_KERNEL;
- err = perf_event__synthesize_build_id(tool, dso, misc, perf_event__repipe,
+ err = perf_event__synthesize_build_id(tool, self, misc, perf_event__repipe,
machine);
if (err) {
- pr_err("Can't synthesize build_id event for %s\n", dso->long_name);
+ pr_err("Can't synthesize build_id event for %s\n", self->long_name);
return -1;
}
@@ -237,7 +231,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool,
* account this as unresolved.
*/
} else {
-#ifdef HAVE_LIBELF_SUPPORT
+#ifdef LIBELF_SUPPORT
pr_warning("no symbols found in %s, maybe "
"install a debug package?\n",
al.map->dso->long_name);
@@ -351,10 +345,6 @@ static int __cmd_inject(struct perf_inject *inject)
{
struct perf_session *session;
int ret = -EINVAL;
- struct perf_data_file file = {
- .path = inject->input_name,
- .mode = PERF_DATA_MODE_READ,
- };
signal(SIGINT, sig_handler);
@@ -365,7 +355,7 @@ static int __cmd_inject(struct perf_inject *inject)
inject->tool.tracing_data = perf_event__repipe_tracing_data;
}
- session = perf_session__new(&file, true, &inject->tool);
+ session = perf_session__new(inject->input_name, O_RDONLY, false, true, &inject->tool);
if (session == NULL)
return -ENOMEM;
@@ -383,11 +373,11 @@ static int __cmd_inject(struct perf_inject *inject)
if (perf_evsel__check_stype(evsel, PERF_SAMPLE_TID, "TID"))
return -EINVAL;
- evsel->handler = perf_inject__sched_switch;
+ evsel->handler.func = perf_inject__sched_switch;
} else if (!strcmp(name, "sched:sched_process_exit"))
- evsel->handler = perf_inject__sched_process_exit;
+ evsel->handler.func = perf_inject__sched_process_exit;
else if (!strncmp(name, "sched:sched_stat_", 17))
- evsel->handler = perf_inject__sched_stat;
+ evsel->handler.func = perf_inject__sched_stat;
}
}
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 929462a..9b5f077 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -13,7 +13,6 @@
#include "util/parse-options.h"
#include "util/trace-event.h"
-#include "util/data.h"
#include "util/debug.h"
@@ -315,10 +314,10 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
return -1;
}
- dump_printf(" ... thread: %s:%d\n", thread__comm_str(thread), thread->tid);
+ dump_printf(" ... thread: %s:%d\n", thread->comm, thread->tid);
- if (evsel->handler != NULL) {
- tracepoint_handler f = evsel->handler;
+ if (evsel->handler.func != NULL) {
+ tracepoint_handler f = evsel->handler.func;
return f(evsel, sample);
}
@@ -487,12 +486,8 @@ static int __cmd_kmem(void)
{ "kmem:kfree", perf_evsel__process_free_event, },
{ "kmem:kmem_cache_free", perf_evsel__process_free_event, },
};
- struct perf_data_file file = {
- .path = input_name,
- .mode = PERF_DATA_MODE_READ,
- };
- session = perf_session__new(&file, false, &perf_kmem);
+ session = perf_session__new(input_name, O_RDONLY, 0, false, &perf_kmem);
if (session == NULL)
return -ENOMEM;
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index f8bf5f2..fbc2888 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -17,12 +17,9 @@
#include "util/tool.h"
#include "util/stat.h"
#include "util/top.h"
-#include "util/data.h"
#include <sys/prctl.h>
-#ifdef HAVE_TIMERFD_SUPPORT
#include <sys/timerfd.h>
-#endif
#include <termios.h>
#include <semaphore.h>
@@ -339,7 +336,6 @@ static void init_kvm_event_record(struct perf_kvm_stat *kvm)
INIT_LIST_HEAD(&kvm->kvm_events_cache[i]);
}
-#ifdef HAVE_TIMERFD_SUPPORT
static void clear_events_cache_stats(struct list_head *kvm_events_cache)
{
struct list_head *head;
@@ -361,7 +357,6 @@ static void clear_events_cache_stats(struct list_head *kvm_events_cache)
}
}
}
-#endif
static int kvm_events_hash_fn(u64 key)
{
@@ -787,7 +782,6 @@ static void print_result(struct perf_kvm_stat *kvm)
pr_info("\nLost events: %" PRIu64 "\n\n", kvm->lost_events);
}
-#ifdef HAVE_TIMERFD_SUPPORT
static int process_lost_event(struct perf_tool *tool,
union perf_event *event __maybe_unused,
struct perf_sample *sample __maybe_unused,
@@ -798,7 +792,6 @@ static int process_lost_event(struct perf_tool *tool,
kvm->lost_events++;
return 0;
}
-#endif
static bool skip_sample(struct perf_kvm_stat *kvm,
struct perf_sample *sample)
@@ -878,7 +871,6 @@ static bool verify_vcpu(int vcpu)
return true;
}
-#ifdef HAVE_TIMERFD_SUPPORT
/* keeping the max events to a modest level to keep
* the processing of samples per mmap smooth.
*/
@@ -1220,7 +1212,6 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm)
out:
return rc;
}
-#endif
static int read_events(struct perf_kvm_stat *kvm)
{
@@ -1231,13 +1222,10 @@ static int read_events(struct perf_kvm_stat *kvm)
.comm = perf_event__process_comm,
.ordered_samples = true,
};
- struct perf_data_file file = {
- .path = input_name,
- .mode = PERF_DATA_MODE_READ,
- };
kvm->tool = eops;
- kvm->session = perf_session__new(&file, false, &kvm->tool);
+ kvm->session = perf_session__new(kvm->file_name, O_RDONLY, 0, false,
+ &kvm->tool);
if (!kvm->session) {
pr_err("Initializing perf session failed\n");
return -EINVAL;
@@ -1387,7 +1375,6 @@ kvm_events_report(struct perf_kvm_stat *kvm, int argc, const char **argv)
return kvm_events_report_vcpu(kvm);
}
-#ifdef HAVE_TIMERFD_SUPPORT
static struct perf_evlist *kvm_live_event_list(void)
{
struct perf_evlist *evlist;
@@ -1446,9 +1433,8 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
const struct option live_options[] = {
OPT_STRING('p', "pid", &kvm->opts.target.pid, "pid",
"record events on existing process id"),
- OPT_CALLBACK('m', "mmap-pages", &kvm->opts.mmap_pages, "pages",
- "number of mmap data pages",
- perf_evlist__parse_mmap_pages),
+ OPT_UINTEGER('m', "mmap-pages", &kvm->opts.mmap_pages,
+ "number of mmap data pages"),
OPT_INCR('v', "verbose", &verbose,
"be more verbose (show counter open errors, etc)"),
OPT_BOOLEAN('a', "all-cpus", &kvm->opts.target.system_wide,
@@ -1470,9 +1456,6 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
"perf kvm stat live [<options>]",
NULL
};
- struct perf_data_file file = {
- .mode = PERF_DATA_MODE_WRITE,
- };
/* event handling */
@@ -1510,13 +1493,13 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
/*
* target related setups
*/
- err = target__validate(&kvm->opts.target);
+ err = perf_target__validate(&kvm->opts.target);
if (err) {
- target__strerror(&kvm->opts.target, err, errbuf, BUFSIZ);
+ perf_target__strerror(&kvm->opts.target, err, errbuf, BUFSIZ);
ui__warning("%s", errbuf);
}
- if (target__none(&kvm->opts.target))
+ if (perf_target__none(&kvm->opts.target))
kvm->opts.target.system_wide = true;
@@ -1537,15 +1520,25 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
/*
* perf session
*/
- kvm->session = perf_session__new(&file, false, &kvm->tool);
+ kvm->session = perf_session__new(NULL, O_WRONLY, false, false, &kvm->tool);
if (kvm->session == NULL) {
err = -ENOMEM;
goto out;
}
kvm->session->evlist = kvm->evlist;
perf_session__set_id_hdr_size(kvm->session);
- machine__synthesize_threads(&kvm->session->machines.host, &kvm->opts.target,
- kvm->evlist->threads, false);
+
+
+ if (perf_target__has_task(&kvm->opts.target))
+ perf_event__synthesize_thread_map(&kvm->tool,
+ kvm->evlist->threads,
+ perf_event__process,
+ &kvm->session->machines.host);
+ else
+ perf_event__synthesize_threads(&kvm->tool, perf_event__process,
+ &kvm->session->machines.host);
+
+
err = kvm_live_open_events(kvm);
if (err)
goto out;
@@ -1565,7 +1558,6 @@ out:
return err;
}
-#endif
static void print_kvm_stat_usage(void)
{
@@ -1604,10 +1596,8 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
if (!strncmp(argv[1], "rep", 3))
return kvm_events_report(&kvm, argc - 1 , argv + 1);
-#ifdef HAVE_TIMERFD_SUPPORT
if (!strncmp(argv[1], "live", 4))
return kvm_events_live(&kvm, argc - 1 , argv + 1);
-#endif
perf_stat:
return cmd_stat(argc, argv, NULL);
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 011195e..e79f423 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -14,63 +14,51 @@
#include "util/parse-events.h"
#include "util/cache.h"
#include "util/pmu.h"
-#include "util/parse-options.h"
int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
{
- int i;
- const struct option list_options[] = {
- OPT_END()
- };
- const char * const list_usage[] = {
- "perf list [hw|sw|cache|tracepoint|pmu|event_glob]",
- NULL
- };
-
- argc = parse_options(argc, argv, list_options, list_usage,
- PARSE_OPT_STOP_AT_NON_OPTION);
-
setup_pager();
- if (argc == 0) {
+ if (argc == 1)
print_events(NULL, false);
- return 0;
- }
+ else {
+ int i;
- for (i = 0; i < argc; ++i) {
- if (i)
- putchar('\n');
- if (strncmp(argv[i], "tracepoint", 10) == 0)
- print_tracepoint_events(NULL, NULL, false);
- else if (strcmp(argv[i], "hw") == 0 ||
- strcmp(argv[i], "hardware") == 0)
- print_events_type(PERF_TYPE_HARDWARE);
- else if (strcmp(argv[i], "sw") == 0 ||
- strcmp(argv[i], "software") == 0)
- print_events_type(PERF_TYPE_SOFTWARE);
- else if (strcmp(argv[i], "cache") == 0 ||
- strcmp(argv[i], "hwcache") == 0)
- print_hwcache_events(NULL, false);
- else if (strcmp(argv[i], "pmu") == 0)
- print_pmu_events(NULL, false);
- else if (strcmp(argv[i], "--raw-dump") == 0)
- print_events(NULL, true);
- else {
- char *sep = strchr(argv[i], ':'), *s;
- int sep_idx;
+ for (i = 1; i < argc; ++i) {
+ if (i > 2)
+ putchar('\n');
+ if (strncmp(argv[i], "tracepoint", 10) == 0)
+ print_tracepoint_events(NULL, NULL, false);
+ else if (strcmp(argv[i], "hw") == 0 ||
+ strcmp(argv[i], "hardware") == 0)
+ print_events_type(PERF_TYPE_HARDWARE);
+ else if (strcmp(argv[i], "sw") == 0 ||
+ strcmp(argv[i], "software") == 0)
+ print_events_type(PERF_TYPE_SOFTWARE);
+ else if (strcmp(argv[i], "cache") == 0 ||
+ strcmp(argv[i], "hwcache") == 0)
+ print_hwcache_events(NULL, false);
+ else if (strcmp(argv[i], "pmu") == 0)
+ print_pmu_events(NULL, false);
+ else if (strcmp(argv[i], "--raw-dump") == 0)
+ print_events(NULL, true);
+ else {
+ char *sep = strchr(argv[i], ':'), *s;
+ int sep_idx;
- if (sep == NULL) {
- print_events(argv[i], false);
- continue;
- }
- sep_idx = sep - argv[i];
- s = strdup(argv[i]);
- if (s == NULL)
- return -1;
+ if (sep == NULL) {
+ print_events(argv[i], false);
+ continue;
+ }
+ sep_idx = sep - argv[i];
+ s = strdup(argv[i]);
+ if (s == NULL)
+ return -1;
- s[sep_idx] = '\0';
- print_tracepoint_events(s, s + sep_idx + 1, false);
- free(s);
+ s[sep_idx] = '\0';
+ print_tracepoint_events(s, s + sep_idx + 1, false);
+ free(s);
+ }
}
}
return 0;
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index c852c7a..ee33ba2 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -15,7 +15,6 @@
#include "util/debug.h"
#include "util/session.h"
#include "util/tool.h"
-#include "util/data.h"
#include <sys/types.h>
#include <sys/prctl.h>
@@ -57,9 +56,7 @@ struct lock_stat {
unsigned int nr_readlock;
unsigned int nr_trylock;
-
/* these times are in nano sec. */
- u64 avg_wait_time;
u64 wait_time_total;
u64 wait_time_min;
u64 wait_time_max;
@@ -211,7 +208,6 @@ static struct thread_stat *thread_stat_findnew_first(u32 tid)
SINGLE_KEY(nr_acquired)
SINGLE_KEY(nr_contended)
-SINGLE_KEY(avg_wait_time)
SINGLE_KEY(wait_time_total)
SINGLE_KEY(wait_time_max)
@@ -248,7 +244,6 @@ static struct rb_root result; /* place to store sorted data */
struct lock_key keys[] = {
DEF_KEY_LOCK(acquired, nr_acquired),
DEF_KEY_LOCK(contended, nr_contended),
- DEF_KEY_LOCK(avg_wait, avg_wait_time),
DEF_KEY_LOCK(wait_total, wait_time_total),
DEF_KEY_LOCK(wait_min, wait_time_min),
DEF_KEY_LOCK(wait_max, wait_time_max),
@@ -326,12 +321,10 @@ static struct lock_stat *lock_stat_findnew(void *addr, const char *name)
new->addr = addr;
new->name = zalloc(sizeof(char) * strlen(name) + 1);
- if (!new->name) {
- free(new);
+ if (!new->name)
goto alloc_failed;
- }
-
strcpy(new->name, name);
+
new->wait_time_min = ULLONG_MAX;
list_add(&new->hash_entry, entry);
@@ -407,17 +400,17 @@ static int report_lock_acquire_event(struct perf_evsel *evsel,
ls = lock_stat_findnew(addr, name);
if (!ls)
- return -ENOMEM;
+ return -1;
if (ls->discard)
return 0;
ts = thread_stat_findnew(sample->tid);
if (!ts)
- return -ENOMEM;
+ return -1;
seq = get_seq(ts, addr);
if (!seq)
- return -ENOMEM;
+ return -1;
switch (seq->state) {
case SEQ_STATE_UNINITIALIZED:
@@ -453,6 +446,7 @@ broken:
list_del(&seq->list);
free(seq);
goto end;
+ break;
default:
BUG_ON("Unknown state of lock sequence found!\n");
break;
@@ -479,17 +473,17 @@ static int report_lock_acquired_event(struct perf_evsel *evsel,
ls = lock_stat_findnew(addr, name);
if (!ls)
- return -ENOMEM;
+ return -1;
if (ls->discard)
return 0;
ts = thread_stat_findnew(sample->tid);
if (!ts)
- return -ENOMEM;
+ return -1;
seq = get_seq(ts, addr);
if (!seq)
- return -ENOMEM;
+ return -1;
switch (seq->state) {
case SEQ_STATE_UNINITIALIZED:
@@ -514,6 +508,8 @@ static int report_lock_acquired_event(struct perf_evsel *evsel,
list_del(&seq->list);
free(seq);
goto end;
+ break;
+
default:
BUG_ON("Unknown state of lock sequence found!\n");
break;
@@ -521,7 +517,6 @@ static int report_lock_acquired_event(struct perf_evsel *evsel,
seq->state = SEQ_STATE_ACQUIRED;
ls->nr_acquired++;
- ls->avg_wait_time = ls->nr_contended ? ls->wait_time_total/ls->nr_contended : 0;
seq->prev_event_time = sample->time;
end:
return 0;
@@ -541,17 +536,17 @@ static int report_lock_contended_event(struct perf_evsel *evsel,
ls = lock_stat_findnew(addr, name);
if (!ls)
- return -ENOMEM;
+ return -1;
if (ls->discard)
return 0;
ts = thread_stat_findnew(sample->tid);
if (!ts)
- return -ENOMEM;
+ return -1;
seq = get_seq(ts, addr);
if (!seq)
- return -ENOMEM;
+ return -1;
switch (seq->state) {
case SEQ_STATE_UNINITIALIZED:
@@ -569,6 +564,7 @@ static int report_lock_contended_event(struct perf_evsel *evsel,
list_del(&seq->list);
free(seq);
goto end;
+ break;
default:
BUG_ON("Unknown state of lock sequence found!\n");
break;
@@ -576,7 +572,6 @@ static int report_lock_contended_event(struct perf_evsel *evsel,
seq->state = SEQ_STATE_CONTENDED;
ls->nr_contended++;
- ls->avg_wait_time = ls->wait_time_total/ls->nr_contended;
seq->prev_event_time = sample->time;
end:
return 0;
@@ -596,21 +591,22 @@ static int report_lock_release_event(struct perf_evsel *evsel,
ls = lock_stat_findnew(addr, name);
if (!ls)
- return -ENOMEM;
+ return -1;
if (ls->discard)
return 0;
ts = thread_stat_findnew(sample->tid);
if (!ts)
- return -ENOMEM;
+ return -1;
seq = get_seq(ts, addr);
if (!seq)
- return -ENOMEM;
+ return -1;
switch (seq->state) {
case SEQ_STATE_UNINITIALIZED:
goto end;
+ break;
case SEQ_STATE_ACQUIRED:
break;
case SEQ_STATE_READ_ACQUIRED:
@@ -628,6 +624,7 @@ static int report_lock_release_event(struct perf_evsel *evsel,
ls->discard = 1;
bad_hist[BROKEN_RELEASE]++;
goto free_seq;
+ break;
default:
BUG_ON("Unknown state of lock sequence found!\n");
break;
@@ -693,7 +690,7 @@ static void print_bad_events(int bad, int total)
pr_info("\n=== output for debug===\n\n");
pr_info("bad: %d, total: %d\n", bad, total);
- pr_info("bad rate: %.2f %%\n", (double)bad / (double)total * 100);
+ pr_info("bad rate: %f %%\n", (double)bad / (double)total * 100);
pr_info("histogram of events caused bad sequence\n");
for (i = 0; i < BROKEN_MAX; i++)
pr_info(" %10s: %d\n", name[i], bad_hist[i]);
@@ -710,7 +707,6 @@ static void print_result(void)
pr_info("%10s ", "acquired");
pr_info("%10s ", "contended");
- pr_info("%15s ", "avg wait (ns)");
pr_info("%15s ", "total wait (ns)");
pr_info("%15s ", "max wait (ns)");
pr_info("%15s ", "min wait (ns)");
@@ -742,7 +738,6 @@ static void print_result(void)
pr_info("%10u ", st->nr_acquired);
pr_info("%10u ", st->nr_contended);
- pr_info("%15" PRIu64 " ", st->avg_wait_time);
pr_info("%15" PRIu64 " ", st->wait_time_total);
pr_info("%15" PRIu64 " ", st->wait_time_max);
pr_info("%15" PRIu64 " ", st->wait_time_min == ULLONG_MAX ?
@@ -767,7 +762,7 @@ static void dump_threads(void)
while (node) {
st = container_of(node, struct thread_stat, rb);
t = perf_session__findnew(session, st->tid);
- pr_info("%10d: %s\n", st->tid, thread__comm_str(t));
+ pr_info("%10d: %s\n", st->tid, t->comm);
node = rb_next(node);
};
}
@@ -819,26 +814,14 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
return -1;
}
- if (evsel->handler != NULL) {
- tracepoint_handler f = evsel->handler;
+ if (evsel->handler.func != NULL) {
+ tracepoint_handler f = evsel->handler.func;
return f(evsel, sample);
}
return 0;
}
-static void sort_result(void)
-{
- unsigned int i;
- struct lock_stat *st;
-
- for (i = 0; i < LOCKHASH_SIZE; i++) {
- list_for_each_entry(st, &lockhash_table[i], hash_entry) {
- insert_to_result(st, compare);
- }
- }
-}
-
static const struct perf_evsel_str_handler lock_tracepoints[] = {
{ "lock:lock_acquire", perf_evsel__process_lock_acquire, }, /* CONFIG_LOCKDEP */
{ "lock:lock_acquired", perf_evsel__process_lock_acquired, }, /* CONFIG_LOCKDEP, CONFIG_LOCK_STAT */
@@ -846,51 +829,51 @@ static const struct perf_evsel_str_handler lock_tracepoints[] = {
{ "lock:lock_release", perf_evsel__process_lock_release, }, /* CONFIG_LOCKDEP */
};
-static int __cmd_report(bool display_info)
+static int read_events(void)
{
- int err = -EINVAL;
struct perf_tool eops = {
.sample = process_sample_event,
.comm = perf_event__process_comm,
.ordered_samples = true,
};
- struct perf_data_file file = {
- .path = input_name,
- .mode = PERF_DATA_MODE_READ,
- };
-
- session = perf_session__new(&file, false, &eops);
+ session = perf_session__new(input_name, O_RDONLY, 0, false, &eops);
if (!session) {
pr_err("Initializing perf session failed\n");
- return -ENOMEM;
+ return -1;
}
- if (!perf_session__has_traces(session, "lock record"))
- goto out_delete;
-
if (perf_session__set_tracepoints_handlers(session, lock_tracepoints)) {
pr_err("Initializing perf session tracepoint handlers failed\n");
- goto out_delete;
+ return -1;
}
- if (select_key())
- goto out_delete;
+ return perf_session__process_events(session, &eops);
+}
+
+static void sort_result(void)
+{
+ unsigned int i;
+ struct lock_stat *st;
- err = perf_session__process_events(session, &eops);
- if (err)
- goto out_delete;
+ for (i = 0; i < LOCKHASH_SIZE; i++) {
+ list_for_each_entry(st, &lockhash_table[i], hash_entry) {
+ insert_to_result(st, compare);
+ }
+ }
+}
+static int __cmd_report(void)
+{
setup_pager();
- if (display_info) /* used for info subcommand */
- err = dump_info();
- else {
- sort_result();
- print_result();
- }
-out_delete:
- perf_session__delete(session);
- return err;
+ if ((select_key() != 0) ||
+ (read_events() != 0))
+ return -1;
+
+ sort_result();
+ print_result();
+
+ return 0;
}
static int __cmd_record(int argc, const char **argv)
@@ -898,7 +881,7 @@ static int __cmd_record(int argc, const char **argv)
const char *record_args[] = {
"record", "-R", "-m", "1024", "-c", "1",
};
- unsigned int rec_argc, i, j, ret;
+ unsigned int rec_argc, i, j;
const char **rec_argv;
for (i = 0; i < ARRAY_SIZE(lock_tracepoints); i++) {
@@ -915,7 +898,7 @@ static int __cmd_record(int argc, const char **argv)
rec_argc += 2 * ARRAY_SIZE(lock_tracepoints);
rec_argv = calloc(rec_argc + 1, sizeof(char *));
- if (!rec_argv)
+ if (rec_argv == NULL)
return -ENOMEM;
for (i = 0; i < ARRAY_SIZE(record_args); i++)
@@ -931,9 +914,7 @@ static int __cmd_record(int argc, const char **argv)
BUG_ON(i != rec_argc);
- ret = cmd_record(i, rec_argv, NULL);
- free(rec_argv);
- return ret;
+ return cmd_record(i, rec_argv, NULL);
}
int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
@@ -953,7 +934,7 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
};
const struct option report_options[] = {
OPT_STRING('k', "key", &sort_key, "acquired",
- "key for sorting (acquired / contended / avg_wait / wait_total / wait_max / wait_min)"),
+ "key for sorting (acquired / contended / wait_total / wait_max / wait_min)"),
/* TODO: type */
OPT_END()
};
@@ -991,7 +972,7 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
if (argc)
usage_with_options(report_usage, report_options);
}
- rc = __cmd_report(false);
+ __cmd_report();
} else if (!strcmp(argv[0], "script")) {
/* Aliased to 'perf script' */
return cmd_script(argc, argv, prefix);
@@ -1004,7 +985,11 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused)
}
/* recycling report_lock_ops */
trace_handler = &report_lock_ops;
- rc = __cmd_report(true);
+ setup_pager();
+ if (read_events() != 0)
+ rc = -1;
+ else
+ rc = dump_info();
} else {
usage_with_options(lock_usage, lock_options);
}
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 31c00f1..253133a 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -5,7 +5,6 @@
#include "util/trace-event.h"
#include "util/tool.h"
#include "util/session.h"
-#include "util/data.h"
#define MEM_OPERATION_LOAD "load"
#define MEM_OPERATION_STORE "store"
@@ -120,14 +119,10 @@ static int process_sample_event(struct perf_tool *tool,
static int report_raw_events(struct perf_mem *mem)
{
- struct perf_data_file file = {
- .path = input_name,
- .mode = PERF_DATA_MODE_READ,
- };
int err = -EINVAL;
int ret;
- struct perf_session *session = perf_session__new(&file, false,
- &mem->tool);
+ struct perf_session *session = perf_session__new(input_name, O_RDONLY,
+ 0, false, &mem->tool);
if (session == NULL)
return -ENOMEM;
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 6ea9e85..e8a66f9 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -173,7 +173,7 @@ static int opt_set_target(const struct option *opt, const char *str,
if (str && !params.target) {
if (!strcmp(opt->long_name, "exec"))
params.uprobes = true;
-#ifdef HAVE_DWARF_SUPPORT
+#ifdef DWARF_SUPPORT
else if (!strcmp(opt->long_name, "module"))
params.uprobes = false;
#endif
@@ -187,7 +187,7 @@ static int opt_set_target(const struct option *opt, const char *str,
return ret;
}
-#ifdef HAVE_DWARF_SUPPORT
+#ifdef DWARF_SUPPORT
static int opt_show_lines(const struct option *opt __maybe_unused,
const char *str, int unset __maybe_unused)
{
@@ -257,7 +257,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
"perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]",
"perf probe [<options>] --del '[GROUP:]EVENT' ...",
"perf probe --list",
-#ifdef HAVE_DWARF_SUPPORT
+#ifdef DWARF_SUPPORT
"perf probe [<options>] --line 'LINEDESC'",
"perf probe [<options>] --vars 'PROBEPOINT'",
#endif
@@ -271,7 +271,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_CALLBACK('d', "del", NULL, "[GROUP:]EVENT", "delete a probe event.",
opt_del_probe_event),
OPT_CALLBACK('a', "add", NULL,
-#ifdef HAVE_DWARF_SUPPORT
+#ifdef DWARF_SUPPORT
"[EVENT=]FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT"
" [[NAME=]ARG ...]",
#else
@@ -283,7 +283,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
"\t\tFUNC:\tFunction name\n"
"\t\tOFF:\tOffset from function entry (in byte)\n"
"\t\t%return:\tPut the probe at function return\n"
-#ifdef HAVE_DWARF_SUPPORT
+#ifdef DWARF_SUPPORT
"\t\tSRC:\tSource code path\n"
"\t\tRL:\tRelative line number from function entry.\n"
"\t\tAL:\tAbsolute line number in file.\n"
@@ -296,7 +296,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
opt_add_probe_event),
OPT_BOOLEAN('f', "force", &params.force_add, "forcibly add events"
" with existing name"),
-#ifdef HAVE_DWARF_SUPPORT
+#ifdef DWARF_SUPPORT
OPT_CALLBACK('L', "line", NULL,
"FUNC[:RLN[+NUM|-RLN2]]|SRC:ALN[+NUM|-ALN2]",
"Show source code lines.", opt_show_lines),
@@ -325,8 +325,6 @@ int cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
opt_set_filter),
OPT_CALLBACK('x', "exec", NULL, "executable|path",
"target executable name or path", opt_set_target),
- OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
- "Disable symbol demangling"),
OPT_END()
};
int ret;
@@ -410,7 +408,7 @@ int cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
return ret;
}
-#ifdef HAVE_DWARF_SUPPORT
+#ifdef DWARF_SUPPORT
if (params.show_lines && !params.uprobes) {
if (params.mod_events) {
pr_err(" Error: Don't use --line with"
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 7c8020a..d046514 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -24,13 +24,12 @@
#include "util/symbol.h"
#include "util/cpumap.h"
#include "util/thread_map.h"
-#include "util/data.h"
#include <unistd.h>
#include <sched.h>
#include <sys/mman.h>
-#ifndef HAVE_ON_EXIT_SUPPORT
+#ifndef HAVE_ON_EXIT
#ifndef ATEXIT_MAX
#define ATEXIT_MAX 32
#endif
@@ -66,25 +65,31 @@ struct perf_record {
struct perf_tool tool;
struct perf_record_opts opts;
u64 bytes_written;
- struct perf_data_file file;
+ const char *output_name;
struct perf_evlist *evlist;
struct perf_session *session;
const char *progname;
+ int output;
+ unsigned int page_size;
int realtime_prio;
bool no_buildid;
bool no_buildid_cache;
long samples;
+ off_t post_processing_offset;
};
-static int do_write_output(struct perf_record *rec, void *buf, size_t size)
+static void advance_output(struct perf_record *rec, size_t size)
{
- struct perf_data_file *file = &rec->file;
+ rec->bytes_written += size;
+}
+static int write_output(struct perf_record *rec, void *buf, size_t size)
+{
while (size) {
- ssize_t ret = write(file->fd, buf, size);
+ int ret = write(rec->output, buf, size);
if (ret < 0) {
- pr_err("failed to write perf data, error: %m\n");
+ pr_err("failed to write\n");
return -1;
}
@@ -97,11 +102,6 @@ static int do_write_output(struct perf_record *rec, void *buf, size_t size)
return 0;
}
-static int write_output(struct perf_record *rec, void *buf, size_t size)
-{
- return do_write_output(rec, buf, size);
-}
-
static int process_synthesized_event(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample __maybe_unused,
@@ -119,7 +119,7 @@ static int perf_record__mmap_read(struct perf_record *rec,
{
unsigned int head = perf_mmap__read_head(md);
unsigned int old = md->prev;
- unsigned char *data = md->base + page_size;
+ unsigned char *data = md->base + rec->page_size;
unsigned long size;
void *buf;
int rc = 0;
@@ -234,6 +234,10 @@ try_again:
"or try again with a smaller value of -m/--mmap_pages.\n"
"(current value: %d)\n", opts->mmap_pages);
rc = -errno;
+ } else if (!is_power_of_2(opts->mmap_pages) &&
+ (opts->mmap_pages != UINT_MAX)) {
+ pr_err("--mmap_pages/-m value must be a power of two.");
+ rc = -EINVAL;
} else {
pr_err("failed to mmap with %d (%s)\n", errno, strerror(errno));
rc = -errno;
@@ -249,34 +253,31 @@ out:
static int process_buildids(struct perf_record *rec)
{
- struct perf_data_file *file = &rec->file;
- struct perf_session *session = rec->session;
- u64 start = session->header.data_offset;
+ u64 size = lseek(rec->output, 0, SEEK_CUR);
- u64 size = lseek(file->fd, 0, SEEK_CUR);
if (size == 0)
return 0;
- return __perf_session__process_events(session, start,
- size - start,
+ rec->session->fd = rec->output;
+ return __perf_session__process_events(rec->session, rec->post_processing_offset,
+ size - rec->post_processing_offset,
size, &build_id__mark_dso_hit_ops);
}
static void perf_record__exit(int status, void *arg)
{
struct perf_record *rec = arg;
- struct perf_data_file *file = &rec->file;
if (status != 0)
return;
- if (!file->is_pipe) {
+ if (!rec->opts.pipe_output) {
rec->session->header.data_size += rec->bytes_written;
if (!rec->no_buildid)
process_buildids(rec);
perf_session__write_header(rec->session, rec->evlist,
- file->fd, true);
+ rec->output, true);
perf_session__delete(rec->session);
perf_evlist__delete(rec->evlist);
symbol__exit();
@@ -342,47 +343,64 @@ out:
return rc;
}
-static void perf_record__init_features(struct perf_record *rec)
-{
- struct perf_evlist *evsel_list = rec->evlist;
- struct perf_session *session = rec->session;
- int feat;
-
- for (feat = HEADER_FIRST_FEATURE; feat < HEADER_LAST_FEATURE; feat++)
- perf_header__set_feat(&session->header, feat);
-
- if (rec->no_buildid)
- perf_header__clear_feat(&session->header, HEADER_BUILD_ID);
-
- if (!have_tracepoints(&evsel_list->entries))
- perf_header__clear_feat(&session->header, HEADER_TRACING_DATA);
-
- if (!rec->opts.branch_stack)
- perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK);
-}
-
static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
{
- int err;
+ struct stat st;
+ int flags;
+ int err, output, feat;
unsigned long waking = 0;
const bool forks = argc > 0;
struct machine *machine;
struct perf_tool *tool = &rec->tool;
struct perf_record_opts *opts = &rec->opts;
struct perf_evlist *evsel_list = rec->evlist;
- struct perf_data_file *file = &rec->file;
+ const char *output_name = rec->output_name;
struct perf_session *session;
bool disabled = false;
rec->progname = argv[0];
+ rec->page_size = sysconf(_SC_PAGE_SIZE);
+
on_exit(perf_record__sig_exit, rec);
signal(SIGCHLD, sig_handler);
signal(SIGINT, sig_handler);
signal(SIGUSR1, sig_handler);
signal(SIGTERM, sig_handler);
- session = perf_session__new(file, false, NULL);
+ if (!output_name) {
+ if (!fstat(STDOUT_FILENO, &st) && S_ISFIFO(st.st_mode))
+ opts->pipe_output = true;
+ else
+ rec->output_name = output_name = "perf.data";
+ }
+ if (output_name) {
+ if (!strcmp(output_name, "-"))
+ opts->pipe_output = true;
+ else if (!stat(output_name, &st) && st.st_size) {
+ char oldname[PATH_MAX];
+ snprintf(oldname, sizeof(oldname), "%s.old",
+ output_name);
+ unlink(oldname);
+ rename(output_name, oldname);
+ }
+ }
+
+ flags = O_CREAT|O_RDWR|O_TRUNC;
+
+ if (opts->pipe_output)
+ output = STDOUT_FILENO;
+ else
+ output = open(output_name, flags, S_IRUSR | S_IWUSR);
+ if (output < 0) {
+ perror("failed to create output file");
+ return -1;
+ }
+
+ rec->output = output;
+
+ session = perf_session__new(output_name, O_WRONLY,
+ true, false, NULL);
if (session == NULL) {
pr_err("Not enough memory for reading perf file header\n");
return -1;
@@ -390,11 +408,21 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
rec->session = session;
- perf_record__init_features(rec);
+ for (feat = HEADER_FIRST_FEATURE; feat < HEADER_LAST_FEATURE; feat++)
+ perf_header__set_feat(&session->header, feat);
+
+ if (rec->no_buildid)
+ perf_header__clear_feat(&session->header, HEADER_BUILD_ID);
+
+ if (!have_tracepoints(&evsel_list->entries))
+ perf_header__clear_feat(&session->header, HEADER_TRACING_DATA);
+
+ if (!rec->opts.branch_stack)
+ perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK);
if (forks) {
err = perf_evlist__prepare_workload(evsel_list, &opts->target,
- argv, file->is_pipe,
+ argv, opts->pipe_output,
true);
if (err < 0) {
pr_err("Couldn't run the workload!\n");
@@ -415,13 +443,13 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
*/
on_exit(perf_record__exit, rec);
- if (file->is_pipe) {
- err = perf_header__write_pipe(file->fd);
+ if (opts->pipe_output) {
+ err = perf_header__write_pipe(output);
if (err < 0)
goto out_delete_session;
} else {
err = perf_session__write_header(session, evsel_list,
- file->fd, false);
+ output, false);
if (err < 0)
goto out_delete_session;
}
@@ -434,9 +462,11 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
goto out_delete_session;
}
+ rec->post_processing_offset = lseek(output, 0, SEEK_CUR);
+
machine = &session->machines.host;
- if (file->is_pipe) {
+ if (opts->pipe_output) {
err = perf_event__synthesize_attrs(tool, session,
process_synthesized_event);
if (err < 0) {
@@ -453,13 +483,13 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
* return this more properly and also
* propagate errors that now are calling die()
*/
- err = perf_event__synthesize_tracing_data(tool, file->fd, evsel_list,
+ err = perf_event__synthesize_tracing_data(tool, output, evsel_list,
process_synthesized_event);
if (err <= 0) {
pr_err("Couldn't record tracing data.\n");
goto out_delete_session;
}
- rec->bytes_written += err;
+ advance_output(rec, err);
}
}
@@ -485,8 +515,16 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
perf_event__synthesize_guest_os, tool);
}
- err = __machine__synthesize_threads(machine, tool, &opts->target, evsel_list->threads,
- process_synthesized_event, opts->sample_address);
+ if (perf_target__has_task(&opts->target))
+ err = perf_event__synthesize_thread_map(tool, evsel_list->threads,
+ process_synthesized_event,
+ machine);
+ else if (perf_target__has_cpu(&opts->target))
+ err = perf_event__synthesize_threads(tool, process_synthesized_event,
+ machine);
+ else /* command specified */
+ err = 0;
+
if (err != 0)
goto out_delete_session;
@@ -506,7 +544,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
* (apart from group members) have enable_on_exec=1 set,
* so don't spoil it by prematurely enabling them.
*/
- if (!target__none(&opts->target))
+ if (!perf_target__none(&opts->target))
perf_evlist__enable(evsel_list);
/*
@@ -535,7 +573,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
* die with the process and we wait for that. Thus no need to
* disable events in this case.
*/
- if (done && !disabled && !target__none(&opts->target)) {
+ if (done && !disabled && !perf_target__none(&opts->target)) {
perf_evlist__disable(evsel_list);
disabled = true;
}
@@ -552,7 +590,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
fprintf(stderr,
"[ perf record: Captured and wrote %.3f MB %s (~%" PRIu64 " samples) ]\n",
(double)rec->bytes_written / 1024.0 / 1024.0,
- file->path,
+ output_name,
rec->bytes_written / 24);
return 0;
@@ -580,9 +618,6 @@ static const struct branch_mode branch_modes[] = {
BRANCH_OPT("any_call", PERF_SAMPLE_BRANCH_ANY_CALL),
BRANCH_OPT("any_ret", PERF_SAMPLE_BRANCH_ANY_RETURN),
BRANCH_OPT("ind_call", PERF_SAMPLE_BRANCH_IND_CALL),
- BRANCH_OPT("abort_tx", PERF_SAMPLE_BRANCH_ABORT_TX),
- BRANCH_OPT("in_tx", PERF_SAMPLE_BRANCH_IN_TX),
- BRANCH_OPT("no_tx", PERF_SAMPLE_BRANCH_NO_TX),
BRANCH_END
};
@@ -649,7 +684,7 @@ error:
return ret;
}
-#ifdef HAVE_LIBUNWIND_SUPPORT
+#ifdef LIBUNWIND_SUPPORT
static int get_stack_size(char *str, unsigned long *_size)
{
char *endptr;
@@ -675,7 +710,7 @@ static int get_stack_size(char *str, unsigned long *_size)
max_size, str);
return -1;
}
-#endif /* HAVE_LIBUNWIND_SUPPORT */
+#endif /* LIBUNWIND_SUPPORT */
int record_parse_callchain(const char *arg, struct perf_record_opts *opts)
{
@@ -704,7 +739,7 @@ int record_parse_callchain(const char *arg, struct perf_record_opts *opts)
"needed for -g fp\n");
break;
-#ifdef HAVE_LIBUNWIND_SUPPORT
+#ifdef LIBUNWIND_SUPPORT
/* Dwarf style */
} else if (!strncmp(name, "dwarf", sizeof("dwarf"))) {
const unsigned long default_stack_dump_size = 8192;
@@ -720,7 +755,7 @@ int record_parse_callchain(const char *arg, struct perf_record_opts *opts)
ret = get_stack_size(tok, &size);
opts->stack_dump_size = size;
}
-#endif /* HAVE_LIBUNWIND_SUPPORT */
+#endif /* LIBUNWIND_SUPPORT */
} else {
pr_err("callchain: Unknown --call-graph option "
"value: %s\n", arg);
@@ -806,7 +841,7 @@ static struct perf_record record = {
#define CALLCHAIN_HELP "setup and enables call-graph (stack chain/backtrace) recording: "
-#ifdef HAVE_LIBUNWIND_SUPPORT
+#ifdef LIBUNWIND_SUPPORT
const char record_callchain_help[] = CALLCHAIN_HELP "fp dwarf";
#else
const char record_callchain_help[] = CALLCHAIN_HELP "fp";
@@ -840,14 +875,13 @@ const struct option record_options[] = {
OPT_STRING('C', "cpu", &record.opts.target.cpu_list, "cpu",
"list of cpus to monitor"),
OPT_U64('c', "count", &record.opts.user_interval, "event period to sample"),
- OPT_STRING('o', "output", &record.file.path, "file",
+ OPT_STRING('o', "output", &record.output_name, "file",
"output file name"),
OPT_BOOLEAN('i', "no-inherit", &record.opts.no_inherit,
"child tasks do not inherit counters"),
OPT_UINTEGER('F', "freq", &record.opts.user_freq, "profile at this frequency"),
- OPT_CALLBACK('m', "mmap-pages", &record.opts.mmap_pages, "pages",
- "number of mmap data pages",
- perf_evlist__parse_mmap_pages),
+ OPT_UINTEGER('m', "mmap-pages", &record.opts.mmap_pages,
+ "number of mmap data pages"),
OPT_BOOLEAN(0, "group", &record.opts.group,
"put the counters into a counter group"),
OPT_CALLBACK_NOOPT('g', NULL, &record.opts,
@@ -886,10 +920,6 @@ const struct option record_options[] = {
parse_branch_stack),
OPT_BOOLEAN('W', "weight", &record.opts.sample_weight,
"sample by weight (on special events only)"),
- OPT_BOOLEAN(0, "transaction", &record.opts.sample_transaction,
- "sample transaction flags (special events only)"),
- OPT_BOOLEAN(0, "force-per-cpu", &record.opts.target.force_per_cpu,
- "force the use of per-cpu mmaps"),
OPT_END()
};
@@ -908,7 +938,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
argc = parse_options(argc, argv, record_options, record_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
- if (!argc && target__none(&rec->opts.target))
+ if (!argc && perf_target__none(&rec->opts.target))
usage_with_options(record_usage, record_options);
if (nr_cgroups && !rec->opts.target.system_wide) {
@@ -938,17 +968,17 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
goto out_symbol_exit;
}
- err = target__validate(&rec->opts.target);
+ err = perf_target__validate(&rec->opts.target);
if (err) {
- target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
+ perf_target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
ui__warning("%s", errbuf);
}
- err = target__parse_uid(&rec->opts.target);
+ err = perf_target__parse_uid(&rec->opts.target);
if (err) {
int saved_errno = errno;
- target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
+ perf_target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
ui__error("%s", errbuf);
err = -saved_errno;
@@ -959,7 +989,20 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused)
if (perf_evlist__create_maps(evsel_list, &rec->opts.target) < 0)
usage_with_options(record_usage, record_options);
- if (perf_record_opts__config(&rec->opts)) {
+ if (rec->opts.user_interval != ULLONG_MAX)
+ rec->opts.default_interval = rec->opts.user_interval;
+ if (rec->opts.user_freq != UINT_MAX)
+ rec->opts.freq = rec->opts.user_freq;
+
+ /*
+ * User specified count overrides default frequency.
+ */
+ if (rec->opts.default_interval)
+ rec->opts.freq = 0;
+ else if (rec->opts.freq) {
+ rec->opts.default_interval = rec->opts.freq;
+ } else {
+ ui__error("frequency and count are zero, aborting\n");
err = -EINVAL;
goto out_free_fd;
}
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 8cf8e66..72eae74 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -33,10 +33,8 @@
#include "util/thread.h"
#include "util/sort.h"
#include "util/hist.h"
-#include "util/data.h"
#include "arch/common.h"
-#include <dlfcn.h>
#include <linux/bitmap.h>
struct perf_report {
@@ -49,7 +47,6 @@ struct perf_report {
bool show_threads;
bool inverted_callchain;
bool mem_mode;
- int max_stack;
struct perf_read_values show_threads_values;
const char *pretty_printing_style;
const char *cpu_list;
@@ -91,8 +88,7 @@ static int perf_report__add_mem_hist_entry(struct perf_tool *tool,
if ((sort__has_parent || symbol_conf.use_callchain) &&
sample->callchain) {
err = machine__resolve_callchain(machine, evsel, al->thread,
- sample, &parent, al,
- rep->max_stack);
+ sample, &parent, al);
if (err)
return err;
}
@@ -115,8 +111,7 @@ static int perf_report__add_mem_hist_entry(struct perf_tool *tool,
* and this is indirectly achieved by passing period=weight here
* and the he_stat__add_period() function.
*/
- he = __hists__add_entry(&evsel->hists, al, parent, NULL, mi,
- cost, cost, 0);
+ he = __hists__add_mem_entry(&evsel->hists, al, parent, mi, cost, cost);
if (!he)
return -ENOMEM;
@@ -184,8 +179,7 @@ static int perf_report__add_branch_hist_entry(struct perf_tool *tool,
if ((sort__has_parent || symbol_conf.use_callchain)
&& sample->callchain) {
err = machine__resolve_callchain(machine, evsel, al->thread,
- sample, &parent, al,
- rep->max_stack);
+ sample, &parent, al);
if (err)
return err;
}
@@ -201,16 +195,12 @@ static int perf_report__add_branch_hist_entry(struct perf_tool *tool,
err = -ENOMEM;
- /* overwrite the 'al' to branch-to info */
- al->map = bi[i].to.map;
- al->sym = bi[i].to.sym;
- al->addr = bi[i].to.addr;
/*
* The report shows the percentage of total branches captured
* and not events sampled. Thus we use a pseudo period of 1.
*/
- he = __hists__add_entry(&evsel->hists, al, parent, &bi[i], NULL,
- 1, 1, 0);
+ he = __hists__add_branch_entry(&evsel->hists, al, parent,
+ &bi[i], 1, 1);
if (he) {
struct annotation *notes;
bx = he->branch_info;
@@ -252,28 +242,24 @@ out:
return err;
}
-static int perf_evsel__add_hist_entry(struct perf_tool *tool,
- struct perf_evsel *evsel,
+static int perf_evsel__add_hist_entry(struct perf_evsel *evsel,
struct addr_location *al,
struct perf_sample *sample,
struct machine *machine)
{
- struct perf_report *rep = container_of(tool, struct perf_report, tool);
struct symbol *parent = NULL;
int err = 0;
struct hist_entry *he;
if ((sort__has_parent || symbol_conf.use_callchain) && sample->callchain) {
err = machine__resolve_callchain(machine, evsel, al->thread,
- sample, &parent, al,
- rep->max_stack);
+ sample, &parent, al);
if (err)
return err;
}
- he = __hists__add_entry(&evsel->hists, al, parent, NULL, NULL,
- sample->period, sample->weight,
- sample->transaction);
+ he = __hists__add_entry(&evsel->hists, al, parent, sample->period,
+ sample->weight);
if (he == NULL)
return -ENOMEM;
@@ -344,8 +330,7 @@ static int process_sample_event(struct perf_tool *tool,
if (al.map != NULL)
al.map->dso->hit = 1;
- ret = perf_evsel__add_hist_entry(tool, evsel, &al, sample,
- machine);
+ ret = perf_evsel__add_hist_entry(evsel, &al, sample, machine);
if (ret < 0)
pr_debug("problem incrementing symbol period, skipping event\n");
}
@@ -379,11 +364,10 @@ static int process_read_event(struct perf_tool *tool,
/* For pipe mode, sample_type is not currently set */
static int perf_report__setup_sample_type(struct perf_report *rep)
{
- struct perf_session *session = rep->session;
- u64 sample_type = perf_evlist__combined_sample_type(session->evlist);
- bool is_pipe = perf_data_file__is_pipe(session->file);
+ struct perf_session *self = rep->session;
+ u64 sample_type = perf_evlist__combined_sample_type(self->evlist);
- if (!is_pipe && !(sample_type & PERF_SAMPLE_CALLCHAIN)) {
+ if (!self->fd_pipe && !(sample_type & PERF_SAMPLE_CALLCHAIN)) {
if (sort__has_parent) {
ui__error("Selected --sort parent, but no "
"callchain data. Did you call "
@@ -406,7 +390,7 @@ static int perf_report__setup_sample_type(struct perf_report *rep)
}
if (sort__mode == SORT_MODE__BRANCH) {
- if (!is_pipe &&
+ if (!self->fd_pipe &&
!(sample_type & PERF_SAMPLE_BRANCH_STACK)) {
ui__error("Selected -b but no branch data. "
"Did you call perf record without -b?\n");
@@ -423,14 +407,14 @@ static void sig_handler(int sig __maybe_unused)
}
static size_t hists__fprintf_nr_sample_events(struct perf_report *rep,
- struct hists *hists,
+ struct hists *self,
const char *evname, FILE *fp)
{
size_t ret;
char unit;
- unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
- u64 nr_events = hists->stats.total_period;
- struct perf_evsel *evsel = hists_to_evsel(hists);
+ unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE];
+ u64 nr_events = self->stats.total_period;
+ struct perf_evsel *evsel = hists_to_evsel(self);
char buf[512];
size_t size = sizeof(buf);
@@ -502,8 +486,6 @@ static int __cmd_report(struct perf_report *rep)
struct map *kernel_map;
struct kmap *kernel_kmap;
const char *help = "For a higher level overview, try: perf report --sort comm,dso";
- struct ui_progress prog;
- struct perf_data_file *file = session->file;
signal(SIGINT, sig_handler);
@@ -565,19 +547,13 @@ static int __cmd_report(struct perf_report *rep)
}
nr_samples = 0;
- list_for_each_entry(pos, &session->evlist->entries, node)
- nr_samples += pos->hists.nr_entries;
-
- ui_progress__init(&prog, nr_samples, "Merging related events...");
-
- nr_samples = 0;
list_for_each_entry(pos, &session->evlist->entries, node) {
struct hists *hists = &pos->hists;
if (pos->idx == 0)
hists->symbol_filter_str = rep->symbol_filter_str;
- hists__collapse_resort(hists, &prog);
+ hists__collapse_resort(hists);
nr_samples += hists->stats.nr_events[PERF_RECORD_SAMPLE];
/* Non-group events are considered as leader */
@@ -589,13 +565,12 @@ static int __cmd_report(struct perf_report *rep)
hists__link(leader_hists, hists);
}
}
- ui_progress__finish();
if (session_done())
return 0;
if (nr_samples == 0) {
- ui__error("The %s file has no samples!\n", file->path);
+ ui__error("The %s file has no samples!\n", session->filename);
return 0;
}
@@ -616,19 +591,8 @@ static int __cmd_report(struct perf_report *rep)
ret = 0;
} else if (use_browser == 2) {
- int (*hist_browser)(struct perf_evlist *,
- const char *,
- struct hist_browser_timer *,
- float min_pcnt);
-
- hist_browser = dlsym(perf_gtk_handle,
- "perf_evlist__gtk_browse_hists");
- if (hist_browser == NULL) {
- ui__error("GTK browser not found!\n");
- return ret;
- }
- hist_browser(session->evlist, help, NULL,
- rep->min_percent);
+ perf_evlist__gtk_browse_hists(session->evlist, help,
+ NULL, rep->min_percent);
}
} else
perf_evlist__tty_browse_hists(session->evlist, rep, help);
@@ -793,7 +757,6 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
.ordered_samples = true,
.ordering_requires_timestamps = true,
},
- .max_stack = PERF_MAX_STACK_DEPTH,
.pretty_printing_style = "normal",
};
const struct option options[] = {
@@ -824,7 +787,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
"sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline,"
" dso_to, dso_from, symbol_to, symbol_from, mispredict,"
" weight, local_weight, mem, symbol_daddr, dso_daddr, tlb, "
- "snoop, locked, abort, in_tx, transaction"),
+ "snoop, locked"),
OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
"Show sample percentage for different cpu modes"),
OPT_STRING('p', "parent", &parent_pattern, "regex",
@@ -834,10 +797,6 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order",
"Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit, callchain order, key (function or address). "
"Default: fractal,0.5,callee,function", &parse_callchain_opt, callchain_default_opt),
- OPT_INTEGER(0, "max-stack", &report.max_stack,
- "Set the maximum stack depth when parsing the callchain, "
- "anything beyond the specified depth will be ignored. "
- "Default: " __stringify(PERF_MAX_STACK_DEPTH)),
OPT_BOOLEAN('G', "inverted", &report.inverted_callchain,
"alias for inverted call graph"),
OPT_CALLBACK(0, "ignore-callees", NULL, "regex",
@@ -886,9 +845,6 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
"Don't show entries under that percent", parse_percent_limit),
OPT_END()
};
- struct perf_data_file file = {
- .mode = PERF_DATA_MODE_READ,
- };
perf_config(perf_report_config, &report);
@@ -911,11 +867,16 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
input_name = "perf.data";
}
- file.path = input_name;
- file.force = report.force;
+ if (strcmp(input_name, "-") != 0)
+ setup_browser(true);
+ else {
+ use_browser = 0;
+ perf_hpp__init();
+ }
repeat:
- session = perf_session__new(&file, false, &report.tool);
+ session = perf_session__new(input_name, O_RDONLY,
+ report.force, false, &report.tool);
if (session == NULL)
return -ENOMEM;
@@ -953,22 +914,8 @@ repeat:
sort_order = "local_weight,mem,sym,dso,symbol_daddr,dso_daddr,snoop,tlb,locked";
}
- if (setup_sorting() < 0) {
- parse_options_usage(report_usage, options, "s", 1);
- goto error;
- }
-
- if (parent_pattern != default_parent_pattern) {
- if (sort_dimension__add("parent") < 0)
- goto error;
- }
-
- if (strcmp(input_name, "-") != 0)
- setup_browser(true);
- else {
- use_browser = 0;
- perf_hpp__init();
- }
+ if (setup_sorting() < 0)
+ usage_with_options(report_usage, options);
/*
* Only in the TUI browser we are doing integrated annotation,
@@ -999,6 +946,11 @@ repeat:
if (symbol__init() < 0)
goto error;
+ if (parent_pattern != default_parent_pattern) {
+ if (sort_dimension__add("parent") < 0)
+ goto error;
+ }
+
if (argc) {
/*
* Special case: if there's an argument left then assume that
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 0f3c6551..d8c51b2 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -737,12 +737,12 @@ static int replay_fork_event(struct perf_sched *sched,
if (verbose) {
printf("fork event\n");
- printf("... parent: %s/%d\n", thread__comm_str(parent), parent->tid);
- printf("... child: %s/%d\n", thread__comm_str(child), child->tid);
+ printf("... parent: %s/%d\n", parent->comm, parent->tid);
+ printf("... child: %s/%d\n", child->comm, child->tid);
}
- register_pid(sched, parent->tid, thread__comm_str(parent));
- register_pid(sched, child->tid, thread__comm_str(child));
+ register_pid(sched, parent->tid, parent->comm);
+ register_pid(sched, child->tid, child->comm);
return 0;
}
@@ -1077,7 +1077,7 @@ static int latency_migrate_task_event(struct perf_sched *sched,
if (!atoms) {
if (thread_atoms_insert(sched, migrant))
return -1;
- register_pid(sched, migrant->tid, thread__comm_str(migrant));
+ register_pid(sched, migrant->tid, migrant->comm);
atoms = thread_atoms_search(&sched->atom_root, migrant, &sched->cmp_pid);
if (!atoms) {
pr_err("migration-event: Internal tree error");
@@ -1111,13 +1111,13 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_
/*
* Ignore idle threads:
*/
- if (!strcmp(thread__comm_str(work_list->thread), "swapper"))
+ if (!strcmp(work_list->thread->comm, "swapper"))
return;
sched->all_runtime += work_list->total_runtime;
sched->all_count += work_list->nb_atoms;
- ret = printf(" %s:%d ", thread__comm_str(work_list->thread), work_list->thread->tid);
+ ret = printf(" %s:%d ", work_list->thread->comm, work_list->thread->tid);
for (i = 0; i < 24 - ret; i++)
printf(" ");
@@ -1334,7 +1334,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
printf(" %12.6f secs ", (double)timestamp/1e9);
if (new_shortname) {
printf("%s => %s:%d\n",
- sched_in->shortname, thread__comm_str(sched_in), sched_in->tid);
+ sched_in->shortname, sched_in->comm, sched_in->tid);
} else {
printf("\n");
}
@@ -1427,8 +1427,8 @@ static int perf_sched__process_tracepoint_sample(struct perf_tool *tool __maybe_
evsel->hists.stats.total_period += sample->period;
hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
- if (evsel->handler != NULL) {
- tracepoint_handler f = evsel->handler;
+ if (evsel->handler.func != NULL) {
+ tracepoint_handler f = evsel->handler.func;
err = f(tool, evsel, sample, machine);
}
@@ -1446,12 +1446,8 @@ static int perf_sched__read_events(struct perf_sched *sched,
{ "sched:sched_migrate_task", process_sched_migrate_task_event, },
};
struct perf_session *session;
- struct perf_data_file file = {
- .path = input_name,
- .mode = PERF_DATA_MODE_READ,
- };
- session = perf_session__new(&file, false, &sched->tool);
+ session = perf_session__new(input_name, O_RDONLY, 0, false, &sched->tool);
if (session == NULL) {
pr_debug("No Memory for session\n");
return -1;
@@ -1655,27 +1651,29 @@ static int __cmd_record(int argc, const char **argv)
return cmd_record(i, rec_argv, NULL);
}
+static const char default_sort_order[] = "avg, max, switch, runtime";
+static struct perf_sched sched = {
+ .tool = {
+ .sample = perf_sched__process_tracepoint_sample,
+ .comm = perf_event__process_comm,
+ .lost = perf_event__process_lost,
+ .fork = perf_sched__process_fork_event,
+ .ordered_samples = true,
+ },
+ .cmp_pid = LIST_HEAD_INIT(sched.cmp_pid),
+ .sort_list = LIST_HEAD_INIT(sched.sort_list),
+ .start_work_mutex = PTHREAD_MUTEX_INITIALIZER,
+ .work_done_wait_mutex = PTHREAD_MUTEX_INITIALIZER,
+ .curr_pid = { [0 ... MAX_CPUS - 1] = -1 },
+ .sort_order = default_sort_order,
+ .replay_repeat = 10,
+ .profile_cpu = -1,
+ .next_shortname1 = 'A',
+ .next_shortname2 = '0',
+};
+
int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
{
- const char default_sort_order[] = "avg, max, switch, runtime";
- struct perf_sched sched = {
- .tool = {
- .sample = perf_sched__process_tracepoint_sample,
- .comm = perf_event__process_comm,
- .lost = perf_event__process_lost,
- .fork = perf_sched__process_fork_event,
- .ordered_samples = true,
- },
- .cmp_pid = LIST_HEAD_INIT(sched.cmp_pid),
- .sort_list = LIST_HEAD_INIT(sched.sort_list),
- .start_work_mutex = PTHREAD_MUTEX_INITIALIZER,
- .work_done_wait_mutex = PTHREAD_MUTEX_INITIALIZER,
- .sort_order = default_sort_order,
- .replay_repeat = 10,
- .profile_cpu = -1,
- .next_shortname1 = 'A',
- .next_shortname2 = '0',
- };
const struct option latency_options[] = {
OPT_STRING('s', "sort", &sched.sort_order, "key[,key2...]",
"sort by key(s): runtime, switch, avg, max"),
@@ -1731,10 +1729,6 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
.switch_event = replay_switch_event,
.fork_event = replay_fork_event,
};
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(sched.curr_pid); i++)
- sched.curr_pid[i] = -1;
argc = parse_options(argc, argv, sched_options, sched_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index baf1798..9c333ff 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -15,7 +15,6 @@
#include "util/evlist.h"
#include "util/evsel.h"
#include "util/sort.h"
-#include "util/data.h"
#include <linux/bitmap.h>
static char const *script_name;
@@ -229,24 +228,6 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
return 0;
}
-static void set_print_ip_opts(struct perf_event_attr *attr)
-{
- unsigned int type = attr->type;
-
- output[type].print_ip_opts = 0;
- if (PRINT_FIELD(IP))
- output[type].print_ip_opts |= PRINT_IP_OPT_IP;
-
- if (PRINT_FIELD(SYM))
- output[type].print_ip_opts |= PRINT_IP_OPT_SYM;
-
- if (PRINT_FIELD(DSO))
- output[type].print_ip_opts |= PRINT_IP_OPT_DSO;
-
- if (PRINT_FIELD(SYMOFFSET))
- output[type].print_ip_opts |= PRINT_IP_OPT_SYMOFFSET;
-}
-
/*
* verify all user requested events exist and the samples
* have the expected data
@@ -255,6 +236,7 @@ static int perf_session__check_output_opt(struct perf_session *session)
{
int j;
struct perf_evsel *evsel;
+ struct perf_event_attr *attr;
for (j = 0; j < PERF_TYPE_MAX; ++j) {
evsel = perf_session__find_first_evtype(session, j);
@@ -277,7 +259,20 @@ static int perf_session__check_output_opt(struct perf_session *session)
if (evsel == NULL)
continue;
- set_print_ip_opts(&evsel->attr);
+ attr = &evsel->attr;
+
+ output[j].print_ip_opts = 0;
+ if (PRINT_FIELD(IP))
+ output[j].print_ip_opts |= PRINT_IP_OPT_IP;
+
+ if (PRINT_FIELD(SYM))
+ output[j].print_ip_opts |= PRINT_IP_OPT_SYM;
+
+ if (PRINT_FIELD(DSO))
+ output[j].print_ip_opts |= PRINT_IP_OPT_DSO;
+
+ if (PRINT_FIELD(SYMOFFSET))
+ output[j].print_ip_opts |= PRINT_IP_OPT_SYMOFFSET;
}
return 0;
@@ -295,11 +290,11 @@ static void print_sample_start(struct perf_sample *sample,
if (PRINT_FIELD(COMM)) {
if (latency_format)
- printf("%8.8s ", thread__comm_str(thread));
+ printf("%8.8s ", thread->comm);
else if (PRINT_FIELD(IP) && symbol_conf.use_callchain)
- printf("%s ", thread__comm_str(thread));
+ printf("%s ", thread->comm);
else
- printf("%16s ", thread__comm_str(thread));
+ printf("%16s ", thread->comm);
}
if (PRINT_FIELD(PID) && PRINT_FIELD(TID))
@@ -414,9 +409,7 @@ static void print_sample_bts(union perf_event *event,
printf(" => ");
/* print branch_to information */
- if (PRINT_FIELD(ADDR) ||
- ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) &&
- !output[attr->type].user_set))
+ if (PRINT_FIELD(ADDR))
print_sample_addr(event, sample, machine, thread, attr);
printf("\n");
@@ -546,51 +539,32 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
return 0;
}
-struct perf_script {
- struct perf_tool tool;
- struct perf_session *session;
+static struct perf_tool perf_script = {
+ .sample = process_sample_event,
+ .mmap = perf_event__process_mmap,
+ .mmap2 = perf_event__process_mmap2,
+ .comm = perf_event__process_comm,
+ .exit = perf_event__process_exit,
+ .fork = perf_event__process_fork,
+ .attr = perf_event__process_attr,
+ .tracing_data = perf_event__process_tracing_data,
+ .build_id = perf_event__process_build_id,
+ .ordered_samples = true,
+ .ordering_requires_timestamps = true,
};
-static int process_attr(struct perf_tool *tool, union perf_event *event,
- struct perf_evlist **pevlist)
-{
- struct perf_script *scr = container_of(tool, struct perf_script, tool);
- struct perf_evlist *evlist;
- struct perf_evsel *evsel, *pos;
- int err;
-
- err = perf_event__process_attr(tool, event, pevlist);
- if (err)
- return err;
-
- evlist = *pevlist;
- evsel = perf_evlist__last(*pevlist);
-
- if (evsel->attr.type >= PERF_TYPE_MAX)
- return 0;
-
- list_for_each_entry(pos, &evlist->entries, node) {
- if (pos->attr.type == evsel->attr.type && pos != evsel)
- return 0;
- }
-
- set_print_ip_opts(&evsel->attr);
-
- return perf_evsel__check_attr(evsel, scr->session);
-}
-
static void sig_handler(int sig __maybe_unused)
{
session_done = 1;
}
-static int __cmd_script(struct perf_script *script)
+static int __cmd_script(struct perf_session *session)
{
int ret;
signal(SIGINT, sig_handler);
- ret = perf_session__process_events(script->session, &script->tool);
+ ret = perf_session__process_events(session, &perf_script);
if (debug_mode)
pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered);
@@ -1139,14 +1113,10 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
char scripts_path[MAXPATHLEN], lang_path[MAXPATHLEN];
DIR *scripts_dir, *lang_dir;
struct perf_session *session;
- struct perf_data_file file = {
- .path = input_name,
- .mode = PERF_DATA_MODE_READ,
- };
char *temp;
int i = 0;
- session = perf_session__new(&file, false, NULL);
+ session = perf_session__new(input_name, O_RDONLY, 0, false, NULL);
if (!session)
return -1;
@@ -1296,21 +1266,6 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
char *script_path = NULL;
const char **__argv;
int i, j, err;
- struct perf_script script = {
- .tool = {
- .sample = process_sample_event,
- .mmap = perf_event__process_mmap,
- .mmap2 = perf_event__process_mmap2,
- .comm = perf_event__process_comm,
- .exit = perf_event__process_exit,
- .fork = perf_event__process_fork,
- .attr = process_attr,
- .tracing_data = perf_event__process_tracing_data,
- .build_id = perf_event__process_build_id,
- .ordered_samples = true,
- .ordering_requires_timestamps = true,
- },
- };
const struct option options[] = {
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
"dump raw trace in ASCII"),
@@ -1362,17 +1317,12 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
"perf script [<options>] <top-script> [script-args]",
NULL
};
- struct perf_data_file file = {
- .mode = PERF_DATA_MODE_READ,
- };
setup_scripting();
argc = parse_options(argc, argv, options, script_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
- file.path = input_name;
-
if (argc > 1 && !strncmp(argv[0], "rec", strlen("rec"))) {
rec_script_path = get_script_path(argv[1], RECORD_SUFFIX);
if (!rec_script_path)
@@ -1536,12 +1486,11 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
if (!script_name)
setup_pager();
- session = perf_session__new(&file, false, &script.tool);
+ session = perf_session__new(input_name, O_RDONLY, 0, false,
+ &perf_script);
if (session == NULL)
return -ENOMEM;
- script.session = session;
-
if (cpu_list) {
if (perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap))
return -1;
@@ -1565,7 +1514,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
return -1;
}
- input = open(file.path, O_RDONLY); /* input_name */
+ input = open(session->filename, O_RDONLY); /* input_name */
if (input < 0) {
perror("failed to open file");
return -1;
@@ -1605,7 +1554,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
if (err < 0)
goto out;
- err = __cmd_script(&script);
+ err = __cmd_script(session);
perf_session__delete(session);
cleanup_scripting();
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index ee0d565..5098f14 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -46,7 +46,6 @@
#include "util/util.h"
#include "util/parse-options.h"
#include "util/parse-events.h"
-#include "util/pmu.h"
#include "util/event.h"
#include "util/evlist.h"
#include "util/evsel.h"
@@ -71,44 +70,9 @@ static void print_counter_aggr(struct perf_evsel *counter, char *prefix);
static void print_counter(struct perf_evsel *counter, char *prefix);
static void print_aggr(char *prefix);
-/* Default events used for perf stat -T */
-static const char * const transaction_attrs[] = {
- "task-clock",
- "{"
- "instructions,"
- "cycles,"
- "cpu/cycles-t/,"
- "cpu/tx-start/,"
- "cpu/el-start/,"
- "cpu/cycles-ct/"
- "}"
-};
-
-/* More limited version when the CPU does not have all events. */
-static const char * const transaction_limited_attrs[] = {
- "task-clock",
- "{"
- "instructions,"
- "cycles,"
- "cpu/cycles-t/,"
- "cpu/tx-start/"
- "}"
-};
-
-/* must match transaction_attrs and the beginning limited_attrs */
-enum {
- T_TASK_CLOCK,
- T_INSTRUCTIONS,
- T_CYCLES,
- T_CYCLES_IN_TX,
- T_TRANSACTION_START,
- T_ELISION_START,
- T_CYCLES_IN_TX_CP,
-};
-
static struct perf_evlist *evsel_list;
-static struct target target = {
+static struct perf_target target = {
.uid = UINT_MAX,
};
@@ -126,7 +90,6 @@ static enum aggr_mode aggr_mode = AGGR_GLOBAL;
static volatile pid_t child_pid = -1;
static bool null_run = false;
static int detailed_run = 0;
-static bool transaction_run;
static bool big_num = true;
static int big_num_opt = -1;
static const char *csv_sep = NULL;
@@ -251,10 +214,7 @@ static struct stats runtime_l1_icache_stats[MAX_NR_CPUS];
static struct stats runtime_ll_cache_stats[MAX_NR_CPUS];
static struct stats runtime_itlb_cache_stats[MAX_NR_CPUS];
static struct stats runtime_dtlb_cache_stats[MAX_NR_CPUS];
-static struct stats runtime_cycles_in_tx_stats[MAX_NR_CPUS];
static struct stats walltime_nsecs_stats;
-static struct stats runtime_transaction_stats[MAX_NR_CPUS];
-static struct stats runtime_elision_stats[MAX_NR_CPUS];
static void perf_stat__reset_stats(struct perf_evlist *evlist)
{
@@ -276,11 +236,6 @@ static void perf_stat__reset_stats(struct perf_evlist *evlist)
memset(runtime_ll_cache_stats, 0, sizeof(runtime_ll_cache_stats));
memset(runtime_itlb_cache_stats, 0, sizeof(runtime_itlb_cache_stats));
memset(runtime_dtlb_cache_stats, 0, sizeof(runtime_dtlb_cache_stats));
- memset(runtime_cycles_in_tx_stats, 0,
- sizeof(runtime_cycles_in_tx_stats));
- memset(runtime_transaction_stats, 0,
- sizeof(runtime_transaction_stats));
- memset(runtime_elision_stats, 0, sizeof(runtime_elision_stats));
memset(&walltime_nsecs_stats, 0, sizeof(walltime_nsecs_stats));
}
@@ -294,10 +249,11 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
attr->inherit = !no_inherit;
- if (target__has_cpu(&target))
+ if (perf_target__has_cpu(&target))
return perf_evsel__open_per_cpu(evsel, perf_evsel__cpus(evsel));
- if (!target__has_task(&target) && perf_evsel__is_group_leader(evsel)) {
+ if (!perf_target__has_task(&target) &&
+ perf_evsel__is_group_leader(evsel)) {
attr->disabled = 1;
if (!initial_delay)
attr->enable_on_exec = 1;
@@ -318,29 +274,6 @@ static inline int nsec_counter(struct perf_evsel *evsel)
return 0;
}
-static struct perf_evsel *nth_evsel(int n)
-{
- static struct perf_evsel **array;
- static int array_len;
- struct perf_evsel *ev;
- int j;
-
- /* Assumes this only called when evsel_list does not change anymore. */
- if (!array) {
- list_for_each_entry(ev, &evsel_list->entries, node)
- array_len++;
- array = malloc(array_len * sizeof(void *));
- if (!array)
- exit(ENOMEM);
- j = 0;
- list_for_each_entry(ev, &evsel_list->entries, node)
- array[j++] = ev;
- }
- if (n < array_len)
- return array[n];
- return NULL;
-}
-
/*
* Update various tracking values we maintain to print
* more semantic information such as miss/hit ratios,
@@ -352,15 +285,6 @@ static void update_shadow_stats(struct perf_evsel *counter, u64 *count)
update_stats(&runtime_nsecs_stats[0], count[0]);
else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
update_stats(&runtime_cycles_stats[0], count[0]);
- else if (transaction_run &&
- perf_evsel__cmp(counter, nth_evsel(T_CYCLES_IN_TX)))
- update_stats(&runtime_cycles_in_tx_stats[0], count[0]);
- else if (transaction_run &&
- perf_evsel__cmp(counter, nth_evsel(T_TRANSACTION_START)))
- update_stats(&runtime_transaction_stats[0], count[0]);
- else if (transaction_run &&
- perf_evsel__cmp(counter, nth_evsel(T_ELISION_START)))
- update_stats(&runtime_elision_stats[0], count[0]);
else if (perf_evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_FRONTEND))
update_stats(&runtime_stalled_cycles_front_stats[0], count[0]);
else if (perf_evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_BACKEND))
@@ -705,13 +629,10 @@ static void nsec_printout(int cpu, int nr, struct perf_evsel *evsel, double avg)
{
double msecs = avg / 1e6;
const char *fmt = csv_output ? "%.6f%s%s" : "%18.6f%s%-25s";
- char name[25];
aggr_printout(evsel, cpu, nr);
- scnprintf(name, sizeof(name), "%s%s",
- perf_evsel__name(evsel), csv_output ? "" : " (msec)");
- fprintf(output, fmt, msecs, csv_sep, name);
+ fprintf(output, fmt, msecs, csv_sep, perf_evsel__name(evsel));
if (evsel->cgrp)
fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
@@ -907,7 +828,7 @@ static void print_ll_cache_misses(int cpu,
static void abs_printout(int cpu, int nr, struct perf_evsel *evsel, double avg)
{
- double total, ratio = 0.0, total2;
+ double total, ratio = 0.0;
const char *fmt;
if (csv_output)
@@ -932,10 +853,11 @@ static void abs_printout(int cpu, int nr, struct perf_evsel *evsel, double avg)
if (perf_evsel__match(evsel, HARDWARE, HW_INSTRUCTIONS)) {
total = avg_stats(&runtime_cycles_stats[cpu]);
- if (total) {
+ if (total)
ratio = avg / total;
- fprintf(output, " # %5.2f insns per cycle ", ratio);
- }
+
+ fprintf(output, " # %5.2f insns per cycle ", ratio);
+
total = avg_stats(&runtime_stalled_cycles_front_stats[cpu]);
total = max(total, avg_stats(&runtime_stalled_cycles_back_stats[cpu]));
@@ -998,47 +920,10 @@ static void abs_printout(int cpu, int nr, struct perf_evsel *evsel, double avg)
} else if (perf_evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) {
total = avg_stats(&runtime_nsecs_stats[cpu]);
- if (total) {
- ratio = avg / total;
- fprintf(output, " # %8.3f GHz ", ratio);
- }
- } else if (transaction_run &&
- perf_evsel__cmp(evsel, nth_evsel(T_CYCLES_IN_TX))) {
- total = avg_stats(&runtime_cycles_stats[cpu]);
- if (total)
- fprintf(output,
- " # %5.2f%% transactional cycles ",
- 100.0 * (avg / total));
- } else if (transaction_run &&
- perf_evsel__cmp(evsel, nth_evsel(T_CYCLES_IN_TX_CP))) {
- total = avg_stats(&runtime_cycles_stats[cpu]);
- total2 = avg_stats(&runtime_cycles_in_tx_stats[cpu]);
- if (total2 < avg)
- total2 = avg;
- if (total)
- fprintf(output,
- " # %5.2f%% aborted cycles ",
- 100.0 * ((total2-avg) / total));
- } else if (transaction_run &&
- perf_evsel__cmp(evsel, nth_evsel(T_TRANSACTION_START)) &&
- avg > 0 &&
- runtime_cycles_in_tx_stats[cpu].n != 0) {
- total = avg_stats(&runtime_cycles_in_tx_stats[cpu]);
-
if (total)
- ratio = total / avg;
+ ratio = 1.0 * avg / total;
- fprintf(output, " # %8.0f cycles / transaction ", ratio);
- } else if (transaction_run &&
- perf_evsel__cmp(evsel, nth_evsel(T_ELISION_START)) &&
- avg > 0 &&
- runtime_cycles_in_tx_stats[cpu].n != 0) {
- total = avg_stats(&runtime_cycles_in_tx_stats[cpu]);
-
- if (total)
- ratio = total / avg;
-
- fprintf(output, " # %8.0f cycles / elision ", ratio);
+ fprintf(output, " # %8.3f GHz ", ratio);
} else if (runtime_nsecs_stats[cpu].n != 0) {
char unit = 'M';
@@ -1231,11 +1116,7 @@ static void print_stat(int argc, const char **argv)
if (!csv_output) {
fprintf(output, "\n");
fprintf(output, " Performance counter stats for ");
- if (target.system_wide)
- fprintf(output, "\'system wide");
- else if (target.cpu_list)
- fprintf(output, "\'CPU(s) %s", target.cpu_list);
- else if (!target__has_task(&target)) {
+ if (!perf_target__has_task(&target)) {
fprintf(output, "\'%s", argv[0]);
for (i = 1; i < argc; i++)
fprintf(output, " %s", argv[i]);
@@ -1356,16 +1237,6 @@ static int perf_stat_init_aggr_mode(void)
return 0;
}
-static int setup_events(const char * const *attrs, unsigned len)
-{
- unsigned i;
-
- for (i = 0; i < len; i++) {
- if (parse_events(evsel_list, attrs[i]))
- return -1;
- }
- return 0;
-}
/*
* Add default attributes, if there were no attributes specified or
@@ -1484,22 +1355,6 @@ static int add_default_attributes(void)
if (null_run)
return 0;
- if (transaction_run) {
- int err;
- if (pmu_have_event("cpu", "cycles-ct") &&
- pmu_have_event("cpu", "el-start"))
- err = setup_events(transaction_attrs,
- ARRAY_SIZE(transaction_attrs));
- else
- err = setup_events(transaction_limited_attrs,
- ARRAY_SIZE(transaction_limited_attrs));
- if (err < 0) {
- fprintf(stderr, "Cannot set up transaction events\n");
- return -1;
- }
- return 0;
- }
-
if (!evsel_list->nr_entries) {
if (perf_evlist__add_default_attrs(evsel_list, default_attrs) < 0)
return -1;
@@ -1534,8 +1389,6 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
int output_fd = 0;
const char *output_name = NULL;
const struct option options[] = {
- OPT_BOOLEAN('T', "transaction", &transaction_run,
- "hardware transaction statistics"),
OPT_CALLBACK('e', "event", &evsel_list, "event",
"event selector. use 'perf list' to list available events",
parse_events_option),
@@ -1595,7 +1448,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
"perf stat [<options>] [<command>]",
NULL
};
- int status = -EINVAL, run_idx;
+ int status = -ENOMEM, run_idx;
const char *mode;
setlocale(LC_ALL, "");
@@ -1613,15 +1466,12 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
if (output_name && output_fd) {
fprintf(stderr, "cannot use both --output and --log-fd\n");
- parse_options_usage(stat_usage, options, "o", 1);
- parse_options_usage(NULL, options, "log-fd", 0);
- goto out;
+ usage_with_options(stat_usage, options);
}
if (output_fd < 0) {
fprintf(stderr, "argument to --log-fd must be a > 0\n");
- parse_options_usage(stat_usage, options, "log-fd", 0);
- goto out;
+ usage_with_options(stat_usage, options);
}
if (!output) {
@@ -1658,66 +1508,56 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
/* User explicitly passed -B? */
if (big_num_opt == 1) {
fprintf(stderr, "-B option not supported with -x\n");
- parse_options_usage(stat_usage, options, "B", 1);
- parse_options_usage(NULL, options, "x", 1);
- goto out;
+ usage_with_options(stat_usage, options);
} else /* Nope, so disable big number formatting */
big_num = false;
} else if (big_num_opt == 0) /* User passed --no-big-num */
big_num = false;
- if (!argc && target__none(&target))
+ if (!argc && !perf_target__has_task(&target))
usage_with_options(stat_usage, options);
-
if (run_count < 0) {
- pr_err("Run count must be a positive number\n");
- parse_options_usage(stat_usage, options, "r", 1);
- goto out;
+ usage_with_options(stat_usage, options);
} else if (run_count == 0) {
forever = true;
run_count = 1;
}
/* no_aggr, cgroup are for system-wide only */
- if ((aggr_mode != AGGR_GLOBAL || nr_cgroups) &&
- !target__has_cpu(&target)) {
+ if ((aggr_mode != AGGR_GLOBAL || nr_cgroups)
+ && !perf_target__has_cpu(&target)) {
fprintf(stderr, "both cgroup and no-aggregation "
"modes only available in system-wide mode\n");
- parse_options_usage(stat_usage, options, "G", 1);
- parse_options_usage(NULL, options, "A", 1);
- parse_options_usage(NULL, options, "a", 1);
- goto out;
+ usage_with_options(stat_usage, options);
+ return -1;
}
if (add_default_attributes())
goto out;
- target__validate(&target);
+ perf_target__validate(&target);
if (perf_evlist__create_maps(evsel_list, &target) < 0) {
- if (target__has_task(&target)) {
+ if (perf_target__has_task(&target))
pr_err("Problems finding threads of monitor\n");
- parse_options_usage(stat_usage, options, "p", 1);
- parse_options_usage(NULL, options, "t", 1);
- } else if (target__has_cpu(&target)) {
+ if (perf_target__has_cpu(&target))
perror("failed to parse CPUs map");
- parse_options_usage(stat_usage, options, "C", 1);
- parse_options_usage(NULL, options, "a", 1);
- }
- goto out;
+
+ usage_with_options(stat_usage, options);
+ return -1;
}
if (interval && interval < 100) {
pr_err("print interval must be >= 100ms\n");
- parse_options_usage(stat_usage, options, "I", 1);
- goto out_free_maps;
+ usage_with_options(stat_usage, options);
+ return -1;
}
if (perf_evlist__alloc_stats(evsel_list, interval))
goto out_free_maps;
if (perf_stat_init_aggr_mode())
- goto out_free_maps;
+ goto out;
/*
* We dont want to block the signals - that would cause
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 41c9bde..c2e0231 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -36,7 +36,6 @@
#include "util/session.h"
#include "util/svghelper.h"
#include "util/tool.h"
-#include "util/data.h"
#define SUPPORT_OLD_POWER_EVENTS 1
#define PWR_EVENT_EXIT -1
@@ -483,8 +482,8 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
if (sample->cpu > numcpus)
numcpus = sample->cpu;
- if (evsel->handler != NULL) {
- tracepoint_handler f = evsel->handler;
+ if (evsel->handler.func != NULL) {
+ tracepoint_handler f = evsel->handler.func;
return f(evsel, sample);
}
@@ -991,13 +990,8 @@ static int __cmd_timechart(const char *output_name)
{ "power:power_frequency", process_sample_power_frequency },
#endif
};
- struct perf_data_file file = {
- .path = input_name,
- .mode = PERF_DATA_MODE_READ,
- };
-
- struct perf_session *session = perf_session__new(&file, false,
- &perf_timechart);
+ struct perf_session *session = perf_session__new(input_name, O_RDONLY,
+ 0, false, &perf_timechart);
int ret = -EINVAL;
if (session == NULL)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 71e6402..5a11f13 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -246,10 +246,10 @@ static struct hist_entry *perf_evsel__add_hist_entry(struct perf_evsel *evsel,
struct hist_entry *he;
pthread_mutex_lock(&evsel->hists.lock);
- he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL,
- sample->period, sample->weight,
- sample->transaction);
+ he = __hists__add_entry(&evsel->hists, al, NULL, sample->period,
+ sample->weight);
pthread_mutex_unlock(&evsel->hists.lock);
+
if (he == NULL)
return NULL;
@@ -287,7 +287,7 @@ static void perf_top__print_sym_table(struct perf_top *top)
return;
}
- hists__collapse_resort(&top->sym_evsel->hists, NULL);
+ hists__collapse_resort(&top->sym_evsel->hists);
hists__output_resort(&top->sym_evsel->hists);
hists__decay_entries(&top->sym_evsel->hists,
top->hide_user_symbols,
@@ -553,7 +553,7 @@ static void perf_top__sort_new_samples(void *arg)
if (t->evlist->selected != NULL)
t->sym_evsel = t->evlist->selected;
- hists__collapse_resort(&t->sym_evsel->hists, NULL);
+ hists__collapse_resort(&t->sym_evsel->hists);
hists__output_resort(&t->sym_evsel->hists);
hists__decay_entries(&t->sym_evsel->hists,
t->hide_user_symbols,
@@ -771,8 +771,7 @@ static void perf_event__process_sample(struct perf_tool *tool,
sample->callchain) {
err = machine__resolve_callchain(machine, evsel,
al.thread, sample,
- &parent, &al,
- top->max_stack);
+ &parent, &al);
if (err)
return;
}
@@ -857,7 +856,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
&sample, machine);
} else if (event->header.type < PERF_RECORD_MAX) {
hists__inc_nr_events(&evsel->hists, event->header.type);
- machine__process_event(machine, event, &sample);
+ machine__process_event(machine, event);
} else
++session->stats.nr_unknown_events;
next_event:
@@ -933,8 +932,11 @@ static int __cmd_top(struct perf_top *top)
struct perf_record_opts *opts = &top->record_opts;
pthread_t thread;
int ret;
-
- top->session = perf_session__new(NULL, false, NULL);
+ /*
+ * FIXME: perf_session__new should allow passing a O_MMAP, so that all this
+ * mmap reading, etc is encapsulated in it. Use O_WRONLY for now.
+ */
+ top->session = perf_session__new(NULL, O_WRONLY, false, false, NULL);
if (top->session == NULL)
return -ENOMEM;
@@ -950,8 +952,14 @@ static int __cmd_top(struct perf_top *top)
if (ret)
goto out_delete;
- machine__synthesize_threads(&top->session->machines.host, &opts->target,
- top->evlist->threads, false);
+ if (perf_target__has_task(&opts->target))
+ perf_event__synthesize_thread_map(&top->tool, top->evlist->threads,
+ perf_event__process,
+ &top->session->machines.host);
+ else
+ perf_event__synthesize_threads(&top->tool, perf_event__process,
+ &top->session->machines.host);
+
ret = perf_top__start_counters(top);
if (ret)
goto out_delete;
@@ -967,7 +975,7 @@ static int __cmd_top(struct perf_top *top)
* XXX 'top' still doesn't start workloads like record, trace, but should,
* so leave the check here.
*/
- if (!target__none(&opts->target))
+ if (!perf_target__none(&opts->target))
perf_evlist__enable(top->evlist);
/* Wait for a minimal set of events before starting the snapshot */
@@ -1035,7 +1043,7 @@ parse_percent_limit(const struct option *opt, const char *arg,
int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
{
- int status = -1;
+ int status;
char errbuf[BUFSIZ];
struct perf_top top = {
.count_filter = 5,
@@ -1045,15 +1053,14 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
.user_freq = UINT_MAX,
.user_interval = ULLONG_MAX,
.freq = 4000, /* 4 KHz */
- .target = {
+ .target = {
.uses_mmap = true,
},
},
- .max_stack = PERF_MAX_STACK_DEPTH,
.sym_pcnt_filter = 5,
};
struct perf_record_opts *opts = &top.record_opts;
- struct target *target = &opts->target;
+ struct perf_target *target = &opts->target;
const struct option options[] = {
OPT_CALLBACK('e', "event", &top.evlist, "event",
"event selector. use 'perf list' to list available events",
@@ -1069,13 +1076,10 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
"list of cpus to monitor"),
OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
"file", "vmlinux pathname"),
- OPT_BOOLEAN(0, "ignore-vmlinux", &symbol_conf.ignore_vmlinux,
- "don't load vmlinux even if found"),
OPT_BOOLEAN('K', "hide_kernel_symbols", &top.hide_kernel_symbols,
"hide kernel symbols"),
- OPT_CALLBACK('m', "mmap-pages", &opts->mmap_pages, "pages",
- "number of mmap data pages",
- perf_evlist__parse_mmap_pages),
+ OPT_UINTEGER('m', "mmap-pages", &opts->mmap_pages,
+ "number of mmap data pages"),
OPT_INTEGER('r', "realtime", &top.realtime_prio,
"collect data with this RT SCHED_FIFO priority"),
OPT_INTEGER('d', "delay", &top.delay_secs,
@@ -1101,8 +1105,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_INCR('v', "verbose", &verbose,
"be more verbose (show counter open errors, etc)"),
OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
- "sort by key(s): pid, comm, dso, symbol, parent, weight, local_weight,"
- " abort, in_tx, transaction"),
+ "sort by key(s): pid, comm, dso, symbol, parent, weight, local_weight"),
OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
"Show a column with the number of samples"),
OPT_CALLBACK_NOOPT('G', NULL, &top.record_opts,
@@ -1111,9 +1114,6 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_CALLBACK(0, "call-graph", &top.record_opts,
"mode[,dump_size]", record_callchain_help,
&parse_callchain_opt),
- OPT_INTEGER(0, "max-stack", &top.max_stack,
- "Set the maximum stack depth when parsing the callchain. "
- "Default: " __stringify(PERF_MAX_STACK_DEPTH)),
OPT_CALLBACK(0, "ignore-callees", NULL, "regex",
"ignore callees of these functions in call graphs",
report_parse_ignore_callees_opt),
@@ -1154,10 +1154,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
if (sort_order == default_sort_order)
sort_order = "dso,symbol";
- if (setup_sorting() < 0) {
- parse_options_usage(top_usage, options, "s", 1);
- goto out_delete_evlist;
- }
+ if (setup_sorting() < 0)
+ usage_with_options(top_usage, options);
/* display thread wants entries to be collapsed in a different tree */
sort__need_collapse = 1;
@@ -1169,24 +1167,24 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
setup_browser(false);
- status = target__validate(target);
+ status = perf_target__validate(target);
if (status) {
- target__strerror(target, status, errbuf, BUFSIZ);
- ui__warning("%s\n", errbuf);
+ perf_target__strerror(target, status, errbuf, BUFSIZ);
+ ui__warning("%s", errbuf);
}
- status = target__parse_uid(target);
+ status = perf_target__parse_uid(target);
if (status) {
int saved_errno = errno;
- target__strerror(target, status, errbuf, BUFSIZ);
- ui__error("%s\n", errbuf);
+ perf_target__strerror(target, status, errbuf, BUFSIZ);
+ ui__error("%s", errbuf);
status = -saved_errno;
goto out_delete_evlist;
}
- if (target__none(target))
+ if (perf_target__none(target))
target->system_wide = true;
if (perf_evlist__create_maps(top.evlist, target) < 0)
@@ -1203,7 +1201,20 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
if (top.delay_secs < 1)
top.delay_secs = 1;
- if (perf_record_opts__config(opts)) {
+ if (opts->user_interval != ULLONG_MAX)
+ opts->default_interval = opts->user_interval;
+ if (opts->user_freq != UINT_MAX)
+ opts->freq = opts->user_freq;
+
+ /*
+ * User specified count overrides default frequency.
+ */
+ if (opts->default_interval)
+ opts->freq = 0;
+ else if (opts->freq) {
+ opts->default_interval = opts->freq;
+ } else {
+ ui__error("frequency and count are zero, aborting\n");
status = -EINVAL;
goto out_delete_maps;
}
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 8be17fc..99c8d9a 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -10,11 +10,9 @@
#include "util/strlist.h"
#include "util/intlist.h"
#include "util/thread_map.h"
-#include "util/stat.h"
#include <libaudit.h>
#include <stdlib.h>
-#include <sys/eventfd.h>
#include <sys/mman.h>
#include <linux/futex.h>
@@ -35,289 +33,49 @@
# define MADV_UNMERGEABLE 13
#endif
-struct tp_field {
- int offset;
- union {
- u64 (*integer)(struct tp_field *field, struct perf_sample *sample);
- void *(*pointer)(struct tp_field *field, struct perf_sample *sample);
- };
-};
-
-#define TP_UINT_FIELD(bits) \
-static u64 tp_field__u##bits(struct tp_field *field, struct perf_sample *sample) \
-{ \
- return *(u##bits *)(sample->raw_data + field->offset); \
-}
-
-TP_UINT_FIELD(8);
-TP_UINT_FIELD(16);
-TP_UINT_FIELD(32);
-TP_UINT_FIELD(64);
-
-#define TP_UINT_FIELD__SWAPPED(bits) \
-static u64 tp_field__swapped_u##bits(struct tp_field *field, struct perf_sample *sample) \
-{ \
- u##bits value = *(u##bits *)(sample->raw_data + field->offset); \
- return bswap_##bits(value);\
-}
-
-TP_UINT_FIELD__SWAPPED(16);
-TP_UINT_FIELD__SWAPPED(32);
-TP_UINT_FIELD__SWAPPED(64);
-
-static int tp_field__init_uint(struct tp_field *field,
- struct format_field *format_field,
- bool needs_swap)
-{
- field->offset = format_field->offset;
-
- switch (format_field->size) {
- case 1:
- field->integer = tp_field__u8;
- break;
- case 2:
- field->integer = needs_swap ? tp_field__swapped_u16 : tp_field__u16;
- break;
- case 4:
- field->integer = needs_swap ? tp_field__swapped_u32 : tp_field__u32;
- break;
- case 8:
- field->integer = needs_swap ? tp_field__swapped_u64 : tp_field__u64;
- break;
- default:
- return -1;
- }
-
- return 0;
-}
-
-static void *tp_field__ptr(struct tp_field *field, struct perf_sample *sample)
-{
- return sample->raw_data + field->offset;
-}
-
-static int tp_field__init_ptr(struct tp_field *field, struct format_field *format_field)
-{
- field->offset = format_field->offset;
- field->pointer = tp_field__ptr;
- return 0;
-}
-
-struct syscall_tp {
- struct tp_field id;
- union {
- struct tp_field args, ret;
- };
-};
-
-static int perf_evsel__init_tp_uint_field(struct perf_evsel *evsel,
- struct tp_field *field,
- const char *name)
-{
- struct format_field *format_field = perf_evsel__field(evsel, name);
-
- if (format_field == NULL)
- return -1;
-
- return tp_field__init_uint(field, format_field, evsel->needs_swap);
-}
-
-#define perf_evsel__init_sc_tp_uint_field(evsel, name) \
- ({ struct syscall_tp *sc = evsel->priv;\
- perf_evsel__init_tp_uint_field(evsel, &sc->name, #name); })
-
-static int perf_evsel__init_tp_ptr_field(struct perf_evsel *evsel,
- struct tp_field *field,
- const char *name)
-{
- struct format_field *format_field = perf_evsel__field(evsel, name);
-
- if (format_field == NULL)
- return -1;
-
- return tp_field__init_ptr(field, format_field);
-}
-
-#define perf_evsel__init_sc_tp_ptr_field(evsel, name) \
- ({ struct syscall_tp *sc = evsel->priv;\
- perf_evsel__init_tp_ptr_field(evsel, &sc->name, #name); })
-
-static void perf_evsel__delete_priv(struct perf_evsel *evsel)
+static size_t syscall_arg__scnprintf_hex(char *bf, size_t size,
+ unsigned long arg,
+ u8 arg_idx __maybe_unused,
+ u8 *arg_mask __maybe_unused)
{
- free(evsel->priv);
- evsel->priv = NULL;
- perf_evsel__delete(evsel);
+ return scnprintf(bf, size, "%#lx", arg);
}
-static int perf_evsel__init_syscall_tp(struct perf_evsel *evsel, void *handler)
-{
- evsel->priv = malloc(sizeof(struct syscall_tp));
- if (evsel->priv != NULL) {
- if (perf_evsel__init_sc_tp_uint_field(evsel, id))
- goto out_delete;
-
- evsel->handler = handler;
- return 0;
- }
-
- return -ENOMEM;
-
-out_delete:
- free(evsel->priv);
- evsel->priv = NULL;
- return -ENOENT;
-}
+#define SCA_HEX syscall_arg__scnprintf_hex
-static struct perf_evsel *perf_evsel__syscall_newtp(const char *direction, void *handler)
+static size_t syscall_arg__scnprintf_whence(char *bf, size_t size,
+ unsigned long arg,
+ u8 arg_idx __maybe_unused,
+ u8 *arg_mask __maybe_unused)
{
- struct perf_evsel *evsel = perf_evsel__newtp("raw_syscalls", direction);
+ int whence = arg;
- if (evsel) {
- if (perf_evsel__init_syscall_tp(evsel, handler))
- goto out_delete;
+ switch (whence) {
+#define P_WHENCE(n) case SEEK_##n: return scnprintf(bf, size, #n)
+ P_WHENCE(SET);
+ P_WHENCE(CUR);
+ P_WHENCE(END);
+#ifdef SEEK_DATA
+ P_WHENCE(DATA);
+#endif
+#ifdef SEEK_HOLE
+ P_WHENCE(HOLE);
+#endif
+#undef P_WHENCE
+ default: break;
}
- return evsel;
-
-out_delete:
- perf_evsel__delete_priv(evsel);
- return NULL;
-}
-
-#define perf_evsel__sc_tp_uint(evsel, name, sample) \
- ({ struct syscall_tp *fields = evsel->priv; \
- fields->name.integer(&fields->name, sample); })
-
-#define perf_evsel__sc_tp_ptr(evsel, name, sample) \
- ({ struct syscall_tp *fields = evsel->priv; \
- fields->name.pointer(&fields->name, sample); })
-
-static int perf_evlist__add_syscall_newtp(struct perf_evlist *evlist,
- void *sys_enter_handler,
- void *sys_exit_handler)
-{
- int ret = -1;
- struct perf_evsel *sys_enter, *sys_exit;
-
- sys_enter = perf_evsel__syscall_newtp("sys_enter", sys_enter_handler);
- if (sys_enter == NULL)
- goto out;
-
- if (perf_evsel__init_sc_tp_ptr_field(sys_enter, args))
- goto out_delete_sys_enter;
-
- sys_exit = perf_evsel__syscall_newtp("sys_exit", sys_exit_handler);
- if (sys_exit == NULL)
- goto out_delete_sys_enter;
-
- if (perf_evsel__init_sc_tp_uint_field(sys_exit, ret))
- goto out_delete_sys_exit;
-
- perf_evlist__add(evlist, sys_enter);
- perf_evlist__add(evlist, sys_exit);
-
- ret = 0;
-out:
- return ret;
-
-out_delete_sys_exit:
- perf_evsel__delete_priv(sys_exit);
-out_delete_sys_enter:
- perf_evsel__delete_priv(sys_enter);
- goto out;
-}
-
-
-struct syscall_arg {
- unsigned long val;
- struct thread *thread;
- struct trace *trace;
- void *parm;
- u8 idx;
- u8 mask;
-};
-
-struct strarray {
- int offset;
- int nr_entries;
- const char **entries;
-};
-
-#define DEFINE_STRARRAY(array) struct strarray strarray__##array = { \
- .nr_entries = ARRAY_SIZE(array), \
- .entries = array, \
-}
-
-#define DEFINE_STRARRAY_OFFSET(array, off) struct strarray strarray__##array = { \
- .offset = off, \
- .nr_entries = ARRAY_SIZE(array), \
- .entries = array, \
-}
-
-static size_t __syscall_arg__scnprintf_strarray(char *bf, size_t size,
- const char *intfmt,
- struct syscall_arg *arg)
-{
- struct strarray *sa = arg->parm;
- int idx = arg->val - sa->offset;
-
- if (idx < 0 || idx >= sa->nr_entries)
- return scnprintf(bf, size, intfmt, arg->val);
-
- return scnprintf(bf, size, "%s", sa->entries[idx]);
-}
-
-static size_t syscall_arg__scnprintf_strarray(char *bf, size_t size,
- struct syscall_arg *arg)
-{
- return __syscall_arg__scnprintf_strarray(bf, size, "%d", arg);
-}
-
-#define SCA_STRARRAY syscall_arg__scnprintf_strarray
-
-static size_t syscall_arg__scnprintf_strhexarray(char *bf, size_t size,
- struct syscall_arg *arg)
-{
- return __syscall_arg__scnprintf_strarray(bf, size, "%#x", arg);
-}
-
-#define SCA_STRHEXARRAY syscall_arg__scnprintf_strhexarray
-
-static size_t syscall_arg__scnprintf_fd(char *bf, size_t size,
- struct syscall_arg *arg);
-
-#define SCA_FD syscall_arg__scnprintf_fd
-
-static size_t syscall_arg__scnprintf_fd_at(char *bf, size_t size,
- struct syscall_arg *arg)
-{
- int fd = arg->val;
-
- if (fd == AT_FDCWD)
- return scnprintf(bf, size, "CWD");
-
- return syscall_arg__scnprintf_fd(bf, size, arg);
+ return scnprintf(bf, size, "%#x", whence);
}
-#define SCA_FDAT syscall_arg__scnprintf_fd_at
-
-static size_t syscall_arg__scnprintf_close_fd(char *bf, size_t size,
- struct syscall_arg *arg);
-
-#define SCA_CLOSE_FD syscall_arg__scnprintf_close_fd
-
-static size_t syscall_arg__scnprintf_hex(char *bf, size_t size,
- struct syscall_arg *arg)
-{
- return scnprintf(bf, size, "%#lx", arg->val);
-}
-
-#define SCA_HEX syscall_arg__scnprintf_hex
+#define SCA_WHENCE syscall_arg__scnprintf_whence
static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size,
- struct syscall_arg *arg)
+ unsigned long arg,
+ u8 arg_idx __maybe_unused,
+ u8 *arg_mask __maybe_unused)
{
- int printed = 0, prot = arg->val;
+ int printed = 0, prot = arg;
if (prot == PROT_NONE)
return scnprintf(bf, size, "NONE");
@@ -346,9 +104,10 @@ static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size,
#define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot
static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size,
- struct syscall_arg *arg)
+ unsigned long arg, u8 arg_idx __maybe_unused,
+ u8 *arg_mask __maybe_unused)
{
- int printed = 0, flags = arg->val;
+ int printed = 0, flags = arg;
#define P_MMAP_FLAG(n) \
if (flags & MAP_##n) { \
@@ -389,9 +148,10 @@ static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size,
#define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags
static size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size,
- struct syscall_arg *arg)
+ unsigned long arg, u8 arg_idx __maybe_unused,
+ u8 *arg_mask __maybe_unused)
{
- int behavior = arg->val;
+ int behavior = arg;
switch (behavior) {
#define P_MADV_BHV(n) case MADV_##n: return scnprintf(bf, size, #n)
@@ -430,38 +190,8 @@ static size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size,
#define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior
-static size_t syscall_arg__scnprintf_flock(char *bf, size_t size,
- struct syscall_arg *arg)
-{
- int printed = 0, op = arg->val;
-
- if (op == 0)
- return scnprintf(bf, size, "NONE");
-#define P_CMD(cmd) \
- if ((op & LOCK_##cmd) == LOCK_##cmd) { \
- printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #cmd); \
- op &= ~LOCK_##cmd; \
- }
-
- P_CMD(SH);
- P_CMD(EX);
- P_CMD(NB);
- P_CMD(UN);
- P_CMD(MAND);
- P_CMD(RW);
- P_CMD(READ);
- P_CMD(WRITE);
-#undef P_OP
-
- if (op)
- printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", op);
-
- return printed;
-}
-
-#define SCA_FLOCK syscall_arg__scnprintf_flock
-
-static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct syscall_arg *arg)
+static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, unsigned long arg,
+ u8 arg_idx __maybe_unused, u8 *arg_mask)
{
enum syscall_futex_args {
SCF_UADDR = (1 << 0),
@@ -471,24 +201,24 @@ static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct sysc
SCF_UADDR2 = (1 << 4),
SCF_VAL3 = (1 << 5),
};
- int op = arg->val;
+ int op = arg;
int cmd = op & FUTEX_CMD_MASK;
size_t printed = 0;
switch (cmd) {
#define P_FUTEX_OP(n) case FUTEX_##n: printed = scnprintf(bf, size, #n);
- P_FUTEX_OP(WAIT); arg->mask |= SCF_VAL3|SCF_UADDR2; break;
- P_FUTEX_OP(WAKE); arg->mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
- P_FUTEX_OP(FD); arg->mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
- P_FUTEX_OP(REQUEUE); arg->mask |= SCF_VAL3|SCF_TIMEOUT; break;
- P_FUTEX_OP(CMP_REQUEUE); arg->mask |= SCF_TIMEOUT; break;
- P_FUTEX_OP(CMP_REQUEUE_PI); arg->mask |= SCF_TIMEOUT; break;
+ P_FUTEX_OP(WAIT); *arg_mask |= SCF_VAL3|SCF_UADDR2; break;
+ P_FUTEX_OP(WAKE); *arg_mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
+ P_FUTEX_OP(FD); *arg_mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
+ P_FUTEX_OP(REQUEUE); *arg_mask |= SCF_VAL3|SCF_TIMEOUT; break;
+ P_FUTEX_OP(CMP_REQUEUE); *arg_mask |= SCF_TIMEOUT; break;
+ P_FUTEX_OP(CMP_REQUEUE_PI); *arg_mask |= SCF_TIMEOUT; break;
P_FUTEX_OP(WAKE_OP); break;
- P_FUTEX_OP(LOCK_PI); arg->mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
- P_FUTEX_OP(UNLOCK_PI); arg->mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
- P_FUTEX_OP(TRYLOCK_PI); arg->mask |= SCF_VAL3|SCF_UADDR2; break;
- P_FUTEX_OP(WAIT_BITSET); arg->mask |= SCF_UADDR2; break;
- P_FUTEX_OP(WAKE_BITSET); arg->mask |= SCF_UADDR2; break;
+ P_FUTEX_OP(LOCK_PI); *arg_mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
+ P_FUTEX_OP(UNLOCK_PI); *arg_mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
+ P_FUTEX_OP(TRYLOCK_PI); *arg_mask |= SCF_VAL3|SCF_UADDR2; break;
+ P_FUTEX_OP(WAIT_BITSET); *arg_mask |= SCF_UADDR2; break;
+ P_FUTEX_OP(WAKE_BITSET); *arg_mask |= SCF_UADDR2; break;
P_FUTEX_OP(WAIT_REQUEUE_PI); break;
default: printed = scnprintf(bf, size, "%#x", cmd); break;
}
@@ -504,194 +234,14 @@ static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct sysc
#define SCA_FUTEX_OP syscall_arg__scnprintf_futex_op
-static const char *epoll_ctl_ops[] = { "ADD", "DEL", "MOD", };
-static DEFINE_STRARRAY_OFFSET(epoll_ctl_ops, 1);
-
-static const char *itimers[] = { "REAL", "VIRTUAL", "PROF", };
-static DEFINE_STRARRAY(itimers);
-
-static const char *whences[] = { "SET", "CUR", "END",
-#ifdef SEEK_DATA
-"DATA",
-#endif
-#ifdef SEEK_HOLE
-"HOLE",
-#endif
-};
-static DEFINE_STRARRAY(whences);
-
-static const char *fcntl_cmds[] = {
- "DUPFD", "GETFD", "SETFD", "GETFL", "SETFL", "GETLK", "SETLK",
- "SETLKW", "SETOWN", "GETOWN", "SETSIG", "GETSIG", "F_GETLK64",
- "F_SETLK64", "F_SETLKW64", "F_SETOWN_EX", "F_GETOWN_EX",
- "F_GETOWNER_UIDS",
-};
-static DEFINE_STRARRAY(fcntl_cmds);
-
-static const char *rlimit_resources[] = {
- "CPU", "FSIZE", "DATA", "STACK", "CORE", "RSS", "NPROC", "NOFILE",
- "MEMLOCK", "AS", "LOCKS", "SIGPENDING", "MSGQUEUE", "NICE", "RTPRIO",
- "RTTIME",
-};
-static DEFINE_STRARRAY(rlimit_resources);
-
-static const char *sighow[] = { "BLOCK", "UNBLOCK", "SETMASK", };
-static DEFINE_STRARRAY(sighow);
-
-static const char *clockid[] = {
- "REALTIME", "MONOTONIC", "PROCESS_CPUTIME_ID", "THREAD_CPUTIME_ID",
- "MONOTONIC_RAW", "REALTIME_COARSE", "MONOTONIC_COARSE",
-};
-static DEFINE_STRARRAY(clockid);
-
-static const char *socket_families[] = {
- "UNSPEC", "LOCAL", "INET", "AX25", "IPX", "APPLETALK", "NETROM",
- "BRIDGE", "ATMPVC", "X25", "INET6", "ROSE", "DECnet", "NETBEUI",
- "SECURITY", "KEY", "NETLINK", "PACKET", "ASH", "ECONET", "ATMSVC",
- "RDS", "SNA", "IRDA", "PPPOX", "WANPIPE", "LLC", "IB", "CAN", "TIPC",
- "BLUETOOTH", "IUCV", "RXRPC", "ISDN", "PHONET", "IEEE802154", "CAIF",
- "ALG", "NFC", "VSOCK",
-};
-static DEFINE_STRARRAY(socket_families);
-
-#ifndef SOCK_TYPE_MASK
-#define SOCK_TYPE_MASK 0xf
-#endif
-
-static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size,
- struct syscall_arg *arg)
-{
- size_t printed;
- int type = arg->val,
- flags = type & ~SOCK_TYPE_MASK;
-
- type &= SOCK_TYPE_MASK;
- /*
- * Can't use a strarray, MIPS may override for ABI reasons.
- */
- switch (type) {
-#define P_SK_TYPE(n) case SOCK_##n: printed = scnprintf(bf, size, #n); break;
- P_SK_TYPE(STREAM);
- P_SK_TYPE(DGRAM);
- P_SK_TYPE(RAW);
- P_SK_TYPE(RDM);
- P_SK_TYPE(SEQPACKET);
- P_SK_TYPE(DCCP);
- P_SK_TYPE(PACKET);
-#undef P_SK_TYPE
- default:
- printed = scnprintf(bf, size, "%#x", type);
- }
-
-#define P_SK_FLAG(n) \
- if (flags & SOCK_##n) { \
- printed += scnprintf(bf + printed, size - printed, "|%s", #n); \
- flags &= ~SOCK_##n; \
- }
-
- P_SK_FLAG(CLOEXEC);
- P_SK_FLAG(NONBLOCK);
-#undef P_SK_FLAG
-
- if (flags)
- printed += scnprintf(bf + printed, size - printed, "|%#x", flags);
-
- return printed;
-}
-
-#define SCA_SK_TYPE syscall_arg__scnprintf_socket_type
-
-#ifndef MSG_PROBE
-#define MSG_PROBE 0x10
-#endif
-#ifndef MSG_WAITFORONE
-#define MSG_WAITFORONE 0x10000
-#endif
-#ifndef MSG_SENDPAGE_NOTLAST
-#define MSG_SENDPAGE_NOTLAST 0x20000
-#endif
-#ifndef MSG_FASTOPEN
-#define MSG_FASTOPEN 0x20000000
-#endif
-
-static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size,
- struct syscall_arg *arg)
-{
- int printed = 0, flags = arg->val;
-
- if (flags == 0)
- return scnprintf(bf, size, "NONE");
-#define P_MSG_FLAG(n) \
- if (flags & MSG_##n) { \
- printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
- flags &= ~MSG_##n; \
- }
-
- P_MSG_FLAG(OOB);
- P_MSG_FLAG(PEEK);
- P_MSG_FLAG(DONTROUTE);
- P_MSG_FLAG(TRYHARD);
- P_MSG_FLAG(CTRUNC);
- P_MSG_FLAG(PROBE);
- P_MSG_FLAG(TRUNC);
- P_MSG_FLAG(DONTWAIT);
- P_MSG_FLAG(EOR);
- P_MSG_FLAG(WAITALL);
- P_MSG_FLAG(FIN);
- P_MSG_FLAG(SYN);
- P_MSG_FLAG(CONFIRM);
- P_MSG_FLAG(RST);
- P_MSG_FLAG(ERRQUEUE);
- P_MSG_FLAG(NOSIGNAL);
- P_MSG_FLAG(MORE);
- P_MSG_FLAG(WAITFORONE);
- P_MSG_FLAG(SENDPAGE_NOTLAST);
- P_MSG_FLAG(FASTOPEN);
- P_MSG_FLAG(CMSG_CLOEXEC);
-#undef P_MSG_FLAG
-
- if (flags)
- printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
-
- return printed;
-}
-
-#define SCA_MSG_FLAGS syscall_arg__scnprintf_msg_flags
-
-static size_t syscall_arg__scnprintf_access_mode(char *bf, size_t size,
- struct syscall_arg *arg)
-{
- size_t printed = 0;
- int mode = arg->val;
-
- if (mode == F_OK) /* 0 */
- return scnprintf(bf, size, "F");
-#define P_MODE(n) \
- if (mode & n##_OK) { \
- printed += scnprintf(bf + printed, size - printed, "%s", #n); \
- mode &= ~n##_OK; \
- }
-
- P_MODE(R);
- P_MODE(W);
- P_MODE(X);
-#undef P_MODE
-
- if (mode)
- printed += scnprintf(bf + printed, size - printed, "|%#x", mode);
-
- return printed;
-}
-
-#define SCA_ACCMODE syscall_arg__scnprintf_access_mode
-
static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size,
- struct syscall_arg *arg)
+ unsigned long arg,
+ u8 arg_idx, u8 *arg_mask)
{
- int printed = 0, flags = arg->val;
+ int printed = 0, flags = arg;
if (!(flags & O_CREAT))
- arg->mask |= 1 << (arg->idx + 1); /* Mask the mode parm */
+ *arg_mask |= 1 << (arg_idx + 1); /* Mask the mode parm */
if (flags == 0)
return scnprintf(bf, size, "RDONLY");
@@ -741,321 +291,60 @@ static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size,
#define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags
-static size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size,
- struct syscall_arg *arg)
-{
- int printed = 0, flags = arg->val;
-
- if (flags == 0)
- return scnprintf(bf, size, "NONE");
-#define P_FLAG(n) \
- if (flags & EFD_##n) { \
- printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
- flags &= ~EFD_##n; \
- }
-
- P_FLAG(SEMAPHORE);
- P_FLAG(CLOEXEC);
- P_FLAG(NONBLOCK);
-#undef P_FLAG
-
- if (flags)
- printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
-
- return printed;
-}
-
-#define SCA_EFD_FLAGS syscall_arg__scnprintf_eventfd_flags
-
-static size_t syscall_arg__scnprintf_pipe_flags(char *bf, size_t size,
- struct syscall_arg *arg)
-{
- int printed = 0, flags = arg->val;
-
-#define P_FLAG(n) \
- if (flags & O_##n) { \
- printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
- flags &= ~O_##n; \
- }
-
- P_FLAG(CLOEXEC);
- P_FLAG(NONBLOCK);
-#undef P_FLAG
-
- if (flags)
- printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
-
- return printed;
-}
-
-#define SCA_PIPE_FLAGS syscall_arg__scnprintf_pipe_flags
-
-static size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg)
-{
- int sig = arg->val;
-
- switch (sig) {
-#define P_SIGNUM(n) case SIG##n: return scnprintf(bf, size, #n)
- P_SIGNUM(HUP);
- P_SIGNUM(INT);
- P_SIGNUM(QUIT);
- P_SIGNUM(ILL);
- P_SIGNUM(TRAP);
- P_SIGNUM(ABRT);
- P_SIGNUM(BUS);
- P_SIGNUM(FPE);
- P_SIGNUM(KILL);
- P_SIGNUM(USR1);
- P_SIGNUM(SEGV);
- P_SIGNUM(USR2);
- P_SIGNUM(PIPE);
- P_SIGNUM(ALRM);
- P_SIGNUM(TERM);
- P_SIGNUM(STKFLT);
- P_SIGNUM(CHLD);
- P_SIGNUM(CONT);
- P_SIGNUM(STOP);
- P_SIGNUM(TSTP);
- P_SIGNUM(TTIN);
- P_SIGNUM(TTOU);
- P_SIGNUM(URG);
- P_SIGNUM(XCPU);
- P_SIGNUM(XFSZ);
- P_SIGNUM(VTALRM);
- P_SIGNUM(PROF);
- P_SIGNUM(WINCH);
- P_SIGNUM(IO);
- P_SIGNUM(PWR);
- P_SIGNUM(SYS);
- default: break;
- }
-
- return scnprintf(bf, size, "%#x", sig);
-}
-
-#define SCA_SIGNUM syscall_arg__scnprintf_signum
-
-#define TCGETS 0x5401
-
-static const char *tioctls[] = {
- "TCGETS", "TCSETS", "TCSETSW", "TCSETSF", "TCGETA", "TCSETA", "TCSETAW",
- "TCSETAF", "TCSBRK", "TCXONC", "TCFLSH", "TIOCEXCL", "TIOCNXCL",
- "TIOCSCTTY", "TIOCGPGRP", "TIOCSPGRP", "TIOCOUTQ", "TIOCSTI",
- "TIOCGWINSZ", "TIOCSWINSZ", "TIOCMGET", "TIOCMBIS", "TIOCMBIC",
- "TIOCMSET", "TIOCGSOFTCAR", "TIOCSSOFTCAR", "FIONREAD", "TIOCLINUX",
- "TIOCCONS", "TIOCGSERIAL", "TIOCSSERIAL", "TIOCPKT", "FIONBIO",
- "TIOCNOTTY", "TIOCSETD", "TIOCGETD", "TCSBRKP", [0x27] = "TIOCSBRK",
- "TIOCCBRK", "TIOCGSID", "TCGETS2", "TCSETS2", "TCSETSW2", "TCSETSF2",
- "TIOCGRS485", "TIOCSRS485", "TIOCGPTN", "TIOCSPTLCK",
- "TIOCGDEV||TCGETX", "TCSETX", "TCSETXF", "TCSETXW", "TIOCSIG",
- "TIOCVHANGUP", "TIOCGPKT", "TIOCGPTLCK", "TIOCGEXCL",
- [0x50] = "FIONCLEX", "FIOCLEX", "FIOASYNC", "TIOCSERCONFIG",
- "TIOCSERGWILD", "TIOCSERSWILD", "TIOCGLCKTRMIOS", "TIOCSLCKTRMIOS",
- "TIOCSERGSTRUCT", "TIOCSERGETLSR", "TIOCSERGETMULTI", "TIOCSERSETMULTI",
- "TIOCMIWAIT", "TIOCGICOUNT", [0x60] = "FIOQSIZE",
-};
-
-static DEFINE_STRARRAY_OFFSET(tioctls, 0x5401);
-
-#define STRARRAY(arg, name, array) \
- .arg_scnprintf = { [arg] = SCA_STRARRAY, }, \
- .arg_parm = { [arg] = &strarray__##array, }
-
static struct syscall_fmt {
const char *name;
const char *alias;
- size_t (*arg_scnprintf[6])(char *bf, size_t size, struct syscall_arg *arg);
- void *arg_parm[6];
+ size_t (*arg_scnprintf[6])(char *bf, size_t size, unsigned long arg, u8 arg_idx, u8 *arg_mask);
bool errmsg;
bool timeout;
bool hexret;
} syscall_fmts[] = {
- { .name = "access", .errmsg = true,
- .arg_scnprintf = { [1] = SCA_ACCMODE, /* mode */ }, },
+ { .name = "access", .errmsg = true, },
{ .name = "arch_prctl", .errmsg = true, .alias = "prctl", },
{ .name = "brk", .hexret = true,
.arg_scnprintf = { [0] = SCA_HEX, /* brk */ }, },
- { .name = "clock_gettime", .errmsg = true, STRARRAY(0, clk_id, clockid), },
- { .name = "close", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_CLOSE_FD, /* fd */ }, },
+ { .name = "mmap", .hexret = true, },
{ .name = "connect", .errmsg = true, },
- { .name = "dup", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "dup2", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "dup3", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "epoll_ctl", .errmsg = true, STRARRAY(1, op, epoll_ctl_ops), },
- { .name = "eventfd2", .errmsg = true,
- .arg_scnprintf = { [1] = SCA_EFD_FLAGS, /* flags */ }, },
- { .name = "faccessat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, },
- { .name = "fadvise64", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "fallocate", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "fchdir", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "fchmod", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "fchmodat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ }, },
- { .name = "fchown", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "fchownat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ }, },
- { .name = "fcntl", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */
- [1] = SCA_STRARRAY, /* cmd */ },
- .arg_parm = { [1] = &strarray__fcntl_cmds, /* cmd */ }, },
- { .name = "fdatasync", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "flock", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */
- [1] = SCA_FLOCK, /* cmd */ }, },
- { .name = "fsetxattr", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "fstat", .errmsg = true, .alias = "newfstat",
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "fstatat", .errmsg = true, .alias = "newfstatat",
- .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, },
- { .name = "fstatfs", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "fsync", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "ftruncate", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
+ { .name = "fstat", .errmsg = true, .alias = "newfstat", },
+ { .name = "fstatat", .errmsg = true, .alias = "newfstatat", },
{ .name = "futex", .errmsg = true,
.arg_scnprintf = { [1] = SCA_FUTEX_OP, /* op */ }, },
- { .name = "futimesat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ }, },
- { .name = "getdents", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "getdents64", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "getitimer", .errmsg = true, STRARRAY(0, which, itimers), },
- { .name = "getrlimit", .errmsg = true, STRARRAY(0, resource, rlimit_resources), },
{ .name = "ioctl", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */
- [1] = SCA_STRHEXARRAY, /* cmd */
- [2] = SCA_HEX, /* arg */ },
- .arg_parm = { [1] = &strarray__tioctls, /* cmd */ }, },
- { .name = "kill", .errmsg = true,
- .arg_scnprintf = { [1] = SCA_SIGNUM, /* sig */ }, },
- { .name = "linkat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ }, },
+ .arg_scnprintf = { [2] = SCA_HEX, /* arg */ }, },
{ .name = "lseek", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */
- [2] = SCA_STRARRAY, /* whence */ },
- .arg_parm = { [2] = &strarray__whences, /* whence */ }, },
+ .arg_scnprintf = { [2] = SCA_WHENCE, /* whence */ }, },
{ .name = "lstat", .errmsg = true, .alias = "newlstat", },
{ .name = "madvise", .errmsg = true,
.arg_scnprintf = { [0] = SCA_HEX, /* start */
[2] = SCA_MADV_BHV, /* behavior */ }, },
- { .name = "mkdirat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ }, },
- { .name = "mknodat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ }, },
- { .name = "mlock", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, },
- { .name = "mlockall", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, },
{ .name = "mmap", .hexret = true,
.arg_scnprintf = { [0] = SCA_HEX, /* addr */
[2] = SCA_MMAP_PROT, /* prot */
- [3] = SCA_MMAP_FLAGS, /* flags */
- [4] = SCA_FD, /* fd */ }, },
+ [3] = SCA_MMAP_FLAGS, /* flags */ }, },
{ .name = "mprotect", .errmsg = true,
.arg_scnprintf = { [0] = SCA_HEX, /* start */
[2] = SCA_MMAP_PROT, /* prot */ }, },
{ .name = "mremap", .hexret = true,
.arg_scnprintf = { [0] = SCA_HEX, /* addr */
[4] = SCA_HEX, /* new_addr */ }, },
- { .name = "munlock", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, },
{ .name = "munmap", .errmsg = true,
.arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, },
- { .name = "name_to_handle_at", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, },
- { .name = "newfstatat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, },
{ .name = "open", .errmsg = true,
.arg_scnprintf = { [1] = SCA_OPEN_FLAGS, /* flags */ }, },
{ .name = "open_by_handle_at", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */
- [2] = SCA_OPEN_FLAGS, /* flags */ }, },
+ .arg_scnprintf = { [2] = SCA_OPEN_FLAGS, /* flags */ }, },
{ .name = "openat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */
- [2] = SCA_OPEN_FLAGS, /* flags */ }, },
- { .name = "pipe2", .errmsg = true,
- .arg_scnprintf = { [1] = SCA_PIPE_FLAGS, /* flags */ }, },
+ .arg_scnprintf = { [2] = SCA_OPEN_FLAGS, /* flags */ }, },
{ .name = "poll", .errmsg = true, .timeout = true, },
{ .name = "ppoll", .errmsg = true, .timeout = true, },
- { .name = "pread", .errmsg = true, .alias = "pread64",
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "preadv", .errmsg = true, .alias = "pread",
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "prlimit64", .errmsg = true, STRARRAY(1, resource, rlimit_resources), },
- { .name = "pwrite", .errmsg = true, .alias = "pwrite64",
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "pwritev", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "read", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "readlinkat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, },
- { .name = "readv", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "recvfrom", .errmsg = true,
- .arg_scnprintf = { [3] = SCA_MSG_FLAGS, /* flags */ }, },
- { .name = "recvmmsg", .errmsg = true,
- .arg_scnprintf = { [3] = SCA_MSG_FLAGS, /* flags */ }, },
- { .name = "recvmsg", .errmsg = true,
- .arg_scnprintf = { [2] = SCA_MSG_FLAGS, /* flags */ }, },
- { .name = "renameat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, },
- { .name = "rt_sigaction", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_SIGNUM, /* sig */ }, },
- { .name = "rt_sigprocmask", .errmsg = true, STRARRAY(0, how, sighow), },
- { .name = "rt_sigqueueinfo", .errmsg = true,
- .arg_scnprintf = { [1] = SCA_SIGNUM, /* sig */ }, },
- { .name = "rt_tgsigqueueinfo", .errmsg = true,
- .arg_scnprintf = { [2] = SCA_SIGNUM, /* sig */ }, },
+ { .name = "pread", .errmsg = true, .alias = "pread64", },
+ { .name = "pwrite", .errmsg = true, .alias = "pwrite64", },
+ { .name = "read", .errmsg = true, },
+ { .name = "recvfrom", .errmsg = true, },
{ .name = "select", .errmsg = true, .timeout = true, },
- { .name = "sendmmsg", .errmsg = true,
- .arg_scnprintf = { [3] = SCA_MSG_FLAGS, /* flags */ }, },
- { .name = "sendmsg", .errmsg = true,
- .arg_scnprintf = { [2] = SCA_MSG_FLAGS, /* flags */ }, },
- { .name = "sendto", .errmsg = true,
- .arg_scnprintf = { [3] = SCA_MSG_FLAGS, /* flags */ }, },
- { .name = "setitimer", .errmsg = true, STRARRAY(0, which, itimers), },
- { .name = "setrlimit", .errmsg = true, STRARRAY(0, resource, rlimit_resources), },
- { .name = "shutdown", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "socket", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_STRARRAY, /* family */
- [1] = SCA_SK_TYPE, /* type */ },
- .arg_parm = { [0] = &strarray__socket_families, /* family */ }, },
- { .name = "socketpair", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_STRARRAY, /* family */
- [1] = SCA_SK_TYPE, /* type */ },
- .arg_parm = { [0] = &strarray__socket_families, /* family */ }, },
+ { .name = "socket", .errmsg = true, },
{ .name = "stat", .errmsg = true, .alias = "newstat", },
- { .name = "symlinkat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, },
- { .name = "tgkill", .errmsg = true,
- .arg_scnprintf = { [2] = SCA_SIGNUM, /* sig */ }, },
- { .name = "tkill", .errmsg = true,
- .arg_scnprintf = { [1] = SCA_SIGNUM, /* sig */ }, },
{ .name = "uname", .errmsg = true, .alias = "newuname", },
- { .name = "unlinkat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ }, },
- { .name = "utimensat", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FDAT, /* dirfd */ }, },
- { .name = "write", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
- { .name = "writev", .errmsg = true,
- .arg_scnprintf = { [0] = SCA_FD, /* fd */ }, },
};
static int syscall_fmt__cmp(const void *name, const void *fmtp)
@@ -1075,8 +364,8 @@ struct syscall {
const char *name;
bool filtered;
struct syscall_fmt *fmt;
- size_t (**arg_scnprintf)(char *bf, size_t size, struct syscall_arg *arg);
- void **arg_parm;
+ size_t (**arg_scnprintf)(char *bf, size_t size,
+ unsigned long arg, u8 arg_idx, u8 *args_mask);
};
static size_t fprintf_duration(unsigned long t, FILE *fp)
@@ -1100,24 +389,11 @@ struct thread_trace {
unsigned long nr_events;
char *entry_str;
double runtime_ms;
- struct {
- int max;
- char **table;
- } paths;
-
- struct intlist *syscall_stats;
};
static struct thread_trace *thread_trace__new(void)
{
- struct thread_trace *ttrace = zalloc(sizeof(struct thread_trace));
-
- if (ttrace)
- ttrace->paths.max = -1;
-
- ttrace->syscall_stats = intlist__new(NULL);
-
- return ttrace;
+ return zalloc(sizeof(struct thread_trace));
}
static struct thread_trace *thread__trace(struct thread *thread, FILE *fp)
@@ -1145,141 +421,26 @@ fail:
struct trace {
struct perf_tool tool;
- struct {
- int machine;
- int open_id;
- } audit;
+ int audit_machine;
struct {
int max;
struct syscall *table;
} syscalls;
struct perf_record_opts opts;
- struct machine *host;
+ struct machine host;
u64 base_time;
- bool full_time;
FILE *output;
unsigned long nr_events;
struct strlist *ev_qualifier;
bool not_ev_qualifier;
- bool live;
- const char *last_vfs_getname;
struct intlist *tid_list;
struct intlist *pid_list;
bool sched;
bool multiple_threads;
- bool summary;
- bool summary_only;
- bool show_comm;
- bool show_tool_stats;
double duration_filter;
double runtime_ms;
- struct {
- u64 vfs_getname, proc_getname;
- } stats;
};
-static int trace__set_fd_pathname(struct thread *thread, int fd, const char *pathname)
-{
- struct thread_trace *ttrace = thread->priv;
-
- if (fd > ttrace->paths.max) {
- char **npath = realloc(ttrace->paths.table, (fd + 1) * sizeof(char *));
-
- if (npath == NULL)
- return -1;
-
- if (ttrace->paths.max != -1) {
- memset(npath + ttrace->paths.max + 1, 0,
- (fd - ttrace->paths.max) * sizeof(char *));
- } else {
- memset(npath, 0, (fd + 1) * sizeof(char *));
- }
-
- ttrace->paths.table = npath;
- ttrace->paths.max = fd;
- }
-
- ttrace->paths.table[fd] = strdup(pathname);
-
- return ttrace->paths.table[fd] != NULL ? 0 : -1;
-}
-
-static int thread__read_fd_path(struct thread *thread, int fd)
-{
- char linkname[PATH_MAX], pathname[PATH_MAX];
- struct stat st;
- int ret;
-
- if (thread->pid_ == thread->tid) {
- scnprintf(linkname, sizeof(linkname),
- "/proc/%d/fd/%d", thread->pid_, fd);
- } else {
- scnprintf(linkname, sizeof(linkname),
- "/proc/%d/task/%d/fd/%d", thread->pid_, thread->tid, fd);
- }
-
- if (lstat(linkname, &st) < 0 || st.st_size + 1 > (off_t)sizeof(pathname))
- return -1;
-
- ret = readlink(linkname, pathname, sizeof(pathname));
-
- if (ret < 0 || ret > st.st_size)
- return -1;
-
- pathname[ret] = '\0';
- return trace__set_fd_pathname(thread, fd, pathname);
-}
-
-static const char *thread__fd_path(struct thread *thread, int fd,
- struct trace *trace)
-{
- struct thread_trace *ttrace = thread->priv;
-
- if (ttrace == NULL)
- return NULL;
-
- if (fd < 0)
- return NULL;
-
- if ((fd > ttrace->paths.max || ttrace->paths.table[fd] == NULL))
- if (!trace->live)
- return NULL;
- ++trace->stats.proc_getname;
- if (thread__read_fd_path(thread, fd)) {
- return NULL;
- }
-
- return ttrace->paths.table[fd];
-}
-
-static size_t syscall_arg__scnprintf_fd(char *bf, size_t size,
- struct syscall_arg *arg)
-{
- int fd = arg->val;
- size_t printed = scnprintf(bf, size, "%d", fd);
- const char *path = thread__fd_path(arg->thread, fd, arg->trace);
-
- if (path)
- printed += scnprintf(bf + printed, size - printed, "<%s>", path);
-
- return printed;
-}
-
-static size_t syscall_arg__scnprintf_close_fd(char *bf, size_t size,
- struct syscall_arg *arg)
-{
- int fd = arg->val;
- size_t printed = syscall_arg__scnprintf_fd(bf, size, arg);
- struct thread_trace *ttrace = arg->thread->priv;
-
- if (ttrace && fd >= 0 && fd <= ttrace->paths.max) {
- free(ttrace->paths.table[fd]);
- ttrace->paths.table[fd] = NULL;
- }
-
- return printed;
-}
-
static bool trace__filter_duration(struct trace *trace, double t)
{
return t < (trace->duration_filter * NSEC_PER_MSEC);
@@ -1293,12 +454,10 @@ static size_t trace__fprintf_tstamp(struct trace *trace, u64 tstamp, FILE *fp)
}
static bool done = false;
-static bool interrupted = false;
-static void sig_handler(int sig)
+static void sig_handler(int sig __maybe_unused)
{
done = true;
- interrupted = sig == SIGINT;
}
static size_t trace__fprintf_entry_head(struct trace *trace, struct thread *thread,
@@ -1307,17 +466,14 @@ static size_t trace__fprintf_entry_head(struct trace *trace, struct thread *thre
size_t printed = trace__fprintf_tstamp(trace, tstamp, fp);
printed += fprintf_duration(duration, fp);
- if (trace->multiple_threads) {
- if (trace->show_comm)
- printed += fprintf(fp, "%.14s/", thread__comm_str(thread));
+ if (trace->multiple_threads)
printed += fprintf(fp, "%d ", thread->tid);
- }
return printed;
}
static int trace__process_event(struct trace *trace, struct machine *machine,
- union perf_event *event, struct perf_sample *sample)
+ union perf_event *event)
{
int ret = 0;
@@ -1325,9 +481,9 @@ static int trace__process_event(struct trace *trace, struct machine *machine,
case PERF_RECORD_LOST:
color_fprintf(trace->output, PERF_COLOR_RED,
"LOST %" PRIu64 " events!\n", event->lost.lost);
- ret = machine__process_lost_event(machine, event, sample);
+ ret = machine__process_lost_event(machine, event);
default:
- ret = machine__process_event(machine, event, sample);
+ ret = machine__process_event(machine, event);
break;
}
@@ -1336,11 +492,11 @@ static int trace__process_event(struct trace *trace, struct machine *machine,
static int trace__tool_process(struct perf_tool *tool,
union perf_event *event,
- struct perf_sample *sample,
+ struct perf_sample *sample __maybe_unused,
struct machine *machine)
{
struct trace *trace = container_of(tool, struct trace, tool);
- return trace__process_event(trace, machine, event, sample);
+ return trace__process_event(trace, machine, event);
}
static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
@@ -1350,12 +506,18 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
if (err)
return err;
- trace->host = machine__new_host();
- if (trace->host == NULL)
- return -ENOMEM;
+ machine__init(&trace->host, "", HOST_KERNEL_ID);
+ machine__create_kernel_maps(&trace->host);
+
+ if (perf_target__has_task(&trace->opts.target)) {
+ err = perf_event__synthesize_thread_map(&trace->tool, evlist->threads,
+ trace__tool_process,
+ &trace->host);
+ } else {
+ err = perf_event__synthesize_threads(&trace->tool, trace__tool_process,
+ &trace->host);
+ }
- err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target,
- evlist->threads, trace__tool_process, false);
if (err)
symbol__exit();
@@ -1371,9 +533,6 @@ static int syscall__set_arg_fmts(struct syscall *sc)
if (sc->arg_scnprintf == NULL)
return -1;
- if (sc->fmt)
- sc->arg_parm = sc->fmt->arg_parm;
-
for (field = sc->tp_format->format.fields->next; field; field = field->next) {
if (sc->fmt && sc->fmt->arg_scnprintf[idx])
sc->arg_scnprintf[idx] = sc->fmt->arg_scnprintf[idx];
@@ -1389,7 +548,7 @@ static int trace__read_syscall_info(struct trace *trace, int id)
{
char tp_name[128];
struct syscall *sc;
- const char *name = audit_syscall_to_name(id, trace->audit.machine);
+ const char *name = audit_syscall_to_name(id, trace->audit_machine);
if (name == NULL)
return -1;
@@ -1444,52 +603,32 @@ static int trace__read_syscall_info(struct trace *trace, int id)
}
static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size,
- unsigned long *args, struct trace *trace,
- struct thread *thread)
+ unsigned long *args)
{
+ int i = 0;
size_t printed = 0;
if (sc->tp_format != NULL) {
struct format_field *field;
- u8 bit = 1;
- struct syscall_arg arg = {
- .idx = 0,
- .mask = 0,
- .trace = trace,
- .thread = thread,
- };
+ u8 mask = 0, bit = 1;
for (field = sc->tp_format->format.fields->next; field;
- field = field->next, ++arg.idx, bit <<= 1) {
- if (arg.mask & bit)
- continue;
- /*
- * Suppress this argument if its value is zero and
- * and we don't have a string associated in an
- * strarray for it.
- */
- if (args[arg.idx] == 0 &&
- !(sc->arg_scnprintf &&
- sc->arg_scnprintf[arg.idx] == SCA_STRARRAY &&
- sc->arg_parm[arg.idx]))
+ field = field->next, ++i, bit <<= 1) {
+ if (mask & bit)
continue;
printed += scnprintf(bf + printed, size - printed,
"%s%s: ", printed ? ", " : "", field->name);
- if (sc->arg_scnprintf && sc->arg_scnprintf[arg.idx]) {
- arg.val = args[arg.idx];
- if (sc->arg_parm)
- arg.parm = sc->arg_parm[arg.idx];
- printed += sc->arg_scnprintf[arg.idx](bf + printed,
- size - printed, &arg);
+
+ if (sc->arg_scnprintf && sc->arg_scnprintf[i]) {
+ printed += sc->arg_scnprintf[i](bf + printed, size - printed,
+ args[i], i, &mask);
} else {
printed += scnprintf(bf + printed, size - printed,
- "%ld", args[arg.idx]);
+ "%ld", args[i]);
}
}
} else {
- int i = 0;
-
while (i < 6) {
printed += scnprintf(bf + printed, size - printed,
"%sarg%d: %ld",
@@ -1505,8 +644,10 @@ typedef int (*tracepoint_handler)(struct trace *trace, struct perf_evsel *evsel,
struct perf_sample *sample);
static struct syscall *trace__syscall_info(struct trace *trace,
- struct perf_evsel *evsel, int id)
+ struct perf_evsel *evsel,
+ struct perf_sample *sample)
{
+ int id = perf_evsel__intval(evsel, sample, "id");
if (id < 0) {
@@ -1547,32 +688,6 @@ out_cant_read:
return NULL;
}
-static void thread__update_stats(struct thread_trace *ttrace,
- int id, struct perf_sample *sample)
-{
- struct int_node *inode;
- struct stats *stats;
- u64 duration = 0;
-
- inode = intlist__findnew(ttrace->syscall_stats, id);
- if (inode == NULL)
- return;
-
- stats = inode->priv;
- if (stats == NULL) {
- stats = malloc(sizeof(struct stats));
- if (stats == NULL)
- return;
- init_stats(stats);
- inode->priv = stats;
- }
-
- if (ttrace->entry_time && sample->time > ttrace->entry_time)
- duration = sample->time - ttrace->entry_time;
-
- update_stats(stats, duration);
-}
-
static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
struct perf_sample *sample)
{
@@ -1580,8 +695,7 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
void *args;
size_t printed = 0;
struct thread *thread;
- int id = perf_evsel__sc_tp_uint(evsel, id, sample);
- struct syscall *sc = trace__syscall_info(trace, evsel, id);
+ struct syscall *sc = trace__syscall_info(trace, evsel, sample);
struct thread_trace *ttrace;
if (sc == NULL)
@@ -1590,12 +704,18 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
if (sc->filtered)
return 0;
- thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
+ thread = machine__findnew_thread(&trace->host, sample->pid,
+ sample->tid);
ttrace = thread__trace(thread, trace->output);
if (ttrace == NULL)
return -1;
- args = perf_evsel__sc_tp_ptr(evsel, args, sample);
+ args = perf_evsel__rawptr(evsel, sample, "args");
+ if (args == NULL) {
+ fprintf(trace->output, "Problems reading syscall arguments\n");
+ return -1;
+ }
+
ttrace = thread->priv;
if (ttrace->entry_str == NULL) {
@@ -1608,11 +728,10 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
msg = ttrace->entry_str;
printed += scnprintf(msg + printed, 1024 - printed, "%s(", sc->name);
- printed += syscall__scnprintf_args(sc, msg + printed, 1024 - printed,
- args, trace, thread);
+ printed += syscall__scnprintf_args(sc, msg + printed, 1024 - printed, args);
if (!strcmp(sc->name, "exit_group") || !strcmp(sc->name, "exit")) {
- if (!trace->duration_filter && !trace->summary_only) {
+ if (!trace->duration_filter) {
trace__fprintf_entry_head(trace, thread, 1, sample->time, trace->output);
fprintf(trace->output, "%-70s\n", ttrace->entry_str);
}
@@ -1628,8 +747,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
int ret;
u64 duration = 0;
struct thread *thread;
- int id = perf_evsel__sc_tp_uint(evsel, id, sample);
- struct syscall *sc = trace__syscall_info(trace, evsel, id);
+ struct syscall *sc = trace__syscall_info(trace, evsel, sample);
struct thread_trace *ttrace;
if (sc == NULL)
@@ -1638,21 +756,13 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
if (sc->filtered)
return 0;
- thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
+ thread = machine__findnew_thread(&trace->host, sample->pid,
+ sample->tid);
ttrace = thread__trace(thread, trace->output);
if (ttrace == NULL)
return -1;
- if (trace->summary)
- thread__update_stats(ttrace, id, sample);
-
- ret = perf_evsel__sc_tp_uint(evsel, ret, sample);
-
- if (id == trace->audit.open_id && ret >= 0 && trace->last_vfs_getname) {
- trace__set_fd_pathname(thread, ret, trace->last_vfs_getname);
- trace->last_vfs_getname = NULL;
- ++trace->stats.vfs_getname;
- }
+ ret = perf_evsel__intval(evsel, sample, "ret");
ttrace = thread->priv;
@@ -1665,9 +775,6 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
} else if (trace->duration_filter)
goto out;
- if (trace->summary_only)
- goto out;
-
trace__fprintf_entry_head(trace, thread, duration, sample->time, trace->output);
if (ttrace->entry_pending) {
@@ -1701,19 +808,12 @@ out:
return 0;
}
-static int trace__vfs_getname(struct trace *trace, struct perf_evsel *evsel,
- struct perf_sample *sample)
-{
- trace->last_vfs_getname = perf_evsel__rawptr(evsel, sample, "pathname");
- return 0;
-}
-
static int trace__sched_stat_runtime(struct trace *trace, struct perf_evsel *evsel,
struct perf_sample *sample)
{
u64 runtime = perf_evsel__intval(evsel, sample, "runtime");
double runtime_ms = (double)runtime / NSEC_PER_MSEC;
- struct thread *thread = machine__findnew_thread(trace->host,
+ struct thread *thread = machine__findnew_thread(&trace->host,
sample->pid,
sample->tid);
struct thread_trace *ttrace = thread__trace(thread, trace->output);
@@ -1756,12 +856,12 @@ static int trace__process_sample(struct perf_tool *tool,
struct trace *trace = container_of(tool, struct trace, tool);
int err = 0;
- tracepoint_handler handler = evsel->handler;
+ tracepoint_handler handler = evsel->handler.func;
if (skip_sample(trace, sample))
return 0;
- if (!trace->full_time && trace->base_time == 0)
+ if (trace->base_time == 0)
trace->base_time = sample->time;
if (handler)
@@ -1770,6 +870,16 @@ static int trace__process_sample(struct perf_tool *tool,
return err;
}
+static bool
+perf_session__has_tp(struct perf_session *session, const char *name)
+{
+ struct perf_evsel *evsel;
+
+ evsel = perf_evlist__find_tracepoint_by_name(session->evlist, name);
+
+ return evsel != NULL;
+}
+
static int parse_target_str(struct trace *trace)
{
if (trace->opts.target.pid) {
@@ -1791,50 +901,6 @@ static int parse_target_str(struct trace *trace)
return 0;
}
-static int trace__record(int argc, const char **argv)
-{
- unsigned int rec_argc, i, j;
- const char **rec_argv;
- const char * const record_args[] = {
- "record",
- "-R",
- "-m", "1024",
- "-c", "1",
- "-e", "raw_syscalls:sys_enter,raw_syscalls:sys_exit",
- };
-
- rec_argc = ARRAY_SIZE(record_args) + argc;
- rec_argv = calloc(rec_argc + 1, sizeof(char *));
-
- if (rec_argv == NULL)
- return -ENOMEM;
-
- for (i = 0; i < ARRAY_SIZE(record_args); i++)
- rec_argv[i] = record_args[i];
-
- for (j = 0; j < (unsigned int)argc; j++, i++)
- rec_argv[i] = argv[j];
-
- return cmd_record(i, rec_argv, NULL);
-}
-
-static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp);
-
-static void perf_evlist__add_vfs_getname(struct perf_evlist *evlist)
-{
- struct perf_evsel *evsel = perf_evsel__newtp("probe", "vfs_getname");
- if (evsel == NULL)
- return;
-
- if (perf_evsel__field(evsel, "pathname") == NULL) {
- perf_evsel__delete(evsel);
- return;
- }
-
- evsel->handler = trace__vfs_getname;
- perf_evlist__add(evlist, evsel);
-}
-
static int trace__run(struct trace *trace, int argc, const char **argv)
{
struct perf_evlist *evlist = perf_evlist__new();
@@ -1843,22 +909,23 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
unsigned long before;
const bool forks = argc > 0;
- trace->live = true;
-
if (evlist == NULL) {
fprintf(trace->output, "Not enough memory to run!\n");
goto out;
}
- if (perf_evlist__add_syscall_newtp(evlist, trace__sys_enter, trace__sys_exit))
- goto out_error_tp;
-
- perf_evlist__add_vfs_getname(evlist);
+ if (perf_evlist__add_newtp(evlist, "raw_syscalls", "sys_enter", trace__sys_enter) ||
+ perf_evlist__add_newtp(evlist, "raw_syscalls", "sys_exit", trace__sys_exit)) {
+ fprintf(trace->output, "Couldn't read the raw_syscalls tracepoints information!\n");
+ goto out_delete_evlist;
+ }
if (trace->sched &&
- perf_evlist__add_newtp(evlist, "sched", "sched_stat_runtime",
- trace__sched_stat_runtime))
- goto out_error_tp;
+ perf_evlist__add_newtp(evlist, "sched", "sched_stat_runtime",
+ trace__sched_stat_runtime)) {
+ fprintf(trace->output, "Couldn't read the sched_stat_runtime tracepoint information!\n");
+ goto out_delete_evlist;
+ }
err = perf_evlist__create_maps(evlist, &trace->opts.target);
if (err < 0) {
@@ -1887,8 +954,10 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
}
err = perf_evlist__open(evlist);
- if (err < 0)
- goto out_error_open;
+ if (err < 0) {
+ fprintf(trace->output, "Couldn't create the events: %s\n", strerror(errno));
+ goto out_delete_maps;
+ }
err = perf_evlist__mmap(evlist, UINT_MAX, false);
if (err < 0) {
@@ -1921,11 +990,11 @@ again:
goto next_event;
}
- if (!trace->full_time && trace->base_time == 0)
+ if (trace->base_time == 0)
trace->base_time = sample.time;
if (type != PERF_RECORD_SAMPLE) {
- trace__process_event(trace, trace->host, event, &sample);
+ trace__process_event(trace, &trace->host, event);
continue;
}
@@ -1942,41 +1011,29 @@ again:
goto next_event;
}
- handler = evsel->handler;
+ handler = evsel->handler.func;
handler(trace, evsel, &sample);
next_event:
perf_evlist__mmap_consume(evlist, i);
- if (interrupted)
- goto out_disable;
+ if (done)
+ goto out_unmap_evlist;
}
}
if (trace->nr_events == before) {
- int timeout = done ? 100 : -1;
+ if (done)
+ goto out_unmap_evlist;
- if (poll(evlist->pollfd, evlist->nr_fds, timeout) > 0)
- goto again;
- } else {
- goto again;
+ poll(evlist->pollfd, evlist->nr_fds, -1);
}
-out_disable:
- perf_evlist__disable(evlist);
+ if (done)
+ perf_evlist__disable(evlist);
- if (!err) {
- if (trace->summary)
- trace__fprintf_thread_summary(trace, trace->output);
-
- if (trace->show_tool_stats) {
- fprintf(trace->output, "Stats:\n "
- " vfs_getname : %" PRIu64 "\n"
- " proc_getname: %" PRIu64 "\n",
- trace->stats.vfs_getname,
- trace->stats.proc_getname);
- }
- }
+ goto again;
+out_unmap_evlist:
perf_evlist__munmap(evlist);
out_close_evlist:
perf_evlist__close(evlist);
@@ -1985,35 +1042,17 @@ out_delete_maps:
out_delete_evlist:
perf_evlist__delete(evlist);
out:
- trace->live = false;
return err;
-{
- char errbuf[BUFSIZ];
-
-out_error_tp:
- perf_evlist__strerror_tp(evlist, errno, errbuf, sizeof(errbuf));
- goto out_error;
-
-out_error_open:
- perf_evlist__strerror_open(evlist, errno, errbuf, sizeof(errbuf));
-
-out_error:
- fprintf(trace->output, "%s\n", errbuf);
- goto out_delete_evlist;
-}
}
static int trace__replay(struct trace *trace)
{
const struct perf_evsel_str_handler handlers[] = {
- { "probe:vfs_getname", trace__vfs_getname, },
- };
- struct perf_data_file file = {
- .path = input_name,
- .mode = PERF_DATA_MODE_READ,
+ { "raw_syscalls:sys_enter", trace__sys_enter, },
+ { "raw_syscalls:sys_exit", trace__sys_exit, },
};
+
struct perf_session *session;
- struct perf_evsel *evsel;
int err = -1;
trace->tool.sample = trace__process_sample;
@@ -2035,39 +1074,22 @@ static int trace__replay(struct trace *trace)
if (symbol__init() < 0)
return -1;
- session = perf_session__new(&file, false, &trace->tool);
+ session = perf_session__new(input_name, O_RDONLY, 0, false,
+ &trace->tool);
if (session == NULL)
return -ENOMEM;
- trace->host = &session->machines.host;
-
err = perf_session__set_tracepoints_handlers(session, handlers);
if (err)
goto out;
- evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
- "raw_syscalls:sys_enter");
- if (evsel == NULL) {
- pr_err("Data file does not have raw_syscalls:sys_enter event\n");
- goto out;
- }
-
- if (perf_evsel__init_syscall_tp(evsel, trace__sys_enter) < 0 ||
- perf_evsel__init_sc_tp_ptr_field(evsel, args)) {
- pr_err("Error during initialize raw_syscalls:sys_enter event\n");
- goto out;
- }
-
- evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
- "raw_syscalls:sys_exit");
- if (evsel == NULL) {
- pr_err("Data file does not have raw_syscalls:sys_exit event\n");
+ if (!perf_session__has_tp(session, "raw_syscalls:sys_enter")) {
+ pr_err("Data file does not have raw_syscalls:sys_enter events\n");
goto out;
}
- if (perf_evsel__init_syscall_tp(evsel, trace__sys_exit) < 0 ||
- perf_evsel__init_sc_tp_uint_field(evsel, ret)) {
- pr_err("Error during initialize raw_syscalls:sys_exit event\n");
+ if (!perf_session__has_tp(session, "raw_syscalls:sys_exit")) {
+ pr_err("Data file does not have raw_syscalls:sys_exit events\n");
goto out;
}
@@ -2081,9 +1103,6 @@ static int trace__replay(struct trace *trace)
if (err)
pr_err("Failed to process events, error %d", err);
- else if (trace->summary)
- trace__fprintf_thread_summary(trace, trace->output);
-
out:
perf_session__delete(session);
@@ -2094,108 +1113,45 @@ static size_t trace__fprintf_threads_header(FILE *fp)
{
size_t printed;
- printed = fprintf(fp, "\n Summary of events:\n\n");
+ printed = fprintf(fp, "\n _____________________________________________________________________\n");
+ printed += fprintf(fp," __) Summary of events (__\n\n");
+ printed += fprintf(fp," [ task - pid ] [ events ] [ ratio ] [ runtime ]\n");
+ printed += fprintf(fp," _____________________________________________________________________\n\n");
return printed;
}
-static size_t thread__dump_stats(struct thread_trace *ttrace,
- struct trace *trace, FILE *fp)
-{
- struct stats *stats;
- size_t printed = 0;
- struct syscall *sc;
- struct int_node *inode = intlist__first(ttrace->syscall_stats);
-
- if (inode == NULL)
- return 0;
-
- printed += fprintf(fp, "\n");
-
- printed += fprintf(fp, " syscall calls min avg max stddev\n");
- printed += fprintf(fp, " (msec) (msec) (msec) (%%)\n");
- printed += fprintf(fp, " --------------- -------- --------- --------- --------- ------\n");
-
- /* each int_node is a syscall */
- while (inode) {
- stats = inode->priv;
- if (stats) {
- double min = (double)(stats->min) / NSEC_PER_MSEC;
- double max = (double)(stats->max) / NSEC_PER_MSEC;
- double avg = avg_stats(stats);
- double pct;
- u64 n = (u64) stats->n;
-
- pct = avg ? 100.0 * stddev_stats(stats)/avg : 0.0;
- avg /= NSEC_PER_MSEC;
-
- sc = &trace->syscalls.table[inode->i];
- printed += fprintf(fp, " %-15s", sc->name);
- printed += fprintf(fp, " %8" PRIu64 " %9.3f %9.3f",
- n, min, avg);
- printed += fprintf(fp, " %9.3f %9.2f%%\n", max, pct);
- }
-
- inode = intlist__next(inode);
- }
-
- printed += fprintf(fp, "\n\n");
-
- return printed;
-}
-
-/* struct used to pass data to per-thread function */
-struct summary_data {
- FILE *fp;
- struct trace *trace;
- size_t printed;
-};
-
-static int trace__fprintf_one_thread(struct thread *thread, void *priv)
+static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp)
{
- struct summary_data *data = priv;
- FILE *fp = data->fp;
- size_t printed = data->printed;
- struct trace *trace = data->trace;
- struct thread_trace *ttrace = thread->priv;
- const char *color;
- double ratio;
-
- if (ttrace == NULL)
- return 0;
+ size_t printed = trace__fprintf_threads_header(fp);
+ struct rb_node *nd;
- ratio = (double)ttrace->nr_events / trace->nr_events * 100.0;
+ for (nd = rb_first(&trace->host.threads); nd; nd = rb_next(nd)) {
+ struct thread *thread = rb_entry(nd, struct thread, rb_node);
+ struct thread_trace *ttrace = thread->priv;
+ const char *color;
+ double ratio;
- color = PERF_COLOR_NORMAL;
- if (ratio > 50.0)
- color = PERF_COLOR_RED;
- else if (ratio > 25.0)
- color = PERF_COLOR_GREEN;
- else if (ratio > 5.0)
- color = PERF_COLOR_YELLOW;
+ if (ttrace == NULL)
+ continue;
- printed += color_fprintf(fp, color, " %s (%d), ", thread__comm_str(thread), thread->tid);
- printed += fprintf(fp, "%lu events, ", ttrace->nr_events);
- printed += color_fprintf(fp, color, "%.1f%%", ratio);
- printed += fprintf(fp, ", %.3f msec\n", ttrace->runtime_ms);
- printed += thread__dump_stats(ttrace, trace, fp);
+ ratio = (double)ttrace->nr_events / trace->nr_events * 100.0;
- data->printed += printed;
+ color = PERF_COLOR_NORMAL;
+ if (ratio > 50.0)
+ color = PERF_COLOR_RED;
+ else if (ratio > 25.0)
+ color = PERF_COLOR_GREEN;
+ else if (ratio > 5.0)
+ color = PERF_COLOR_YELLOW;
- return 0;
-}
-
-static size_t trace__fprintf_thread_summary(struct trace *trace, FILE *fp)
-{
- struct summary_data data = {
- .fp = fp,
- .trace = trace
- };
- data.printed = trace__fprintf_threads_header(fp);
-
- machine__for_each_thread(trace->host, trace__fprintf_one_thread, &data);
+ printed += color_fprintf(fp, color, "%20s", thread->comm);
+ printed += fprintf(fp, " - %-5d :%11lu [", thread->tid, ttrace->nr_events);
+ printed += color_fprintf(fp, color, "%5.1f%%", ratio);
+ printed += fprintf(fp, " ] %10.3f ms\n", ttrace->runtime_ms);
+ }
- return data.printed;
+ return printed;
}
static int trace__set_duration(const struct option *opt, const char *str,
@@ -2229,15 +1185,10 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
const char * const trace_usage[] = {
"perf trace [<options>] [<command>]",
"perf trace [<options>] -- <command> [<options>]",
- "perf trace record [<options>] [<command>]",
- "perf trace record [<options>] -- <command> [<options>]",
NULL
};
struct trace trace = {
- .audit = {
- .machine = audit_detect_machine(),
- .open_id = audit_name_to_syscall("open", trace.audit.machine),
- },
+ .audit_machine = audit_detect_machine(),
.syscalls = {
. max = -1,
},
@@ -2252,14 +1203,10 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
.mmap_pages = 1024,
},
.output = stdout,
- .show_comm = true,
};
const char *output_name = NULL;
const char *ev_qualifier_str = NULL;
const struct option trace_options[] = {
- OPT_BOOLEAN(0, "comm", &trace.show_comm,
- "show the thread COMM next to its id"),
- OPT_BOOLEAN(0, "tool_stats", &trace.show_tool_stats, "show tool stats"),
OPT_STRING('e', "expr", &ev_qualifier_str, "expr",
"list of events to trace"),
OPT_STRING('o', "output", &output_name, "file", "output file name"),
@@ -2274,9 +1221,8 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
"list of cpus to monitor"),
OPT_BOOLEAN(0, "no-inherit", &trace.opts.no_inherit,
"child tasks do not inherit counters"),
- OPT_CALLBACK('m', "mmap-pages", &trace.opts.mmap_pages, "pages",
- "number of mmap data pages",
- perf_evlist__parse_mmap_pages),
+ OPT_UINTEGER('m', "mmap-pages", &trace.opts.mmap_pages,
+ "number of mmap data pages"),
OPT_STRING('u', "uid", &trace.opts.target.uid_str, "user",
"user to profile"),
OPT_CALLBACK(0, "duration", &trace, "float",
@@ -2284,26 +1230,13 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
trace__set_duration),
OPT_BOOLEAN(0, "sched", &trace.sched, "show blocking scheduler events"),
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
- OPT_BOOLEAN('T', "time", &trace.full_time,
- "Show full timestamp, not time relative to first start"),
- OPT_BOOLEAN('s', "summary", &trace.summary_only,
- "Show only syscall summary with statistics"),
- OPT_BOOLEAN('S', "with-summary", &trace.summary,
- "Show all syscalls and summary with statistics"),
OPT_END()
};
int err;
char bf[BUFSIZ];
- if ((argc > 1) && (strcmp(argv[1], "record") == 0))
- return trace__record(argc-2, &argv[2]);
-
argc = parse_options(argc, argv, trace_options, trace_usage, 0);
- /* summary_only implies summary option, but don't overwrite summary if set */
- if (trace.summary_only)
- trace.summary = trace.summary_only;
-
if (output_name != NULL) {
err = trace__open_output(&trace, output_name);
if (err < 0) {
@@ -2327,21 +1260,21 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
}
}
- err = target__validate(&trace.opts.target);
+ err = perf_target__validate(&trace.opts.target);
if (err) {
- target__strerror(&trace.opts.target, err, bf, sizeof(bf));
+ perf_target__strerror(&trace.opts.target, err, bf, sizeof(bf));
fprintf(trace.output, "%s", bf);
goto out_close;
}
- err = target__parse_uid(&trace.opts.target);
+ err = perf_target__parse_uid(&trace.opts.target);
if (err) {
- target__strerror(&trace.opts.target, err, bf, sizeof(bf));
+ perf_target__strerror(&trace.opts.target, err, bf, sizeof(bf));
fprintf(trace.output, "%s", bf);
goto out_close;
}
- if (!argc && target__none(&trace.opts.target))
+ if (!argc && perf_target__none(&trace.opts.target))
trace.opts.target.system_wide = true;
if (input_name)
@@ -2349,6 +1282,9 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
else
err = trace__run(&trace, argc, argv);
+ if (trace.sched && !err)
+ trace__fprintf_thread_summary(&trace, trace.output);
+
out_close:
if (output_name != NULL)
fclose(trace.output);
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index f7d11a8..5f6f9b3 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -23,21 +23,15 @@ ifeq ($(ARCH),x86_64)
endif
ifeq (${IS_X86_64}, 1)
RAW_ARCH := x86_64
- CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT
+ CFLAGS += -DARCH_X86_64
ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
- LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
- else
- LIBUNWIND_LIBS = -lunwind -lunwind-x86
endif
NO_PERF_REGS := 0
-endif
-ifeq ($(ARCH),arm)
- NO_PERF_REGS := 0
- LIBUNWIND_LIBS = -lunwind -lunwind-arm
+ LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
endif
ifeq ($(NO_PERF_REGS),0)
- CFLAGS += -DHAVE_PERF_REGS_SUPPORT
+ CFLAGS += -DHAVE_PERF_REGS
endif
ifeq ($(src-perf),)
@@ -57,6 +51,7 @@ LIB_INCLUDE := $(srctree)/tools/lib/
# include ARCH specific config
-include $(src-perf)/arch/$(ARCH)/Makefile
+include $(src-perf)/config/feature-tests.mak
include $(src-perf)/config/utilities.mak
ifeq ($(call get-executable,$(FLEX)),)
@@ -72,11 +67,10 @@ ifneq ($(WERROR),0)
CFLAGS += -Werror
endif
-ifndef DEBUG
- DEBUG := 0
+ifeq ("$(origin DEBUG)", "command line")
+ PERF_DEBUG = $(DEBUG)
endif
-
-ifeq ($(DEBUG),0)
+ifndef PERF_DEBUG
CFLAGS += -O6
endif
@@ -95,126 +89,20 @@ CFLAGS += -std=gnu99
EXTLIBS = -lelf -lpthread -lrt -lm -ldl
-ifneq ($(OUTPUT),)
- OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
- $(shell mkdir -p $(OUTPUT_FEATURES))
-endif
-
-feature_check = $(eval $(feature_check_code))
-define feature_check_code
- feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBUNWIND_LIBS="$(LIBUNWIND_LIBS)" -C config/feature-checks test-$1 >/dev/null 2>/dev/null && echo 1 || echo 0)
-endef
-
-feature_set = $(eval $(feature_set_code))
-define feature_set_code
- feature-$(1) := 1
-endef
-
-#
-# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
-#
-
-#
-# Note that this is not a complete list of all feature tests, just
-# those that are typically built on a fully configured system.
-#
-# [ Feature tests not mentioned here have to be built explicitly in
-# the rule that uses them - an example for that is the 'bionic'
-# feature check. ]
-#
-CORE_FEATURE_TESTS = \
- backtrace \
- dwarf \
- fortify-source \
- glibc \
- gtk2 \
- gtk2-infobar \
- libaudit \
- libbfd \
- libelf \
- libelf-getphdrnum \
- libelf-mmap \
- libnuma \
- libperl \
- libpython \
- libpython-version \
- libslang \
- libunwind \
- on-exit \
- stackprotector \
- stackprotector-all \
- timerfd
-
-#
-# So here we detect whether test-all was rebuilt, to be able
-# to skip the print-out of the long features list if the file
-# existed before and after it was built:
-#
-ifeq ($(wildcard $(OUTPUT)config/feature-checks/test-all),)
- test-all-failed := 1
-else
- test-all-failed := 0
-endif
-
-#
-# Special fast-path for the 'all features are available' case:
-#
-$(call feature_check,all,$(MSG))
-
-#
-# Just in case the build freshly failed, make sure we print the
-# feature matrix:
-#
-ifeq ($(feature-all), 0)
- test-all-failed := 1
-endif
-
-ifeq ($(test-all-failed),1)
- $(info )
- $(info Auto-detecting system features:)
-endif
-
-ifeq ($(feature-all), 1)
- #
- # test-all.c passed - just set all the core feature flags to 1:
- #
- $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_set,$(feat)))
-else
- $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(CORE_FEATURE_TESTS) >/dev/null 2>&1)
- $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_check,$(feat)))
-endif
-
-#
-# Print the result of the feature test:
-#
-feature_print = $(eval $(feature_print_code)) $(info $(MSG))
-
-define feature_print_code
- ifeq ($(feature-$(1)), 1)
- MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1))
- else
- MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1))
- endif
-endef
-
-#
-# Only print out our features if we rebuilt the testcases or if a test failed:
-#
-ifeq ($(test-all-failed), 1)
- $(foreach feat,$(CORE_FEATURE_TESTS),$(call feature_print,$(feat)))
- $(info )
-endif
-
-ifeq ($(feature-stackprotector-all), 1)
+ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y)
CFLAGS += -fstack-protector-all
endif
-ifeq ($(feature-stackprotector), 1)
+ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y)
CFLAGS += -Wstack-protector
endif
-ifeq ($(DEBUG),0)
- ifeq ($(feature-fortify-source), 1)
+ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y)
+ CFLAGS += -Wvolatile-register-var
+endif
+
+ifndef PERF_DEBUG
+ ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y)
CFLAGS += -D_FORTIFY_SOURCE=2
endif
endif
@@ -240,121 +128,120 @@ CFLAGS += -I$(LIB_INCLUDE)
CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
ifndef NO_BIONIC
- $(call feature_check,bionic)
- ifeq ($(feature-bionic), 1)
- BIONIC := 1
- EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
- EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
- endif
+ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y)
+ BIONIC := 1
+ EXTLIBS := $(filter-out -lrt,$(EXTLIBS))
+ EXTLIBS := $(filter-out -lpthread,$(EXTLIBS))
endif
+endif # NO_BIONIC
ifdef NO_LIBELF
NO_DWARF := 1
NO_DEMANGLE := 1
NO_LIBUNWIND := 1
else
- ifeq ($(feature-libelf), 0)
- ifeq ($(feature-glibc), 1)
- LIBC_SUPPORT := 1
- endif
- ifeq ($(BIONIC),1)
- LIBC_SUPPORT := 1
- endif
- ifeq ($(LIBC_SUPPORT),1)
- msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
+FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS)
+ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y)
+ FLAGS_GLIBC=$(CFLAGS) $(LDFLAGS)
+ ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y)
+ LIBC_SUPPORT := 1
+ endif
+ ifeq ($(BIONIC),1)
+ LIBC_SUPPORT := 1
+ endif
+ ifeq ($(LIBC_SUPPORT),1)
+ msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev);
- NO_LIBELF := 1
- NO_DWARF := 1
- NO_DEMANGLE := 1
- else
- msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
- endif
+ NO_LIBELF := 1
+ NO_DWARF := 1
+ NO_DEMANGLE := 1
else
- # for linking with debug library, run like:
- # make DEBUG=1 LIBDW_DIR=/opt/libdw/
- ifdef LIBDW_DIR
- LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
- LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
- endif
+ msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static);
+ endif
+else
+ # for linking with debug library, run like:
+ # make DEBUG=1 LIBDW_DIR=/opt/libdw/
+ ifdef LIBDW_DIR
+ LIBDW_CFLAGS := -I$(LIBDW_DIR)/include
+ LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib
+ endif
- ifneq ($(feature-dwarf), 1)
- msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev);
- NO_DWARF := 1
- endif # Dwarf support
- endif # libelf support
+ FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lz -lelf $(LIBDW_LDFLAGS) $(LDFLAGS) $(EXTLIBS)
+ ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y)
+ msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev);
+ NO_DWARF := 1
+ endif # Dwarf support
+endif # SOURCE_LIBELF
endif # NO_LIBELF
ifndef NO_LIBELF
- CFLAGS += -DHAVE_LIBELF_SUPPORT
+CFLAGS += -DLIBELF_SUPPORT
+FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS)
+ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y)
+ CFLAGS += -DLIBELF_MMAP
+endif
+ifeq ($(call try-cc,$(SOURCE_ELF_GETPHDRNUM),$(FLAGS_LIBELF),-DHAVE_ELF_GETPHDRNUM),y)
+ CFLAGS += -DHAVE_ELF_GETPHDRNUM
+endif
- ifeq ($(feature-libelf-mmap), 1)
- CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT
- endif
+# include ARCH specific config
+-include $(src-perf)/arch/$(ARCH)/Makefile
- ifeq ($(feature-libelf-getphdrnum), 1)
- CFLAGS += -DHAVE_ELF_GETPHDRNUM_SUPPORT
- endif
+ifndef NO_DWARF
+ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
+ msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
+ NO_DWARF := 1
+else
+ CFLAGS += -DDWARF_SUPPORT $(LIBDW_CFLAGS)
+ LDFLAGS += $(LIBDW_LDFLAGS)
+ EXTLIBS += -lelf -ldw
+endif # PERF_HAVE_DWARF_REGS
+endif # NO_DWARF
- # include ARCH specific config
- -include $(src-perf)/arch/$(ARCH)/Makefile
+endif # NO_LIBELF
- ifndef NO_DWARF
- ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined)
- msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled);
- NO_DWARF := 1
- else
- CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
- LDFLAGS += $(LIBDW_LDFLAGS)
- EXTLIBS += -lelf -ldw
- endif # PERF_HAVE_DWARF_REGS
- endif # NO_DWARF
+ifndef NO_LIBELF
+CFLAGS += -DLIBELF_SUPPORT
+FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS)
+ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y)
+ CFLAGS += -DLIBELF_MMAP
+endif # try-cc
endif # NO_LIBELF
-ifeq ($(LIBUNWIND_LIBS),)
+# There's only x86 (both 32 and 64) support for CFI unwind so far
+ifneq ($(ARCH),x86)
NO_LIBUNWIND := 1
endif
ifndef NO_LIBUNWIND
- #
- # For linking with debug library, run like:
- #
- # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
- #
- ifdef LIBUNWIND_DIR
- LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include
- LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib
- endif
-
- ifneq ($(feature-libunwind), 1)
- msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 1.1);
- NO_LIBUNWIND := 1
- else
- ifeq ($(ARCH),arm)
- $(call feature_check,libunwind-debug-frame)
- ifneq ($(feature-libunwind-debug-frame), 1)
- msg := $(warning No debug_frame support found in libunwind);
- CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
- endif
- else
- # non-ARM has no dwarf_find_debug_frame() function:
- CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
- endif
- endif
+# for linking with debug library, run like:
+# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
+ifdef LIBUNWIND_DIR
+ LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include
+ LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib
endif
+FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(CFLAGS) $(LIBUNWIND_LDFLAGS) $(LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS)
+ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y)
+ msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] >= 0.99);
+ NO_LIBUNWIND := 1
+endif # Libunwind support
+endif # NO_LIBUNWIND
+
ifndef NO_LIBUNWIND
- CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
+ CFLAGS += -DLIBUNWIND_SUPPORT
EXTLIBS += $(LIBUNWIND_LIBS)
CFLAGS += $(LIBUNWIND_CFLAGS)
LDFLAGS += $(LIBUNWIND_LDFLAGS)
-endif
+endif # NO_LIBUNWIND
ifndef NO_LIBAUDIT
- ifneq ($(feature-libaudit), 1)
+ FLAGS_LIBAUDIT = $(CFLAGS) $(LDFLAGS) -laudit
+ ifneq ($(call try-cc,$(SOURCE_LIBAUDIT),$(FLAGS_LIBAUDIT),libaudit),y)
msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
NO_LIBAUDIT := 1
else
- CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
+ CFLAGS += -DLIBAUDIT_SUPPORT
EXTLIBS += -laudit
endif
endif
@@ -364,30 +251,30 @@ ifdef NO_NEWT
endif
ifndef NO_SLANG
- ifneq ($(feature-libslang), 1)
+ FLAGS_SLANG=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -I/usr/include/slang -lslang
+ ifneq ($(call try-cc,$(SOURCE_SLANG),$(FLAGS_SLANG),libslang),y)
msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev);
NO_SLANG := 1
else
# Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
CFLAGS += -I/usr/include/slang
- CFLAGS += -DHAVE_SLANG_SUPPORT
+ CFLAGS += -DSLANG_SUPPORT
EXTLIBS += -lslang
endif
endif
ifndef NO_GTK2
FLAGS_GTK2=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
- ifneq ($(feature-gtk2), 1)
+ ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2),gtk2),y)
msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
NO_GTK2 := 1
else
- ifeq ($(feature-gtk2-infobar), 1)
- GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
+ ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2),-DHAVE_GTK_INFO_BAR),y)
+ CFLAGS += -DHAVE_GTK_INFO_BAR
endif
- CFLAGS += -DHAVE_GTK2_SUPPORT
- GTK_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
- GTK_LIBS := $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
- EXTLIBS += -ldl
+ CFLAGS += -DGTK2_SUPPORT
+ CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
+ EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
endif
endif
@@ -403,7 +290,7 @@ else
PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
- ifneq ($(feature-libperl), 1)
+ ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED),perl),y)
CFLAGS += -DNO_LIBPERL
NO_LIBPERL := 1
else
@@ -412,12 +299,6 @@ else
endif
endif
-ifeq ($(feature-timerfd), 1)
- CFLAGS += -DHAVE_TIMERFD_SUPPORT
-else
- msg := $(warning No timerfd support. Disables 'perf kvm stat live');
-endif
-
disable-python = $(eval $(disable-python_code))
define disable-python_code
CFLAGS += -DNO_LIBPYTHON
@@ -454,11 +335,11 @@ else
PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
- ifneq ($(feature-libpython), 1)
+ ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED),python),y)
$(call disable-python,Python.h (for Python 2.x))
else
- ifneq ($(feature-libpython-version), 1)
+ ifneq ($(call try-cc,$(SOURCE_PYTHON_VERSION),$(FLAGS_PYTHON_EMBED),python version),y)
$(warning Python 3 is not yet supported; please set)
$(warning PYTHON and/or PYTHON_CONFIG appropriately.)
$(warning If you also have Python 2 installed, then)
@@ -481,30 +362,33 @@ else
endif
endif
-ifeq ($(feature-libbfd), 1)
- EXTLIBS += -lbfd
-endif
-
ifdef NO_DEMANGLE
CFLAGS += -DNO_DEMANGLE
else
- ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
+ ifdef HAVE_CPLUS_DEMANGLE
EXTLIBS += -liberty
- CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
+ CFLAGS += -DHAVE_CPLUS_DEMANGLE
else
- ifneq ($(feature-libbfd), 1)
- $(call feature_check,liberty)
- ifeq ($(feature-liberty), 1)
+ FLAGS_BFD=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd
+ has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd)
+ ifeq ($(has_bfd),y)
+ EXTLIBS += -lbfd
+ else
+ FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
+ has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty)
+ ifeq ($(has_bfd_iberty),y)
EXTLIBS += -lbfd -liberty
else
- $(call feature_check,liberty-z)
- ifeq ($(feature-liberty-z), 1)
+ FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz
+ has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z),libz)
+ ifeq ($(has_bfd_iberty_z),y)
EXTLIBS += -lbfd -liberty -lz
else
- $(call feature_check,cplus-demangle)
- ifeq ($(feature-cplus-demangle), 1)
+ FLAGS_CPLUS_DEMANGLE=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) -liberty
+ has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle)
+ ifeq ($(has_cplus_demangle),y)
EXTLIBS += -liberty
- CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
+ CFLAGS += -DHAVE_CPLUS_DEMANGLE
else
msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling)
CFLAGS += -DNO_DEMANGLE
@@ -515,28 +399,31 @@ else
endif
endif
-ifneq ($(filter -lbfd,$(EXTLIBS)),)
- CFLAGS += -DHAVE_LIBBFD_SUPPORT
+ifndef NO_STRLCPY
+ ifeq ($(call try-cc,$(SOURCE_STRLCPY),,-DHAVE_STRLCPY),y)
+ CFLAGS += -DHAVE_STRLCPY
+ endif
endif
ifndef NO_ON_EXIT
- ifeq ($(feature-on-exit), 1)
- CFLAGS += -DHAVE_ON_EXIT_SUPPORT
+ ifeq ($(call try-cc,$(SOURCE_ON_EXIT),,-DHAVE_ON_EXIT),y)
+ CFLAGS += -DHAVE_ON_EXIT
endif
endif
ifndef NO_BACKTRACE
- ifeq ($(feature-backtrace), 1)
- CFLAGS += -DHAVE_BACKTRACE_SUPPORT
+ ifeq ($(call try-cc,$(SOURCE_BACKTRACE),,-DBACKTRACE_SUPPORT),y)
+ CFLAGS += -DBACKTRACE_SUPPORT
endif
endif
ifndef NO_LIBNUMA
- ifeq ($(feature-libnuma), 0)
+ FLAGS_LIBNUMA = $(CFLAGS) $(LDFLAGS) -lnuma
+ ifneq ($(call try-cc,$(SOURCE_LIBNUMA),$(FLAGS_LIBNUMA),libnuma),y)
msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev);
NO_LIBNUMA := 1
else
- CFLAGS += -DHAVE_LIBNUMA_SUPPORT
+ CFLAGS += -DLIBNUMA_SUPPORT
EXTLIBS += -lnuma
endif
endif
@@ -572,12 +459,7 @@ else
sysconfdir = $(prefix)/etc
ETC_PERFCONFIG = etc/perfconfig
endif
-ifeq ($(IS_X86_64),1)
-lib = lib64
-else
lib = lib
-endif
-libdir = $(prefix)/$(lib)
# Shell quote (do not use $(call) to accommodate ancient setups);
ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
@@ -590,7 +472,6 @@ template_dir_SQ = $(subst ','\'',$(template_dir))
htmldir_SQ = $(subst ','\'',$(htmldir))
prefix_SQ = $(subst ','\'',$(prefix))
sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
-libdir_SQ = $(subst ','\'',$(libdir))
ifneq ($(filter /%,$(firstword $(perfexecdir))),)
perfexec_instdir = $(perfexecdir)
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
deleted file mode 100644
index 87e7900..0000000
--- a/tools/perf/config/feature-checks/Makefile
+++ /dev/null
@@ -1,152 +0,0 @@
-
-FILES= \
- test-all \
- test-backtrace \
- test-bionic \
- test-dwarf \
- test-fortify-source \
- test-glibc \
- test-gtk2 \
- test-gtk2-infobar \
- test-hello \
- test-libaudit \
- test-libbfd \
- test-liberty \
- test-liberty-z \
- test-cplus-demangle \
- test-libelf \
- test-libelf-getphdrnum \
- test-libelf-mmap \
- test-libnuma \
- test-libperl \
- test-libpython \
- test-libpython-version \
- test-libslang \
- test-libunwind \
- test-libunwind-debug-frame \
- test-on-exit \
- test-stackprotector-all \
- test-stackprotector \
- test-timerfd
-
-CC := $(CC) -MD
-
-all: $(FILES)
-
-BUILD = $(CC) $(CFLAGS) $(LDFLAGS) -o $(OUTPUT)$@ $@.c
-
-###############################
-
-test-all:
- $(BUILD) -Werror -fstack-protector -fstack-protector-all -O2 -Werror -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma $(LIBUNWIND_LIBS) -lelf -laudit -I/usr/include/slang -lslang $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl
-
-test-hello:
- $(BUILD)
-
-test-stackprotector-all:
- $(BUILD) -Werror -fstack-protector-all
-
-test-stackprotector:
- $(BUILD) -Werror -fstack-protector -Wstack-protector
-
-test-fortify-source:
- $(BUILD) -O2 -Werror -D_FORTIFY_SOURCE=2
-
-test-bionic:
- $(BUILD)
-
-test-libelf:
- $(BUILD) -lelf
-
-test-glibc:
- $(BUILD)
-
-test-dwarf:
- $(BUILD) -ldw
-
-test-libelf-mmap:
- $(BUILD) -lelf
-
-test-libelf-getphdrnum:
- $(BUILD) -lelf
-
-test-libnuma:
- $(BUILD) -lnuma
-
-test-libunwind:
- $(BUILD) $(LIBUNWIND_LIBS) -lelf
-
-test-libunwind-debug-frame:
- $(BUILD) $(LIBUNWIND_LIBS) -lelf
-
-test-libaudit:
- $(BUILD) -laudit
-
-test-libslang:
- $(BUILD) -I/usr/include/slang -lslang
-
-test-gtk2:
- $(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
-
-test-gtk2-infobar:
- $(BUILD) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
-
-grep-libs = $(filter -l%,$(1))
-strip-libs = $(filter-out -l%,$(1))
-
-PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
-PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
-PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
-PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
-FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
-
-test-libperl:
- $(BUILD) $(FLAGS_PERL_EMBED)
-
-override PYTHON := python
-override PYTHON_CONFIG := python-config
-
-escape-for-shell-sq = $(subst ','\'',$(1))
-shell-sq = '$(escape-for-shell-sq)'
-
-PYTHON_CONFIG_SQ = $(call shell-sq,$(PYTHON_CONFIG))
-
-PYTHON_EMBED_LDOPTS = $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
-PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
-PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
-PYTHON_EMBED_CCOPTS = $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
-FLAGS_PYTHON_EMBED = $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
-
-test-libpython:
- $(BUILD) $(FLAGS_PYTHON_EMBED)
-
-test-libpython-version:
- $(BUILD) $(FLAGS_PYTHON_EMBED)
-
-test-libbfd:
- $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
-
-test-liberty:
- $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
-
-test-liberty-z:
- $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz
-
-test-cplus-demangle:
- $(BUILD) -liberty
-
-test-on-exit:
- $(BUILD)
-
-test-backtrace:
- $(BUILD)
-
-test-timerfd:
- $(BUILD)
-
--include *.d
-
-###############################
-
-clean:
- rm -f $(FILES) *.d
diff --git a/tools/perf/config/feature-checks/test-all.c b/tools/perf/config/feature-checks/test-all.c
deleted file mode 100644
index 59e7a70..0000000
--- a/tools/perf/config/feature-checks/test-all.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * test-all.c: Try to build all the main testcases at once.
- *
- * A well-configured system will have all the prereqs installed, so we can speed
- * up auto-detection on such systems.
- */
-
-/*
- * Quirk: Python and Perl headers cannot be in arbitrary places, so keep
- * these 3 testcases at the top:
- */
-#define main main_test_libpython
-# include "test-libpython.c"
-#undef main
-
-#define main main_test_libpython_version
-# include "test-libpython-version.c"
-#undef main
-
-#define main main_test_libperl
-# include "test-libperl.c"
-#undef main
-
-#define main main_test_hello
-# include "test-hello.c"
-#undef main
-
-#define main main_test_libelf
-# include "test-libelf.c"
-#undef main
-
-#define main main_test_libelf_mmap
-# include "test-libelf-mmap.c"
-#undef main
-
-#define main main_test_glibc
-# include "test-glibc.c"
-#undef main
-
-#define main main_test_dwarf
-# include "test-dwarf.c"
-#undef main
-
-#define main main_test_libelf_getphdrnum
-# include "test-libelf-getphdrnum.c"
-#undef main
-
-#define main main_test_libunwind
-# include "test-libunwind.c"
-#undef main
-
-#define main main_test_libaudit
-# include "test-libaudit.c"
-#undef main
-
-#define main main_test_libslang
-# include "test-libslang.c"
-#undef main
-
-#define main main_test_gtk2
-# include "test-gtk2.c"
-#undef main
-
-#define main main_test_gtk2_infobar
-# include "test-gtk2-infobar.c"
-#undef main
-
-#define main main_test_libbfd
-# include "test-libbfd.c"
-#undef main
-
-#define main main_test_on_exit
-# include "test-on-exit.c"
-#undef main
-
-#define main main_test_backtrace
-# include "test-backtrace.c"
-#undef main
-
-#define main main_test_libnuma
-# include "test-libnuma.c"
-#undef main
-
-#define main main_test_timerfd
-# include "test-timerfd.c"
-#undef main
-
-int main(int argc, char *argv[])
-{
- main_test_libpython();
- main_test_libpython_version();
- main_test_libperl();
- main_test_hello();
- main_test_libelf();
- main_test_libelf_mmap();
- main_test_glibc();
- main_test_dwarf();
- main_test_libelf_getphdrnum();
- main_test_libunwind();
- main_test_libaudit();
- main_test_libslang();
- main_test_gtk2(argc, argv);
- main_test_gtk2_infobar(argc, argv);
- main_test_libbfd();
- main_test_on_exit();
- main_test_backtrace();
- main_test_libnuma();
- main_test_timerfd();
-
- return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-backtrace.c b/tools/perf/config/feature-checks/test-backtrace.c
deleted file mode 100644
index 7124aa1..0000000
--- a/tools/perf/config/feature-checks/test-backtrace.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <execinfo.h>
-#include <stdio.h>
-
-int main(void)
-{
- void *backtrace_fns[10];
- size_t entries;
-
- entries = backtrace(backtrace_fns, 10);
- backtrace_symbols_fd(backtrace_fns, entries, 1);
-
- return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-bionic.c b/tools/perf/config/feature-checks/test-bionic.c
deleted file mode 100644
index eac24e9..0000000
--- a/tools/perf/config/feature-checks/test-bionic.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <android/api-level.h>
-
-int main(void)
-{
- return __ANDROID_API__;
-}
diff --git a/tools/perf/config/feature-checks/test-cplus-demangle.c b/tools/perf/config/feature-checks/test-cplus-demangle.c
deleted file mode 100644
index 610c686..0000000
--- a/tools/perf/config/feature-checks/test-cplus-demangle.c
+++ /dev/null
@@ -1,14 +0,0 @@
-extern int printf(const char *format, ...);
-extern char *cplus_demangle(const char *, int);
-
-int main(void)
-{
- char symbol[4096] = "FieldName__9ClassNameFd";
- char *tmp;
-
- tmp = cplus_demangle(symbol, 0);
-
- printf("demangled symbol: {%s}\n", tmp);
-
- return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-dwarf.c b/tools/perf/config/feature-checks/test-dwarf.c
deleted file mode 100644
index 3fc1801..0000000
--- a/tools/perf/config/feature-checks/test-dwarf.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <dwarf.h>
-#include <elfutils/libdw.h>
-#include <elfutils/version.h>
-
-int main(void)
-{
- Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
-
- return (long)dbg;
-}
diff --git a/tools/perf/config/feature-checks/test-fortify-source.c b/tools/perf/config/feature-checks/test-fortify-source.c
deleted file mode 100644
index c9f398d..0000000
--- a/tools/perf/config/feature-checks/test-fortify-source.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
- return puts("hi");
-}
diff --git a/tools/perf/config/feature-checks/test-glibc.c b/tools/perf/config/feature-checks/test-glibc.c
deleted file mode 100644
index b082034..0000000
--- a/tools/perf/config/feature-checks/test-glibc.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <gnu/libc-version.h>
-
-int main(void)
-{
- const char *version = gnu_get_libc_version();
-
- return (long)version;
-}
diff --git a/tools/perf/config/feature-checks/test-gtk2-infobar.c b/tools/perf/config/feature-checks/test-gtk2-infobar.c
deleted file mode 100644
index 397b464..0000000
--- a/tools/perf/config/feature-checks/test-gtk2-infobar.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma GCC diagnostic ignored "-Wstrict-prototypes"
-#include <gtk/gtk.h>
-#pragma GCC diagnostic error "-Wstrict-prototypes"
-
-int main(int argc, char *argv[])
-{
- gtk_init(&argc, &argv);
- gtk_info_bar_new();
-
- return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-gtk2.c b/tools/perf/config/feature-checks/test-gtk2.c
deleted file mode 100644
index 6bd80e5..0000000
--- a/tools/perf/config/feature-checks/test-gtk2.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma GCC diagnostic ignored "-Wstrict-prototypes"
-#include <gtk/gtk.h>
-#pragma GCC diagnostic error "-Wstrict-prototypes"
-
-int main(int argc, char *argv[])
-{
- gtk_init(&argc, &argv);
-
- return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-hello.c b/tools/perf/config/feature-checks/test-hello.c
deleted file mode 100644
index c9f398d..0000000
--- a/tools/perf/config/feature-checks/test-hello.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
- return puts("hi");
-}
diff --git a/tools/perf/config/feature-checks/test-libaudit.c b/tools/perf/config/feature-checks/test-libaudit.c
deleted file mode 100644
index afc019f..0000000
--- a/tools/perf/config/feature-checks/test-libaudit.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <libaudit.h>
-
-extern int printf(const char *format, ...);
-
-int main(void)
-{
- printf("error message: %s\n", audit_errno_to_name(0));
-
- return audit_open();
-}
diff --git a/tools/perf/config/feature-checks/test-libbfd.c b/tools/perf/config/feature-checks/test-libbfd.c
deleted file mode 100644
index 2405990..0000000
--- a/tools/perf/config/feature-checks/test-libbfd.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <bfd.h>
-
-extern int printf(const char *format, ...);
-
-int main(void)
-{
- char symbol[4096] = "FieldName__9ClassNameFd";
- char *tmp;
-
- tmp = bfd_demangle(0, symbol, 0);
-
- printf("demangled symbol: {%s}\n", tmp);
-
- return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-libelf-getphdrnum.c b/tools/perf/config/feature-checks/test-libelf-getphdrnum.c
deleted file mode 100644
index d710459..0000000
--- a/tools/perf/config/feature-checks/test-libelf-getphdrnum.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <libelf.h>
-
-int main(void)
-{
- size_t dst;
-
- return elf_getphdrnum(0, &dst);
-}
diff --git a/tools/perf/config/feature-checks/test-libelf-mmap.c b/tools/perf/config/feature-checks/test-libelf-mmap.c
deleted file mode 100644
index 564427d..0000000
--- a/tools/perf/config/feature-checks/test-libelf-mmap.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <libelf.h>
-
-int main(void)
-{
- Elf *elf = elf_begin(0, ELF_C_READ_MMAP, 0);
-
- return (long)elf;
-}
diff --git a/tools/perf/config/feature-checks/test-libelf.c b/tools/perf/config/feature-checks/test-libelf.c
deleted file mode 100644
index 08db322..0000000
--- a/tools/perf/config/feature-checks/test-libelf.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <libelf.h>
-
-int main(void)
-{
- Elf *elf = elf_begin(0, ELF_C_READ, 0);
-
- return (long)elf;
-}
diff --git a/tools/perf/config/feature-checks/test-libnuma.c b/tools/perf/config/feature-checks/test-libnuma.c
deleted file mode 100644
index 4763d9c..0000000
--- a/tools/perf/config/feature-checks/test-libnuma.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <numa.h>
-#include <numaif.h>
-
-int main(void)
-{
- numa_available();
-
- return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-libperl.c b/tools/perf/config/feature-checks/test-libperl.c
deleted file mode 100644
index 8871f6a..0000000
--- a/tools/perf/config/feature-checks/test-libperl.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <EXTERN.h>
-#include <perl.h>
-
-int main(void)
-{
- perl_alloc();
-
- return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-libpython-version.c b/tools/perf/config/feature-checks/test-libpython-version.c
deleted file mode 100644
index facea12..0000000
--- a/tools/perf/config/feature-checks/test-libpython-version.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <Python.h>
-
-#if PY_VERSION_HEX >= 0x03000000
- #error
-#endif
-
-int main(void)
-{
- return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-libpython.c b/tools/perf/config/feature-checks/test-libpython.c
deleted file mode 100644
index b24b28a..0000000
--- a/tools/perf/config/feature-checks/test-libpython.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <Python.h>
-
-int main(void)
-{
- Py_Initialize();
-
- return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-libslang.c b/tools/perf/config/feature-checks/test-libslang.c
deleted file mode 100644
index 22ff22e..0000000
--- a/tools/perf/config/feature-checks/test-libslang.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <slang.h>
-
-int main(void)
-{
- return SLsmg_init_smg();
-}
diff --git a/tools/perf/config/feature-checks/test-libunwind-debug-frame.c b/tools/perf/config/feature-checks/test-libunwind-debug-frame.c
deleted file mode 100644
index 0ef8087..0000000
--- a/tools/perf/config/feature-checks/test-libunwind-debug-frame.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <libunwind.h>
-#include <stdlib.h>
-
-extern int
-UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
- unw_word_t ip, unw_word_t segbase,
- const char *obj_name, unw_word_t start,
- unw_word_t end);
-
-#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
-
-int main(void)
-{
- dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
- return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-libunwind.c b/tools/perf/config/feature-checks/test-libunwind.c
deleted file mode 100644
index 43b9369..0000000
--- a/tools/perf/config/feature-checks/test-libunwind.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <libunwind.h>
-#include <stdlib.h>
-
-extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
- unw_word_t ip,
- unw_dyn_info_t *di,
- unw_proc_info_t *pi,
- int need_unwind_info, void *arg);
-
-
-#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
-
-static unw_accessors_t accessors;
-
-int main(void)
-{
- unw_addr_space_t addr_space;
-
- addr_space = unw_create_addr_space(&accessors, 0);
- if (addr_space)
- return 0;
-
- unw_init_remote(NULL, addr_space, NULL);
- dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
-
- return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-on-exit.c b/tools/perf/config/feature-checks/test-on-exit.c
deleted file mode 100644
index 8e88b16..0000000
--- a/tools/perf/config/feature-checks/test-on-exit.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-static void exit_fn(int status, void *__data)
-{
- printf("exit status: %d, data: %d\n", status, *(int *)__data);
-}
-
-static int data = 123;
-
-int main(void)
-{
- on_exit(exit_fn, &data);
-
- return 321;
-}
diff --git a/tools/perf/config/feature-checks/test-stackprotector-all.c b/tools/perf/config/feature-checks/test-stackprotector-all.c
deleted file mode 100644
index c9f398d..0000000
--- a/tools/perf/config/feature-checks/test-stackprotector-all.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
- return puts("hi");
-}
diff --git a/tools/perf/config/feature-checks/test-stackprotector.c b/tools/perf/config/feature-checks/test-stackprotector.c
deleted file mode 100644
index c9f398d..0000000
--- a/tools/perf/config/feature-checks/test-stackprotector.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
- return puts("hi");
-}
diff --git a/tools/perf/config/feature-checks/test-timerfd.c b/tools/perf/config/feature-checks/test-timerfd.c
deleted file mode 100644
index 8c5c083..0000000
--- a/tools/perf/config/feature-checks/test-timerfd.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * test for timerfd functions used by perf-kvm-stat-live
- */
-#include <sys/timerfd.h>
-
-int main(void)
-{
- struct itimerspec new_value;
-
- int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
- if (fd < 0)
- return 1;
-
- if (timerfd_settime(fd, 0, &new_value, NULL) != 0)
- return 1;
-
- return 0;
-}
diff --git a/tools/perf/config/feature-checks/test-volatile-register-var.c b/tools/perf/config/feature-checks/test-volatile-register-var.c
deleted file mode 100644
index c9f398d..0000000
--- a/tools/perf/config/feature-checks/test-volatile-register-var.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
- return puts("hi");
-}
diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak
new file mode 100644
index 0000000..f793057
--- /dev/null
+++ b/tools/perf/config/feature-tests.mak
@@ -0,0 +1,246 @@
+define SOURCE_HELLO
+#include <stdio.h>
+int main(void)
+{
+ return puts(\"hi\");
+}
+endef
+
+ifndef NO_DWARF
+define SOURCE_DWARF
+#include <dwarf.h>
+#include <elfutils/libdw.h>
+#include <elfutils/version.h>
+#ifndef _ELFUTILS_PREREQ
+#error
+#endif
+
+int main(void)
+{
+ Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
+ return (long)dbg;
+}
+endef
+endif
+
+define SOURCE_LIBELF
+#include <libelf.h>
+
+int main(void)
+{
+ Elf *elf = elf_begin(0, ELF_C_READ, 0);
+ return (long)elf;
+}
+endef
+
+define SOURCE_GLIBC
+#include <gnu/libc-version.h>
+
+int main(void)
+{
+ const char *version = gnu_get_libc_version();
+ return (long)version;
+}
+endef
+
+define SOURCE_BIONIC
+#include <android/api-level.h>
+
+int main(void)
+{
+ return __ANDROID_API__;
+}
+endef
+
+define SOURCE_ELF_MMAP
+#include <libelf.h>
+int main(void)
+{
+ Elf *elf = elf_begin(0, ELF_C_READ_MMAP, 0);
+ return (long)elf;
+}
+endef
+
+define SOURCE_ELF_GETPHDRNUM
+#include <libelf.h>
+int main(void)
+{
+ size_t dst;
+ return elf_getphdrnum(0, &dst);
+}
+endef
+
+ifndef NO_SLANG
+define SOURCE_SLANG
+#include <slang.h>
+
+int main(void)
+{
+ return SLsmg_init_smg();
+}
+endef
+endif
+
+ifndef NO_GTK2
+define SOURCE_GTK2
+#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
+#include <gtk/gtk.h>
+#pragma GCC diagnostic error \"-Wstrict-prototypes\"
+
+int main(int argc, char *argv[])
+{
+ gtk_init(&argc, &argv);
+
+ return 0;
+}
+endef
+
+define SOURCE_GTK2_INFOBAR
+#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
+#include <gtk/gtk.h>
+#pragma GCC diagnostic error \"-Wstrict-prototypes\"
+
+int main(void)
+{
+ gtk_info_bar_new();
+
+ return 0;
+}
+endef
+endif
+
+ifndef NO_LIBPERL
+define SOURCE_PERL_EMBED
+#include <EXTERN.h>
+#include <perl.h>
+
+int main(void)
+{
+perl_alloc();
+return 0;
+}
+endef
+endif
+
+ifndef NO_LIBPYTHON
+define SOURCE_PYTHON_VERSION
+#include <Python.h>
+#if PY_VERSION_HEX >= 0x03000000
+ #error
+#endif
+int main(void)
+{
+ return 0;
+}
+endef
+define SOURCE_PYTHON_EMBED
+#include <Python.h>
+int main(void)
+{
+ Py_Initialize();
+ return 0;
+}
+endef
+endif
+
+define SOURCE_BFD
+#include <bfd.h>
+
+int main(void)
+{
+ bfd_demangle(0, 0, 0);
+ return 0;
+}
+endef
+
+define SOURCE_CPLUS_DEMANGLE
+extern char *cplus_demangle(const char *, int);
+
+int main(void)
+{
+ cplus_demangle(0, 0);
+ return 0;
+}
+endef
+
+define SOURCE_STRLCPY
+#include <stdlib.h>
+extern size_t strlcpy(char *dest, const char *src, size_t size);
+
+int main(void)
+{
+ strlcpy(NULL, NULL, 0);
+ return 0;
+}
+endef
+
+ifndef NO_LIBUNWIND
+define SOURCE_LIBUNWIND
+#include <libunwind.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+ unw_word_t ip,
+ unw_dyn_info_t *di,
+ unw_proc_info_t *pi,
+ int need_unwind_info, void *arg);
+
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+int main(void)
+{
+ unw_addr_space_t addr_space;
+ addr_space = unw_create_addr_space(NULL, 0);
+ unw_init_remote(NULL, addr_space, NULL);
+ dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+ return 0;
+}
+endef
+endif
+
+ifndef NO_BACKTRACE
+define SOURCE_BACKTRACE
+#include <execinfo.h>
+#include <stdio.h>
+
+int main(void)
+{
+ backtrace(NULL, 0);
+ backtrace_symbols(NULL, 0);
+ return 0;
+}
+endef
+endif
+
+ifndef NO_LIBAUDIT
+define SOURCE_LIBAUDIT
+#include <libaudit.h>
+
+int main(void)
+{
+ printf(\"error message: %s\", audit_errno_to_name(0));
+ return audit_open();
+}
+endef
+endif
+
+define SOURCE_ON_EXIT
+#include <stdio.h>
+
+int main(void)
+{
+ return on_exit(NULL, NULL);
+}
+endef
+
+define SOURCE_LIBNUMA
+#include <numa.h>
+#include <numaif.h>
+
+int main(void)
+{
+ numa_available();
+ return 0;
+}
+endef
diff --git a/tools/perf/config/utilities.mak b/tools/perf/config/utilities.mak
index f168deb..94d2d4f 100644
--- a/tools/perf/config/utilities.mak
+++ b/tools/perf/config/utilities.mak
@@ -179,9 +179,16 @@ _ge_attempt = $(if $(get-executable),$(get-executable),$(_gea_warn)$(call _gea_e
_gea_warn = $(warning The path '$(1)' is not executable.)
_gea_err = $(if $(1),$(error Please set '$(1)' appropriately))
-ifneq ($(findstring $(MAKEFLAGS),s),s)
- ifneq ($(V),1)
- QUIET_CLEAN = @printf ' CLEAN %s\n' $1;
- QUIET_INSTALL = @printf ' INSTALL %s\n' $1;
- endif
+# try-cc
+# Usage: option = $(call try-cc, source-to-build, cc-options, msg)
+ifneq ($(V),1)
+TRY_CC_OUTPUT= > /dev/null 2>&1
endif
+TRY_CC_MSG=echo " CHK $(3)" 1>&2;
+
+try-cc = $(shell sh -c \
+ 'TMP="$(OUTPUT)$(TMPOUT).$$$$"; \
+ $(TRY_CC_MSG) \
+ echo "$(1)" | \
+ $(CC) -x c - $(2) -o "$$TMP" $(TRY_CC_OUTPUT) && echo y; \
+ rm -f "$$TMP"')
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 8b38b4e..85e1aed 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -49,14 +49,14 @@ static struct cmd_struct commands[] = {
{ "version", cmd_version, 0 },
{ "script", cmd_script, 0 },
{ "sched", cmd_sched, 0 },
-#ifdef HAVE_LIBELF_SUPPORT
+#ifdef LIBELF_SUPPORT
{ "probe", cmd_probe, 0 },
#endif
{ "kmem", cmd_kmem, 0 },
{ "lock", cmd_lock, 0 },
{ "kvm", cmd_kvm, 0 },
{ "test", cmd_test, 0 },
-#ifdef HAVE_LIBAUDIT_SUPPORT
+#ifdef LIBAUDIT_SUPPORT
{ "trace", cmd_trace, 0 },
#endif
{ "inject", cmd_inject, 0 },
@@ -456,7 +456,6 @@ int main(int argc, const char **argv)
{
const char *cmd;
- /* The page_size is placed in util object. */
page_size = sysconf(_SC_PAGE_SIZE);
cmd = perf_extract_argv0_path(argv[0]);
@@ -481,14 +480,7 @@ int main(int argc, const char **argv)
fprintf(stderr, "cannot handle %s internally", cmd);
goto out;
}
-#ifdef HAVE_LIBAUDIT_SUPPORT
- if (!prefixcmp(cmd, "trace")) {
- set_buildid_dir();
- setup_path();
- argv[0] = "trace";
- return cmd_trace(argc, argv, NULL);
- }
-#endif
+
/* Look for flags.. */
argv++;
argc--;
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index b079304..cf20187 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -4,8 +4,6 @@
#include <asm/unistd.h>
#if defined(__i386__)
-#define mb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
-#define wmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
#define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
#define cpu_relax() asm volatile("rep; nop" ::: "memory");
#define CPUINFO_PROC "model name"
@@ -15,8 +13,6 @@
#endif
#if defined(__x86_64__)
-#define mb() asm volatile("mfence" ::: "memory")
-#define wmb() asm volatile("sfence" ::: "memory")
#define rmb() asm volatile("lfence" ::: "memory")
#define cpu_relax() asm volatile("rep; nop" ::: "memory");
#define CPUINFO_PROC "model name"
@@ -27,61 +23,45 @@
#ifdef __powerpc__
#include "../../arch/powerpc/include/uapi/asm/unistd.h"
-#define mb() asm volatile ("sync" ::: "memory")
-#define wmb() asm volatile ("sync" ::: "memory")
#define rmb() asm volatile ("sync" ::: "memory")
+#define cpu_relax() asm volatile ("" ::: "memory");
#define CPUINFO_PROC "cpu"
#endif
#ifdef __s390__
-#define mb() asm volatile("bcr 15,0" ::: "memory")
-#define wmb() asm volatile("bcr 15,0" ::: "memory")
#define rmb() asm volatile("bcr 15,0" ::: "memory")
+#define cpu_relax() asm volatile("" ::: "memory");
#endif
#ifdef __sh__
#if defined(__SH4A__) || defined(__SH5__)
-# define mb() asm volatile("synco" ::: "memory")
-# define wmb() asm volatile("synco" ::: "memory")
# define rmb() asm volatile("synco" ::: "memory")
#else
-# define mb() asm volatile("" ::: "memory")
-# define wmb() asm volatile("" ::: "memory")
# define rmb() asm volatile("" ::: "memory")
#endif
+#define cpu_relax() asm volatile("" ::: "memory")
#define CPUINFO_PROC "cpu type"
#endif
#ifdef __hppa__
-#define mb() asm volatile("" ::: "memory")
-#define wmb() asm volatile("" ::: "memory")
#define rmb() asm volatile("" ::: "memory")
+#define cpu_relax() asm volatile("" ::: "memory");
#define CPUINFO_PROC "cpu"
#endif
#ifdef __sparc__
-#ifdef __LP64__
-#define mb() asm volatile("ba,pt %%xcc, 1f\n" \
- "membar #StoreLoad\n" \
- "1:\n":::"memory")
-#else
-#define mb() asm volatile("":::"memory")
-#endif
-#define wmb() asm volatile("":::"memory")
#define rmb() asm volatile("":::"memory")
+#define cpu_relax() asm volatile("":::"memory")
#define CPUINFO_PROC "cpu"
#endif
#ifdef __alpha__
-#define mb() asm volatile("mb" ::: "memory")
-#define wmb() asm volatile("wmb" ::: "memory")
#define rmb() asm volatile("mb" ::: "memory")
+#define cpu_relax() asm volatile("" ::: "memory")
#define CPUINFO_PROC "cpu model"
#endif
#ifdef __ia64__
-#define mb() asm volatile ("mf" ::: "memory")
-#define wmb() asm volatile ("mf" ::: "memory")
#define rmb() asm volatile ("mf" ::: "memory")
#define cpu_relax() asm volatile ("hint @pause" ::: "memory")
#define CPUINFO_PROC "model name"
@@ -92,55 +72,40 @@
* Use the __kuser_memory_barrier helper in the CPU helper page. See
* arch/arm/kernel/entry-armv.S in the kernel source for details.
*/
-#define mb() ((void(*)(void))0xffff0fa0)()
-#define wmb() ((void(*)(void))0xffff0fa0)()
#define rmb() ((void(*)(void))0xffff0fa0)()
+#define cpu_relax() asm volatile("":::"memory")
#define CPUINFO_PROC "Processor"
#endif
#ifdef __aarch64__
-#define mb() asm volatile("dmb ish" ::: "memory")
-#define wmb() asm volatile("dmb ishld" ::: "memory")
-#define rmb() asm volatile("dmb ishst" ::: "memory")
+#define rmb() asm volatile("dmb ld" ::: "memory")
#define cpu_relax() asm volatile("yield" ::: "memory")
#endif
#ifdef __mips__
-#define mb() asm volatile( \
+#define rmb() asm volatile( \
".set mips2\n\t" \
"sync\n\t" \
".set mips0" \
: /* no output */ \
: /* no input */ \
: "memory")
-#define wmb() mb()
-#define rmb() mb()
+#define cpu_relax() asm volatile("" ::: "memory")
#define CPUINFO_PROC "cpu model"
#endif
#ifdef __arc__
-#define mb() asm volatile("" ::: "memory")
-#define wmb() asm volatile("" ::: "memory")
#define rmb() asm volatile("" ::: "memory")
+#define cpu_relax() rmb()
#define CPUINFO_PROC "Processor"
#endif
#ifdef __metag__
-#define mb() asm volatile("" ::: "memory")
-#define wmb() asm volatile("" ::: "memory")
#define rmb() asm volatile("" ::: "memory")
+#define cpu_relax() asm volatile("" ::: "memory")
#define CPUINFO_PROC "CPU"
#endif
-#define barrier() asm volatile ("" ::: "memory")
-
-#ifndef cpu_relax
-#define cpu_relax() barrier()
-#endif
-
-#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
-
-
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
@@ -217,9 +182,7 @@ struct ip_callchain {
struct branch_flags {
u64 mispred:1;
u64 predicted:1;
- u64 in_tx:1;
- u64 abort:1;
- u64 reserved:60;
+ u64 reserved:62;
};
struct branch_entry {
@@ -248,13 +211,14 @@ enum perf_call_graph_mode {
};
struct perf_record_opts {
- struct target target;
+ struct perf_target target;
int call_graph;
bool group;
bool inherit_stat;
bool no_delay;
bool no_inherit;
bool no_samples;
+ bool pipe_output;
bool raw_samples;
bool sample_address;
bool sample_weight;
@@ -267,7 +231,6 @@ struct perf_record_opts {
u64 default_interval;
u64 user_interval;
u16 stack_dump_size;
- bool sample_transaction;
};
#endif
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/Context.c b/tools/perf/scripts/python/Perf-Trace-Util/Context.c
index fcd1dd6..315067b 100644
--- a/tools/perf/scripts/python/Perf-Trace-Util/Context.c
+++ b/tools/perf/scripts/python/Perf-Trace-Util/Context.c
@@ -25,7 +25,7 @@
PyMODINIT_FUNC initperf_trace_context(void);
-static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args)
+static PyObject *perf_trace_context_common_pc(PyObject *self, PyObject *args)
{
static struct scripting_context *scripting_context;
PyObject *context;
@@ -40,7 +40,7 @@ static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args)
return Py_BuildValue("i", retval);
}
-static PyObject *perf_trace_context_common_flags(PyObject *obj,
+static PyObject *perf_trace_context_common_flags(PyObject *self,
PyObject *args)
{
static struct scripting_context *scripting_context;
@@ -56,7 +56,7 @@ static PyObject *perf_trace_context_common_flags(PyObject *obj,
return Py_BuildValue("i", retval);
}
-static PyObject *perf_trace_context_common_lock_depth(PyObject *obj,
+static PyObject *perf_trace_context_common_lock_depth(PyObject *self,
PyObject *args)
{
static struct scripting_context *scripting_context;
diff --git a/tools/perf/tests/attr/README b/tools/perf/tests/attr/README
index 430024f..d102957 100644
--- a/tools/perf/tests/attr/README
+++ b/tools/perf/tests/attr/README
@@ -44,9 +44,9 @@ Following tests are defined (with perf commands):
perf record -c 123 kill (test-record-count)
perf record -d kill (test-record-data)
perf record -F 100 kill (test-record-freq)
- perf record -g kill (test-record-graph-default)
- perf record --call-graph dwarf kill (test-record-graph-dwarf)
- perf record --call-graph fp kill (test-record-graph-fp)
+ perf record -g -- kill (test-record-graph-default)
+ perf record -g dwarf -- kill (test-record-graph-dwarf)
+ perf record -g fp kill (test-record-graph-fp)
perf record --group -e cycles,instructions kill (test-record-group)
perf record -e '{cycles,instructions}' kill (test-record-group1)
perf record -D kill (test-record-no-delay)
diff --git a/tools/perf/tests/attr/test-record-graph-default b/tools/perf/tests/attr/test-record-graph-default
index 853597a..833d184 100644
--- a/tools/perf/tests/attr/test-record-graph-default
+++ b/tools/perf/tests/attr/test-record-graph-default
@@ -1,6 +1,6 @@
[config]
command = record
-args = -g kill >/dev/null 2>&1
+args = -g -- kill >/dev/null 2>&1
[event:base-record]
sample_type=295
diff --git a/tools/perf/tests/attr/test-record-graph-dwarf b/tools/perf/tests/attr/test-record-graph-dwarf
index d6f324e..e93e082 100644
--- a/tools/perf/tests/attr/test-record-graph-dwarf
+++ b/tools/perf/tests/attr/test-record-graph-dwarf
@@ -1,6 +1,6 @@
[config]
command = record
-args = --call-graph dwarf -- kill >/dev/null 2>&1
+args = -g dwarf -- kill >/dev/null 2>&1
[event:base-record]
sample_type=12583
diff --git a/tools/perf/tests/attr/test-record-graph-fp b/tools/perf/tests/attr/test-record-graph-fp
index 055e3be..7cef374 100644
--- a/tools/perf/tests/attr/test-record-graph-fp
+++ b/tools/perf/tests/attr/test-record-graph-fp
@@ -1,6 +1,6 @@
[config]
command = record
-args = --call-graph fp kill >/dev/null 2>&1
+args = -g fp kill >/dev/null 2>&1
[event:base-record]
sample_type=295
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 85d4919..e3fedfa 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -275,19 +275,8 @@ static int process_event(struct machine *machine, struct perf_evlist *evlist,
if (event->header.type == PERF_RECORD_SAMPLE)
return process_sample_event(machine, evlist, event, state);
- if (event->header.type == PERF_RECORD_THROTTLE ||
- event->header.type == PERF_RECORD_UNTHROTTLE)
- return 0;
-
- if (event->header.type < PERF_RECORD_MAX) {
- int ret;
-
- ret = machine__process_event(machine, event, NULL);
- if (ret < 0)
- pr_debug("machine__process_event failed, event type %u\n",
- event->header.type);
- return ret;
- }
+ if (event->header.type < PERF_RECORD_MAX)
+ return machine__process_event(machine, event);
return 0;
}
@@ -452,7 +441,7 @@ static int do_test_code_reading(bool try_kcore)
}
ret = perf_event__synthesize_thread_map(NULL, threads,
- perf_event__process, machine, false);
+ perf_event__process, machine);
if (ret < 0) {
pr_debug("perf_event__synthesize_thread_map failed\n");
goto out_err;
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c
index 9cc81a3..dffe055 100644
--- a/tools/perf/tests/dso-data.c
+++ b/tools/perf/tests/dso-data.c
@@ -35,7 +35,6 @@ static char *test_file(int size)
if (size != write(fd, buf, size))
templ = NULL;
- free(buf);
close(fd);
return templ;
}
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
index 4774f7f..9b98c15 100644
--- a/tools/perf/tests/evsel-tp-sched.c
+++ b/tools/perf/tests/evsel-tp-sched.c
@@ -32,7 +32,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
int test__perf_evsel__tp_sched_test(void)
{
- struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch");
+ struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch", 0);
int ret = 0;
if (evsel == NULL) {
@@ -63,7 +63,7 @@ int test__perf_evsel__tp_sched_test(void)
perf_evsel__delete(evsel);
- evsel = perf_evsel__newtp("sched", "sched_wakeup");
+ evsel = perf_evsel__newtp("sched", "sched_wakeup", 0);
if (perf_evsel__test_field(evsel, "comm", 16, true))
ret = -1;
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index 173bf42..4228ffc 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -93,7 +93,7 @@ static struct machine *setup_fake_machine(struct machines *machines)
if (thread == NULL)
goto out;
- thread__set_comm(thread, fake_threads[i].comm, 0);
+ thread__set_comm(thread, fake_threads[i].comm);
}
for (i = 0; i < ARRAY_SIZE(fake_mmap_info); i++) {
@@ -110,7 +110,7 @@ static struct machine *setup_fake_machine(struct machines *machines)
strcpy(fake_mmap_event.mmap.filename,
fake_mmap_info[i].filename);
- machine__process_mmap_event(machine, &fake_mmap_event, NULL);
+ machine__process_mmap_event(machine, &fake_mmap_event);
}
for (i = 0; i < ARRAY_SIZE(fake_symbols); i++) {
@@ -222,8 +222,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
&sample) < 0)
goto out;
- he = __hists__add_entry(&evsel->hists, &al, NULL,
- NULL, NULL, 1, 1, 0);
+ he = __hists__add_entry(&evsel->hists, &al, NULL, 1, 1);
if (he == NULL)
goto out;
@@ -245,8 +244,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
&sample) < 0)
goto out;
- he = __hists__add_entry(&evsel->hists, &al, NULL,
- NULL, NULL, 1, 1, 0);
+ he = __hists__add_entry(&evsel->hists, &al, NULL, 1, 1);
if (he == NULL)
goto out;
@@ -421,7 +419,7 @@ static void print_hists(struct hists *hists)
he = rb_entry(node, struct hist_entry, rb_node_in);
pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n",
- i, thread__comm_str(he->thread), he->ms.map->dso->short_name,
+ i, he->thread->comm, he->ms.map->dso->short_name,
he->ms.sym->name, he->stat.period);
i++;
@@ -467,7 +465,7 @@ int test__hists_link(void)
goto out;
list_for_each_entry(evsel, &evlist->entries, node) {
- hists__collapse_resort(&evsel->hists, NULL);
+ hists__collapse_resort(&evsel->hists);
if (verbose > 2)
print_hists(&evsel->hists);
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
index d64ab79..a7232c2 100644
--- a/tools/perf/tests/mmap-basic.c
+++ b/tools/perf/tests/mmap-basic.c
@@ -65,7 +65,7 @@ int test__basic_mmap(void)
char name[64];
snprintf(name, sizeof(name), "sys_enter_%s", syscall_names[i]);
- evsels[i] = perf_evsel__newtp("syscalls", name);
+ evsels[i] = perf_evsel__newtp("syscalls", name, i);
if (evsels[i] == NULL) {
pr_debug("perf_evsel__new\n");
goto out_free_evlist;
diff --git a/tools/perf/tests/open-syscall-all-cpus.c b/tools/perf/tests/open-syscall-all-cpus.c
index 5fecdbd..b0657a9 100644
--- a/tools/perf/tests/open-syscall-all-cpus.c
+++ b/tools/perf/tests/open-syscall-all-cpus.c
@@ -26,7 +26,7 @@ int test__open_syscall_event_on_all_cpus(void)
CPU_ZERO(&cpu_set);
- evsel = perf_evsel__newtp("syscalls", "sys_enter_open");
+ evsel = perf_evsel__newtp("syscalls", "sys_enter_open", 0);
if (evsel == NULL) {
pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
goto out_thread_map_delete;
diff --git a/tools/perf/tests/open-syscall-tp-fields.c b/tools/perf/tests/open-syscall-tp-fields.c
index 41cc0ba..524b221 100644
--- a/tools/perf/tests/open-syscall-tp-fields.c
+++ b/tools/perf/tests/open-syscall-tp-fields.c
@@ -27,7 +27,7 @@ int test__syscall_open_tp_fields(void)
goto out;
}
- evsel = perf_evsel__newtp("syscalls", "sys_enter_open");
+ evsel = perf_evsel__newtp("syscalls", "sys_enter_open", 0);
if (evsel == NULL) {
pr_debug("%s: perf_evsel__newtp\n", __func__);
goto out_delete_evlist;
diff --git a/tools/perf/tests/open-syscall.c b/tools/perf/tests/open-syscall.c
index c1dc7d2..befc067 100644
--- a/tools/perf/tests/open-syscall.c
+++ b/tools/perf/tests/open-syscall.c
@@ -15,7 +15,7 @@ int test__open_syscall_event(void)
return -1;
}
- evsel = perf_evsel__newtp("syscalls", "sys_enter_open");
+ evsel = perf_evsel__newtp("syscalls", "sys_enter_open", 0);
if (evsel == NULL) {
pr_debug("is debugfs mounted on /sys/kernel/debug?\n");
goto out_thread_map_delete;
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 3cbd104..48114d1 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -2,7 +2,7 @@
#include "parse-events.h"
#include "evsel.h"
#include "evlist.h"
-#include "fs.h"
+#include "sysfs.h"
#include <lk/debugfs.h>
#include "tests.h"
#include <linux/hw_breakpoint.h>
@@ -441,8 +441,9 @@ static int test__checkevent_pmu_name(struct perf_evlist *evlist)
static int test__checkevent_pmu_events(struct perf_evlist *evlist)
{
- struct perf_evsel *evsel = perf_evlist__first(evlist);
+ struct perf_evsel *evsel;
+ evsel = list_entry(evlist->entries.next, struct perf_evsel, node);
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
TEST_ASSERT_VAL("wrong exclude_user",
@@ -1455,7 +1456,7 @@ static int test_pmu(void)
int ret;
snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/",
- sysfs__mountpoint());
+ sysfs_find_mountpoint());
ret = stat(path, &st);
if (ret)
@@ -1472,7 +1473,7 @@ static int test_pmu_events(void)
int ret;
snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/",
- sysfs__mountpoint());
+ sysfs_find_mountpoint());
ret = stat(path, &st);
if (ret) {
diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
index 93a62b0..7923b06 100644
--- a/tools/perf/tests/perf-record.c
+++ b/tools/perf/tests/perf-record.c
@@ -45,7 +45,7 @@ int test__PERF_RECORD(void)
};
cpu_set_t cpu_mask;
size_t cpu_mask_size = sizeof(cpu_mask);
- struct perf_evlist *evlist = perf_evlist__new_default();
+ struct perf_evlist *evlist = perf_evlist__new();
struct perf_evsel *evsel;
struct perf_sample sample;
const char *cmd = "sleep";
@@ -66,6 +66,16 @@ int test__PERF_RECORD(void)
}
/*
+ * We need at least one evsel in the evlist, use the default
+ * one: "cycles".
+ */
+ err = perf_evlist__add_default(evlist);
+ if (err < 0) {
+ pr_debug("Not enough memory to create evsel\n");
+ goto out_delete_evlist;
+ }
+
+ /*
* Create maps of threads and cpus to monitor. In this case
* we start with all threads and cpus (-1, -1) but then in
* perf_evlist__prepare_workload we'll fill in the only thread
diff --git a/tools/perf/tests/rdpmc.c b/tools/perf/tests/rdpmc.c
index 46649c2..ff94886 100644
--- a/tools/perf/tests/rdpmc.c
+++ b/tools/perf/tests/rdpmc.c
@@ -9,6 +9,8 @@
#if defined(__x86_64__) || defined(__i386__)
+#define barrier() asm volatile("" ::: "memory")
+
static u64 rdpmc(unsigned int counter)
{
unsigned int low, high;
diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c
index 1b67720..77f598d 100644
--- a/tools/perf/tests/sample-parsing.c
+++ b/tools/perf/tests/sample-parsing.c
@@ -121,9 +121,6 @@ static bool samples_same(const struct perf_sample *s1,
if (type & PERF_SAMPLE_DATA_SRC)
COMP(data_src);
- if (type & PERF_SAMPLE_TRANSACTION)
- COMP(transaction);
-
return true;
}
@@ -168,7 +165,6 @@ static int do_test(u64 sample_type, u64 sample_regs_user, u64 read_format)
.cpu = 110,
.raw_size = sizeof(raw_data),
.data_src = 111,
- .transaction = 112,
.raw_data = (void *)raw_data,
.callchain = &callchain.callchain,
.branch_stack = &branch_stack.branch_stack,
@@ -277,11 +273,10 @@ int test__sample_parsing(void)
/*
* Fail the test if it has not been updated when new sample format bits
- * were added. Please actually update the test rather than just change
- * the condition below.
+ * were added.
*/
- if (PERF_SAMPLE_MAX > PERF_SAMPLE_TRANSACTION << 1) {
- pr_debug("sample format has changed, some new PERF_SAMPLE_ bit was introduced - test needs updating\n");
+ if (PERF_SAMPLE_MAX > PERF_SAMPLE_IDENTIFIER << 1) {
+ pr_debug("sample format has changed - test needs updating\n");
return -1;
}
diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c
index 6664a7c..6e2b44e 100644
--- a/tools/perf/tests/sw-clock.c
+++ b/tools/perf/tests/sw-clock.c
@@ -9,7 +9,7 @@
#include "util/cpumap.h"
#include "util/thread_map.h"
-#define NR_LOOPS 10000000
+#define NR_LOOPS 1000000
/*
* This test will open software clock events (cpu-clock, task-clock)
@@ -34,7 +34,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
.freq = 1,
};
- attr.sample_freq = 500;
+ attr.sample_freq = 10000;
evlist = perf_evlist__new();
if (evlist == NULL) {
@@ -42,7 +42,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
return -1;
}
- evsel = perf_evsel__new(&attr);
+ evsel = perf_evsel__new(&attr, 0);
if (evsel == NULL) {
pr_debug("perf_evsel__new\n");
goto out_free_evlist;
@@ -57,14 +57,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
goto out_delete_maps;
}
- if (perf_evlist__open(evlist)) {
- const char *knob = "/proc/sys/kernel/perf_event_max_sample_rate";
-
- err = -errno;
- pr_debug("Couldn't open evlist: %s\nHint: check %s, using %" PRIu64 " in this test.\n",
- strerror(errno), knob, (u64)attr.sample_freq);
- goto out_delete_maps;
- }
+ perf_evlist__open(evlist);
err = perf_evlist__mmap(evlist, 128, true);
if (err < 0) {
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
index d09ab57..a3e6487 100644
--- a/tools/perf/tests/task-exit.c
+++ b/tools/perf/tests/task-exit.c
@@ -28,7 +28,7 @@ int test__task_exit(void)
union perf_event *event;
struct perf_evsel *evsel;
struct perf_evlist *evlist;
- struct target target = {
+ struct perf_target target = {
.uid = UINT_MAX,
.uses_mmap = true,
};
@@ -37,11 +37,20 @@ int test__task_exit(void)
signal(SIGCHLD, sig_handler);
signal(SIGUSR1, sig_handler);
- evlist = perf_evlist__new_default();
+ evlist = perf_evlist__new();
if (evlist == NULL) {
- pr_debug("perf_evlist__new_default\n");
+ pr_debug("perf_evlist__new\n");
return -1;
}
+ /*
+ * We need at least one evsel in the evlist, use the default
+ * one: "cycles".
+ */
+ err = perf_evlist__add_default(evlist);
+ if (err < 0) {
+ pr_debug("Not enough memory to create evsel\n");
+ goto out_free_evlist;
+ }
/*
* Create maps of threads and cpus to monitor. In this case
@@ -108,6 +117,7 @@ out_close_evlist:
perf_evlist__close(evlist);
out_delete_maps:
perf_evlist__delete_maps(evlist);
+out_free_evlist:
perf_evlist__delete(evlist);
return err;
}
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c
index cbaa7af..bbc782e 100644
--- a/tools/perf/ui/browser.c
+++ b/tools/perf/ui/browser.c
@@ -569,7 +569,7 @@ void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence)
browser->top = browser->top + browser->top_idx + offset;
break;
case SEEK_END:
- browser->top = browser->top + browser->nr_entries - 1 + offset;
+ browser->top = browser->top + browser->nr_entries + offset;
break;
default:
return;
@@ -680,7 +680,7 @@ static void __ui_browser__line_arrow_down(struct ui_browser *browser,
if (end >= browser->top_idx + browser->height)
end_row = browser->height - 1;
else
- end_row = end - browser->top_idx;
+ end_row = end - browser->top_idx;;
ui_browser__gotorc(browser, row, column);
SLsmg_draw_vline(end_row - row + 1);
diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h
index 7d45d2f..404ff66a 100644
--- a/tools/perf/ui/browser.h
+++ b/tools/perf/ui/browser.h
@@ -21,32 +21,32 @@ struct ui_browser {
void *priv;
const char *title;
char *helpline;
- unsigned int (*refresh)(struct ui_browser *browser);
- void (*write)(struct ui_browser *browser, void *entry, int row);
- void (*seek)(struct ui_browser *browser, off_t offset, int whence);
- bool (*filter)(struct ui_browser *browser, void *entry);
+ unsigned int (*refresh)(struct ui_browser *self);
+ void (*write)(struct ui_browser *self, void *entry, int row);
+ void (*seek)(struct ui_browser *self, off_t offset, int whence);
+ bool (*filter)(struct ui_browser *self, void *entry);
u32 nr_entries;
bool navkeypressed;
bool use_navkeypressed;
};
int ui_browser__set_color(struct ui_browser *browser, int color);
-void ui_browser__set_percent_color(struct ui_browser *browser,
+void ui_browser__set_percent_color(struct ui_browser *self,
double percent, bool current);
-bool ui_browser__is_current_entry(struct ui_browser *browser, unsigned row);
-void ui_browser__refresh_dimensions(struct ui_browser *browser);
-void ui_browser__reset_index(struct ui_browser *browser);
+bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row);
+void ui_browser__refresh_dimensions(struct ui_browser *self);
+void ui_browser__reset_index(struct ui_browser *self);
-void ui_browser__gotorc(struct ui_browser *browser, int y, int x);
+void ui_browser__gotorc(struct ui_browser *self, int y, int x);
void ui_browser__write_graph(struct ui_browser *browser, int graph);
void __ui_browser__line_arrow(struct ui_browser *browser, unsigned int column,
u64 start, u64 end);
void __ui_browser__show_title(struct ui_browser *browser, const char *title);
void ui_browser__show_title(struct ui_browser *browser, const char *title);
-int ui_browser__show(struct ui_browser *browser, const char *title,
+int ui_browser__show(struct ui_browser *self, const char *title,
const char *helpline, ...);
-void ui_browser__hide(struct ui_browser *browser);
-int ui_browser__refresh(struct ui_browser *browser);
+void ui_browser__hide(struct ui_browser *self);
+int ui_browser__refresh(struct ui_browser *self);
int ui_browser__run(struct ui_browser *browser, int delay_secs);
void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries);
void ui_browser__handle_resize(struct ui_browser *browser);
@@ -63,11 +63,11 @@ int ui_browser__input_window(const char *title, const char *text, char *input,
void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence);
unsigned int ui_browser__argv_refresh(struct ui_browser *browser);
-void ui_browser__rb_tree_seek(struct ui_browser *browser, off_t offset, int whence);
-unsigned int ui_browser__rb_tree_refresh(struct ui_browser *browser);
+void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence);
+unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self);
-void ui_browser__list_head_seek(struct ui_browser *browser, off_t offset, int whence);
-unsigned int ui_browser__list_head_refresh(struct ui_browser *browser);
+void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whence);
+unsigned int ui_browser__list_head_refresh(struct ui_browser *self);
void ui_browser__init(void);
void annotate_browser__init(void);
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index f0697a3..08545ae 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -442,37 +442,35 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
{
struct map_symbol *ms = browser->b.priv;
struct disasm_line *dl = browser->selection;
+ struct symbol *sym = ms->sym;
struct annotation *notes;
- struct addr_map_symbol target = {
- .map = ms->map,
- .addr = map__objdump_2mem(ms->map, dl->ops.target.addr),
- };
+ struct symbol *target;
+ u64 ip;
char title[SYM_TITLE_MAX_SIZE];
if (!ins__is_call(dl->ins))
return false;
- if (map_groups__find_ams(&target, NULL) ||
- map__rip_2objdump(target.map, target.map->map_ip(target.map,
- target.addr)) !=
- dl->ops.target.addr) {
+ ip = ms->map->map_ip(ms->map, dl->ops.target.addr);
+ target = map__find_symbol(ms->map, ip, NULL);
+ if (target == NULL) {
ui_helpline__puts("The called function was not found.");
return true;
}
- notes = symbol__annotation(target.sym);
+ notes = symbol__annotation(target);
pthread_mutex_lock(&notes->lock);
- if (notes->src == NULL && symbol__alloc_hist(target.sym) < 0) {
+ if (notes->src == NULL && symbol__alloc_hist(target) < 0) {
pthread_mutex_unlock(&notes->lock);
ui__warning("Not enough memory for annotating '%s' symbol!\n",
- target.sym->name);
+ target->name);
return true;
}
pthread_mutex_unlock(&notes->lock);
- symbol__tui_annotate(target.sym, target.map, evsel, hbt);
- sym_title(ms->sym, ms->map, title, sizeof(title));
+ symbol__tui_annotate(target, ms->map, evsel, hbt);
+ sym_title(sym, ms->map, title, sizeof(title));
ui_browser__show_title(&browser->b, title);
return true;
}
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index a440e03..7ef36c3 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1255,7 +1255,7 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size,
if (thread)
printed += scnprintf(bf + printed, size - printed,
", Thread: %s(%d)",
- (thread->comm_set ? thread__comm_str(thread) : ""),
+ (thread->comm_set ? thread->comm : ""),
thread->tid);
if (dso)
printed += scnprintf(bf + printed, size - printed,
@@ -1578,7 +1578,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
if (thread != NULL &&
asprintf(&options[nr_options], "Zoom %s %s(%d) thread",
(browser->hists->thread_filter ? "out of" : "into"),
- (thread->comm_set ? thread__comm_str(thread) : ""),
+ (thread->comm_set ? thread->comm : ""),
thread->tid) > 0)
zoom_thread = nr_options++;
@@ -1598,7 +1598,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
struct symbol *sym;
if (asprintf(&options[nr_options], "Run scripts for samples of thread [%s]",
- thread__comm_str(browser->he_selection->thread)) > 0)
+ browser->he_selection->thread->comm) > 0)
scripts_comm = nr_options++;
sym = browser->he_selection->ms.sym;
@@ -1701,7 +1701,7 @@ zoom_out_thread:
sort_thread.elide = false;
} else {
ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"",
- thread->comm_set ? thread__comm_str(thread) : "",
+ thread->comm_set ? thread->comm : "",
thread->tid);
browser->hists->thread_filter = thread;
sort_thread.elide = true;
@@ -1717,7 +1717,7 @@ do_scripts:
memset(script_opt, 0, 64);
if (choice == scripts_comm)
- sprintf(script_opt, " -c %s ", thread__comm_str(browser->he_selection->thread));
+ sprintf(script_opt, " -c %s ", browser->he_selection->thread->comm);
if (choice == scripts_symbol)
sprintf(script_opt, " -S %s ", browser->he_selection->ms.sym->name);
@@ -1847,15 +1847,15 @@ browse_hists:
switch (key) {
case K_TAB:
if (pos->node.next == &evlist->entries)
- pos = perf_evlist__first(evlist);
+ pos = list_entry(evlist->entries.next, struct perf_evsel, node);
else
- pos = perf_evsel__next(pos);
+ pos = list_entry(pos->node.next, struct perf_evsel, node);
goto browse_hists;
case K_UNTAB:
if (pos->node.prev == &evlist->entries)
- pos = perf_evlist__last(evlist);
+ pos = list_entry(evlist->entries.prev, struct perf_evsel, node);
else
- pos = perf_evsel__prev(pos);
+ pos = list_entry(pos->node.prev, struct perf_evsel, node);
goto browse_hists;
case K_ESC:
if (!ui_browser__dialog_yesno(&menu->b,
@@ -1889,7 +1889,7 @@ out:
return key;
}
-static bool filter_group_entries(struct ui_browser *browser __maybe_unused,
+static bool filter_group_entries(struct ui_browser *self __maybe_unused,
void *entry)
{
struct perf_evsel *evsel = list_entry(entry, struct perf_evsel, node);
@@ -1943,7 +1943,8 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
single_entry:
if (nr_entries == 1) {
- struct perf_evsel *first = perf_evlist__first(evlist);
+ struct perf_evsel *first = list_entry(evlist->entries.next,
+ struct perf_evsel, node);
const char *ev_name = perf_evsel__name(first);
return perf_evsel__hists_browse(first, nr_entries, help,
diff --git a/tools/perf/ui/browsers/map.c b/tools/perf/ui/browsers/map.c
index b11639f..95c7cfb 100644
--- a/tools/perf/ui/browsers/map.c
+++ b/tools/perf/ui/browsers/map.c
@@ -18,30 +18,30 @@ struct map_browser {
u8 addrlen;
};
-static void map_browser__write(struct ui_browser *browser, void *nd, int row)
+static void map_browser__write(struct ui_browser *self, void *nd, int row)
{
struct symbol *sym = rb_entry(nd, struct symbol, rb_node);
- struct map_browser *mb = container_of(browser, struct map_browser, b);
- bool current_entry = ui_browser__is_current_entry(browser, row);
+ struct map_browser *mb = container_of(self, struct map_browser, b);
+ bool current_entry = ui_browser__is_current_entry(self, row);
int width;
- ui_browser__set_percent_color(browser, 0, current_entry);
+ ui_browser__set_percent_color(self, 0, current_entry);
slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ",
mb->addrlen, sym->start, mb->addrlen, sym->end,
sym->binding == STB_GLOBAL ? 'g' :
sym->binding == STB_LOCAL ? 'l' : 'w');
- width = browser->width - ((mb->addrlen * 2) + 4);
+ width = self->width - ((mb->addrlen * 2) + 4);
if (width > 0)
slsmg_write_nstring(sym->name, width);
}
/* FIXME uber-kludgy, see comment on cmd_report... */
-static u32 *symbol__browser_index(struct symbol *browser)
+static u32 *symbol__browser_index(struct symbol *self)
{
- return ((void *)browser) - sizeof(struct rb_node) - sizeof(u32);
+ return ((void *)self) - sizeof(struct rb_node) - sizeof(u32);
}
-static int map_browser__search(struct map_browser *browser)
+static int map_browser__search(struct map_browser *self)
{
char target[512];
struct symbol *sym;
@@ -53,37 +53,37 @@ static int map_browser__search(struct map_browser *browser)
if (target[0] == '0' && tolower(target[1]) == 'x') {
u64 addr = strtoull(target, NULL, 16);
- sym = map__find_symbol(browser->map, addr, NULL);
+ sym = map__find_symbol(self->map, addr, NULL);
} else
- sym = map__find_symbol_by_name(browser->map, target, NULL);
+ sym = map__find_symbol_by_name(self->map, target, NULL);
if (sym != NULL) {
u32 *idx = symbol__browser_index(sym);
- browser->b.top = &sym->rb_node;
- browser->b.index = browser->b.top_idx = *idx;
+ self->b.top = &sym->rb_node;
+ self->b.index = self->b.top_idx = *idx;
} else
ui_helpline__fpush("%s not found!", target);
return 0;
}
-static int map_browser__run(struct map_browser *browser)
+static int map_browser__run(struct map_browser *self)
{
int key;
- if (ui_browser__show(&browser->b, browser->map->dso->long_name,
+ if (ui_browser__show(&self->b, self->map->dso->long_name,
"Press <- or ESC to exit, %s / to search",
verbose ? "" : "restart with -v to use") < 0)
return -1;
while (1) {
- key = ui_browser__run(&browser->b, 0);
+ key = ui_browser__run(&self->b, 0);
switch (key) {
case '/':
if (verbose)
- map_browser__search(browser);
+ map_browser__search(self);
default:
break;
case K_LEFT:
@@ -94,20 +94,20 @@ static int map_browser__run(struct map_browser *browser)
}
}
out:
- ui_browser__hide(&browser->b);
+ ui_browser__hide(&self->b);
return key;
}
-int map__browse(struct map *map)
+int map__browse(struct map *self)
{
struct map_browser mb = {
.b = {
- .entries = &map->dso->symbols[map->type],
+ .entries = &self->dso->symbols[self->type],
.refresh = ui_browser__rb_tree_refresh,
.seek = ui_browser__rb_tree_seek,
.write = map_browser__write,
},
- .map = map,
+ .map = self,
};
struct rb_node *nd;
char tmp[BITS_PER_LONG / 4];
diff --git a/tools/perf/ui/browsers/map.h b/tools/perf/ui/browsers/map.h
index 2d58e4b..df8581a 100644
--- a/tools/perf/ui/browsers/map.h
+++ b/tools/perf/ui/browsers/map.h
@@ -2,5 +2,5 @@
#define _PERF_UI_MAP_BROWSER_H_ 1
struct map;
-int map__browse(struct map *map);
+int map__browse(struct map *self);
#endif /* _PERF_UI_MAP_BROWSER_H_ */
diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c
index d63c68e..12f009e 100644
--- a/tools/perf/ui/browsers/scripts.c
+++ b/tools/perf/ui/browsers/scripts.c
@@ -84,22 +84,22 @@ static void script_browser__write(struct ui_browser *browser,
slsmg_write_nstring(sline->line, browser->width);
}
-static int script_browser__run(struct perf_script_browser *browser)
+static int script_browser__run(struct perf_script_browser *self)
{
int key;
- if (ui_browser__show(&browser->b, browser->script_name,
+ if (ui_browser__show(&self->b, self->script_name,
"Press <- or ESC to exit") < 0)
return -1;
while (1) {
- key = ui_browser__run(&browser->b, 0);
+ key = ui_browser__run(&self->b, 0);
/* We can add some special key handling here if needed */
break;
}
- ui_browser__hide(&browser->b);
+ ui_browser__hide(&self->b);
return key;
}
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
index 9c7ff8d..f538794 100644
--- a/tools/perf/ui/gtk/annotate.c
+++ b/tools/perf/ui/gtk/annotate.c
@@ -154,9 +154,9 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
return 0;
}
-static int symbol__gtk_annotate(struct symbol *sym, struct map *map,
- struct perf_evsel *evsel,
- struct hist_browser_timer *hbt)
+int symbol__gtk_annotate(struct symbol *sym, struct map *map,
+ struct perf_evsel *evsel,
+ struct hist_browser_timer *hbt)
{
GtkWidget *window;
GtkWidget *notebook;
@@ -226,13 +226,6 @@ static int symbol__gtk_annotate(struct symbol *sym, struct map *map,
return 0;
}
-int hist_entry__gtk_annotate(struct hist_entry *he,
- struct perf_evsel *evsel,
- struct hist_browser_timer *hbt)
-{
- return symbol__gtk_annotate(he->ms.sym, he->ms.map, evsel, hbt);
-}
-
void perf_gtk__show_annotations(void)
{
GtkWidget *window;
diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c
index c24d912..c95012c 100644
--- a/tools/perf/ui/gtk/browser.c
+++ b/tools/perf/ui/gtk/browser.c
@@ -43,7 +43,7 @@ const char *perf_gtk__get_percent_color(double percent)
return NULL;
}
-#ifdef HAVE_GTK_INFO_BAR_SUPPORT
+#ifdef HAVE_GTK_INFO_BAR
GtkWidget *perf_gtk__setup_info_bar(void)
{
GtkWidget *info_bar;
diff --git a/tools/perf/ui/gtk/gtk.h b/tools/perf/ui/gtk/gtk.h
index 0a9173f..3d96785 100644
--- a/tools/perf/ui/gtk/gtk.h
+++ b/tools/perf/ui/gtk/gtk.h
@@ -12,7 +12,7 @@ struct perf_gtk_context {
GtkWidget *main_window;
GtkWidget *notebook;
-#ifdef HAVE_GTK_INFO_BAR_SUPPORT
+#ifdef HAVE_GTK_INFO_BAR
GtkWidget *info_bar;
GtkWidget *message_label;
#endif
@@ -20,9 +20,6 @@ struct perf_gtk_context {
guint statbar_ctx_id;
};
-int perf_gtk__init(void);
-void perf_gtk__exit(bool wait_for_ok);
-
extern struct perf_gtk_context *pgctx;
static inline bool perf_gtk__is_active_context(struct perf_gtk_context *ctx)
@@ -34,7 +31,7 @@ struct perf_gtk_context *perf_gtk__activate_context(GtkWidget *window);
int perf_gtk__deactivate_context(struct perf_gtk_context **ctx);
void perf_gtk__init_helpline(void);
-void gtk_ui_progress__init(void);
+void perf_gtk__init_progress(void);
void perf_gtk__init_hpp(void);
void perf_gtk__signal(int sig);
@@ -42,7 +39,7 @@ void perf_gtk__resize_window(GtkWidget *window);
const char *perf_gtk__get_percent_color(double percent);
GtkWidget *perf_gtk__setup_statusbar(void);
-#ifdef HAVE_GTK_INFO_BAR_SUPPORT
+#ifdef HAVE_GTK_INFO_BAR
GtkWidget *perf_gtk__setup_info_bar(void);
#else
static inline GtkWidget *perf_gtk__setup_info_bar(void)
@@ -51,17 +48,4 @@ static inline GtkWidget *perf_gtk__setup_info_bar(void)
}
#endif
-struct perf_evsel;
-struct perf_evlist;
-struct hist_entry;
-struct hist_browser_timer;
-
-int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, const char *help,
- struct hist_browser_timer *hbt,
- float min_pcnt);
-int hist_entry__gtk_annotate(struct hist_entry *he,
- struct perf_evsel *evsel,
- struct hist_browser_timer *hbt);
-void perf_gtk__show_annotations(void);
-
#endif /* _PERF_GTK_H_ */
diff --git a/tools/perf/ui/gtk/progress.c b/tools/perf/ui/gtk/progress.c
index b656655..482bcf3 100644
--- a/tools/perf/ui/gtk/progress.c
+++ b/tools/perf/ui/gtk/progress.c
@@ -7,14 +7,14 @@
static GtkWidget *dialog;
static GtkWidget *progress;
-static void gtk_ui_progress__update(struct ui_progress *p)
+static void gtk_progress_update(u64 curr, u64 total, const char *title)
{
- double fraction = p->total ? 1.0 * p->curr / p->total : 0.0;
+ double fraction = total ? 1.0 * curr / total : 0.0;
char buf[1024];
if (dialog == NULL) {
GtkWidget *vbox = gtk_vbox_new(TRUE, 5);
- GtkWidget *label = gtk_label_new(p->title);
+ GtkWidget *label = gtk_label_new(title);
dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
progress = gtk_progress_bar_new();
@@ -32,7 +32,7 @@ static void gtk_ui_progress__update(struct ui_progress *p)
}
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), fraction);
- snprintf(buf, sizeof(buf), "%"PRIu64" / %"PRIu64, p->curr, p->total);
+ snprintf(buf, sizeof(buf), "%"PRIu64" / %"PRIu64, curr, total);
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress), buf);
/* we didn't call gtk_main yet, so do it manually */
@@ -40,7 +40,7 @@ static void gtk_ui_progress__update(struct ui_progress *p)
gtk_main_iteration();
}
-static void gtk_ui_progress__finish(void)
+static void gtk_progress_finish(void)
{
/* this will also destroy all of its children */
gtk_widget_destroy(dialog);
@@ -48,12 +48,12 @@ static void gtk_ui_progress__finish(void)
dialog = NULL;
}
-static struct ui_progress_ops gtk_ui_progress__ops = {
- .update = gtk_ui_progress__update,
- .finish = gtk_ui_progress__finish,
+static struct ui_progress gtk_progress_fns = {
+ .update = gtk_progress_update,
+ .finish = gtk_progress_finish,
};
-void gtk_ui_progress__init(void)
+void perf_gtk__init_progress(void)
{
- ui_progress__ops = &gtk_ui_progress__ops;
+ progress_fns = &gtk_progress_fns;
}
diff --git a/tools/perf/ui/gtk/setup.c b/tools/perf/ui/gtk/setup.c
index 1d57676..6c2dd2e 100644
--- a/tools/perf/ui/gtk/setup.c
+++ b/tools/perf/ui/gtk/setup.c
@@ -8,7 +8,7 @@ int perf_gtk__init(void)
{
perf_error__register(&perf_gtk_eops);
perf_gtk__init_helpline();
- gtk_ui_progress__init();
+ perf_gtk__init_progress();
perf_gtk__init_hpp();
return gtk_init_check(NULL, NULL) ? 0 : -1;
diff --git a/tools/perf/ui/gtk/util.c b/tools/perf/ui/gtk/util.c
index 696c1fb..c06942a 100644
--- a/tools/perf/ui/gtk/util.c
+++ b/tools/perf/ui/gtk/util.c
@@ -53,7 +53,7 @@ static int perf_gtk__error(const char *format, va_list args)
return 0;
}
-#ifdef HAVE_GTK_INFO_BAR_SUPPORT
+#ifdef HAVE_GTK_INFO_BAR
static int perf_gtk__warning_info_bar(const char *format, va_list args)
{
char *msg;
@@ -105,7 +105,7 @@ static int perf_gtk__warning_statusbar(const char *format, va_list args)
struct perf_error_ops perf_gtk_eops = {
.error = perf_gtk__error,
-#ifdef HAVE_GTK_INFO_BAR_SUPPORT
+#ifdef HAVE_GTK_INFO_BAR
.warning = perf_gtk__warning_info_bar,
#else
.warning = perf_gtk__warning_statusbar,
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 78f4c92..0a19328 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -117,7 +117,7 @@ static int hpp__color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \
struct perf_hpp *hpp, struct hist_entry *he) \
{ \
return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \
- percent_color_snprintf, true); \
+ (hpp_snprint_fn)percent_color_snprintf, true); \
}
#define __HPP_ENTRY_PERCENT_FN(_type, _field) \
diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/progress.c
index a0f24c7..3ec69560 100644
--- a/tools/perf/ui/progress.c
+++ b/tools/perf/ui/progress.c
@@ -1,38 +1,26 @@
#include "../cache.h"
#include "progress.h"
-static void null_progress__update(struct ui_progress *p __maybe_unused)
+static void nop_progress_update(u64 curr __maybe_unused,
+ u64 total __maybe_unused,
+ const char *title __maybe_unused)
{
}
-static struct ui_progress_ops null_progress__ops =
+static struct ui_progress default_progress_fns =
{
- .update = null_progress__update,
+ .update = nop_progress_update,
};
-struct ui_progress_ops *ui_progress__ops = &null_progress__ops;
+struct ui_progress *progress_fns = &default_progress_fns;
-void ui_progress__update(struct ui_progress *p, u64 adv)
+void ui_progress__update(u64 curr, u64 total, const char *title)
{
- p->curr += adv;
-
- if (p->curr >= p->next) {
- p->next += p->step;
- ui_progress__ops->update(p);
- }
-}
-
-void ui_progress__init(struct ui_progress *p, u64 total, const char *title)
-{
- p->curr = 0;
- p->next = p->step = total / 16;
- p->total = total;
- p->title = title;
-
+ return progress_fns->update(curr, total, title);
}
void ui_progress__finish(void)
{
- if (ui_progress__ops->finish)
- ui_progress__ops->finish();
+ if (progress_fns->finish)
+ progress_fns->finish();
}
diff --git a/tools/perf/ui/progress.h b/tools/perf/ui/progress.h
index 29ec8ef..257cc22 100644
--- a/tools/perf/ui/progress.h
+++ b/tools/perf/ui/progress.h
@@ -3,21 +3,16 @@
#include <../types.h>
-void ui_progress__finish(void);
-
struct ui_progress {
- const char *title;
- u64 curr, next, step, total;
-};
-
-void ui_progress__init(struct ui_progress *p, u64 total, const char *title);
-void ui_progress__update(struct ui_progress *p, u64 adv);
-
-struct ui_progress_ops {
- void (*update)(struct ui_progress *p);
+ void (*update)(u64, u64, const char *);
void (*finish)(void);
};
-extern struct ui_progress_ops *ui_progress__ops;
+extern struct ui_progress *progress_fns;
+
+void ui_progress__init(void);
+
+void ui_progress__update(u64 curr, u64 total, const char *title);
+void ui_progress__finish(void);
#endif
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 5df5140..47d9a57 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -1,64 +1,10 @@
#include <pthread.h>
-#include <dlfcn.h>
#include "../util/cache.h"
#include "../util/debug.h"
#include "../util/hist.h"
pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
-void *perf_gtk_handle;
-
-#ifdef HAVE_GTK2_SUPPORT
-static int setup_gtk_browser(void)
-{
- int (*perf_ui_init)(void);
-
- if (perf_gtk_handle)
- return 0;
-
- perf_gtk_handle = dlopen(PERF_GTK_DSO, RTLD_LAZY);
- if (perf_gtk_handle == NULL) {
- char buf[PATH_MAX];
- scnprintf(buf, sizeof(buf), "%s/%s", LIBDIR, PERF_GTK_DSO);
- perf_gtk_handle = dlopen(buf, RTLD_LAZY);
- }
- if (perf_gtk_handle == NULL)
- return -1;
-
- perf_ui_init = dlsym(perf_gtk_handle, "perf_gtk__init");
- if (perf_ui_init == NULL)
- goto out_close;
-
- if (perf_ui_init() == 0)
- return 0;
-
-out_close:
- dlclose(perf_gtk_handle);
- return -1;
-}
-
-static void exit_gtk_browser(bool wait_for_ok)
-{
- void (*perf_ui_exit)(bool);
-
- if (perf_gtk_handle == NULL)
- return;
-
- perf_ui_exit = dlsym(perf_gtk_handle, "perf_gtk__exit");
- if (perf_ui_exit == NULL)
- goto out_close;
-
- perf_ui_exit(wait_for_ok);
-
-out_close:
- dlclose(perf_gtk_handle);
-
- perf_gtk_handle = NULL;
-}
-#else
-static inline int setup_gtk_browser(void) { return -1; }
-static inline void exit_gtk_browser(bool wait_for_ok __maybe_unused) {}
-#endif
void setup_browser(bool fallback_to_pager)
{
@@ -71,11 +17,8 @@ void setup_browser(bool fallback_to_pager)
switch (use_browser) {
case 2:
- if (setup_gtk_browser() == 0)
+ if (perf_gtk__init() == 0)
break;
- printf("GTK browser requested but could not find %s\n",
- PERF_GTK_DSO);
- sleep(1);
/* fall through */
case 1:
use_browser = 1;
@@ -96,7 +39,7 @@ void exit_browser(bool wait_for_ok)
{
switch (use_browser) {
case 2:
- exit_gtk_browser(wait_for_ok);
+ perf_gtk__exit(wait_for_ok);
break;
case 1:
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index c244cb5..6c15268 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -213,19 +213,20 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,
return ret;
}
-static size_t __callchain__fprintf_flat(FILE *fp, struct callchain_node *node,
+static size_t __callchain__fprintf_flat(FILE *fp,
+ struct callchain_node *self,
u64 total_samples)
{
struct callchain_list *chain;
size_t ret = 0;
- if (!node)
+ if (!self)
return 0;
- ret += __callchain__fprintf_flat(fp, node->parent, total_samples);
+ ret += __callchain__fprintf_flat(fp, self->parent, total_samples);
- list_for_each_entry(chain, &node->val, list) {
+ list_for_each_entry(chain, &self->val, list) {
if (chain->ip >= PERF_CONTEXT_MAX)
continue;
if (chain->ms.sym)
@@ -238,14 +239,15 @@ static size_t __callchain__fprintf_flat(FILE *fp, struct callchain_node *node,
return ret;
}
-static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *tree,
+static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *self,
u64 total_samples)
{
size_t ret = 0;
u32 entries_printed = 0;
+ struct rb_node *rb_node;
struct callchain_node *chain;
- struct rb_node *rb_node = rb_first(tree);
+ rb_node = rb_first(self);
while (rb_node) {
double percent;
diff --git a/tools/perf/ui/tui/progress.c b/tools/perf/ui/tui/progress.c
index c61d14b..6c2184d 100644
--- a/tools/perf/ui/tui/progress.c
+++ b/tools/perf/ui/tui/progress.c
@@ -2,10 +2,9 @@
#include "../progress.h"
#include "../libslang.h"
#include "../ui.h"
-#include "tui.h"
#include "../browser.h"
-static void tui_progress__update(struct ui_progress *p)
+static void tui_progress__update(u64 curr, u64 total, const char *title)
{
int bar, y;
/*
@@ -15,30 +14,29 @@ static void tui_progress__update(struct ui_progress *p)
if (use_browser <= 0)
return;
- if (p->total == 0)
+ if (total == 0)
return;
- ui__refresh_dimensions(false);
+ ui__refresh_dimensions(true);
pthread_mutex_lock(&ui__lock);
y = SLtt_Screen_Rows / 2 - 2;
SLsmg_set_color(0);
SLsmg_draw_box(y, 0, 3, SLtt_Screen_Cols);
SLsmg_gotorc(y++, 1);
- SLsmg_write_string((char *)p->title);
- SLsmg_fill_region(y, 1, 1, SLtt_Screen_Cols - 2, ' ');
+ SLsmg_write_string((char *)title);
SLsmg_set_color(HE_COLORSET_SELECTED);
- bar = ((SLtt_Screen_Cols - 2) * p->curr) / p->total;
+ bar = ((SLtt_Screen_Cols - 2) * curr) / total;
SLsmg_fill_region(y, 1, 1, bar, ' ');
SLsmg_refresh();
pthread_mutex_unlock(&ui__lock);
}
-static struct ui_progress_ops tui_progress__ops =
+static struct ui_progress tui_progress_fns =
{
.update = tui_progress__update,
};
-void tui_progress__init(void)
+void ui_progress__init(void)
{
- ui_progress__ops = &tui_progress__ops;
+ progress_fns = &tui_progress_fns;
}
diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c
index 2f61256..b940148 100644
--- a/tools/perf/ui/tui/setup.c
+++ b/tools/perf/ui/tui/setup.c
@@ -9,7 +9,6 @@
#include "../util.h"
#include "../libslang.h"
#include "../keysyms.h"
-#include "tui.h"
static volatile int ui__need_resize;
@@ -120,7 +119,7 @@ int ui__init(void)
ui_helpline__init();
ui_browser__init();
- tui_progress__init();
+ ui_progress__init();
signal(SIGSEGV, ui__signal);
signal(SIGFPE, ui__signal);
diff --git a/tools/perf/ui/tui/tui.h b/tools/perf/ui/tui/tui.h
deleted file mode 100644
index 18961c7..0000000
--- a/tools/perf/ui/tui/tui.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _PERF_TUI_H_
-#define _PERF_TUI_H_ 1
-
-void tui_progress__init(void);
-
-#endif /* _PERF_TUI_H_ */
diff --git a/tools/perf/ui/ui.h b/tools/perf/ui/ui.h
index ab88383..70cb0d4 100644
--- a/tools/perf/ui/ui.h
+++ b/tools/perf/ui/ui.h
@@ -6,14 +6,13 @@
#include <linux/compiler.h>
extern pthread_mutex_t ui__lock;
-extern void *perf_gtk_handle;
extern int use_browser;
void setup_browser(bool fallback_to_pager);
void exit_browser(bool wait_for_ok);
-#ifdef HAVE_SLANG_SUPPORT
+#ifdef SLANG_SUPPORT
int ui__init(void);
void ui__exit(bool wait_for_ok);
#else
@@ -24,6 +23,17 @@ static inline int ui__init(void)
static inline void ui__exit(bool wait_for_ok __maybe_unused) {}
#endif
+#ifdef GTK2_SUPPORT
+int perf_gtk__init(void);
+void perf_gtk__exit(bool wait_for_ok);
+#else
+static inline int perf_gtk__init(void)
+{
+ return -1;
+}
+static inline void perf_gtk__exit(bool wait_for_ok __maybe_unused) {}
+#endif
+
void ui__refresh_dimensions(bool force);
#endif /* _PERF_UI_H_ */
diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN
index 39f1750..15a77b7 100755
--- a/tools/perf/util/PERF-VERSION-GEN
+++ b/tools/perf/util/PERF-VERSION-GEN
@@ -19,9 +19,6 @@ if test -d ../../.git -o -f ../../.git
then
TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null )
CID=$(git log -1 --abbrev=4 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID"
-elif test -f ../../PERF-VERSION-FILE
-then
- TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g')
fi
if test -z "$TAG"
then
@@ -43,7 +40,7 @@ else
VC=unset
fi
test "$VN" = "$VC" || {
- echo >&2 " PERF_VERSION = $VN"
+ echo >&2 "PERF_VERSION = $VN"
echo "#define PERF_VERSION \"$VN\"" >$GVF
}
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index cf6242c..7eae548 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -825,16 +825,20 @@ static int symbol__parse_objdump_line(struct symbol *sym, struct map *map,
dl->ops.target.offset = dl->ops.target.addr -
map__rip_2objdump(map, sym->start);
- /* kcore has no symbols, so add the call target name */
+ /*
+ * kcore has no symbols, so add the call target name if it is on the
+ * same map.
+ */
if (dl->ins && ins__is_call(dl->ins) && !dl->ops.target.name) {
- struct addr_map_symbol target = {
- .map = map,
- .addr = dl->ops.target.addr,
- };
-
- if (!map_groups__find_ams(&target, NULL) &&
- target.sym->start == target.al_addr)
- dl->ops.target.name = strdup(target.sym->name);
+ struct symbol *s;
+ u64 ip = dl->ops.target.addr;
+
+ if (ip >= map->start && ip <= map->end) {
+ ip = map->map_ip(map, ip);
+ s = map__find_symbol(map, ip, NULL);
+ if (s && s->start == ip)
+ dl->ops.target.name = strdup(s->name);
+ }
}
disasm__add(&notes->src->source, dl);
@@ -875,8 +879,6 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
FILE *file;
int err = 0;
char symfs_filename[PATH_MAX];
- struct kcore_extract kce;
- bool delete_extract = false;
if (filename) {
snprintf(symfs_filename, sizeof(symfs_filename), "%s%s",
@@ -938,23 +940,6 @@ fallback:
pr_debug("annotating [%p] %30s : [%p] %30s\n",
dso, dso->long_name, sym, sym->name);
- if (dso__is_kcore(dso)) {
- kce.kcore_filename = symfs_filename;
- kce.addr = map__rip_2objdump(map, sym->start);
- kce.offs = sym->start;
- kce.len = sym->end + 1 - sym->start;
- if (!kcore_extract__create(&kce)) {
- delete_extract = true;
- strlcpy(symfs_filename, kce.extract_filename,
- sizeof(symfs_filename));
- if (free_filename) {
- free(filename);
- free_filename = false;
- }
- filename = symfs_filename;
- }
- }
-
snprintf(command, sizeof(command),
"%s %s%s --start-address=0x%016" PRIx64
" --stop-address=0x%016" PRIx64
@@ -987,8 +972,6 @@ fallback:
pclose(file);
out_free_filename:
- if (delete_extract)
- kcore_extract__delete(&kce);
if (free_filename)
free(filename);
return err;
@@ -1087,7 +1070,7 @@ static void symbol__free_source_line(struct symbol *sym, int len)
(sizeof(src_line->p) * (src_line->nr_pcnt - 1));
for (i = 0; i < len; i++) {
- free_srcline(src_line->path);
+ free(src_line->path);
src_line = (void *)src_line + sizeof_src_line;
}
@@ -1098,11 +1081,13 @@ static void symbol__free_source_line(struct symbol *sym, int len)
/* Get the filename:line for the colored entries */
static int symbol__get_source_line(struct symbol *sym, struct map *map,
struct perf_evsel *evsel,
- struct rb_root *root, int len)
+ struct rb_root *root, int len,
+ const char *filename)
{
u64 start;
int i, k;
int evidx = evsel->idx;
+ char cmd[PATH_MAX * 2];
struct source_line *src_line;
struct annotation *notes = symbol__annotation(sym);
struct sym_hist *h = annotation__histogram(notes, evidx);
@@ -1130,7 +1115,10 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
start = map__rip_2objdump(map, sym->start);
for (i = 0; i < len; i++) {
+ char *path = NULL;
+ size_t line_len;
u64 offset;
+ FILE *fp;
double percent_max = 0.0;
src_line->nr_pcnt = nr_pcnt;
@@ -1147,9 +1135,23 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
goto next;
offset = start + i;
- src_line->path = get_srcline(map->dso, offset);
+ sprintf(cmd, "addr2line -e %s %016" PRIx64, filename, offset);
+ fp = popen(cmd, "r");
+ if (!fp)
+ goto next;
+
+ if (getline(&path, &line_len, fp) < 0 || !line_len)
+ goto next_close;
+
+ src_line->path = malloc(sizeof(char) * line_len + 1);
+ if (!src_line->path)
+ goto next_close;
+
+ strcpy(src_line->path, path);
insert_source_line(&tmp_root, src_line);
+ next_close:
+ pclose(fp);
next:
src_line = (void *)src_line + sizeof_src_line;
}
@@ -1190,7 +1192,7 @@ static void print_summary(struct rb_root *root, const char *filename)
path = src_line->path;
color = get_percent_color(percent_max);
- color_fprintf(stdout, color, " %s\n", path);
+ color_fprintf(stdout, color, " %s", path);
node = rb_next(node);
}
@@ -1354,6 +1356,7 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map,
bool full_paths, int min_pcnt, int max_lines)
{
struct dso *dso = map->dso;
+ const char *filename = dso->long_name;
struct rb_root source_line = RB_ROOT;
u64 len;
@@ -1363,8 +1366,9 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map,
len = symbol__size(sym);
if (print_lines) {
- symbol__get_source_line(sym, map, evsel, &source_line, len);
- print_summary(&source_line, dso->long_name);
+ symbol__get_source_line(sym, map, evsel, &source_line,
+ len, filename);
+ print_summary(&source_line, filename);
}
symbol__annotate_printf(sym, map, evsel, full_paths,
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 834b7b5..af75515 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -150,7 +150,7 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map,
struct perf_evsel *evsel, bool print_lines,
bool full_paths, int min_pcnt, int max_lines);
-#ifdef HAVE_SLANG_SUPPORT
+#ifdef SLANG_SUPPORT
int symbol__tui_annotate(struct symbol *sym, struct map *map,
struct perf_evsel *evsel,
struct hist_browser_timer *hbt);
@@ -165,6 +165,30 @@ static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused,
}
#endif
+#ifdef GTK2_SUPPORT
+int symbol__gtk_annotate(struct symbol *sym, struct map *map,
+ struct perf_evsel *evsel,
+ struct hist_browser_timer *hbt);
+
+static inline int hist_entry__gtk_annotate(struct hist_entry *he,
+ struct perf_evsel *evsel,
+ struct hist_browser_timer *hbt)
+{
+ return symbol__gtk_annotate(he->ms.sym, he->ms.map, evsel, hbt);
+}
+
+void perf_gtk__show_annotations(void);
+#else
+static inline int hist_entry__gtk_annotate(struct hist_entry *he __maybe_unused,
+ struct perf_evsel *evsel __maybe_unused,
+ struct hist_browser_timer *hbt __maybe_unused)
+{
+ return 0;
+}
+
+static inline void perf_gtk__show_annotations(void) {}
+#endif
+
extern const char *disassembler_style;
#endif /* __PERF_ANNOTATE_H */
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index a92770c..7ded71d 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -89,14 +89,14 @@ int build_id__sprintf(const u8 *build_id, int len, char *bf)
return raw - build_id;
}
-char *dso__build_id_filename(struct dso *dso, char *bf, size_t size)
+char *dso__build_id_filename(struct dso *self, char *bf, size_t size)
{
char build_id_hex[BUILD_ID_SIZE * 2 + 1];
- if (!dso->has_build_id)
+ if (!self->has_build_id)
return NULL;
- build_id__sprintf(dso->build_id, sizeof(dso->build_id), build_id_hex);
+ build_id__sprintf(self->build_id, sizeof(self->build_id), build_id_hex);
if (bf == NULL) {
if (asprintf(&bf, "%s/.build-id/%.2s/%s", buildid_dir,
build_id_hex, build_id_hex + 2) < 0)
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
index 929f28a..a811f5c 100644
--- a/tools/perf/util/build-id.h
+++ b/tools/perf/util/build-id.h
@@ -10,9 +10,10 @@ extern struct perf_tool build_id__mark_dso_hit_ops;
struct dso;
int build_id__sprintf(const u8 *build_id, int len, char *bf);
-char *dso__build_id_filename(struct dso *dso, char *bf, size_t size);
+char *dso__build_id_filename(struct dso *self, char *bf, size_t size);
int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event,
struct perf_sample *sample, struct perf_evsel *evsel,
struct machine *machine);
+
#endif
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 7b176dd..26e3672 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -70,7 +70,8 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2
extern char *perf_pathdup(const char *fmt, ...)
__attribute__((format (printf, 1, 2)));
-/* Matches the libc/libbsd function attribute so we declare this unconditionally: */
+#ifndef HAVE_STRLCPY
extern size_t strlcpy(char *dest, const char *src, size_t size);
+#endif
#endif /* __PERF_CACHE_H */
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index e3970e3..482f680 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -21,6 +21,12 @@
__thread struct callchain_cursor callchain_cursor;
+#define chain_for_each_child(child, parent) \
+ list_for_each_entry(child, &parent->children, siblings)
+
+#define chain_for_each_child_safe(child, next, parent) \
+ list_for_each_entry_safe(child, next, &parent->children, siblings)
+
static void
rb_insert_callchain(struct rb_root *root, struct callchain_node *chain,
enum chain_mode mode)
@@ -65,16 +71,10 @@ static void
__sort_chain_flat(struct rb_root *rb_root, struct callchain_node *node,
u64 min_hit)
{
- struct rb_node *n;
struct callchain_node *child;
- n = rb_first(&node->rb_root_in);
- while (n) {
- child = rb_entry(n, struct callchain_node, rb_node_in);
- n = rb_next(n);
-
+ chain_for_each_child(child, node)
__sort_chain_flat(rb_root, child, min_hit);
- }
if (node->hit && node->hit >= min_hit)
rb_insert_callchain(rb_root, node, CHAIN_FLAT);
@@ -94,16 +94,11 @@ sort_chain_flat(struct rb_root *rb_root, struct callchain_root *root,
static void __sort_chain_graph_abs(struct callchain_node *node,
u64 min_hit)
{
- struct rb_node *n;
struct callchain_node *child;
node->rb_root = RB_ROOT;
- n = rb_first(&node->rb_root_in);
-
- while (n) {
- child = rb_entry(n, struct callchain_node, rb_node_in);
- n = rb_next(n);
+ chain_for_each_child(child, node) {
__sort_chain_graph_abs(child, min_hit);
if (callchain_cumul_hits(child) >= min_hit)
rb_insert_callchain(&node->rb_root, child,
@@ -122,18 +117,13 @@ sort_chain_graph_abs(struct rb_root *rb_root, struct callchain_root *chain_root,
static void __sort_chain_graph_rel(struct callchain_node *node,
double min_percent)
{
- struct rb_node *n;
struct callchain_node *child;
u64 min_hit;
node->rb_root = RB_ROOT;
min_hit = ceil(node->children_hit * min_percent);
- n = rb_first(&node->rb_root_in);
- while (n) {
- child = rb_entry(n, struct callchain_node, rb_node_in);
- n = rb_next(n);
-
+ chain_for_each_child(child, node) {
__sort_chain_graph_rel(child, min_percent);
if (callchain_cumul_hits(child) >= min_hit)
rb_insert_callchain(&node->rb_root, child,
@@ -183,26 +173,19 @@ create_child(struct callchain_node *parent, bool inherit_children)
return NULL;
}
new->parent = parent;
+ INIT_LIST_HEAD(&new->children);
INIT_LIST_HEAD(&new->val);
if (inherit_children) {
- struct rb_node *n;
- struct callchain_node *child;
-
- new->rb_root_in = parent->rb_root_in;
- parent->rb_root_in = RB_ROOT;
+ struct callchain_node *next;
- n = rb_first(&new->rb_root_in);
- while (n) {
- child = rb_entry(n, struct callchain_node, rb_node_in);
- child->parent = new;
- n = rb_next(n);
- }
+ list_splice(&parent->children, &new->children);
+ INIT_LIST_HEAD(&parent->children);
- /* make it the first child */
- rb_link_node(&new->rb_node_in, NULL, &parent->rb_root_in.rb_node);
- rb_insert_color(&new->rb_node_in, &parent->rb_root_in);
+ chain_for_each_child(next, new)
+ next->parent = new;
}
+ list_add_tail(&new->siblings, &parent->children);
return new;
}
@@ -240,7 +223,7 @@ fill_node(struct callchain_node *node, struct callchain_cursor *cursor)
}
}
-static struct callchain_node *
+static void
add_child(struct callchain_node *parent,
struct callchain_cursor *cursor,
u64 period)
@@ -252,19 +235,6 @@ add_child(struct callchain_node *parent,
new->children_hit = 0;
new->hit = period;
- return new;
-}
-
-static s64 match_chain(struct callchain_cursor_node *node,
- struct callchain_list *cnode)
-{
- struct symbol *sym = node->sym;
-
- if (cnode->ms.sym && sym &&
- callchain_param.key == CCKEY_FUNCTION)
- return cnode->ms.sym->start - sym->start;
- else
- return cnode->ip - node->ip;
}
/*
@@ -302,33 +272,9 @@ split_add_child(struct callchain_node *parent,
/* create a new child for the new branch if any */
if (idx_total < cursor->nr) {
- struct callchain_node *first;
- struct callchain_list *cnode;
- struct callchain_cursor_node *node;
- struct rb_node *p, **pp;
-
parent->hit = 0;
+ add_child(parent, cursor, period);
parent->children_hit += period;
-
- node = callchain_cursor_current(cursor);
- new = add_child(parent, cursor, period);
-
- /*
- * This is second child since we moved parent's children
- * to new (first) child above.
- */
- p = parent->rb_root_in.rb_node;
- first = rb_entry(p, struct callchain_node, rb_node_in);
- cnode = list_first_entry(&first->val, struct callchain_list,
- list);
-
- if (match_chain(node, cnode) < 0)
- pp = &p->rb_left;
- else
- pp = &p->rb_right;
-
- rb_link_node(&new->rb_node_in, p, pp);
- rb_insert_color(&new->rb_node_in, &parent->rb_root_in);
} else {
parent->hit = period;
}
@@ -345,40 +291,16 @@ append_chain_children(struct callchain_node *root,
u64 period)
{
struct callchain_node *rnode;
- struct callchain_cursor_node *node;
- struct rb_node **p = &root->rb_root_in.rb_node;
- struct rb_node *parent = NULL;
-
- node = callchain_cursor_current(cursor);
- if (!node)
- return;
/* lookup in childrens */
- while (*p) {
- s64 ret;
- struct callchain_list *cnode;
+ chain_for_each_child(rnode, root) {
+ unsigned int ret = append_chain(rnode, cursor, period);
- parent = *p;
- rnode = rb_entry(parent, struct callchain_node, rb_node_in);
- cnode = list_first_entry(&rnode->val, struct callchain_list,
- list);
-
- /* just check first entry */
- ret = match_chain(node, cnode);
- if (ret == 0) {
- append_chain(rnode, cursor, period);
+ if (!ret)
goto inc_children_hit;
- }
-
- if (ret < 0)
- p = &parent->rb_left;
- else
- p = &parent->rb_right;
}
/* nothing in children, add to the current node */
- rnode = add_child(root, cursor, period);
- rb_link_node(&rnode->rb_node_in, parent, p);
- rb_insert_color(&rnode->rb_node_in, &root->rb_root_in);
+ add_child(root, cursor, period);
inc_children_hit:
root->children_hit += period;
@@ -403,20 +325,28 @@ append_chain(struct callchain_node *root,
*/
list_for_each_entry(cnode, &root->val, list) {
struct callchain_cursor_node *node;
+ struct symbol *sym;
node = callchain_cursor_current(cursor);
if (!node)
break;
- if (match_chain(node, cnode) != 0)
+ sym = node->sym;
+
+ if (cnode->ms.sym && sym &&
+ callchain_param.key == CCKEY_FUNCTION) {
+ if (cnode->ms.sym->start != sym->start)
+ break;
+ } else if (cnode->ip != node->ip)
break;
- found = true;
+ if (!found)
+ found = true;
callchain_cursor_advance(cursor);
}
- /* matches not, relay no the parent */
+ /* matches not, relay on the parent */
if (!found) {
cursor->curr = curr_snap;
cursor->pos = start;
@@ -465,9 +395,8 @@ merge_chain_branch(struct callchain_cursor *cursor,
struct callchain_node *dst, struct callchain_node *src)
{
struct callchain_cursor_node **old_last = cursor->last;
- struct callchain_node *child;
+ struct callchain_node *child, *next_child;
struct callchain_list *list, *next_list;
- struct rb_node *n;
int old_pos = cursor->nr;
int err = 0;
@@ -483,16 +412,12 @@ merge_chain_branch(struct callchain_cursor *cursor,
append_chain_children(dst, cursor, src->hit);
}
- n = rb_first(&src->rb_root_in);
- while (n) {
- child = container_of(n, struct callchain_node, rb_node_in);
- n = rb_next(n);
- rb_erase(&child->rb_node_in, &src->rb_root_in);
-
+ chain_for_each_child_safe(child, next_child, src) {
err = merge_chain_branch(cursor, dst, child);
if (err)
break;
+ list_del(&child->siblings);
free(child);
}
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 4f7f989..9e99060 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -21,11 +21,11 @@ enum chain_order {
struct callchain_node {
struct callchain_node *parent;
+ struct list_head siblings;
+ struct list_head children;
struct list_head val;
- struct rb_node rb_node_in; /* to insert nodes in an rbtree */
- struct rb_node rb_node; /* to sort nodes in an output tree */
- struct rb_root rb_root_in; /* input tree of children */
- struct rb_root rb_root; /* sorted output tree of children */
+ struct rb_node rb_node; /* to sort nodes in an rbtree */
+ struct rb_root rb_root; /* sorted tree of children */
unsigned int val_nr;
u64 hit;
u64 children_hit;
@@ -86,12 +86,13 @@ extern __thread struct callchain_cursor callchain_cursor;
static inline void callchain_init(struct callchain_root *root)
{
+ INIT_LIST_HEAD(&root->node.siblings);
+ INIT_LIST_HEAD(&root->node.children);
INIT_LIST_HEAD(&root->node.val);
root->node.parent = NULL;
root->node.hit = 0;
root->node.children_hit = 0;
- root->node.rb_root_in = RB_ROOT;
root->max_depth = 0;
}
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
index 66e44a5..11e46da 100644
--- a/tools/perf/util/color.c
+++ b/tools/perf/util/color.c
@@ -318,15 +318,8 @@ int percent_color_fprintf(FILE *fp, const char *fmt, double percent)
return r;
}
-int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...)
+int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent)
{
- va_list args;
- double percent;
- const char *color;
-
- va_start(args, fmt);
- percent = va_arg(args, double);
- va_end(args);
- color = get_percent_color(percent);
+ const char *color = get_percent_color(percent);
return color_snprintf(bf, size, color, fmt, percent);
}
diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h
index fced384..dea082b 100644
--- a/tools/perf/util/color.h
+++ b/tools/perf/util/color.h
@@ -39,7 +39,7 @@ int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
int color_snprintf(char *bf, size_t size, const char *color, const char *fmt, ...);
int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf);
-int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...);
+int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent);
int percent_color_fprintf(FILE *fp, const char *fmt, double percent);
const char *get_percent_color(double percent);
diff --git a/tools/perf/util/comm.c b/tools/perf/util/comm.c
deleted file mode 100644
index ee0df0e..0000000
--- a/tools/perf/util/comm.c
+++ /dev/null
@@ -1,121 +0,0 @@
-#include "comm.h"
-#include "util.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-struct comm_str {
- char *str;
- struct rb_node rb_node;
- int ref;
-};
-
-/* Should perhaps be moved to struct machine */
-static struct rb_root comm_str_root;
-
-static void comm_str__get(struct comm_str *cs)
-{
- cs->ref++;
-}
-
-static void comm_str__put(struct comm_str *cs)
-{
- if (!--cs->ref) {
- rb_erase(&cs->rb_node, &comm_str_root);
- free(cs->str);
- free(cs);
- }
-}
-
-static struct comm_str *comm_str__alloc(const char *str)
-{
- struct comm_str *cs;
-
- cs = zalloc(sizeof(*cs));
- if (!cs)
- return NULL;
-
- cs->str = strdup(str);
- if (!cs->str) {
- free(cs);
- return NULL;
- }
-
- return cs;
-}
-
-static struct comm_str *comm_str__findnew(const char *str, struct rb_root *root)
-{
- struct rb_node **p = &root->rb_node;
- struct rb_node *parent = NULL;
- struct comm_str *iter, *new;
- int cmp;
-
- while (*p != NULL) {
- parent = *p;
- iter = rb_entry(parent, struct comm_str, rb_node);
-
- cmp = strcmp(str, iter->str);
- if (!cmp)
- return iter;
-
- if (cmp < 0)
- p = &(*p)->rb_left;
- else
- p = &(*p)->rb_right;
- }
-
- new = comm_str__alloc(str);
- if (!new)
- return NULL;
-
- rb_link_node(&new->rb_node, parent, p);
- rb_insert_color(&new->rb_node, root);
-
- return new;
-}
-
-struct comm *comm__new(const char *str, u64 timestamp)
-{
- struct comm *comm = zalloc(sizeof(*comm));
-
- if (!comm)
- return NULL;
-
- comm->start = timestamp;
-
- comm->comm_str = comm_str__findnew(str, &comm_str_root);
- if (!comm->comm_str) {
- free(comm);
- return NULL;
- }
-
- comm_str__get(comm->comm_str);
-
- return comm;
-}
-
-void comm__override(struct comm *comm, const char *str, u64 timestamp)
-{
- struct comm_str *old = comm->comm_str;
-
- comm->comm_str = comm_str__findnew(str, &comm_str_root);
- if (!comm->comm_str) {
- comm->comm_str = old;
- return;
- }
-
- comm->start = timestamp;
- comm_str__get(comm->comm_str);
- comm_str__put(old);
-}
-
-void comm__free(struct comm *comm)
-{
- comm_str__put(comm->comm_str);
- free(comm);
-}
-
-const char *comm__str(const struct comm *comm)
-{
- return comm->comm_str->str;
-}
diff --git a/tools/perf/util/comm.h b/tools/perf/util/comm.h
deleted file mode 100644
index 7a86e56..0000000
--- a/tools/perf/util/comm.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __PERF_COMM_H
-#define __PERF_COMM_H
-
-#include "../perf.h"
-#include <linux/rbtree.h>
-#include <linux/list.h>
-
-struct comm_str;
-
-struct comm {
- struct comm_str *comm_str;
- u64 start;
- struct list_head list;
-};
-
-void comm__free(struct comm *comm);
-struct comm *comm__new(const char *str, u64 timestamp);
-const char *comm__str(const struct comm *comm);
-void comm__override(struct comm *comm, const char *str, u64 timestamp);
-
-#endif /* __PERF_COMM_H */
diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c
index a9b48c4..beb8cf9 100644
--- a/tools/perf/util/cpumap.c
+++ b/tools/perf/util/cpumap.c
@@ -1,5 +1,5 @@
#include "util.h"
-#include "fs.h"
+#include "sysfs.h"
#include "../perf.h"
#include "cpumap.h"
#include <assert.h>
@@ -216,7 +216,7 @@ int cpu_map__get_socket(struct cpu_map *map, int idx)
cpu = map->map[idx];
- mnt = sysfs__mountpoint();
+ mnt = sysfs_find_mountpoint();
if (!mnt)
return -1;
@@ -279,7 +279,7 @@ int cpu_map__get_core(struct cpu_map *map, int idx)
cpu = map->map[idx];
- mnt = sysfs__mountpoint();
+ mnt = sysfs_find_mountpoint();
if (!mnt)
return -1;
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
deleted file mode 100644
index 7d09faf..0000000
--- a/tools/perf/util/data.c
+++ /dev/null
@@ -1,120 +0,0 @@
-#include <linux/compiler.h>
-#include <linux/kernel.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "data.h"
-#include "util.h"
-
-static bool check_pipe(struct perf_data_file *file)
-{
- struct stat st;
- bool is_pipe = false;
- int fd = perf_data_file__is_read(file) ?
- STDIN_FILENO : STDOUT_FILENO;
-
- if (!file->path) {
- if (!fstat(fd, &st) && S_ISFIFO(st.st_mode))
- is_pipe = true;
- } else {
- if (!strcmp(file->path, "-"))
- is_pipe = true;
- }
-
- if (is_pipe)
- file->fd = fd;
-
- return file->is_pipe = is_pipe;
-}
-
-static int check_backup(struct perf_data_file *file)
-{
- struct stat st;
-
- if (!stat(file->path, &st) && st.st_size) {
- /* TODO check errors properly */
- char oldname[PATH_MAX];
- snprintf(oldname, sizeof(oldname), "%s.old",
- file->path);
- unlink(oldname);
- rename(file->path, oldname);
- }
-
- return 0;
-}
-
-static int open_file_read(struct perf_data_file *file)
-{
- struct stat st;
- int fd;
-
- fd = open(file->path, O_RDONLY);
- if (fd < 0) {
- int err = errno;
-
- pr_err("failed to open %s: %s", file->path, strerror(err));
- if (err == ENOENT && !strcmp(file->path, "perf.data"))
- pr_err(" (try 'perf record' first)");
- pr_err("\n");
- return -err;
- }
-
- if (fstat(fd, &st) < 0)
- goto out_close;
-
- if (!file->force && st.st_uid && (st.st_uid != geteuid())) {
- pr_err("file %s not owned by current user or root\n",
- file->path);
- goto out_close;
- }
-
- if (!st.st_size) {
- pr_info("zero-sized file (%s), nothing to do!\n",
- file->path);
- goto out_close;
- }
-
- file->size = st.st_size;
- return fd;
-
- out_close:
- close(fd);
- return -1;
-}
-
-static int open_file_write(struct perf_data_file *file)
-{
- if (check_backup(file))
- return -1;
-
- return open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR);
-}
-
-static int open_file(struct perf_data_file *file)
-{
- int fd;
-
- fd = perf_data_file__is_read(file) ?
- open_file_read(file) : open_file_write(file);
-
- file->fd = fd;
- return fd < 0 ? -1 : 0;
-}
-
-int perf_data_file__open(struct perf_data_file *file)
-{
- if (check_pipe(file))
- return 0;
-
- if (!file->path)
- file->path = "perf.data";
-
- return open_file(file);
-}
-
-void perf_data_file__close(struct perf_data_file *file)
-{
- close(file->fd);
-}
diff --git a/tools/perf/util/data.h b/tools/perf/util/data.h
deleted file mode 100644
index 8c2df80..0000000
--- a/tools/perf/util/data.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef __PERF_DATA_H
-#define __PERF_DATA_H
-
-#include <stdbool.h>
-
-enum perf_data_mode {
- PERF_DATA_MODE_WRITE,
- PERF_DATA_MODE_READ,
-};
-
-struct perf_data_file {
- const char *path;
- int fd;
- bool is_pipe;
- bool force;
- unsigned long size;
- enum perf_data_mode mode;
-};
-
-static inline bool perf_data_file__is_read(struct perf_data_file *file)
-{
- return file->mode == PERF_DATA_MODE_READ;
-}
-
-static inline bool perf_data_file__is_write(struct perf_data_file *file)
-{
- return file->mode == PERF_DATA_MODE_WRITE;
-}
-
-static inline int perf_data_file__is_pipe(struct perf_data_file *file)
-{
- return file->is_pipe;
-}
-
-static inline int perf_data_file__fd(struct perf_data_file *file)
-{
- return file->fd;
-}
-
-static inline unsigned long perf_data_file__size(struct perf_data_file *file)
-{
- return file->size;
-}
-
-int perf_data_file__open(struct perf_data_file *file);
-void perf_data_file__close(struct perf_data_file *file);
-
-#endif /* __PERF_DATA_H */
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index af4c687c..e3c1ff8 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -7,20 +7,19 @@
char dso__symtab_origin(const struct dso *dso)
{
static const char origin[] = {
- [DSO_BINARY_TYPE__KALLSYMS] = 'k',
- [DSO_BINARY_TYPE__VMLINUX] = 'v',
- [DSO_BINARY_TYPE__JAVA_JIT] = 'j',
- [DSO_BINARY_TYPE__DEBUGLINK] = 'l',
- [DSO_BINARY_TYPE__BUILD_ID_CACHE] = 'B',
- [DSO_BINARY_TYPE__FEDORA_DEBUGINFO] = 'f',
- [DSO_BINARY_TYPE__UBUNTU_DEBUGINFO] = 'u',
- [DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO] = 'o',
- [DSO_BINARY_TYPE__BUILDID_DEBUGINFO] = 'b',
- [DSO_BINARY_TYPE__SYSTEM_PATH_DSO] = 'd',
- [DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE] = 'K',
- [DSO_BINARY_TYPE__GUEST_KALLSYMS] = 'g',
- [DSO_BINARY_TYPE__GUEST_KMODULE] = 'G',
- [DSO_BINARY_TYPE__GUEST_VMLINUX] = 'V',
+ [DSO_BINARY_TYPE__KALLSYMS] = 'k',
+ [DSO_BINARY_TYPE__VMLINUX] = 'v',
+ [DSO_BINARY_TYPE__JAVA_JIT] = 'j',
+ [DSO_BINARY_TYPE__DEBUGLINK] = 'l',
+ [DSO_BINARY_TYPE__BUILD_ID_CACHE] = 'B',
+ [DSO_BINARY_TYPE__FEDORA_DEBUGINFO] = 'f',
+ [DSO_BINARY_TYPE__UBUNTU_DEBUGINFO] = 'u',
+ [DSO_BINARY_TYPE__BUILDID_DEBUGINFO] = 'b',
+ [DSO_BINARY_TYPE__SYSTEM_PATH_DSO] = 'd',
+ [DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE] = 'K',
+ [DSO_BINARY_TYPE__GUEST_KALLSYMS] = 'g',
+ [DSO_BINARY_TYPE__GUEST_KMODULE] = 'G',
+ [DSO_BINARY_TYPE__GUEST_VMLINUX] = 'V',
};
if (dso == NULL || dso->symtab_type == DSO_BINARY_TYPE__NOT_FOUND)
@@ -65,28 +64,6 @@ int dso__binary_type_file(struct dso *dso, enum dso_binary_type type,
symbol_conf.symfs, dso->long_name);
break;
- case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO:
- {
- char *last_slash;
- size_t len;
- size_t dir_size;
-
- last_slash = dso->long_name + dso->long_name_len;
- while (last_slash != dso->long_name && *last_slash != '/')
- last_slash--;
-
- len = scnprintf(file, size, "%s", symbol_conf.symfs);
- dir_size = last_slash - dso->long_name + 2;
- if (dir_size > (size - len)) {
- ret = -1;
- break;
- }
- len += scnprintf(file + len, dir_size, "%s", dso->long_name);
- len += scnprintf(file + len , size - len, ".debug%s",
- last_slash);
- break;
- }
-
case DSO_BINARY_TYPE__BUILDID_DEBUGINFO:
if (!dso->has_build_id) {
ret = -1;
@@ -450,7 +427,6 @@ struct dso *dso__new(const char *name)
dso->rel = 0;
dso->sorted_by_name = 0;
dso->has_build_id = 0;
- dso->has_srcline = 1;
dso->kernel = DSO_TYPE_USER;
dso->needs_swap = DSO_SWAP__UNSET;
INIT_LIST_HEAD(&dso->node);
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 9ac666a..b793053 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -6,7 +6,6 @@
#include <stdbool.h>
#include "types.h"
#include "map.h"
-#include "build-id.h"
enum dso_binary_type {
DSO_BINARY_TYPE__KALLSYMS = 0,
@@ -24,7 +23,6 @@ enum dso_binary_type {
DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE,
DSO_BINARY_TYPE__KCORE,
DSO_BINARY_TYPE__GUEST_KCORE,
- DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
DSO_BINARY_TYPE__NOT_FOUND,
};
@@ -83,7 +81,6 @@ struct dso {
enum dso_binary_type data_type;
u8 adjust_symbols:1;
u8 has_build_id:1;
- u8 has_srcline:1;
u8 hit:1;
u8 annotate_warned:1;
u8 sname_alloc:1;
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index bb788c1..49096ea 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -170,8 +170,7 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
union perf_event *event,
pid_t pid, pid_t tgid,
perf_event__handler_t process,
- struct machine *machine,
- bool mmap_data)
+ struct machine *machine)
{
char filename[PATH_MAX];
FILE *fp;
@@ -189,6 +188,10 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
}
event->header.type = PERF_RECORD_MMAP;
+ /*
+ * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c
+ */
+ event->header.misc = PERF_RECORD_MISC_USER;
while (1) {
char bf[BUFSIZ];
@@ -209,22 +212,12 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
&event->mmap.start, &event->mmap.len, prot,
&event->mmap.pgoff,
execname);
- /*
- * Anon maps don't have the execname.
- */
- if (n < 4)
- continue;
- /*
- * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c
- */
- event->header.misc = PERF_RECORD_MISC_USER;
- if (prot[2] != 'x') {
- if (!mmap_data || prot[0] != 'r')
- continue;
+ if (n != 5)
+ continue;
- event->header.misc |= PERF_RECORD_MISC_MMAP_DATA;
- }
+ if (prot[2] != 'x')
+ continue;
if (!strcmp(execname, ""))
strcpy(execname, anonstr);
@@ -311,21 +304,20 @@ static int __event__synthesize_thread(union perf_event *comm_event,
pid_t pid, int full,
perf_event__handler_t process,
struct perf_tool *tool,
- struct machine *machine, bool mmap_data)
+ struct machine *machine)
{
pid_t tgid = perf_event__synthesize_comm(tool, comm_event, pid, full,
process, machine);
if (tgid == -1)
return -1;
return perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid,
- process, machine, mmap_data);
+ process, machine);
}
int perf_event__synthesize_thread_map(struct perf_tool *tool,
struct thread_map *threads,
perf_event__handler_t process,
- struct machine *machine,
- bool mmap_data)
+ struct machine *machine)
{
union perf_event *comm_event, *mmap_event;
int err = -1, thread, j;
@@ -342,8 +334,7 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
for (thread = 0; thread < threads->nr; ++thread) {
if (__event__synthesize_thread(comm_event, mmap_event,
threads->map[thread], 0,
- process, tool, machine,
- mmap_data)) {
+ process, tool, machine)) {
err = -1;
break;
}
@@ -365,10 +356,10 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
/* if not, generate events for it */
if (need_leader &&
- __event__synthesize_thread(comm_event, mmap_event,
- comm_event->comm.pid, 0,
- process, tool, machine,
- mmap_data)) {
+ __event__synthesize_thread(comm_event,
+ mmap_event,
+ comm_event->comm.pid, 0,
+ process, tool, machine)) {
err = -1;
break;
}
@@ -383,7 +374,7 @@ out:
int perf_event__synthesize_threads(struct perf_tool *tool,
perf_event__handler_t process,
- struct machine *machine, bool mmap_data)
+ struct machine *machine)
{
DIR *proc;
struct dirent dirent, *next;
@@ -413,7 +404,7 @@ int perf_event__synthesize_threads(struct perf_tool *tool,
* one thread couldn't be synthesized.
*/
__event__synthesize_thread(comm_event, mmap_event, pid, 1,
- process, tool, machine, mmap_data);
+ process, tool, machine);
}
err = 0;
@@ -521,55 +512,52 @@ size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp)
int perf_event__process_comm(struct perf_tool *tool __maybe_unused,
union perf_event *event,
- struct perf_sample *sample,
+ struct perf_sample *sample __maybe_unused,
struct machine *machine)
{
- return machine__process_comm_event(machine, event, sample);
+ return machine__process_comm_event(machine, event);
}
int perf_event__process_lost(struct perf_tool *tool __maybe_unused,
union perf_event *event,
- struct perf_sample *sample,
+ struct perf_sample *sample __maybe_unused,
struct machine *machine)
{
- return machine__process_lost_event(machine, event, sample);
+ return machine__process_lost_event(machine, event);
}
size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp)
{
- return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %c %s\n",
+ return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 "]: %s\n",
event->mmap.pid, event->mmap.tid, event->mmap.start,
- event->mmap.len, event->mmap.pgoff,
- (event->header.misc & PERF_RECORD_MISC_MMAP_DATA) ? 'r' : 'x',
- event->mmap.filename);
+ event->mmap.len, event->mmap.pgoff, event->mmap.filename);
}
size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp)
{
return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64
- " %02x:%02x %"PRIu64" %"PRIu64"]: %c %s\n",
+ " %02x:%02x %"PRIu64" %"PRIu64"]: %s\n",
event->mmap2.pid, event->mmap2.tid, event->mmap2.start,
event->mmap2.len, event->mmap2.pgoff, event->mmap2.maj,
event->mmap2.min, event->mmap2.ino,
event->mmap2.ino_generation,
- (event->header.misc & PERF_RECORD_MISC_MMAP_DATA) ? 'r' : 'x',
event->mmap2.filename);
}
int perf_event__process_mmap(struct perf_tool *tool __maybe_unused,
union perf_event *event,
- struct perf_sample *sample,
+ struct perf_sample *sample __maybe_unused,
struct machine *machine)
{
- return machine__process_mmap_event(machine, event, sample);
+ return machine__process_mmap_event(machine, event);
}
int perf_event__process_mmap2(struct perf_tool *tool __maybe_unused,
union perf_event *event,
- struct perf_sample *sample,
+ struct perf_sample *sample __maybe_unused,
struct machine *machine)
{
- return machine__process_mmap2_event(machine, event, sample);
+ return machine__process_mmap2_event(machine, event);
}
size_t perf_event__fprintf_task(union perf_event *event, FILE *fp)
@@ -581,18 +569,18 @@ size_t perf_event__fprintf_task(union perf_event *event, FILE *fp)
int perf_event__process_fork(struct perf_tool *tool __maybe_unused,
union perf_event *event,
- struct perf_sample *sample,
+ struct perf_sample *sample __maybe_unused,
struct machine *machine)
{
- return machine__process_fork_event(machine, event, sample);
+ return machine__process_fork_event(machine, event);
}
int perf_event__process_exit(struct perf_tool *tool __maybe_unused,
union perf_event *event,
- struct perf_sample *sample,
+ struct perf_sample *sample __maybe_unused,
struct machine *machine)
{
- return machine__process_exit_event(machine, event, sample);
+ return machine__process_exit_event(machine, event);
}
size_t perf_event__fprintf(union perf_event *event, FILE *fp)
@@ -623,21 +611,21 @@ size_t perf_event__fprintf(union perf_event *event, FILE *fp)
int perf_event__process(struct perf_tool *tool __maybe_unused,
union perf_event *event,
- struct perf_sample *sample,
+ struct perf_sample *sample __maybe_unused,
struct machine *machine)
{
- return machine__process_event(machine, event, sample);
+ return machine__process_event(machine, event);
}
-void thread__find_addr_map(struct thread *thread,
+void thread__find_addr_map(struct thread *self,
struct machine *machine, u8 cpumode,
enum map_type type, u64 addr,
struct addr_location *al)
{
- struct map_groups *mg = &thread->mg;
+ struct map_groups *mg = &self->mg;
bool load_map = false;
- al->thread = thread;
+ al->thread = self;
al->addr = addr;
al->cpumode = cpumode;
al->filtered = false;
@@ -733,10 +721,10 @@ int perf_event__preprocess_sample(const union perf_event *event,
return -1;
if (symbol_conf.comm_list &&
- !strlist__has_entry(symbol_conf.comm_list, thread__comm_str(thread)))
+ !strlist__has_entry(symbol_conf.comm_list, thread->comm))
goto out_filtered;
- dump_printf(" ... thread: %s:%d\n", thread__comm_str(thread), thread->tid);
+ dump_printf(" ... thread: %s:%d\n", thread->comm, thread->tid);
/*
* Have we already created the kernel maps for this machine?
*
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 30fec99..c67ecc4 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -61,12 +61,6 @@ struct read_event {
u64 id;
};
-struct throttle_event {
- struct perf_event_header header;
- u64 time;
- u64 id;
- u64 stream_id;
-};
#define PERF_SAMPLE_MASK \
(PERF_SAMPLE_IP | PERF_SAMPLE_TID | \
@@ -75,9 +69,6 @@ struct throttle_event {
PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD | \
PERF_SAMPLE_IDENTIFIER)
-/* perf sample has 16 bits size limit */
-#define PERF_SAMPLE_MAX_SIZE (1 << 16)
-
struct sample_event {
struct perf_event_header header;
u64 array[];
@@ -120,7 +111,6 @@ struct perf_sample {
u64 stream_id;
u64 period;
u64 weight;
- u64 transaction;
u32 cpu;
u32 raw_size;
u64 data_src;
@@ -187,7 +177,6 @@ union perf_event {
struct fork_event fork;
struct lost_event lost;
struct read_event read;
- struct throttle_event throttle;
struct sample_event sample;
struct attr_event attr;
struct event_type_event event_type;
@@ -208,10 +197,10 @@ typedef int (*perf_event__handler_t)(struct perf_tool *tool,
int perf_event__synthesize_thread_map(struct perf_tool *tool,
struct thread_map *threads,
perf_event__handler_t process,
- struct machine *machine, bool mmap_data);
+ struct machine *machine);
int perf_event__synthesize_threads(struct perf_tool *tool,
perf_event__handler_t process,
- struct machine *machine, bool mmap_data);
+ struct machine *machine);
int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
perf_event__handler_t process,
struct machine *machine,
@@ -251,8 +240,7 @@ int perf_event__process(struct perf_tool *tool,
struct machine *machine);
struct addr_location;
-
-int perf_event__preprocess_sample(const union perf_event *event,
+int perf_event__preprocess_sample(const union perf_event *self,
struct machine *machine,
struct addr_location *al,
struct perf_sample *sample);
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index bbc746a..e584cd3 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -18,7 +18,6 @@
#include <unistd.h>
#include "parse-events.h"
-#include "parse-options.h"
#include <sys/mman.h>
@@ -50,18 +49,6 @@ struct perf_evlist *perf_evlist__new(void)
return evlist;
}
-struct perf_evlist *perf_evlist__new_default(void)
-{
- struct perf_evlist *evlist = perf_evlist__new();
-
- if (evlist && perf_evlist__add_default(evlist)) {
- perf_evlist__delete(evlist);
- evlist = NULL;
- }
-
- return evlist;
-}
-
/**
* perf_evlist__set_id_pos - set the positions of event ids.
* @evlist: selected event list
@@ -117,8 +104,6 @@ void perf_evlist__delete(struct perf_evlist *evlist)
void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry)
{
list_add_tail(&entry->node, &evlist->entries);
- entry->idx = evlist->nr_entries;
-
if (!evlist->nr_entries++)
perf_evlist__set_id_pos(evlist);
}
@@ -167,7 +152,7 @@ int perf_evlist__add_default(struct perf_evlist *evlist)
event_attr_init(&attr);
- evsel = perf_evsel__new(&attr);
+ evsel = perf_evsel__new(&attr, 0);
if (evsel == NULL)
goto error;
@@ -192,7 +177,7 @@ static int perf_evlist__add_attrs(struct perf_evlist *evlist,
size_t i;
for (i = 0; i < nr_attrs; i++) {
- evsel = perf_evsel__new_idx(attrs + i, evlist->nr_entries + i);
+ evsel = perf_evsel__new(attrs + i, evlist->nr_entries + i);
if (evsel == NULL)
goto out_delete_partial_list;
list_add_tail(&evsel->node, &head);
@@ -251,12 +236,13 @@ perf_evlist__find_tracepoint_by_name(struct perf_evlist *evlist,
int perf_evlist__add_newtp(struct perf_evlist *evlist,
const char *sys, const char *name, void *handler)
{
- struct perf_evsel *evsel = perf_evsel__newtp(sys, name);
+ struct perf_evsel *evsel;
+ evsel = perf_evsel__newtp(sys, name, evlist->nr_entries);
if (evsel == NULL)
return -1;
- evsel->handler = handler;
+ evsel->handler.func = handler;
perf_evlist__add(evlist, evsel);
return 0;
}
@@ -541,7 +527,7 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
if ((old & md->mask) + size != ((old + size) & md->mask)) {
unsigned int offset = old;
unsigned int len = min(sizeof(*event), size), cpy;
- void *dst = md->event_copy;
+ void *dst = &md->event_copy;
do {
cpy = min(md->mask + 1 - (offset & md->mask), len);
@@ -551,7 +537,7 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
len -= cpy;
} while (len);
- event = (union perf_event *) md->event_copy;
+ event = &md->event_copy;
}
old += size;
@@ -608,8 +594,6 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist,
evlist->mmap[idx].base = mmap(NULL, evlist->mmap_len, prot,
MAP_SHARED, fd, 0);
if (evlist->mmap[idx].base == MAP_FAILED) {
- pr_debug2("failed to mmap perf event ring buffer, error %d\n",
- errno);
evlist->mmap[idx].base = NULL;
return -1;
}
@@ -618,36 +602,9 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist,
return 0;
}
-static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx,
- int prot, int mask, int cpu, int thread,
- int *output)
+static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot, int mask)
{
struct perf_evsel *evsel;
-
- list_for_each_entry(evsel, &evlist->entries, node) {
- int fd = FD(evsel, cpu, thread);
-
- if (*output == -1) {
- *output = fd;
- if (__perf_evlist__mmap(evlist, idx, prot, mask,
- *output) < 0)
- return -1;
- } else {
- if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0)
- return -1;
- }
-
- if ((evsel->attr.read_format & PERF_FORMAT_ID) &&
- perf_evlist__id_add_fd(evlist, evsel, cpu, thread, fd) < 0)
- return -1;
- }
-
- return 0;
-}
-
-static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot,
- int mask)
-{
int cpu, thread;
int nr_cpus = cpu_map__nr(evlist->cpus);
int nr_threads = thread_map__nr(evlist->threads);
@@ -657,9 +614,23 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, int prot,
int output = -1;
for (thread = 0; thread < nr_threads; thread++) {
- if (perf_evlist__mmap_per_evsel(evlist, cpu, prot, mask,
- cpu, thread, &output))
- goto out_unmap;
+ list_for_each_entry(evsel, &evlist->entries, node) {
+ int fd = FD(evsel, cpu, thread);
+
+ if (output == -1) {
+ output = fd;
+ if (__perf_evlist__mmap(evlist, cpu,
+ prot, mask, output) < 0)
+ goto out_unmap;
+ } else {
+ if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, output) != 0)
+ goto out_unmap;
+ }
+
+ if ((evsel->attr.read_format & PERF_FORMAT_ID) &&
+ perf_evlist__id_add_fd(evlist, evsel, cpu, thread, fd) < 0)
+ goto out_unmap;
+ }
}
}
@@ -671,9 +642,9 @@ out_unmap:
return -1;
}
-static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot,
- int mask)
+static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot, int mask)
{
+ struct perf_evsel *evsel;
int thread;
int nr_threads = thread_map__nr(evlist->threads);
@@ -681,9 +652,23 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, int prot,
for (thread = 0; thread < nr_threads; thread++) {
int output = -1;
- if (perf_evlist__mmap_per_evsel(evlist, thread, prot, mask, 0,
- thread, &output))
- goto out_unmap;
+ list_for_each_entry(evsel, &evlist->entries, node) {
+ int fd = FD(evsel, 0, thread);
+
+ if (output == -1) {
+ output = fd;
+ if (__perf_evlist__mmap(evlist, thread,
+ prot, mask, output) < 0)
+ goto out_unmap;
+ } else {
+ if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, output) != 0)
+ goto out_unmap;
+ }
+
+ if ((evsel->attr.read_format & PERF_FORMAT_ID) &&
+ perf_evlist__id_add_fd(evlist, evsel, 0, thread, fd) < 0)
+ goto out_unmap;
+ }
}
return 0;
@@ -694,90 +679,20 @@ out_unmap:
return -1;
}
-static size_t perf_evlist__mmap_size(unsigned long pages)
-{
- /* 512 kiB: default amount of unprivileged mlocked memory */
- if (pages == UINT_MAX)
- pages = (512 * 1024) / page_size;
- else if (!is_power_of_2(pages))
- return 0;
-
- return (pages + 1) * page_size;
-}
-
-static long parse_pages_arg(const char *str, unsigned long min,
- unsigned long max)
-{
- unsigned long pages, val;
- static struct parse_tag tags[] = {
- { .tag = 'B', .mult = 1 },
- { .tag = 'K', .mult = 1 << 10 },
- { .tag = 'M', .mult = 1 << 20 },
- { .tag = 'G', .mult = 1 << 30 },
- { .tag = 0 },
- };
-
- if (str == NULL)
- return -EINVAL;
-
- val = parse_tag_value(str, tags);
- if (val != (unsigned long) -1) {
- /* we got file size value */
- pages = PERF_ALIGN(val, page_size) / page_size;
- } else {
- /* we got pages count value */
- char *eptr;
- pages = strtoul(str, &eptr, 10);
- if (*eptr != '\0')
- return -EINVAL;
- }
-
- if ((pages == 0) && (min == 0)) {
- /* leave number of pages at 0 */
- } else if (pages < (1UL << 31) && !is_power_of_2(pages)) {
- /* round pages up to next power of 2 */
- pages = next_pow2(pages);
- pr_info("rounding mmap pages size to %lu bytes (%lu pages)\n",
- pages * page_size, pages);
- }
-
- if (pages > max)
- return -EINVAL;
-
- return pages;
-}
-
-int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,
- int unset __maybe_unused)
-{
- unsigned int *mmap_pages = opt->value;
- unsigned long max = UINT_MAX;
- long pages;
-
- if (max < SIZE_MAX / page_size)
- max = SIZE_MAX / page_size;
-
- pages = parse_pages_arg(str, 1, max);
- if (pages < 0) {
- pr_err("Invalid argument for --mmap_pages/-m\n");
- return -1;
- }
-
- *mmap_pages = pages;
- return 0;
-}
-
-/**
- * perf_evlist__mmap - Create mmaps to receive events.
- * @evlist: list of events
- * @pages: map length in pages
- * @overwrite: overwrite older events?
+/** perf_evlist__mmap - Create per cpu maps to receive events
+ *
+ * @evlist - list of events
+ * @pages - map length in pages
+ * @overwrite - overwrite older events?
*
- * If @overwrite is %false the user needs to signal event consumption using
- * perf_mmap__write_tail(). Using perf_evlist__mmap_read() does this
- * automatically.
+ * If overwrite is false the user needs to signal event consuption using:
*
- * Return: %0 on success, negative error code otherwise.
+ * struct perf_mmap *m = &evlist->mmap[cpu];
+ * unsigned int head = perf_mmap__read_head(m);
+ *
+ * perf_mmap__write_tail(m, head)
+ *
+ * Using perf_evlist__read_on_cpu does this automatically.
*/
int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
bool overwrite)
@@ -787,6 +702,14 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
const struct thread_map *threads = evlist->threads;
int prot = PROT_READ | (overwrite ? 0 : PROT_WRITE), mask;
+ /* 512 kiB: default amount of unprivileged mlocked memory */
+ if (pages == UINT_MAX)
+ pages = (512 * 1024) / page_size;
+ else if (!is_power_of_2(pages))
+ return -EINVAL;
+
+ mask = pages * page_size - 1;
+
if (evlist->mmap == NULL && perf_evlist__alloc_mmap(evlist) < 0)
return -ENOMEM;
@@ -794,9 +717,7 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
return -ENOMEM;
evlist->overwrite = overwrite;
- evlist->mmap_len = perf_evlist__mmap_size(pages);
- pr_debug("mmap size %zuB\n", evlist->mmap_len);
- mask = evlist->mmap_len - page_size - 1;
+ evlist->mmap_len = (pages + 1) * page_size;
list_for_each_entry(evsel, &evlist->entries, node) {
if ((evsel->attr.read_format & PERF_FORMAT_ID) &&
@@ -811,7 +732,8 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
return perf_evlist__mmap_per_cpu(evlist, prot, mask);
}
-int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
+int perf_evlist__create_maps(struct perf_evlist *evlist,
+ struct perf_target *target)
{
evlist->threads = thread_map__new_str(target->pid, target->tid,
target->uid);
@@ -819,11 +741,9 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
if (evlist->threads == NULL)
return -1;
- if (target->force_per_cpu)
- evlist->cpus = cpu_map__new(target->cpu_list);
- else if (target__has_task(target))
+ if (perf_target__has_task(target))
evlist->cpus = cpu_map__dummy_new();
- else if (!target__has_cpu(target) && !target->uses_mmap)
+ else if (!perf_target__has_cpu(target) && !target->uses_mmap)
evlist->cpus = cpu_map__dummy_new();
else
evlist->cpus = cpu_map__new(target->cpu_list);
@@ -1032,7 +952,8 @@ out_err:
return err;
}
-int perf_evlist__prepare_workload(struct perf_evlist *evlist, struct target *target,
+int perf_evlist__prepare_workload(struct perf_evlist *evlist,
+ struct perf_target *target,
const char *argv[], bool pipe_output,
bool want_signal)
{
@@ -1084,7 +1005,7 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist, struct target *tar
exit(-1);
}
- if (target__none(target))
+ if (perf_target__none(target))
evlist->threads->map[0] = evlist->workload.pid;
close(child_ready_pipe[1]);
@@ -1150,68 +1071,5 @@ size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp)
perf_evsel__name(evsel));
}
- return printed + fprintf(fp, "\n");
-}
-
-int perf_evlist__strerror_tp(struct perf_evlist *evlist __maybe_unused,
- int err, char *buf, size_t size)
-{
- char sbuf[128];
-
- switch (err) {
- case ENOENT:
- scnprintf(buf, size, "%s",
- "Error:\tUnable to find debugfs\n"
- "Hint:\tWas your kernel was compiled with debugfs support?\n"
- "Hint:\tIs the debugfs filesystem mounted?\n"
- "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
- break;
- case EACCES:
- scnprintf(buf, size,
- "Error:\tNo permissions to read %s/tracing/events/raw_syscalls\n"
- "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
- debugfs_mountpoint, debugfs_mountpoint);
- break;
- default:
- scnprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf)));
- break;
- }
-
- return 0;
-}
-
-int perf_evlist__strerror_open(struct perf_evlist *evlist __maybe_unused,
- int err, char *buf, size_t size)
-{
- int printed, value;
- char sbuf[128], *emsg = strerror_r(err, sbuf, sizeof(sbuf));
-
- switch (err) {
- case EACCES:
- case EPERM:
- printed = scnprintf(buf, size,
- "Error:\t%s.\n"
- "Hint:\tCheck /proc/sys/kernel/perf_event_paranoid setting.", emsg);
-
- if (filename__read_int("/proc/sys/kernel/perf_event_paranoid", &value))
- break;
-
- printed += scnprintf(buf + printed, size - printed, "\nHint:\t");
-
- if (value >= 2) {
- printed += scnprintf(buf + printed, size - printed,
- "For your workloads it needs to be <= 1\nHint:\t");
- }
- printed += scnprintf(buf + printed, size - printed,
- "For system wide tracing it needs to be set to -1");
-
- printed += scnprintf(buf + printed, size - printed,
- ".\nHint:\tThe current value is %d.", value);
- break;
- default:
- scnprintf(buf, size, "%s", emsg);
- break;
- }
-
- return 0;
+ return printed + fprintf(fp, "\n");;
}
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 649d6ea..206d093 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -21,7 +21,7 @@ struct perf_mmap {
void *base;
int mask;
unsigned int prev;
- char event_copy[PERF_SAMPLE_MAX_SIZE];
+ union perf_event event_copy;
};
struct perf_evlist {
@@ -31,7 +31,7 @@ struct perf_evlist {
int nr_groups;
int nr_fds;
int nr_mmaps;
- size_t mmap_len;
+ int mmap_len;
int id_pos;
int is_pos;
u64 combined_sample_type;
@@ -53,7 +53,6 @@ struct perf_evsel_str_handler {
};
struct perf_evlist *perf_evlist__new(void);
-struct perf_evlist *perf_evlist__new_default(void);
void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus,
struct thread_map *threads);
void perf_evlist__exit(struct perf_evlist *evlist);
@@ -88,7 +87,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id);
-union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx);
+union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx);
@@ -99,18 +98,13 @@ void perf_evlist__set_id_pos(struct perf_evlist *evlist);
bool perf_can_sample_identifier(void);
void perf_evlist__config(struct perf_evlist *evlist,
struct perf_record_opts *opts);
-int perf_record_opts__config(struct perf_record_opts *opts);
int perf_evlist__prepare_workload(struct perf_evlist *evlist,
- struct target *target,
+ struct perf_target *target,
const char *argv[], bool pipe_output,
bool want_signal);
int perf_evlist__start_workload(struct perf_evlist *evlist);
-int perf_evlist__parse_mmap_pages(const struct option *opt,
- const char *str,
- int unset);
-
int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages,
bool overwrite);
void perf_evlist__munmap(struct perf_evlist *evlist);
@@ -134,7 +128,8 @@ static inline void perf_evlist__set_maps(struct perf_evlist *evlist,
evlist->threads = threads;
}
-int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target);
+int perf_evlist__create_maps(struct perf_evlist *evlist,
+ struct perf_target *target);
void perf_evlist__delete_maps(struct perf_evlist *evlist);
int perf_evlist__apply_filters(struct perf_evlist *evlist);
@@ -170,13 +165,10 @@ static inline struct perf_evsel *perf_evlist__last(struct perf_evlist *evlist)
size_t perf_evlist__fprintf(struct perf_evlist *evlist, FILE *fp);
-int perf_evlist__strerror_tp(struct perf_evlist *evlist, int err, char *buf, size_t size);
-int perf_evlist__strerror_open(struct perf_evlist *evlist, int err, char *buf, size_t size);
-
static inline unsigned int perf_mmap__read_head(struct perf_mmap *mm)
{
struct perf_event_mmap_page *pc = mm->base;
- int head = ACCESS_ONCE(pc->data_head);
+ int head = pc->data_head;
rmb();
return head;
}
@@ -189,7 +181,7 @@ static inline void perf_mmap__write_tail(struct perf_mmap *md,
/*
* ensure all reads are done before we write the tail out.
*/
- mb();
+ /* mb(); */
pc->data_tail = tail;
}
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 46dd4c2..9f1ef9b 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -168,7 +168,7 @@ void perf_evsel__init(struct perf_evsel *evsel,
perf_evsel__calc_id_pos(evsel);
}
-struct perf_evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx)
+struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx)
{
struct perf_evsel *evsel = zalloc(sizeof(*evsel));
@@ -219,7 +219,7 @@ out:
return format;
}
-struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int idx)
+struct perf_evsel *perf_evsel__newtp(const char *sys, const char *name, int idx)
{
struct perf_evsel *evsel = zalloc(sizeof(*evsel));
@@ -645,7 +645,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
}
}
- if (target__has_cpu(&opts->target) || opts->target.force_per_cpu)
+ if (perf_target__has_cpu(&opts->target))
perf_evsel__set_sample_bit(evsel, CPU);
if (opts->period)
@@ -653,7 +653,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
if (!perf_missing_features.sample_id_all &&
(opts->sample_time || !opts->no_inherit ||
- target__has_cpu(&opts->target) || opts->target.force_per_cpu))
+ perf_target__has_cpu(&opts->target)))
perf_evsel__set_sample_bit(evsel, TIME);
if (opts->raw_samples) {
@@ -663,7 +663,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
}
if (opts->sample_address)
- perf_evsel__set_sample_bit(evsel, DATA_SRC);
+ attr->sample_type |= PERF_SAMPLE_DATA_SRC;
if (opts->no_delay) {
attr->watermark = 0;
@@ -675,14 +675,11 @@ void perf_evsel__config(struct perf_evsel *evsel,
}
if (opts->sample_weight)
- perf_evsel__set_sample_bit(evsel, WEIGHT);
+ attr->sample_type |= PERF_SAMPLE_WEIGHT;
attr->mmap = track;
attr->comm = track;
- if (opts->sample_transaction)
- perf_evsel__set_sample_bit(evsel, TRANSACTION);
-
/*
* XXX see the function comment above
*
@@ -696,7 +693,7 @@ void perf_evsel__config(struct perf_evsel *evsel,
* Setting enable_on_exec for independent events and
* group leaders for traced executed by perf.
*/
- if (target__none(&opts->target) && perf_evsel__is_group_leader(evsel))
+ if (perf_target__none(&opts->target) && perf_evsel__is_group_leader(evsel))
attr->enable_on_exec = 1;
}
@@ -985,7 +982,6 @@ static size_t perf_event_attr__fprintf(struct perf_event_attr *attr, FILE *fp)
ret += PRINT_ATTR2(exclude_host, exclude_guest);
ret += PRINT_ATTR2N("excl.callchain_kern", exclude_callchain_kernel,
"excl.callchain_user", exclude_callchain_user);
- ret += PRINT_ATTR_U32(mmap2);
ret += PRINT_ATTR_U32(wakeup_events);
ret += PRINT_ATTR_U32(wakeup_watermark);
@@ -1051,8 +1047,6 @@ retry_open:
group_fd, flags);
if (FD(evsel, cpu, thread) < 0) {
err = -errno;
- pr_debug2("perf_event_open failed, error %d\n",
- err);
goto try_fallback;
}
set_rlimit = NO_CHANGE;
@@ -1219,7 +1213,6 @@ static int perf_evsel__parse_id_sample(const struct perf_evsel *evsel,
sample->pid = u.val32[0];
sample->tid = u.val32[1];
- array--;
}
return 0;
@@ -1459,9 +1452,6 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
array = (void *)array + sz;
OVERFLOW_CHECK_u64(array);
data->user_stack.size = *array++;
- if (WARN_ONCE(data->user_stack.size > sz,
- "user stack dump failure\n"))
- return -EFAULT;
}
}
@@ -1479,13 +1469,6 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event,
array++;
}
- data->transaction = 0;
- if (type & PERF_SAMPLE_TRANSACTION) {
- OVERFLOW_CHECK_u64(array);
- data->transaction = *array;
- array++;
- }
-
return 0;
}
@@ -1578,9 +1561,6 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type,
if (type & PERF_SAMPLE_DATA_SRC)
result += sizeof(u64);
- if (type & PERF_SAMPLE_TRANSACTION)
- result += sizeof(u64);
-
return result;
}
@@ -1754,11 +1734,6 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type,
array++;
}
- if (type & PERF_SAMPLE_TRANSACTION) {
- *array = sample->transaction;
- array++;
- }
-
return 0;
}
@@ -2006,7 +1981,8 @@ bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
return false;
}
-int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
+int perf_evsel__open_strerror(struct perf_evsel *evsel,
+ struct perf_target *target,
int err, char *msg, size_t size)
{
switch (err) {
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 1ea7c92..4a7bdc7 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -74,7 +74,10 @@ struct perf_evsel {
off_t id_offset;
};
struct cgroup_sel *cgrp;
- void *handler;
+ struct {
+ void *func;
+ void *data;
+ } handler;
struct cpu_map *cpus;
unsigned int sample_size;
int id_pos;
@@ -96,19 +99,8 @@ struct thread_map;
struct perf_evlist;
struct perf_record_opts;
-struct perf_evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx);
-
-static inline struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr)
-{
- return perf_evsel__new_idx(attr, 0);
-}
-
-struct perf_evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int idx);
-
-static inline struct perf_evsel *perf_evsel__newtp(const char *sys, const char *name)
-{
- return perf_evsel__newtp_idx(sys, name, 0);
-}
+struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx);
+struct perf_evsel *perf_evsel__newtp(const char *sys, const char *name, int idx);
struct event_format *event_format__new(const char *sys, const char *name);
@@ -205,12 +197,6 @@ static inline bool perf_evsel__match2(struct perf_evsel *e1,
(e1->attr.config == e2->attr.config);
}
-#define perf_evsel__cmp(a, b) \
- ((a) && \
- (b) && \
- (a)->attr.type == (b)->attr.type && \
- (a)->attr.config == (b)->attr.config)
-
int __perf_evsel__read_on_cpu(struct perf_evsel *evsel,
int cpu, int thread, bool scale);
@@ -279,11 +265,6 @@ static inline struct perf_evsel *perf_evsel__next(struct perf_evsel *evsel)
return list_entry(evsel->node.next, struct perf_evsel, node);
}
-static inline struct perf_evsel *perf_evsel__prev(struct perf_evsel *evsel)
-{
- return list_entry(evsel->node.prev, struct perf_evsel, node);
-}
-
/**
* perf_evsel__is_group_leader - Return whether given evsel is a leader event
*
@@ -323,7 +304,8 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
char *msg, size_t msgsize);
-int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target,
+int perf_evsel__open_strerror(struct perf_evsel *evsel,
+ struct perf_target *target,
int err, char *msg, size_t size);
static inline int perf_evsel__group_idx(struct perf_evsel *evsel)
diff --git a/tools/perf/util/fs.c b/tools/perf/util/fs.c
deleted file mode 100644
index f5be1f2..0000000
--- a/tools/perf/util/fs.c
+++ /dev/null
@@ -1,119 +0,0 @@
-
-/* TODO merge/factor into tools/lib/lk/debugfs.c */
-
-#include "util.h"
-#include "util/fs.h"
-
-static const char * const sysfs__fs_known_mountpoints[] = {
- "/sys",
- 0,
-};
-
-static const char * const procfs__known_mountpoints[] = {
- "/proc",
- 0,
-};
-
-struct fs {
- const char *name;
- const char * const *mounts;
- char path[PATH_MAX + 1];
- bool found;
- long magic;
-};
-
-enum {
- FS__SYSFS = 0,
- FS__PROCFS = 1,
-};
-
-static struct fs fs__entries[] = {
- [FS__SYSFS] = {
- .name = "sysfs",
- .mounts = sysfs__fs_known_mountpoints,
- .magic = SYSFS_MAGIC,
- },
- [FS__PROCFS] = {
- .name = "proc",
- .mounts = procfs__known_mountpoints,
- .magic = PROC_SUPER_MAGIC,
- },
-};
-
-static bool fs__read_mounts(struct fs *fs)
-{
- bool found = false;
- char type[100];
- FILE *fp;
-
- fp = fopen("/proc/mounts", "r");
- if (fp == NULL)
- return NULL;
-
- while (!found &&
- fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n",
- fs->path, type) == 2) {
-
- if (strcmp(type, fs->name) == 0)
- found = true;
- }
-
- fclose(fp);
- return fs->found = found;
-}
-
-static int fs__valid_mount(const char *fs, long magic)
-{
- struct statfs st_fs;
-
- if (statfs(fs, &st_fs) < 0)
- return -ENOENT;
- else if (st_fs.f_type != magic)
- return -ENOENT;
-
- return 0;
-}
-
-static bool fs__check_mounts(struct fs *fs)
-{
- const char * const *ptr;
-
- ptr = fs->mounts;
- while (*ptr) {
- if (fs__valid_mount(*ptr, fs->magic) == 0) {
- fs->found = true;
- strcpy(fs->path, *ptr);
- return true;
- }
- ptr++;
- }
-
- return false;
-}
-
-static const char *fs__get_mountpoint(struct fs *fs)
-{
- if (fs__check_mounts(fs))
- return fs->path;
-
- return fs__read_mounts(fs) ? fs->path : NULL;
-}
-
-static const char *fs__mountpoint(int idx)
-{
- struct fs *fs = &fs__entries[idx];
-
- if (fs->found)
- return (const char *)fs->path;
-
- return fs__get_mountpoint(fs);
-}
-
-#define FS__MOUNTPOINT(name, idx) \
-const char *name##__mountpoint(void) \
-{ \
- return fs__mountpoint(idx); \
-}
-
-FS__MOUNTPOINT(sysfs, FS__SYSFS);
-FS__MOUNTPOINT(procfs, FS__PROCFS);
diff --git a/tools/perf/util/fs.h b/tools/perf/util/fs.h
deleted file mode 100644
index 5e09ce1..0000000
--- a/tools/perf/util/fs.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __PERF_FS
-#define __PERF_FS
-
-const char *sysfs__mountpoint(void);
-const char *procfs__mountpoint(void);
-
-#endif /* __PERF_FS */
diff --git a/tools/perf/util/generate-cmdlist.sh b/tools/perf/util/generate-cmdlist.sh
index 36a885d..3ac3803 100755
--- a/tools/perf/util/generate-cmdlist.sh
+++ b/tools/perf/util/generate-cmdlist.sh
@@ -22,7 +22,7 @@ do
}' "Documentation/perf-$cmd.txt"
done
-echo "#ifdef HAVE_LIBELF_SUPPORT"
+echo "#ifdef LIBELF_SUPPORT"
sed -n -e 's/^perf-\([^ ]*\)[ ].* full.*/\1/p' command-list.txt |
sort |
while read cmd
@@ -35,5 +35,5 @@ do
p
}' "Documentation/perf-$cmd.txt"
done
-echo "#endif /* HAVE_LIBELF_SUPPORT */"
+echo "#endif /* LIBELF_SUPPORT */"
echo "};"
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 1cd0357..c3e5a3b 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -22,7 +22,6 @@
#include "vdso.h"
#include "strbuf.h"
#include "build-id.h"
-#include "data.h"
static bool no_buildid_cache = false;
@@ -2078,10 +2077,8 @@ static int process_group_desc(struct perf_file_section *section __maybe_unused,
if (evsel->idx == (int) desc[i].leader_idx) {
evsel->leader = evsel;
/* {anon_group} is a dummy name */
- if (strcmp(desc[i].name, "{anon_group}")) {
+ if (strcmp(desc[i].name, "{anon_group}"))
evsel->group_name = desc[i].name;
- desc[i].name = NULL;
- }
evsel->nr_members = desc[i].nr_members;
if (i >= nr_groups || nr > 0) {
@@ -2107,7 +2104,7 @@ static int process_group_desc(struct perf_file_section *section __maybe_unused,
ret = 0;
out_free:
- for (i = 0; i < nr_groups; i++)
+ while ((int) --i >= 0)
free(desc[i].name);
free(desc);
@@ -2192,7 +2189,7 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)
{
struct header_print_data hd;
struct perf_header *header = &session->header;
- int fd = perf_data_file__fd(session->file);
+ int fd = session->fd;
hd.fp = fp;
hd.full = full;
@@ -2653,8 +2650,7 @@ static int perf_header__read_pipe(struct perf_session *session)
struct perf_header *header = &session->header;
struct perf_pipe_file_header f_header;
- if (perf_file_header__read_pipe(&f_header, header,
- perf_data_file__fd(session->file),
+ if (perf_file_header__read_pipe(&f_header, header, session->fd,
session->repipe) < 0) {
pr_debug("incompatible file format\n");
return -EINVAL;
@@ -2755,19 +2751,18 @@ static int perf_evlist__prepare_tracepoint_events(struct perf_evlist *evlist,
int perf_session__read_header(struct perf_session *session)
{
- struct perf_data_file *file = session->file;
struct perf_header *header = &session->header;
struct perf_file_header f_header;
struct perf_file_attr f_attr;
u64 f_id;
int nr_attrs, nr_ids, i, j;
- int fd = perf_data_file__fd(file);
+ int fd = session->fd;
session->evlist = perf_evlist__new();
if (session->evlist == NULL)
return -ENOMEM;
- if (perf_data_file__is_pipe(file))
+ if (session->fd_pipe)
return perf_header__read_pipe(session);
if (perf_file_header__read(&f_header, header, fd) < 0)
@@ -2782,7 +2777,7 @@ int perf_session__read_header(struct perf_session *session)
if (f_header.data.size == 0) {
pr_warning("WARNING: The %s file's data size field is 0 which is unexpected.\n"
"Was the 'perf record' command properly terminated?\n",
- file->path);
+ session->filename);
}
nr_attrs = f_header.attrs.size / f_header.attr_size;
@@ -2799,7 +2794,7 @@ int perf_session__read_header(struct perf_session *session)
perf_event__attr_swap(&f_attr.attr);
tmp = lseek(fd, 0, SEEK_CUR);
- evsel = perf_evsel__new(&f_attr.attr);
+ evsel = perf_evsel__new(&f_attr.attr, i);
if (evsel == NULL)
goto out_delete_evlist;
@@ -2918,7 +2913,7 @@ int perf_event__process_attr(struct perf_tool *tool __maybe_unused,
return -ENOMEM;
}
- evsel = perf_evsel__new(&event->attr.attr);
+ evsel = perf_evsel__new(&event->attr.attr, evlist->nr_entries);
if (evsel == NULL)
return -ENOMEM;
@@ -2995,19 +2990,18 @@ int perf_event__process_tracing_data(struct perf_tool *tool __maybe_unused,
struct perf_session *session)
{
ssize_t size_read, padding, size = event->tracing_data.size;
- int fd = perf_data_file__fd(session->file);
- off_t offset = lseek(fd, 0, SEEK_CUR);
+ off_t offset = lseek(session->fd, 0, SEEK_CUR);
char buf[BUFSIZ];
/* setup for reading amidst mmap */
- lseek(fd, offset + sizeof(struct tracing_data_event),
+ lseek(session->fd, offset + sizeof(struct tracing_data_event),
SEEK_SET);
- size_read = trace_report(fd, &session->pevent,
+ size_read = trace_report(session->fd, &session->pevent,
session->repipe);
padding = PERF_ALIGN(size_read, sizeof(u64)) - size_read;
- if (readn(fd, buf, padding) < 0) {
+ if (readn(session->fd, buf, padding) < 0) {
pr_err("%s: reading input file", __func__);
return -1;
}
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 822903e..9ff6cf3 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -160,10 +160,6 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
hists__new_col_len(hists, HISTC_MEM_LVL, 21 + 3);
hists__new_col_len(hists, HISTC_LOCAL_WEIGHT, 12);
hists__new_col_len(hists, HISTC_GLOBAL_WEIGHT, 12);
-
- if (h->transaction)
- hists__new_col_len(hists, HISTC_TRANSACTION,
- hist_entry__transaction_len());
}
void hists__output_recalc_col_len(struct hists *hists, int max_rows)
@@ -350,7 +346,7 @@ static struct hist_entry *add_hist_entry(struct hists *hists,
struct rb_node **p;
struct rb_node *parent = NULL;
struct hist_entry *he;
- int64_t cmp;
+ int cmp;
p = &hists->entries_in->rb_node;
@@ -399,7 +395,6 @@ static struct hist_entry *add_hist_entry(struct hists *hists,
if (!he)
return NULL;
- hists->nr_entries++;
rb_link_node(&he->rb_node_in, parent, p);
rb_insert_color(&he->rb_node_in, hists->entries_in);
out:
@@ -407,37 +402,94 @@ out:
return he;
}
-struct hist_entry *__hists__add_entry(struct hists *hists,
- struct addr_location *al,
- struct symbol *sym_parent,
- struct branch_info *bi,
- struct mem_info *mi,
- u64 period, u64 weight, u64 transaction)
+struct hist_entry *__hists__add_mem_entry(struct hists *self,
+ struct addr_location *al,
+ struct symbol *sym_parent,
+ struct mem_info *mi,
+ u64 period,
+ u64 weight)
{
struct hist_entry entry = {
.thread = al->thread,
- .comm = thread__comm(al->thread),
.ms = {
.map = al->map,
.sym = al->sym,
},
+ .stat = {
+ .period = period,
+ .weight = weight,
+ .nr_events = 1,
+ },
.cpu = al->cpu,
.ip = al->addr,
.level = al->level,
+ .parent = sym_parent,
+ .filtered = symbol__parent_filter(sym_parent),
+ .hists = self,
+ .mem_info = mi,
+ .branch_info = NULL,
+ };
+ return add_hist_entry(self, &entry, al, period, weight);
+}
+
+struct hist_entry *__hists__add_branch_entry(struct hists *self,
+ struct addr_location *al,
+ struct symbol *sym_parent,
+ struct branch_info *bi,
+ u64 period,
+ u64 weight)
+{
+ struct hist_entry entry = {
+ .thread = al->thread,
+ .ms = {
+ .map = bi->to.map,
+ .sym = bi->to.sym,
+ },
+ .cpu = al->cpu,
+ .ip = bi->to.addr,
+ .level = al->level,
.stat = {
- .nr_events = 1,
.period = period,
+ .nr_events = 1,
.weight = weight,
},
.parent = sym_parent,
.filtered = symbol__parent_filter(sym_parent),
- .hists = hists,
.branch_info = bi,
- .mem_info = mi,
- .transaction = transaction,
+ .hists = self,
+ .mem_info = NULL,
};
- return add_hist_entry(hists, &entry, al, period, weight);
+ return add_hist_entry(self, &entry, al, period, weight);
+}
+
+struct hist_entry *__hists__add_entry(struct hists *self,
+ struct addr_location *al,
+ struct symbol *sym_parent, u64 period,
+ u64 weight)
+{
+ struct hist_entry entry = {
+ .thread = al->thread,
+ .ms = {
+ .map = al->map,
+ .sym = al->sym,
+ },
+ .cpu = al->cpu,
+ .ip = al->addr,
+ .level = al->level,
+ .stat = {
+ .period = period,
+ .nr_events = 1,
+ .weight = weight,
+ },
+ .parent = sym_parent,
+ .filtered = symbol__parent_filter(sym_parent),
+ .hists = self,
+ .branch_info = NULL,
+ .mem_info = NULL,
+ };
+
+ return add_hist_entry(self, &entry, al, period, weight);
}
int64_t
@@ -478,7 +530,6 @@ void hist_entry__free(struct hist_entry *he)
{
free(he->branch_info);
free(he->mem_info);
- free_srcline(he->srcline);
free(he);
}
@@ -547,7 +598,7 @@ static void hists__apply_filters(struct hists *hists, struct hist_entry *he)
hists__filter_entry_by_symbol(hists, he);
}
-void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
+void hists__collapse_resort(struct hists *hists)
{
struct rb_root *root;
struct rb_node *next;
@@ -574,8 +625,6 @@ void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
*/
hists__apply_filters(hists, n);
}
- if (prog)
- ui_progress__update(prog, 1);
}
}
@@ -835,7 +884,7 @@ static struct hist_entry *hists__add_dummy_entry(struct hists *hists,
struct rb_node **p;
struct rb_node *parent = NULL;
struct hist_entry *he;
- int64_t cmp;
+ int cmp;
if (sort__need_collapse)
root = &hists->entries_collapsed;
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index b621347a..ce8dc61 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -6,7 +6,6 @@
#include "callchain.h"
#include "header.h"
#include "color.h"
-#include "ui/progress.h"
extern struct callchain_param callchain_param;
@@ -47,8 +46,6 @@ enum hist_column {
HISTC_CPU,
HISTC_SRCLINE,
HISTC_MISPREDICT,
- HISTC_IN_TX,
- HISTC_ABORT,
HISTC_SYMBOL_FROM,
HISTC_SYMBOL_TO,
HISTC_DSO_FROM,
@@ -61,7 +58,6 @@ enum hist_column {
HISTC_MEM_TLB,
HISTC_MEM_LVL,
HISTC_MEM_SNOOP,
- HISTC_TRANSACTION,
HISTC_NR_COLS, /* Last entry */
};
@@ -84,43 +80,54 @@ struct hists {
u16 col_len[HISTC_NR_COLS];
};
-struct hist_entry *__hists__add_entry(struct hists *hists,
+struct hist_entry *__hists__add_entry(struct hists *self,
struct addr_location *al,
- struct symbol *parent,
- struct branch_info *bi,
- struct mem_info *mi, u64 period,
- u64 weight, u64 transaction);
+ struct symbol *parent, u64 period,
+ u64 weight);
int64_t hist_entry__cmp(struct hist_entry *left, struct hist_entry *right);
int64_t hist_entry__collapse(struct hist_entry *left, struct hist_entry *right);
-int hist_entry__transaction_len(void);
-int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size,
+int hist_entry__sort_snprintf(struct hist_entry *self, char *bf, size_t size,
struct hists *hists);
void hist_entry__free(struct hist_entry *);
-void hists__output_resort(struct hists *hists);
-void hists__collapse_resort(struct hists *hists, struct ui_progress *prog);
+struct hist_entry *__hists__add_branch_entry(struct hists *self,
+ struct addr_location *al,
+ struct symbol *sym_parent,
+ struct branch_info *bi,
+ u64 period,
+ u64 weight);
+
+struct hist_entry *__hists__add_mem_entry(struct hists *self,
+ struct addr_location *al,
+ struct symbol *sym_parent,
+ struct mem_info *mi,
+ u64 period,
+ u64 weight);
+
+void hists__output_resort(struct hists *self);
+void hists__collapse_resort(struct hists *self);
void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel);
void hists__output_recalc_col_len(struct hists *hists, int max_rows);
void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h);
-void hists__inc_nr_events(struct hists *hists, u32 type);
+void hists__inc_nr_events(struct hists *self, u32 type);
void events_stats__inc(struct events_stats *stats, u32 type);
size_t events_stats__fprintf(struct events_stats *stats, FILE *fp);
-size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
+size_t hists__fprintf(struct hists *self, bool show_header, int max_rows,
int max_cols, float min_pcnt, FILE *fp);
-int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 addr);
-int hist_entry__annotate(struct hist_entry *he, size_t privsize);
+int hist_entry__inc_addr_samples(struct hist_entry *self, int evidx, u64 addr);
+int hist_entry__annotate(struct hist_entry *self, size_t privsize);
void hists__filter_by_dso(struct hists *hists);
void hists__filter_by_thread(struct hists *hists);
void hists__filter_by_symbol(struct hists *hists);
-u16 hists__col_len(struct hists *hists, enum hist_column col);
-void hists__set_col_len(struct hists *hists, enum hist_column col, u16 len);
-bool hists__new_col_len(struct hists *hists, enum hist_column col, u16 len);
+u16 hists__col_len(struct hists *self, enum hist_column col);
+void hists__set_col_len(struct hists *self, enum hist_column col, u16 len);
+bool hists__new_col_len(struct hists *self, enum hist_column col, u16 len);
void hists__reset_col_len(struct hists *hists);
void hists__calc_col_len(struct hists *hists, struct hist_entry *he);
@@ -189,7 +196,7 @@ struct hist_browser_timer {
int refresh;
};
-#ifdef HAVE_SLANG_SUPPORT
+#ifdef SLANG_SUPPORT
#include "../ui/keysyms.h"
int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
struct hist_browser_timer *hbt);
@@ -210,9 +217,12 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused,
return 0;
}
-static inline int hist_entry__tui_annotate(struct hist_entry *he __maybe_unused,
- struct perf_evsel *evsel __maybe_unused,
- struct hist_browser_timer *hbt __maybe_unused)
+static inline int hist_entry__tui_annotate(struct hist_entry *self
+ __maybe_unused,
+ struct perf_evsel *evsel
+ __maybe_unused,
+ struct hist_browser_timer *hbt
+ __maybe_unused)
{
return 0;
}
@@ -227,5 +237,20 @@ static inline int script_browse(const char *script_opt __maybe_unused)
#define K_SWITCH_INPUT_DATA -3000
#endif
-unsigned int hists__sort_list_width(struct hists *hists);
+#ifdef GTK2_SUPPORT
+int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, const char *help,
+ struct hist_browser_timer *hbt __maybe_unused,
+ float min_pcnt);
+#else
+static inline
+int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist __maybe_unused,
+ const char *help __maybe_unused,
+ struct hist_browser_timer *hbt __maybe_unused,
+ float min_pcnt __maybe_unused)
+{
+ return 0;
+}
+#endif
+
+unsigned int hists__sort_list_width(struct hists *self);
#endif /* __PERF_HIST_H */
diff --git a/tools/perf/util/include/dwarf-regs.h b/tools/perf/util/include/dwarf-regs.h
index 8f14965..cf6727e 100644
--- a/tools/perf/util/include/dwarf-regs.h
+++ b/tools/perf/util/include/dwarf-regs.h
@@ -1,7 +1,7 @@
#ifndef _PERF_DWARF_REGS_H_
#define _PERF_DWARF_REGS_H_
-#ifdef HAVE_DWARF_SUPPORT
+#ifdef DWARF_SUPPORT
const char *get_arch_regstr(unsigned int n);
#endif
diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
index b003ad7..96b919d 100644
--- a/tools/perf/util/include/linux/compiler.h
+++ b/tools/perf/util/include/linux/compiler.h
@@ -2,29 +2,20 @@
#define _PERF_LINUX_COMPILER_H_
#ifndef __always_inline
-# define __always_inline inline __attribute__((always_inline))
+#define __always_inline inline
#endif
-
#define __user
-
#ifndef __attribute_const__
-# define __attribute_const__
+#define __attribute_const__
#endif
#ifndef __maybe_unused
-# define __maybe_unused __attribute__((unused))
-#endif
-
-#ifndef __packed
-# define __packed __attribute__((__packed__))
+#define __maybe_unused __attribute__((unused))
#endif
+#define __packed __attribute__((__packed__))
#ifndef __force
-# define __force
-#endif
-
-#ifndef __weak
-# define __weak __attribute__((weak))
+#define __force
#endif
#endif
diff --git a/tools/perf/util/include/linux/magic.h b/tools/perf/util/include/linux/magic.h
index 07d63cf..58b64ed 100644
--- a/tools/perf/util/include/linux/magic.h
+++ b/tools/perf/util/include/linux/magic.h
@@ -9,8 +9,4 @@
#define SYSFS_MAGIC 0x62656572
#endif
-#ifndef PROC_SUPER_MAGIC
-#define PROC_SUPER_MAGIC 0x9fa0
-#endif
-
#endif
diff --git a/tools/perf/util/intlist.c b/tools/perf/util/intlist.c
index 89715b6..11a8d86 100644
--- a/tools/perf/util/intlist.c
+++ b/tools/perf/util/intlist.c
@@ -20,7 +20,6 @@ static struct rb_node *intlist__node_new(struct rblist *rblist __maybe_unused,
if (node != NULL) {
node->i = i;
- node->priv = NULL;
rc = &node->rb_node;
}
@@ -58,36 +57,22 @@ void intlist__remove(struct intlist *ilist, struct int_node *node)
rblist__remove_node(&ilist->rblist, &node->rb_node);
}
-static struct int_node *__intlist__findnew(struct intlist *ilist,
- int i, bool create)
+struct int_node *intlist__find(struct intlist *ilist, int i)
{
- struct int_node *node = NULL;
+ struct int_node *node;
struct rb_node *rb_node;
if (ilist == NULL)
return NULL;
- if (create)
- rb_node = rblist__findnew(&ilist->rblist, (void *)((long)i));
- else
- rb_node = rblist__find(&ilist->rblist, (void *)((long)i));
-
+ node = NULL;
+ rb_node = rblist__find(&ilist->rblist, (void *)((long)i));
if (rb_node)
node = container_of(rb_node, struct int_node, rb_node);
return node;
}
-struct int_node *intlist__find(struct intlist *ilist, int i)
-{
- return __intlist__findnew(ilist, i, false);
-}
-
-struct int_node *intlist__findnew(struct intlist *ilist, int i)
-{
- return __intlist__findnew(ilist, i, true);
-}
-
static int intlist__parse_list(struct intlist *ilist, const char *s)
{
char *sep;
diff --git a/tools/perf/util/intlist.h b/tools/perf/util/intlist.h
index aa6877d..62351da 100644
--- a/tools/perf/util/intlist.h
+++ b/tools/perf/util/intlist.h
@@ -9,7 +9,6 @@
struct int_node {
struct rb_node rb_node;
int i;
- void *priv;
};
struct intlist {
@@ -24,7 +23,6 @@ int intlist__add(struct intlist *ilist, int i);
struct int_node *intlist__entry(const struct intlist *ilist, unsigned int idx);
struct int_node *intlist__find(struct intlist *ilist, int i);
-struct int_node *intlist__findnew(struct intlist *ilist, int i);
static inline bool intlist__has_entry(struct intlist *ilist, int i)
{
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 84cdb07..6188d28 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -40,29 +40,12 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
return -ENOMEM;
snprintf(comm, sizeof(comm), "[guest/%d]", pid);
- thread__set_comm(thread, comm, 0);
+ thread__set_comm(thread, comm);
}
return 0;
}
-struct machine *machine__new_host(void)
-{
- struct machine *machine = malloc(sizeof(*machine));
-
- if (machine != NULL) {
- machine__init(machine, "", HOST_KERNEL_ID);
-
- if (machine__create_kernel_maps(machine) < 0)
- goto out_delete;
- }
-
- return machine;
-out_delete:
- free(machine);
- return NULL;
-}
-
static void dsos__delete(struct list_head *dsos)
{
struct dso *pos, *n;
@@ -331,8 +314,7 @@ struct thread *machine__find_thread(struct machine *machine, pid_t tid)
return __machine__findnew_thread(machine, 0, tid, false);
}
-int machine__process_comm_event(struct machine *machine, union perf_event *event,
- struct perf_sample *sample)
+int machine__process_comm_event(struct machine *machine, union perf_event *event)
{
struct thread *thread = machine__findnew_thread(machine,
event->comm.pid,
@@ -341,7 +323,7 @@ int machine__process_comm_event(struct machine *machine, union perf_event *event
if (dump_trace)
perf_event__fprintf_comm(event, stdout);
- if (thread == NULL || thread__set_comm(thread, event->comm.comm, sample->time)) {
+ if (thread == NULL || thread__set_comm(thread, event->comm.comm)) {
dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
return -1;
}
@@ -350,7 +332,7 @@ int machine__process_comm_event(struct machine *machine, union perf_event *event
}
int machine__process_lost_event(struct machine *machine __maybe_unused,
- union perf_event *event, struct perf_sample *sample __maybe_unused)
+ union perf_event *event)
{
dump_printf(": id:%" PRIu64 ": lost:%" PRIu64 "\n",
event->lost.id, event->lost.lost);
@@ -794,44 +776,75 @@ static int machine__set_modules_path(struct machine *machine)
return map_groups__set_modules_path_dir(&machine->kmaps, modules_path);
}
-static int machine__create_module(void *arg, const char *name, u64 start)
-{
- struct machine *machine = arg;
- struct map *map;
-
- map = machine__new_module(machine, start, name);
- if (map == NULL)
- return -1;
-
- dso__kernel_module_get_build_id(map->dso, machine->root_dir);
-
- return 0;
-}
-
static int machine__create_modules(struct machine *machine)
{
+ char *line = NULL;
+ size_t n;
+ FILE *file;
+ struct map *map;
const char *modules;
char path[PATH_MAX];
- if (machine__is_default_guest(machine)) {
+ if (machine__is_default_guest(machine))
modules = symbol_conf.default_guest_modules;
- } else {
- snprintf(path, PATH_MAX, "%s/proc/modules", machine->root_dir);
+ else {
+ sprintf(path, "%s/proc/modules", machine->root_dir);
modules = path;
}
if (symbol__restricted_filename(modules, "/proc/modules"))
return -1;
- if (modules__parse(modules, machine, machine__create_module))
+ file = fopen(modules, "r");
+ if (file == NULL)
return -1;
- if (!machine__set_modules_path(machine))
- return 0;
+ while (!feof(file)) {
+ char name[PATH_MAX];
+ u64 start;
+ char *sep;
+ int line_len;
+
+ line_len = getline(&line, &n, file);
+ if (line_len < 0)
+ break;
+
+ if (!line)
+ goto out_failure;
+
+ line[--line_len] = '\0'; /* \n */
+
+ sep = strrchr(line, 'x');
+ if (sep == NULL)
+ continue;
+
+ hex2u64(sep + 1, &start);
+
+ sep = strchr(line, ' ');
+ if (sep == NULL)
+ continue;
+
+ *sep = '\0';
+
+ snprintf(name, sizeof(name), "[%s]", line);
+ map = machine__new_module(machine, start, name);
+ if (map == NULL)
+ goto out_delete_line;
+ dso__kernel_module_get_build_id(map->dso, machine->root_dir);
+ }
- pr_debug("Problems setting modules path maps, continuing anyway...\n");
+ free(line);
+ fclose(file);
+ if (machine__set_modules_path(machine) < 0) {
+ pr_debug("Problems setting modules path maps, continuing anyway...\n");
+ }
return 0;
+
+out_delete_line:
+ free(line);
+out_failure:
+ return -1;
}
int machine__create_kernel_maps(struct machine *machine)
@@ -985,8 +998,7 @@ out_problem:
}
int machine__process_mmap2_event(struct machine *machine,
- union perf_event *event,
- struct perf_sample *sample __maybe_unused)
+ union perf_event *event)
{
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
struct thread *thread;
@@ -1033,8 +1045,7 @@ out_problem:
return 0;
}
-int machine__process_mmap_event(struct machine *machine, union perf_event *event,
- struct perf_sample *sample __maybe_unused)
+int machine__process_mmap_event(struct machine *machine, union perf_event *event)
{
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
struct thread *thread;
@@ -1091,8 +1102,7 @@ static void machine__remove_thread(struct machine *machine, struct thread *th)
list_add_tail(&th->node, &machine->dead_threads);
}
-int machine__process_fork_event(struct machine *machine, union perf_event *event,
- struct perf_sample *sample)
+int machine__process_fork_event(struct machine *machine, union perf_event *event)
{
struct thread *thread = machine__find_thread(machine, event->fork.tid);
struct thread *parent = machine__findnew_thread(machine,
@@ -1109,7 +1119,7 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event
perf_event__fprintf_task(event, stdout);
if (thread == NULL || parent == NULL ||
- thread__fork(thread, parent, sample->time) < 0) {
+ thread__fork(thread, parent) < 0) {
dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n");
return -1;
}
@@ -1117,8 +1127,8 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event
return 0;
}
-int machine__process_exit_event(struct machine *machine, union perf_event *event,
- struct perf_sample *sample __maybe_unused)
+int machine__process_exit_event(struct machine *machine __maybe_unused,
+ union perf_event *event)
{
struct thread *thread = machine__find_thread(machine, event->fork.tid);
@@ -1131,24 +1141,23 @@ int machine__process_exit_event(struct machine *machine, union perf_event *event
return 0;
}
-int machine__process_event(struct machine *machine, union perf_event *event,
- struct perf_sample *sample)
+int machine__process_event(struct machine *machine, union perf_event *event)
{
int ret;
switch (event->header.type) {
case PERF_RECORD_COMM:
- ret = machine__process_comm_event(machine, event, sample); break;
+ ret = machine__process_comm_event(machine, event); break;
case PERF_RECORD_MMAP:
- ret = machine__process_mmap_event(machine, event, sample); break;
+ ret = machine__process_mmap_event(machine, event); break;
case PERF_RECORD_MMAP2:
- ret = machine__process_mmap2_event(machine, event, sample); break;
+ ret = machine__process_mmap2_event(machine, event); break;
case PERF_RECORD_FORK:
- ret = machine__process_fork_event(machine, event, sample); break;
+ ret = machine__process_fork_event(machine, event); break;
case PERF_RECORD_EXIT:
- ret = machine__process_exit_event(machine, event, sample); break;
+ ret = machine__process_exit_event(machine, event); break;
case PERF_RECORD_LOST:
- ret = machine__process_lost_event(machine, event, sample); break;
+ ret = machine__process_lost_event(machine, event); break;
default:
ret = -1;
break;
@@ -1258,12 +1267,10 @@ static int machine__resolve_callchain_sample(struct machine *machine,
struct thread *thread,
struct ip_callchain *chain,
struct symbol **parent,
- struct addr_location *root_al,
- int max_stack)
+ struct addr_location *root_al)
{
u8 cpumode = PERF_RECORD_MISC_USER;
- int chain_nr = min(max_stack, (int)chain->nr);
- int i;
+ unsigned int i;
int err;
callchain_cursor_reset(&callchain_cursor);
@@ -1273,7 +1280,7 @@ static int machine__resolve_callchain_sample(struct machine *machine,
return 0;
}
- for (i = 0; i < chain_nr; i++) {
+ for (i = 0; i < chain->nr; i++) {
u64 ip;
struct addr_location al;
@@ -1345,14 +1352,12 @@ int machine__resolve_callchain(struct machine *machine,
struct thread *thread,
struct perf_sample *sample,
struct symbol **parent,
- struct addr_location *root_al,
- int max_stack)
+ struct addr_location *root_al)
{
int ret;
ret = machine__resolve_callchain_sample(machine, thread,
- sample->callchain, parent,
- root_al, max_stack);
+ sample->callchain, parent, root_al);
if (ret)
return ret;
@@ -1368,41 +1373,6 @@ int machine__resolve_callchain(struct machine *machine,
return unwind__get_entries(unwind_entry, &callchain_cursor, machine,
thread, evsel->attr.sample_regs_user,
- sample, max_stack);
+ sample);
}
-
-int machine__for_each_thread(struct machine *machine,
- int (*fn)(struct thread *thread, void *p),
- void *priv)
-{
- struct rb_node *nd;
- struct thread *thread;
- int rc = 0;
-
- for (nd = rb_first(&machine->threads); nd; nd = rb_next(nd)) {
- thread = rb_entry(nd, struct thread, rb_node);
- rc = fn(thread, priv);
- if (rc != 0)
- return rc;
- }
-
- list_for_each_entry(thread, &machine->dead_threads, node) {
- rc = fn(thread, priv);
- if (rc != 0)
- return rc;
- }
- return rc;
-}
-
-int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
- struct target *target, struct thread_map *threads,
- perf_event__handler_t process, bool data_mmap)
-{
- if (target__has_task(target))
- return perf_event__synthesize_thread_map(tool, threads, process, machine, data_mmap);
- else if (target__has_cpu(target))
- return perf_event__synthesize_threads(tool, process, machine, data_mmap);
- /* command specified */
- return 0;
-}
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 4771330..58a6be1 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -4,7 +4,6 @@
#include <sys/types.h>
#include <linux/rbtree.h>
#include "map.h"
-#include "event.h"
struct addr_location;
struct branch_stack;
@@ -41,20 +40,13 @@ struct map *machine__kernel_map(struct machine *machine, enum map_type type)
struct thread *machine__find_thread(struct machine *machine, pid_t tid);
-int machine__process_comm_event(struct machine *machine, union perf_event *event,
- struct perf_sample *sample);
-int machine__process_exit_event(struct machine *machine, union perf_event *event,
- struct perf_sample *sample);
-int machine__process_fork_event(struct machine *machine, union perf_event *event,
- struct perf_sample *sample);
-int machine__process_lost_event(struct machine *machine, union perf_event *event,
- struct perf_sample *sample);
-int machine__process_mmap_event(struct machine *machine, union perf_event *event,
- struct perf_sample *sample);
-int machine__process_mmap2_event(struct machine *machine, union perf_event *event,
- struct perf_sample *sample);
-int machine__process_event(struct machine *machine, union perf_event *event,
- struct perf_sample *sample);
+int machine__process_comm_event(struct machine *machine, union perf_event *event);
+int machine__process_exit_event(struct machine *machine, union perf_event *event);
+int machine__process_fork_event(struct machine *machine, union perf_event *event);
+int machine__process_lost_event(struct machine *machine, union perf_event *event);
+int machine__process_mmap_event(struct machine *machine, union perf_event *event);
+int machine__process_mmap2_event(struct machine *machine, union perf_event *event);
+int machine__process_event(struct machine *machine, union perf_event *event);
typedef void (*machine__process_t)(struct machine *machine, void *data);
@@ -82,7 +74,6 @@ char *machine__mmap_name(struct machine *machine, char *bf, size_t size);
void machines__set_symbol_filter(struct machines *machines,
symbol_filter_t symbol_filter);
-struct machine *machine__new_host(void);
int machine__init(struct machine *machine, const char *root_dir, pid_t pid);
void machine__exit(struct machine *machine);
void machine__delete_dead_threads(struct machine *machine);
@@ -100,8 +91,7 @@ int machine__resolve_callchain(struct machine *machine,
struct thread *thread,
struct perf_sample *sample,
struct symbol **parent,
- struct addr_location *root_al,
- int max_stack);
+ struct addr_location *root_al);
/*
* Default guest kernel is defined by parameter --guestkallsyms
@@ -175,19 +165,4 @@ void machines__destroy_kernel_maps(struct machines *machines);
size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp);
-int machine__for_each_thread(struct machine *machine,
- int (*fn)(struct thread *thread, void *p),
- void *priv);
-
-int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
- struct target *target, struct thread_map *threads,
- perf_event__handler_t process, bool data_mmap);
-static inline
-int machine__synthesize_threads(struct machine *machine, struct target *target,
- struct thread_map *threads, bool data_mmap)
-{
- return __machine__synthesize_threads(machine, NULL, target, threads,
- perf_event__process, data_mmap);
-}
-
#endif /* __PERF_MACHINE_H */
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index ef5bc91..4f6680d 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -172,7 +172,7 @@ int map__load(struct map *map, symbol_filter_t filter)
pr_warning(", continuing without symbols\n");
return -1;
} else if (nr == 0) {
-#ifdef HAVE_LIBELF_SUPPORT
+#ifdef LIBELF_SUPPORT
const size_t len = strlen(name);
const size_t real_len = len - sizeof(DSO__DELETED);
@@ -252,16 +252,10 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp)
return fprintf(fp, "%s", dsoname);
}
-/**
- * map__rip_2objdump - convert symbol start address to objdump address.
- * @map: memory map
- * @rip: symbol start address
- *
+/*
* objdump wants/reports absolute IPs for ET_EXEC, and RIPs for ET_DYN.
* map->dso->adjust_symbols==1 for ET_EXEC-like cases except ET_REL which is
* relative to section start.
- *
- * Return: Address suitable for passing to "objdump --start-address="
*/
u64 map__rip_2objdump(struct map *map, u64 rip)
{
@@ -274,29 +268,6 @@ u64 map__rip_2objdump(struct map *map, u64 rip)
return map->unmap_ip(map, rip);
}
-/**
- * map__objdump_2mem - convert objdump address to a memory address.
- * @map: memory map
- * @ip: objdump address
- *
- * Closely related to map__rip_2objdump(), this function takes an address from
- * objdump and converts it to a memory address. Note this assumes that @map
- * contains the address. To be sure the result is valid, check it forwards
- * e.g. map__rip_2objdump(map->map_ip(map, map__objdump_2mem(map, ip))) == ip
- *
- * Return: Memory address.
- */
-u64 map__objdump_2mem(struct map *map, u64 ip)
-{
- if (!map->dso->adjust_symbols)
- return map->unmap_ip(map, ip);
-
- if (map->dso->rel)
- return map->unmap_ip(map, ip + map->pgoff);
-
- return ip;
-}
-
void map_groups__init(struct map_groups *mg)
{
int i;
@@ -400,23 +371,6 @@ struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg,
return NULL;
}
-int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter)
-{
- if (ams->addr < ams->map->start || ams->addr > ams->map->end) {
- if (ams->map->groups == NULL)
- return -1;
- ams->map = map_groups__find(ams->map->groups, ams->map->type,
- ams->addr);
- if (ams->map == NULL)
- return -1;
- }
-
- ams->al_addr = ams->map->map_ip(ams->map, ams->addr);
- ams->sym = map__find_symbol(ams->map, ams->al_addr, filter);
-
- return ams->sym ? 0 : -1;
-}
-
size_t __map_groups__fprintf_maps(struct map_groups *mg,
enum map_type type, int verbose, FILE *fp)
{
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index e4e259c..4886ca2 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -84,9 +84,6 @@ static inline u64 identity__map_ip(struct map *map __maybe_unused, u64 ip)
/* rip/ip <-> addr suitable for passing to `objdump --start-address=` */
u64 map__rip_2objdump(struct map *map, u64 rip);
-/* objdump address -> memory address */
-u64 map__objdump_2mem(struct map *map, u64 ip);
-
struct symbol;
typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);
@@ -170,10 +167,6 @@ struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg,
struct map **mapp,
symbol_filter_t filter);
-struct addr_map_symbol;
-
-int map_groups__find_ams(struct addr_map_symbol *ams, symbol_filter_t filter);
-
static inline
struct symbol *map_groups__find_function_by_name(struct map_groups *mg,
const char *name, struct map **mapp,
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 6de6f89..9812531 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -277,7 +277,7 @@ static int __add_event(struct list_head *list, int *idx,
event_attr_init(attr);
- evsel = perf_evsel__new_idx(attr, (*idx)++);
+ evsel = perf_evsel__new(attr, (*idx)++);
if (!evsel)
return -ENOMEM;
@@ -378,7 +378,7 @@ static int add_tracepoint(struct list_head *list, int *idx,
{
struct perf_evsel *evsel;
- evsel = perf_evsel__newtp_idx(sys_name, evt_name, (*idx)++);
+ evsel = perf_evsel__newtp(sys_name, evt_name, (*idx)++);
if (!evsel)
return -ENOMEM;
@@ -998,10 +998,8 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob,
char evt_path[MAXPATHLEN];
char dir_path[MAXPATHLEN];
- if (debugfs_valid_mountpoint(tracing_events_path)) {
- printf(" [ Tracepoints not available: %s ]\n", strerror(errno));
+ if (debugfs_valid_mountpoint(tracing_events_path))
return;
- }
sys_dir = opendir(tracing_events_path);
if (!sys_dir)
@@ -1097,7 +1095,7 @@ static bool is_event_supported(u8 type, unsigned config)
.threads = { 0 },
};
- evsel = perf_evsel__new(&attr);
+ evsel = perf_evsel__new(&attr, 0);
if (evsel) {
ret = perf_evsel__open(evsel, NULL, &tmap.map) >= 0;
perf_evsel__delete(evsel);
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 3432995..91346b7 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -126,37 +126,6 @@ modifier_bp [rwx]{1,3}
}
-<config>{
-config { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG); }
-config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); }
-config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); }
-name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); }
-period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
-branch_type { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }
-, { return ','; }
-"/" { BEGIN(INITIAL); return '/'; }
-{name_minus} { return str(yyscanner, PE_NAME); }
-}
-
-<mem>{
-{modifier_bp} { return str(yyscanner, PE_MODIFIER_BP); }
-: { return ':'; }
-{num_dec} { return value(yyscanner, 10); }
-{num_hex} { return value(yyscanner, 16); }
- /*
- * We need to separate 'mem:' scanner part, in order to get specific
- * modifier bits parsed out. Otherwise we would need to handle PE_NAME
- * and we'd need to parse it manually. During the escape from <mem>
- * state we need to put the escaping char back, so we dont miss it.
- */
-. { unput(*yytext); BEGIN(INITIAL); }
- /*
- * We destroy the scanner after reaching EOF,
- * but anyway just to be sure get back to INIT state.
- */
-<<EOF>> { BEGIN(INITIAL); }
-}
-
cpu-cycles|cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES); }
stalled-cycles-frontend|idle-cycles-frontend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); }
stalled-cycles-backend|idle-cycles-backend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); }
@@ -193,6 +162,18 @@ speculative-read|speculative-load |
refs|Reference|ops|access |
misses|miss { return str(yyscanner, PE_NAME_CACHE_OP_RESULT); }
+<config>{
+config { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG); }
+config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); }
+config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); }
+name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); }
+period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
+branch_type { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }
+, { return ','; }
+"/" { BEGIN(INITIAL); return '/'; }
+{name_minus} { return str(yyscanner, PE_NAME); }
+}
+
mem: { BEGIN(mem); return PE_PREFIX_MEM; }
r{num_raw_hex} { return raw(yyscanner); }
{num_dec} { return value(yyscanner, 10); }
@@ -208,7 +189,25 @@ r{num_raw_hex} { return raw(yyscanner); }
"}" { return '}'; }
= { return '='; }
\n { }
-. { }
+
+<mem>{
+{modifier_bp} { return str(yyscanner, PE_MODIFIER_BP); }
+: { return ':'; }
+{num_dec} { return value(yyscanner, 10); }
+{num_hex} { return value(yyscanner, 16); }
+ /*
+ * We need to separate 'mem:' scanner part, in order to get specific
+ * modifier bits parsed out. Otherwise we would need to handle PE_NAME
+ * and we'd need to parse it manually. During the escape from <mem>
+ * state we need to put the escaping char back, so we dont miss it.
+ */
+. { unput(*yytext); BEGIN(INITIAL); }
+ /*
+ * We destroy the scanner after reaching EOF,
+ * but anyway just to be sure get back to INIT state.
+ */
+<<EOF>> { BEGIN(INITIAL); }
+}
%%
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c
index 31f404a..2bc9e70 100644
--- a/tools/perf/util/parse-options.c
+++ b/tools/perf/util/parse-options.c
@@ -339,10 +339,10 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
if (arg[1] != '-') {
ctx->opt = arg + 1;
if (internal_help && *ctx->opt == 'h')
- return usage_with_options_internal(usagestr, options, 0);
+ return parse_options_usage(usagestr, options);
switch (parse_short_opt(ctx, options)) {
case -1:
- return parse_options_usage(usagestr, options, arg + 1, 1);
+ return parse_options_usage(usagestr, options);
case -2:
goto unknown;
default:
@@ -352,11 +352,10 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
check_typos(arg + 1, options);
while (ctx->opt) {
if (internal_help && *ctx->opt == 'h')
- return usage_with_options_internal(usagestr, options, 0);
- arg = ctx->opt;
+ return parse_options_usage(usagestr, options);
switch (parse_short_opt(ctx, options)) {
case -1:
- return parse_options_usage(usagestr, options, arg, 1);
+ return parse_options_usage(usagestr, options);
case -2:
/* fake a short option thing to hide the fact that we may have
* started to parse aggregated stuff
@@ -384,12 +383,12 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
if (internal_help && !strcmp(arg + 2, "help-all"))
return usage_with_options_internal(usagestr, options, 1);
if (internal_help && !strcmp(arg + 2, "help"))
- return usage_with_options_internal(usagestr, options, 0);
+ return parse_options_usage(usagestr, options);
if (!strcmp(arg + 2, "list-opts"))
return PARSE_OPT_LIST;
switch (parse_long_opt(ctx, arg + 2, options)) {
case -1:
- return parse_options_usage(usagestr, options, arg + 2, 0);
+ return parse_options_usage(usagestr, options);
case -2:
goto unknown;
default:
@@ -446,89 +445,6 @@ int parse_options(int argc, const char **argv, const struct option *options,
#define USAGE_OPTS_WIDTH 24
#define USAGE_GAP 2
-static void print_option_help(const struct option *opts, int full)
-{
- size_t pos;
- int pad;
-
- if (opts->type == OPTION_GROUP) {
- fputc('\n', stderr);
- if (*opts->help)
- fprintf(stderr, "%s\n", opts->help);
- return;
- }
- if (!full && (opts->flags & PARSE_OPT_HIDDEN))
- return;
-
- pos = fprintf(stderr, " ");
- if (opts->short_name)
- pos += fprintf(stderr, "-%c", opts->short_name);
- else
- pos += fprintf(stderr, " ");
-
- if (opts->long_name && opts->short_name)
- pos += fprintf(stderr, ", ");
- if (opts->long_name)
- pos += fprintf(stderr, "--%s", opts->long_name);
-
- switch (opts->type) {
- case OPTION_ARGUMENT:
- break;
- case OPTION_LONG:
- case OPTION_U64:
- case OPTION_INTEGER:
- case OPTION_UINTEGER:
- if (opts->flags & PARSE_OPT_OPTARG)
- if (opts->long_name)
- pos += fprintf(stderr, "[=<n>]");
- else
- pos += fprintf(stderr, "[<n>]");
- else
- pos += fprintf(stderr, " <n>");
- break;
- case OPTION_CALLBACK:
- if (opts->flags & PARSE_OPT_NOARG)
- break;
- /* FALLTHROUGH */
- case OPTION_STRING:
- if (opts->argh) {
- if (opts->flags & PARSE_OPT_OPTARG)
- if (opts->long_name)
- pos += fprintf(stderr, "[=<%s>]", opts->argh);
- else
- pos += fprintf(stderr, "[<%s>]", opts->argh);
- else
- pos += fprintf(stderr, " <%s>", opts->argh);
- } else {
- if (opts->flags & PARSE_OPT_OPTARG)
- if (opts->long_name)
- pos += fprintf(stderr, "[=...]");
- else
- pos += fprintf(stderr, "[...]");
- else
- pos += fprintf(stderr, " ...");
- }
- break;
- default: /* OPTION_{BIT,BOOLEAN,SET_UINT,SET_PTR} */
- case OPTION_END:
- case OPTION_GROUP:
- case OPTION_BIT:
- case OPTION_BOOLEAN:
- case OPTION_INCR:
- case OPTION_SET_UINT:
- case OPTION_SET_PTR:
- break;
- }
-
- if (pos <= USAGE_OPTS_WIDTH)
- pad = USAGE_OPTS_WIDTH - pos;
- else {
- fputc('\n', stderr);
- pad = USAGE_OPTS_WIDTH;
- }
- fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
-}
-
int usage_with_options_internal(const char * const *usagestr,
const struct option *opts, int full)
{
@@ -548,9 +464,87 @@ int usage_with_options_internal(const char * const *usagestr,
if (opts->type != OPTION_GROUP)
fputc('\n', stderr);
- for ( ; opts->type != OPTION_END; opts++)
- print_option_help(opts, full);
+ for (; opts->type != OPTION_END; opts++) {
+ size_t pos;
+ int pad;
+
+ if (opts->type == OPTION_GROUP) {
+ fputc('\n', stderr);
+ if (*opts->help)
+ fprintf(stderr, "%s\n", opts->help);
+ continue;
+ }
+ if (!full && (opts->flags & PARSE_OPT_HIDDEN))
+ continue;
+
+ pos = fprintf(stderr, " ");
+ if (opts->short_name)
+ pos += fprintf(stderr, "-%c", opts->short_name);
+ else
+ pos += fprintf(stderr, " ");
+
+ if (opts->long_name && opts->short_name)
+ pos += fprintf(stderr, ", ");
+ if (opts->long_name)
+ pos += fprintf(stderr, "--%s", opts->long_name);
+
+ switch (opts->type) {
+ case OPTION_ARGUMENT:
+ break;
+ case OPTION_LONG:
+ case OPTION_U64:
+ case OPTION_INTEGER:
+ case OPTION_UINTEGER:
+ if (opts->flags & PARSE_OPT_OPTARG)
+ if (opts->long_name)
+ pos += fprintf(stderr, "[=<n>]");
+ else
+ pos += fprintf(stderr, "[<n>]");
+ else
+ pos += fprintf(stderr, " <n>");
+ break;
+ case OPTION_CALLBACK:
+ if (opts->flags & PARSE_OPT_NOARG)
+ break;
+ /* FALLTHROUGH */
+ case OPTION_STRING:
+ if (opts->argh) {
+ if (opts->flags & PARSE_OPT_OPTARG)
+ if (opts->long_name)
+ pos += fprintf(stderr, "[=<%s>]", opts->argh);
+ else
+ pos += fprintf(stderr, "[<%s>]", opts->argh);
+ else
+ pos += fprintf(stderr, " <%s>", opts->argh);
+ } else {
+ if (opts->flags & PARSE_OPT_OPTARG)
+ if (opts->long_name)
+ pos += fprintf(stderr, "[=...]");
+ else
+ pos += fprintf(stderr, "[...]");
+ else
+ pos += fprintf(stderr, " ...");
+ }
+ break;
+ default: /* OPTION_{BIT,BOOLEAN,SET_UINT,SET_PTR} */
+ case OPTION_END:
+ case OPTION_GROUP:
+ case OPTION_BIT:
+ case OPTION_BOOLEAN:
+ case OPTION_INCR:
+ case OPTION_SET_UINT:
+ case OPTION_SET_PTR:
+ break;
+ }
+ if (pos <= USAGE_OPTS_WIDTH)
+ pad = USAGE_OPTS_WIDTH - pos;
+ else {
+ fputc('\n', stderr);
+ pad = USAGE_OPTS_WIDTH;
+ }
+ fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", opts->help);
+ }
fputc('\n', stderr);
return PARSE_OPT_HELP;
@@ -565,45 +559,9 @@ void usage_with_options(const char * const *usagestr,
}
int parse_options_usage(const char * const *usagestr,
- const struct option *opts,
- const char *optstr, bool short_opt)
+ const struct option *opts)
{
- if (!usagestr)
- goto opt;
-
- fprintf(stderr, "\n usage: %s\n", *usagestr++);
- while (*usagestr && **usagestr)
- fprintf(stderr, " or: %s\n", *usagestr++);
- while (*usagestr) {
- fprintf(stderr, "%s%s\n",
- **usagestr ? " " : "",
- *usagestr);
- usagestr++;
- }
- fputc('\n', stderr);
-
-opt:
- for ( ; opts->type != OPTION_END; opts++) {
- if (short_opt) {
- if (opts->short_name == *optstr)
- break;
- continue;
- }
-
- if (opts->long_name == NULL)
- continue;
-
- if (!prefixcmp(optstr, opts->long_name))
- break;
- if (!prefixcmp(optstr, "no-") &&
- !prefixcmp(optstr + 3, opts->long_name))
- break;
- }
-
- if (opts->type != OPTION_END)
- print_option_help(opts, 0);
-
- return PARSE_OPT_HELP;
+ return usage_with_options_internal(usagestr, opts, 0);
}
diff --git a/tools/perf/util/parse-options.h b/tools/perf/util/parse-options.h
index b0241e2..7bb5999 100644
--- a/tools/perf/util/parse-options.h
+++ b/tools/perf/util/parse-options.h
@@ -158,9 +158,7 @@ struct parse_opt_ctx_t {
};
extern int parse_options_usage(const char * const *usagestr,
- const struct option *opts,
- const char *optstr,
- bool short_opt);
+ const struct option *opts);
extern void parse_options_start(struct parse_opt_ctx_t *ctx,
int argc, const char **argv, int flags);
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c
index 5d13cb4..a8c4954 100644
--- a/tools/perf/util/path.c
+++ b/tools/perf/util/path.c
@@ -22,23 +22,19 @@ static const char *get_perf_dir(void)
return ".";
}
-/*
- * If libc has strlcpy() then that version will override this
- * implementation:
- */
-size_t __weak strlcpy(char *dest, const char *src, size_t size)
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char *dest, const char *src, size_t size)
{
size_t ret = strlen(src);
if (size) {
size_t len = (ret >= size) ? size - 1 : ret;
-
memcpy(dest, src, len);
dest[len] = '\0';
}
-
return ret;
}
+#endif
static char *get_pathname(void)
{
diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h
index a3d42cd..5a4f2b6f 100644
--- a/tools/perf/util/perf_regs.h
+++ b/tools/perf/util/perf_regs.h
@@ -1,7 +1,7 @@
#ifndef __PERF_REGS_H
#define __PERF_REGS_H
-#ifdef HAVE_PERF_REGS_SUPPORT
+#ifdef HAVE_PERF_REGS
#include <perf_regs.h>
#else
#define PERF_REGS_MASK 0
@@ -10,5 +10,5 @@ static inline const char *perf_reg_name(int id __maybe_unused)
{
return NULL;
}
-#endif /* HAVE_PERF_REGS_SUPPORT */
+#endif /* HAVE_PERF_REGS */
#endif /* __PERF_REGS_H */
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index c232d8d..bc9d806 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -4,7 +4,7 @@
#include <unistd.h>
#include <stdio.h>
#include <dirent.h>
-#include "fs.h"
+#include "sysfs.h"
#include "util.h"
#include "pmu.h"
#include "parse-events.h"
@@ -77,8 +77,9 @@ static int pmu_format(const char *name, struct list_head *format)
{
struct stat st;
char path[PATH_MAX];
- const char *sysfs = sysfs__mountpoint();
+ const char *sysfs;
+ sysfs = sysfs_find_mountpoint();
if (!sysfs)
return -1;
@@ -165,8 +166,9 @@ static int pmu_aliases(const char *name, struct list_head *head)
{
struct stat st;
char path[PATH_MAX];
- const char *sysfs = sysfs__mountpoint();
+ const char *sysfs;
+ sysfs = sysfs_find_mountpoint();
if (!sysfs)
return -1;
@@ -210,10 +212,11 @@ static int pmu_type(const char *name, __u32 *type)
{
struct stat st;
char path[PATH_MAX];
+ const char *sysfs;
FILE *file;
int ret = 0;
- const char *sysfs = sysfs__mountpoint();
+ sysfs = sysfs_find_mountpoint();
if (!sysfs)
return -1;
@@ -238,10 +241,11 @@ static int pmu_type(const char *name, __u32 *type)
static void pmu_read_sysfs(void)
{
char path[PATH_MAX];
+ const char *sysfs;
DIR *dir;
struct dirent *dent;
- const char *sysfs = sysfs__mountpoint();
+ sysfs = sysfs_find_mountpoint();
if (!sysfs)
return;
@@ -266,10 +270,11 @@ static struct cpu_map *pmu_cpumask(const char *name)
{
struct stat st;
char path[PATH_MAX];
+ const char *sysfs;
FILE *file;
struct cpu_map *cpus;
- const char *sysfs = sysfs__mountpoint();
+ sysfs = sysfs_find_mountpoint();
if (!sysfs)
return NULL;
@@ -632,19 +637,3 @@ void print_pmu_events(const char *event_glob, bool name_only)
printf("\n");
free(aliases);
}
-
-bool pmu_have_event(const char *pname, const char *name)
-{
- struct perf_pmu *pmu;
- struct perf_pmu_alias *alias;
-
- pmu = NULL;
- while ((pmu = perf_pmu__scan(pmu)) != NULL) {
- if (strcmp(pname, pmu->name))
- continue;
- list_for_each_entry(alias, &pmu->aliases, list)
- if (!strcmp(alias->name, name))
- return true;
- }
- return false;
-}
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 1179b26..6b2cbe2 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -42,7 +42,6 @@ int perf_pmu__format_parse(char *dir, struct list_head *head);
struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
void print_pmu_events(const char *event_glob, bool name_only);
-bool pmu_have_event(const char *pname, const char *name);
int perf_pmu__test(void);
#endif /* __PMU_H */
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 9c6989c..aa04bf9 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -47,6 +47,7 @@
#include "session.h"
#define MAX_CMDLEN 256
+#define MAX_PROBE_ARGS 128
#define PERFPROBE_GROUP "probe"
bool probe_event_dry_run; /* Dry run flag */
@@ -200,7 +201,7 @@ static int convert_to_perf_probe_point(struct probe_trace_point *tp,
return 0;
}
-#ifdef HAVE_DWARF_SUPPORT
+#ifdef DWARF_SUPPORT
/* Open new debuginfo of given module */
static struct debuginfo *open_debuginfo(const char *module)
{
@@ -629,7 +630,7 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs,
return ret;
}
-#else /* !HAVE_DWARF_SUPPORT */
+#else /* !DWARF_SUPPORT */
static int kprobe_convert_to_perf_probe(struct probe_trace_point *tp,
struct perf_probe_point *pp)
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index ffb657f..f069273 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -115,7 +115,7 @@ static const Dwfl_Callbacks offline_callbacks = {
};
/* Get a Dwarf from offline image */
-static int debuginfo__init_offline_dwarf(struct debuginfo *dbg,
+static int debuginfo__init_offline_dwarf(struct debuginfo *self,
const char *path)
{
int fd;
@@ -124,25 +124,25 @@ static int debuginfo__init_offline_dwarf(struct debuginfo *dbg,
if (fd < 0)
return fd;
- dbg->dwfl = dwfl_begin(&offline_callbacks);
- if (!dbg->dwfl)
+ self->dwfl = dwfl_begin(&offline_callbacks);
+ if (!self->dwfl)
goto error;
- dbg->mod = dwfl_report_offline(dbg->dwfl, "", "", fd);
- if (!dbg->mod)
+ self->mod = dwfl_report_offline(self->dwfl, "", "", fd);
+ if (!self->mod)
goto error;
- dbg->dbg = dwfl_module_getdwarf(dbg->mod, &dbg->bias);
- if (!dbg->dbg)
+ self->dbg = dwfl_module_getdwarf(self->mod, &self->bias);
+ if (!self->dbg)
goto error;
return 0;
error:
- if (dbg->dwfl)
- dwfl_end(dbg->dwfl);
+ if (self->dwfl)
+ dwfl_end(self->dwfl);
else
close(fd);
- memset(dbg, 0, sizeof(*dbg));
+ memset(self, 0, sizeof(*self));
return -ENOENT;
}
@@ -180,24 +180,24 @@ static const Dwfl_Callbacks kernel_callbacks = {
};
/* Get a Dwarf from live kernel image */
-static int debuginfo__init_online_kernel_dwarf(struct debuginfo *dbg,
+static int debuginfo__init_online_kernel_dwarf(struct debuginfo *self,
Dwarf_Addr addr)
{
- dbg->dwfl = dwfl_begin(&kernel_callbacks);
- if (!dbg->dwfl)
+ self->dwfl = dwfl_begin(&kernel_callbacks);
+ if (!self->dwfl)
return -EINVAL;
/* Load the kernel dwarves: Don't care the result here */
- dwfl_linux_kernel_report_kernel(dbg->dwfl);
- dwfl_linux_kernel_report_modules(dbg->dwfl);
+ dwfl_linux_kernel_report_kernel(self->dwfl);
+ dwfl_linux_kernel_report_modules(self->dwfl);
- dbg->dbg = dwfl_addrdwarf(dbg->dwfl, addr, &dbg->bias);
+ self->dbg = dwfl_addrdwarf(self->dwfl, addr, &self->bias);
/* Here, check whether we could get a real dwarf */
- if (!dbg->dbg) {
+ if (!self->dbg) {
pr_debug("Failed to find kernel dwarf at %lx\n",
(unsigned long)addr);
- dwfl_end(dbg->dwfl);
- memset(dbg, 0, sizeof(*dbg));
+ dwfl_end(self->dwfl);
+ memset(self, 0, sizeof(*self));
return -ENOENT;
}
@@ -205,7 +205,7 @@ static int debuginfo__init_online_kernel_dwarf(struct debuginfo *dbg,
}
#else
/* With older elfutils, this just support kernel module... */
-static int debuginfo__init_online_kernel_dwarf(struct debuginfo *dbg,
+static int debuginfo__init_online_kernel_dwarf(struct debuginfo *self,
Dwarf_Addr addr __maybe_unused)
{
const char *path = kernel_get_module_path("kernel");
@@ -216,45 +216,44 @@ static int debuginfo__init_online_kernel_dwarf(struct debuginfo *dbg,
}
pr_debug2("Use file %s for debuginfo\n", path);
- return debuginfo__init_offline_dwarf(dbg, path);
+ return debuginfo__init_offline_dwarf(self, path);
}
#endif
struct debuginfo *debuginfo__new(const char *path)
{
- struct debuginfo *dbg = zalloc(sizeof(*dbg));
- if (!dbg)
+ struct debuginfo *self = zalloc(sizeof(struct debuginfo));
+ if (!self)
return NULL;
- if (debuginfo__init_offline_dwarf(dbg, path) < 0) {
- free(dbg);
- dbg = NULL;
+ if (debuginfo__init_offline_dwarf(self, path) < 0) {
+ free(self);
+ self = NULL;
}
- return dbg;
+ return self;
}
struct debuginfo *debuginfo__new_online_kernel(unsigned long addr)
{
- struct debuginfo *dbg = zalloc(sizeof(*dbg));
-
- if (!dbg)
+ struct debuginfo *self = zalloc(sizeof(struct debuginfo));
+ if (!self)
return NULL;
- if (debuginfo__init_online_kernel_dwarf(dbg, (Dwarf_Addr)addr) < 0) {
- free(dbg);
- dbg = NULL;
+ if (debuginfo__init_online_kernel_dwarf(self, (Dwarf_Addr)addr) < 0) {
+ free(self);
+ self = NULL;
}
- return dbg;
+ return self;
}
-void debuginfo__delete(struct debuginfo *dbg)
+void debuginfo__delete(struct debuginfo *self)
{
- if (dbg) {
- if (dbg->dwfl)
- dwfl_end(dbg->dwfl);
- free(dbg);
+ if (self) {
+ if (self->dwfl)
+ dwfl_end(self->dwfl);
+ free(self);
}
}
@@ -274,15 +273,12 @@ static struct probe_trace_arg_ref *alloc_trace_arg_ref(long offs)
/*
* Convert a location into trace_arg.
* If tvar == NULL, this just checks variable can be converted.
- * If fentry == true and vr_die is a parameter, do huristic search
- * for the location fuzzed by function entry mcount.
*/
static int convert_variable_location(Dwarf_Die *vr_die, Dwarf_Addr addr,
- Dwarf_Op *fb_ops, Dwarf_Die *sp_die,
+ Dwarf_Op *fb_ops,
struct probe_trace_arg *tvar)
{
Dwarf_Attribute attr;
- Dwarf_Addr tmp = 0;
Dwarf_Op *op;
size_t nops;
unsigned int regn;
@@ -295,29 +291,12 @@ static int convert_variable_location(Dwarf_Die *vr_die, Dwarf_Addr addr,
goto static_var;
/* TODO: handle more than 1 exprs */
- if (dwarf_attr(vr_die, DW_AT_location, &attr) == NULL)
- return -EINVAL; /* Broken DIE ? */
- if (dwarf_getlocation_addr(&attr, addr, &op, &nops, 1) <= 0) {
- ret = dwarf_entrypc(sp_die, &tmp);
- if (ret || addr != tmp ||
- dwarf_tag(vr_die) != DW_TAG_formal_parameter ||
- dwarf_highpc(sp_die, &tmp))
- return -ENOENT;
- /*
- * This is fuzzed by fentry mcount. We try to find the
- * parameter location at the earliest address.
- */
- for (addr += 1; addr <= tmp; addr++) {
- if (dwarf_getlocation_addr(&attr, addr, &op,
- &nops, 1) > 0)
- goto found;
- }
- return -ENOENT;
- }
-found:
- if (nops == 0)
+ if (dwarf_attr(vr_die, DW_AT_location, &attr) == NULL ||
+ dwarf_getlocation_addr(&attr, addr, &op, &nops, 1) <= 0 ||
+ nops == 0) {
/* TODO: Support const_value */
return -ENOENT;
+ }
if (op->atom == DW_OP_addr) {
static_var:
@@ -584,7 +563,7 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
}
if (die_find_member(&type, field->name, die_mem) == NULL) {
- pr_warning("%s(type:%s) has no member %s.\n", varname,
+ pr_warning("%s(tyep:%s) has no member %s.\n", varname,
dwarf_diename(&type), field->name);
return -EINVAL;
}
@@ -621,7 +600,7 @@ static int convert_variable(Dwarf_Die *vr_die, struct probe_finder *pf)
dwarf_diename(vr_die));
ret = convert_variable_location(vr_die, pf->addr, pf->fb_ops,
- &pf->sp_die, pf->tvar);
+ pf->tvar);
if (ret == -ENOENT)
pr_err("Failed to find the location of %s at this address.\n"
" Perhaps, it has been optimized out.\n", pf->pvar->var);
@@ -1084,7 +1063,7 @@ static int pubname_search_cb(Dwarf *dbg, Dwarf_Global *gl, void *data)
}
/* Find probe points from debuginfo */
-static int debuginfo__find_probes(struct debuginfo *dbg,
+static int debuginfo__find_probes(struct debuginfo *self,
struct probe_finder *pf)
{
struct perf_probe_point *pp = &pf->pev->point;
@@ -1095,7 +1074,7 @@ static int debuginfo__find_probes(struct debuginfo *dbg,
#if _ELFUTILS_PREREQ(0, 142)
/* Get the call frame information from this dwarf */
- pf->cfi = dwarf_getcfi(dbg->dbg);
+ pf->cfi = dwarf_getcfi(self->dbg);
#endif
off = 0;
@@ -1114,7 +1093,7 @@ static int debuginfo__find_probes(struct debuginfo *dbg,
.data = pf,
};
- dwarf_getpubnames(dbg->dbg, pubname_search_cb,
+ dwarf_getpubnames(self->dbg, pubname_search_cb,
&pubname_param, 0);
if (pubname_param.found) {
ret = probe_point_search_cb(&pf->sp_die, &probe_param);
@@ -1124,9 +1103,9 @@ static int debuginfo__find_probes(struct debuginfo *dbg,
}
/* Loop on CUs (Compilation Unit) */
- while (!dwarf_nextcu(dbg->dbg, off, &noff, &cuhl, NULL, NULL, NULL)) {
+ while (!dwarf_nextcu(self->dbg, off, &noff, &cuhl, NULL, NULL, NULL)) {
/* Get the DIE(Debugging Information Entry) of this CU */
- diep = dwarf_offdie(dbg->dbg, off + cuhl, &pf->cu_die);
+ diep = dwarf_offdie(self->dbg, off + cuhl, &pf->cu_die);
if (!diep)
continue;
@@ -1157,80 +1136,12 @@ found:
return ret;
}
-struct local_vars_finder {
- struct probe_finder *pf;
- struct perf_probe_arg *args;
- int max_args;
- int nargs;
- int ret;
-};
-
-/* Collect available variables in this scope */
-static int copy_variables_cb(Dwarf_Die *die_mem, void *data)
-{
- struct local_vars_finder *vf = data;
- struct probe_finder *pf = vf->pf;
- int tag;
-
- tag = dwarf_tag(die_mem);
- if (tag == DW_TAG_formal_parameter ||
- tag == DW_TAG_variable) {
- if (convert_variable_location(die_mem, vf->pf->addr,
- vf->pf->fb_ops, &pf->sp_die,
- NULL) == 0) {
- vf->args[vf->nargs].var = (char *)dwarf_diename(die_mem);
- if (vf->args[vf->nargs].var == NULL) {
- vf->ret = -ENOMEM;
- return DIE_FIND_CB_END;
- }
- pr_debug(" %s", vf->args[vf->nargs].var);
- vf->nargs++;
- }
- }
-
- if (dwarf_haspc(die_mem, vf->pf->addr))
- return DIE_FIND_CB_CONTINUE;
- else
- return DIE_FIND_CB_SIBLING;
-}
-
-static int expand_probe_args(Dwarf_Die *sc_die, struct probe_finder *pf,
- struct perf_probe_arg *args)
-{
- Dwarf_Die die_mem;
- int i;
- int n = 0;
- struct local_vars_finder vf = {.pf = pf, .args = args,
- .max_args = MAX_PROBE_ARGS, .ret = 0};
-
- for (i = 0; i < pf->pev->nargs; i++) {
- /* var never be NULL */
- if (strcmp(pf->pev->args[i].var, "$vars") == 0) {
- pr_debug("Expanding $vars into:");
- vf.nargs = n;
- /* Special local variables */
- die_find_child(sc_die, copy_variables_cb, (void *)&vf,
- &die_mem);
- pr_debug(" (%d)\n", vf.nargs - n);
- if (vf.ret < 0)
- return vf.ret;
- n = vf.nargs;
- } else {
- /* Copy normal argument */
- args[n] = pf->pev->args[i];
- n++;
- }
- }
- return n;
-}
-
/* Add a found probe point into trace event list */
static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
{
struct trace_event_finder *tf =
container_of(pf, struct trace_event_finder, pf);
struct probe_trace_event *tev;
- struct perf_probe_arg *args;
int ret, i;
/* Check number of tevs */
@@ -1250,45 +1161,31 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
pr_debug("Probe point found: %s+%lu\n", tev->point.symbol,
tev->point.offset);
- /* Expand special probe argument if exist */
- args = zalloc(sizeof(struct perf_probe_arg) * MAX_PROBE_ARGS);
- if (args == NULL)
- return -ENOMEM;
-
- ret = expand_probe_args(sc_die, pf, args);
- if (ret < 0)
- goto end;
-
- tev->nargs = ret;
- tev->args = zalloc(sizeof(struct probe_trace_arg) * tev->nargs);
- if (tev->args == NULL) {
- ret = -ENOMEM;
- goto end;
- }
-
/* Find each argument */
- for (i = 0; i < tev->nargs; i++) {
- pf->pvar = &args[i];
+ tev->nargs = pf->pev->nargs;
+ tev->args = zalloc(sizeof(struct probe_trace_arg) * tev->nargs);
+ if (tev->args == NULL)
+ return -ENOMEM;
+ for (i = 0; i < pf->pev->nargs; i++) {
+ pf->pvar = &pf->pev->args[i];
pf->tvar = &tev->args[i];
/* Variable should be found from scope DIE */
ret = find_variable(sc_die, pf);
if (ret != 0)
- break;
+ return ret;
}
-end:
- free(args);
- return ret;
+ return 0;
}
/* Find probe_trace_events specified by perf_probe_event from debuginfo */
-int debuginfo__find_trace_events(struct debuginfo *dbg,
+int debuginfo__find_trace_events(struct debuginfo *self,
struct perf_probe_event *pev,
struct probe_trace_event **tevs, int max_tevs)
{
struct trace_event_finder tf = {
.pf = {.pev = pev, .callback = add_probe_trace_event},
- .mod = dbg->mod, .max_tevs = max_tevs};
+ .mod = self->mod, .max_tevs = max_tevs};
int ret;
/* Allocate result tevs array */
@@ -1299,7 +1196,7 @@ int debuginfo__find_trace_events(struct debuginfo *dbg,
tf.tevs = *tevs;
tf.ntevs = 0;
- ret = debuginfo__find_probes(dbg, &tf.pf);
+ ret = debuginfo__find_probes(self, &tf.pf);
if (ret < 0) {
free(*tevs);
*tevs = NULL;
@@ -1325,8 +1222,7 @@ static int collect_variables_cb(Dwarf_Die *die_mem, void *data)
if (tag == DW_TAG_formal_parameter ||
tag == DW_TAG_variable) {
ret = convert_variable_location(die_mem, af->pf.addr,
- af->pf.fb_ops, &af->pf.sp_die,
- NULL);
+ af->pf.fb_ops, NULL);
if (ret == 0) {
ret = die_get_varname(die_mem, buf, MAX_VAR_LEN);
pr_debug2("Add new var: %s\n", buf);
@@ -1390,14 +1286,14 @@ out:
}
/* Find available variables at given probe point */
-int debuginfo__find_available_vars_at(struct debuginfo *dbg,
+int debuginfo__find_available_vars_at(struct debuginfo *self,
struct perf_probe_event *pev,
struct variable_list **vls,
int max_vls, bool externs)
{
struct available_var_finder af = {
.pf = {.pev = pev, .callback = add_available_vars},
- .mod = dbg->mod,
+ .mod = self->mod,
.max_vls = max_vls, .externs = externs};
int ret;
@@ -1409,7 +1305,7 @@ int debuginfo__find_available_vars_at(struct debuginfo *dbg,
af.vls = *vls;
af.nvls = 0;
- ret = debuginfo__find_probes(dbg, &af.pf);
+ ret = debuginfo__find_probes(self, &af.pf);
if (ret < 0) {
/* Free vlist for error */
while (af.nvls--) {
@@ -1427,7 +1323,7 @@ int debuginfo__find_available_vars_at(struct debuginfo *dbg,
}
/* Reverse search */
-int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
+int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr,
struct perf_probe_point *ppt)
{
Dwarf_Die cudie, spdie, indie;
@@ -1436,10 +1332,10 @@ int debuginfo__find_probe_point(struct debuginfo *dbg, unsigned long addr,
int baseline = 0, lineno = 0, ret = 0;
/* Adjust address with bias */
- addr += dbg->bias;
+ addr += self->bias;
/* Find cu die */
- if (!dwarf_addrdie(dbg->dbg, (Dwarf_Addr)addr - dbg->bias, &cudie)) {
+ if (!dwarf_addrdie(self->dbg, (Dwarf_Addr)addr - self->bias, &cudie)) {
pr_warning("Failed to find debug information for address %lx\n",
addr);
ret = -EINVAL;
@@ -1640,7 +1536,7 @@ static int find_line_range_by_func(struct line_finder *lf)
return param.retval;
}
-int debuginfo__find_line_range(struct debuginfo *dbg, struct line_range *lr)
+int debuginfo__find_line_range(struct debuginfo *self, struct line_range *lr)
{
struct line_finder lf = {.lr = lr, .found = 0};
int ret = 0;
@@ -1657,7 +1553,7 @@ int debuginfo__find_line_range(struct debuginfo *dbg, struct line_range *lr)
struct dwarf_callback_param line_range_param = {
.data = (void *)&lf, .retval = 0};
- dwarf_getpubnames(dbg->dbg, pubname_search_cb,
+ dwarf_getpubnames(self->dbg, pubname_search_cb,
&pubname_param, 0);
if (pubname_param.found) {
line_range_search_cb(&lf.sp_die, &line_range_param);
@@ -1668,12 +1564,12 @@ int debuginfo__find_line_range(struct debuginfo *dbg, struct line_range *lr)
/* Loop on CUs (Compilation Unit) */
while (!lf.found && ret >= 0) {
- if (dwarf_nextcu(dbg->dbg, off, &noff, &cuhl,
+ if (dwarf_nextcu(self->dbg, off, &noff, &cuhl,
NULL, NULL, NULL) != 0)
break;
/* Get the DIE(Debugging Information Entry) of this CU */
- diep = dwarf_offdie(dbg->dbg, off + cuhl, &lf.cu_die);
+ diep = dwarf_offdie(self->dbg, off + cuhl, &lf.cu_die);
if (!diep)
continue;
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h
index ffc33cd..3b7d630 100644
--- a/tools/perf/util/probe-finder.h
+++ b/tools/perf/util/probe-finder.h
@@ -7,7 +7,6 @@
#define MAX_PROBE_BUFFER 1024
#define MAX_PROBES 128
-#define MAX_PROBE_ARGS 128
static inline int is_c_varname(const char *name)
{
@@ -15,7 +14,7 @@ static inline int is_c_varname(const char *name)
return isalpha(name[0]) || name[0] == '_';
}
-#ifdef HAVE_DWARF_SUPPORT
+#ifdef DWARF_SUPPORT
#include "dwarf-aux.h"
@@ -31,25 +30,25 @@ struct debuginfo {
extern struct debuginfo *debuginfo__new(const char *path);
extern struct debuginfo *debuginfo__new_online_kernel(unsigned long addr);
-extern void debuginfo__delete(struct debuginfo *dbg);
+extern void debuginfo__delete(struct debuginfo *self);
/* Find probe_trace_events specified by perf_probe_event from debuginfo */
-extern int debuginfo__find_trace_events(struct debuginfo *dbg,
+extern int debuginfo__find_trace_events(struct debuginfo *self,
struct perf_probe_event *pev,
struct probe_trace_event **tevs,
int max_tevs);
/* Find a perf_probe_point from debuginfo */
-extern int debuginfo__find_probe_point(struct debuginfo *dbg,
+extern int debuginfo__find_probe_point(struct debuginfo *self,
unsigned long addr,
struct perf_probe_point *ppt);
/* Find a line range */
-extern int debuginfo__find_line_range(struct debuginfo *dbg,
+extern int debuginfo__find_line_range(struct debuginfo *self,
struct line_range *lr);
/* Find available variables */
-extern int debuginfo__find_available_vars_at(struct debuginfo *dbg,
+extern int debuginfo__find_available_vars_at(struct debuginfo *self,
struct perf_probe_event *pev,
struct variable_list **vls,
int max_points, bool externs);
@@ -106,6 +105,6 @@ struct line_finder {
int found;
};
-#endif /* HAVE_DWARF_SUPPORT */
+#endif /* DWARF_SUPPORT */
#endif /*_PROBE_FINDER_H */
diff --git a/tools/perf/util/pstack.h b/tools/perf/util/pstack.h
index c3cb658..4cedea5 100644
--- a/tools/perf/util/pstack.h
+++ b/tools/perf/util/pstack.h
@@ -5,10 +5,10 @@
struct pstack;
struct pstack *pstack__new(unsigned short max_nr_entries);
-void pstack__delete(struct pstack *pstack);
-bool pstack__empty(const struct pstack *pstack);
-void pstack__remove(struct pstack *pstack, void *key);
-void pstack__push(struct pstack *pstack, void *key);
-void *pstack__pop(struct pstack *pstack);
+void pstack__delete(struct pstack *self);
+bool pstack__empty(const struct pstack *self);
+void pstack__remove(struct pstack *self, void *key);
+void pstack__push(struct pstack *self, void *key);
+void *pstack__pop(struct pstack *self);
#endif /* _PERF_PSTACK_ */
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources
index 239036f..f75ae1b 100644
--- a/tools/perf/util/python-ext-sources
+++ b/tools/perf/util/python-ext-sources
@@ -17,5 +17,5 @@ util/xyarray.c
util/cgroup.c
util/rblist.c
util/strlist.c
-util/fs.c
+util/sysfs.c
../../lib/rbtree.c
diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 4bf8ace..2ac4bc9 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -33,6 +33,13 @@ int eprintf(int level, const char *fmt, ...)
# define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
#endif
+struct throttle_event {
+ struct perf_event_header header;
+ u64 time;
+ u64 id;
+ u64 stream_id;
+};
+
PyMODINIT_FUNC initperf(void);
#define member_def(type, member, ptype, help) \
@@ -1031,7 +1038,6 @@ PyMODINIT_FUNC initperf(void)
pyrf_cpu_map__setup_types() < 0)
return;
- /* The page_size is placed in util object. */
page_size = sysconf(_SC_PAGE_SIZE);
Py_INCREF(&pyrf_evlist__type);
diff --git a/tools/perf/util/rblist.c b/tools/perf/util/rblist.c
index 0dfe27d..a16cdd2 100644
--- a/tools/perf/util/rblist.c
+++ b/tools/perf/util/rblist.c
@@ -48,12 +48,10 @@ void rblist__remove_node(struct rblist *rblist, struct rb_node *rb_node)
rblist->node_delete(rblist, rb_node);
}
-static struct rb_node *__rblist__findnew(struct rblist *rblist,
- const void *entry,
- bool create)
+struct rb_node *rblist__find(struct rblist *rblist, const void *entry)
{
struct rb_node **p = &rblist->entries.rb_node;
- struct rb_node *parent = NULL, *new_node = NULL;
+ struct rb_node *parent = NULL;
while (*p != NULL) {
int rc;
@@ -69,26 +67,7 @@ static struct rb_node *__rblist__findnew(struct rblist *rblist,
return parent;
}
- if (create) {
- new_node = rblist->node_new(rblist, entry);
- if (new_node) {
- rb_link_node(new_node, parent, p);
- rb_insert_color(new_node, &rblist->entries);
- ++rblist->nr_entries;
- }
- }
-
- return new_node;
-}
-
-struct rb_node *rblist__find(struct rblist *rblist, const void *entry)
-{
- return __rblist__findnew(rblist, entry, false);
-}
-
-struct rb_node *rblist__findnew(struct rblist *rblist, const void *entry)
-{
- return __rblist__findnew(rblist, entry, true);
+ return NULL;
}
void rblist__init(struct rblist *rblist)
diff --git a/tools/perf/util/rblist.h b/tools/perf/util/rblist.h
index ff9913b..6d0cae5 100644
--- a/tools/perf/util/rblist.h
+++ b/tools/perf/util/rblist.h
@@ -32,7 +32,6 @@ void rblist__delete(struct rblist *rblist);
int rblist__add_node(struct rblist *rblist, const void *new_entry);
void rblist__remove_node(struct rblist *rblist, struct rb_node *rb_node);
struct rb_node *rblist__find(struct rblist *rblist, const void *entry);
-struct rb_node *rblist__findnew(struct rblist *rblist, const void *entry);
struct rb_node *rblist__entry(const struct rblist *rblist, unsigned int idx);
static inline bool rblist__empty(const struct rblist *rblist)
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c
index c8845b1..18d73aa 100644
--- a/tools/perf/util/record.c
+++ b/tools/perf/util/record.c
@@ -2,8 +2,6 @@
#include "evsel.h"
#include "cpumap.h"
#include "parse-events.h"
-#include "fs.h"
-#include "util.h"
typedef void (*setup_probe_fn_t)(struct perf_evsel *evsel);
@@ -108,72 +106,3 @@ void perf_evlist__config(struct perf_evlist *evlist,
perf_evlist__set_id_pos(evlist);
}
-
-static int get_max_rate(unsigned int *rate)
-{
- char path[PATH_MAX];
- const char *procfs = procfs__mountpoint();
-
- if (!procfs)
- return -1;
-
- snprintf(path, PATH_MAX,
- "%s/sys/kernel/perf_event_max_sample_rate", procfs);
-
- return filename__read_int(path, (int *) rate);
-}
-
-static int perf_record_opts__config_freq(struct perf_record_opts *opts)
-{
- bool user_freq = opts->user_freq != UINT_MAX;
- unsigned int max_rate;
-
- if (opts->user_interval != ULLONG_MAX)
- opts->default_interval = opts->user_interval;
- if (user_freq)
- opts->freq = opts->user_freq;
-
- /*
- * User specified count overrides default frequency.
- */
- if (opts->default_interval)
- opts->freq = 0;
- else if (opts->freq) {
- opts->default_interval = opts->freq;
- } else {
- pr_err("frequency and count are zero, aborting\n");
- return -1;
- }
-
- if (get_max_rate(&max_rate))
- return 0;
-
- /*
- * User specified frequency is over current maximum.
- */
- if (user_freq && (max_rate < opts->freq)) {
- pr_err("Maximum frequency rate (%u) reached.\n"
- "Please use -F freq option with lower value or consider\n"
- "tweaking /proc/sys/kernel/perf_event_max_sample_rate.\n",
- max_rate);
- return -1;
- }
-
- /*
- * Default frequency is over current maximum.
- */
- if (max_rate < opts->freq) {
- pr_warning("Lowering default frequency rate to %u.\n"
- "Please consider tweaking "
- "/proc/sys/kernel/perf_event_max_sample_rate.\n",
- max_rate);
- opts->freq = max_rate;
- }
-
- return 0;
-}
-
-int perf_record_opts__config(struct perf_record_opts *opts)
-{
- return perf_record_opts__config_freq(opts);
-}
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index d5e5969..c0c9795 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -273,7 +273,7 @@ static void perl_process_tracepoint(union perf_event *perf_event __maybe_unused,
int cpu = sample->cpu;
void *data = sample->raw_data;
unsigned long long nsecs = sample->time;
- const char *comm = thread__comm_str(thread);
+ char *comm = thread->comm;
dSP;
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 53c20e7..95d91a0 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -250,7 +250,7 @@ static void python_process_tracepoint(union perf_event *perf_event
int cpu = sample->cpu;
void *data = sample->raw_data;
unsigned long long nsecs = sample->time;
- const char *comm = thread__comm_str(thread);
+ char *comm = thread->comm;
t = PyTuple_New(MAX_FIELDS);
if (!t)
@@ -389,7 +389,7 @@ static void python_process_general_event(union perf_event *perf_event
pydict_set_item_string_decref(dict, "raw_buf", PyString_FromStringAndSize(
(const char *)sample->raw_data, sample->raw_size));
pydict_set_item_string_decref(dict, "comm",
- PyString_FromString(thread__comm_str(thread)));
+ PyString_FromString(thread->comm));
if (al->map) {
pydict_set_item_string_decref(dict, "dso",
PyString_FromString(al->map->dso->name));
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index f36d24a..568b750 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -16,34 +16,73 @@
#include "perf_regs.h"
#include "vdso.h"
-static int perf_session__open(struct perf_session *session)
+static int perf_session__open(struct perf_session *self, bool force)
{
- struct perf_data_file *file = session->file;
+ struct stat input_stat;
- if (perf_session__read_header(session) < 0) {
- pr_err("incompatible file format (rerun with -v to learn more)");
- return -1;
- }
+ if (!strcmp(self->filename, "-")) {
+ self->fd_pipe = true;
+ self->fd = STDIN_FILENO;
+
+ if (perf_session__read_header(self) < 0)
+ pr_err("incompatible file format (rerun with -v to learn more)");
- if (perf_data_file__is_pipe(file))
return 0;
+ }
+
+ self->fd = open(self->filename, O_RDONLY);
+ if (self->fd < 0) {
+ int err = errno;
+
+ pr_err("failed to open %s: %s", self->filename, strerror(err));
+ if (err == ENOENT && !strcmp(self->filename, "perf.data"))
+ pr_err(" (try 'perf record' first)");
+ pr_err("\n");
+ return -errno;
+ }
+
+ if (fstat(self->fd, &input_stat) < 0)
+ goto out_close;
+
+ if (!force && input_stat.st_uid && (input_stat.st_uid != geteuid())) {
+ pr_err("file %s not owned by current user or root\n",
+ self->filename);
+ goto out_close;
+ }
+
+ if (!input_stat.st_size) {
+ pr_info("zero-sized file (%s), nothing to do!\n",
+ self->filename);
+ goto out_close;
+ }
- if (!perf_evlist__valid_sample_type(session->evlist)) {
+ if (perf_session__read_header(self) < 0) {
+ pr_err("incompatible file format (rerun with -v to learn more)");
+ goto out_close;
+ }
+
+ if (!perf_evlist__valid_sample_type(self->evlist)) {
pr_err("non matching sample_type");
- return -1;
+ goto out_close;
}
- if (!perf_evlist__valid_sample_id_all(session->evlist)) {
+ if (!perf_evlist__valid_sample_id_all(self->evlist)) {
pr_err("non matching sample_id_all");
- return -1;
+ goto out_close;
}
- if (!perf_evlist__valid_read_format(session->evlist)) {
+ if (!perf_evlist__valid_read_format(self->evlist)) {
pr_err("non matching read_format");
- return -1;
+ goto out_close;
}
+ self->size = input_stat.st_size;
return 0;
+
+out_close:
+ close(self->fd);
+ self->fd = -1;
+ return -1;
}
void perf_session__set_id_hdr_size(struct perf_session *session)
@@ -53,70 +92,71 @@ void perf_session__set_id_hdr_size(struct perf_session *session)
machines__set_id_hdr_size(&session->machines, id_hdr_size);
}
-int perf_session__create_kernel_maps(struct perf_session *session)
+int perf_session__create_kernel_maps(struct perf_session *self)
{
- int ret = machine__create_kernel_maps(&session->machines.host);
+ int ret = machine__create_kernel_maps(&self->machines.host);
if (ret >= 0)
- ret = machines__create_guest_kernel_maps(&session->machines);
+ ret = machines__create_guest_kernel_maps(&self->machines);
return ret;
}
-static void perf_session__destroy_kernel_maps(struct perf_session *session)
+static void perf_session__destroy_kernel_maps(struct perf_session *self)
{
- machines__destroy_kernel_maps(&session->machines);
+ machines__destroy_kernel_maps(&self->machines);
}
-struct perf_session *perf_session__new(struct perf_data_file *file,
- bool repipe, struct perf_tool *tool)
+struct perf_session *perf_session__new(const char *filename, int mode,
+ bool force, bool repipe,
+ struct perf_tool *tool)
{
- struct perf_session *session = zalloc(sizeof(*session));
-
- if (!session)
- goto out;
-
- session->repipe = repipe;
- INIT_LIST_HEAD(&session->ordered_samples.samples);
- INIT_LIST_HEAD(&session->ordered_samples.sample_cache);
- INIT_LIST_HEAD(&session->ordered_samples.to_free);
- machines__init(&session->machines);
+ struct perf_session *self;
+ struct stat st;
+ size_t len;
- if (file) {
- if (perf_data_file__open(file))
- goto out_delete;
+ if (!filename || !strlen(filename)) {
+ if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode))
+ filename = "-";
+ else
+ filename = "perf.data";
+ }
- session->file = file;
+ len = strlen(filename);
+ self = zalloc(sizeof(*self) + len);
- if (perf_data_file__is_read(file)) {
- if (perf_session__open(session) < 0)
- goto out_close;
+ if (self == NULL)
+ goto out;
- perf_session__set_id_hdr_size(session);
- }
- }
+ memcpy(self->filename, filename, len);
+ self->repipe = repipe;
+ INIT_LIST_HEAD(&self->ordered_samples.samples);
+ INIT_LIST_HEAD(&self->ordered_samples.sample_cache);
+ INIT_LIST_HEAD(&self->ordered_samples.to_free);
+ machines__init(&self->machines);
- if (!file || perf_data_file__is_write(file)) {
+ if (mode == O_RDONLY) {
+ if (perf_session__open(self, force) < 0)
+ goto out_delete;
+ perf_session__set_id_hdr_size(self);
+ } else if (mode == O_WRONLY) {
/*
* In O_RDONLY mode this will be performed when reading the
* kernel MMAP event, in perf_event__process_mmap().
*/
- if (perf_session__create_kernel_maps(session) < 0)
+ if (perf_session__create_kernel_maps(self) < 0)
goto out_delete;
}
if (tool && tool->ordering_requires_timestamps &&
- tool->ordered_samples && !perf_evlist__sample_id_all(session->evlist)) {
+ tool->ordered_samples && !perf_evlist__sample_id_all(self->evlist)) {
dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n");
tool->ordered_samples = false;
}
- return session;
-
- out_close:
- perf_data_file__close(file);
- out_delete:
- perf_session__delete(session);
- out:
+out:
+ return self;
+out_delete:
+ perf_session__delete(self);
return NULL;
}
@@ -146,16 +186,15 @@ static void perf_session_env__delete(struct perf_session_env *env)
free(env->pmu_mappings);
}
-void perf_session__delete(struct perf_session *session)
+void perf_session__delete(struct perf_session *self)
{
- perf_session__destroy_kernel_maps(session);
- perf_session__delete_dead_threads(session);
- perf_session__delete_threads(session);
- perf_session_env__delete(&session->header.env);
- machines__exit(&session->machines);
- if (session->file)
- perf_data_file__close(session->file);
- free(session);
+ perf_session__destroy_kernel_maps(self);
+ perf_session__delete_dead_threads(self);
+ perf_session__delete_threads(self);
+ perf_session_env__delete(&self->header.env);
+ machines__exit(&self->machines);
+ close(self->fd);
+ free(self);
vdso__exit();
}
@@ -358,17 +397,6 @@ static void perf_event__read_swap(union perf_event *event, bool sample_id_all)
swap_sample_id_all(event, &event->read + 1);
}
-static void perf_event__throttle_swap(union perf_event *event,
- bool sample_id_all)
-{
- event->throttle.time = bswap_64(event->throttle.time);
- event->throttle.id = bswap_64(event->throttle.id);
- event->throttle.stream_id = bswap_64(event->throttle.stream_id);
-
- if (sample_id_all)
- swap_sample_id_all(event, &event->throttle + 1);
-}
-
static u8 revbyte(u8 b)
{
int rev = (b >> 4) | ((b & 0xf) << 4);
@@ -414,9 +442,6 @@ void perf_event__attr_swap(struct perf_event_attr *attr)
attr->bp_type = bswap_32(attr->bp_type);
attr->bp_addr = bswap_64(attr->bp_addr);
attr->bp_len = bswap_64(attr->bp_len);
- attr->branch_sample_type = bswap_64(attr->branch_sample_type);
- attr->sample_regs_user = bswap_64(attr->sample_regs_user);
- attr->sample_stack_user = bswap_32(attr->sample_stack_user);
swap_bitfield((u8 *) (&attr->read_format + 1), sizeof(u64));
}
@@ -457,8 +482,6 @@ static perf_event__swap_op perf_event__swap_ops[] = {
[PERF_RECORD_EXIT] = perf_event__task_swap,
[PERF_RECORD_LOST] = perf_event__all64_swap,
[PERF_RECORD_READ] = perf_event__read_swap,
- [PERF_RECORD_THROTTLE] = perf_event__throttle_swap,
- [PERF_RECORD_UNTHROTTLE] = perf_event__throttle_swap,
[PERF_RECORD_SAMPLE] = perf_event__all64_swap,
[PERF_RECORD_HEADER_ATTR] = perf_event__hdr_attr_swap,
[PERF_RECORD_HEADER_EVENT_TYPE] = perf_event__event_type_swap,
@@ -502,16 +525,13 @@ static int flush_sample_queue(struct perf_session *s,
struct perf_sample sample;
u64 limit = os->next_flush;
u64 last_ts = os->last_sample ? os->last_sample->timestamp : 0ULL;
+ unsigned idx = 0, progress_next = os->nr_samples / 16;
bool show_progress = limit == ULLONG_MAX;
- struct ui_progress prog;
int ret;
if (!tool->ordered_samples || !limit)
return 0;
- if (show_progress)
- ui_progress__init(&prog, os->nr_samples, "Processing time ordered events...");
-
list_for_each_entry_safe(iter, tmp, head, list) {
if (session_done())
return 0;
@@ -532,9 +552,11 @@ static int flush_sample_queue(struct perf_session *s,
os->last_flush = iter->timestamp;
list_del(&iter->list);
list_add(&iter->list, &os->sample_cache);
-
- if (show_progress)
- ui_progress__update(&prog, 1);
+ if (show_progress && (++idx >= progress_next)) {
+ progress_next += os->nr_samples / 16;
+ ui_progress__update(idx, os->nr_samples,
+ "Processing time ordered events...");
+ }
}
if (list_empty(head)) {
@@ -838,9 +860,6 @@ static void dump_sample(struct perf_evsel *evsel, union perf_event *event,
if (sample_type & PERF_SAMPLE_DATA_SRC)
printf(" . data_src: 0x%"PRIx64"\n", sample->data_src);
- if (sample_type & PERF_SAMPLE_TRANSACTION)
- printf("... transaction: %" PRIx64 "\n", sample->transaction);
-
if (sample_type & PERF_SAMPLE_READ)
sample_read__printf(sample, evsel->attr.read_format);
}
@@ -1012,7 +1031,6 @@ static int perf_session_deliver_event(struct perf_session *session,
static int perf_session__process_user_event(struct perf_session *session, union perf_event *event,
struct perf_tool *tool, u64 file_offset)
{
- int fd = perf_data_file__fd(session->file);
int err;
dump_event(session, event, file_offset, NULL);
@@ -1026,7 +1044,7 @@ static int perf_session__process_user_event(struct perf_session *session, union
return err;
case PERF_RECORD_HEADER_TRACING_DATA:
/* setup for reading amidst mmap */
- lseek(fd, file_offset, SEEK_SET);
+ lseek(session->fd, file_offset, SEEK_SET);
return tool->tracing_data(tool, event, session);
case PERF_RECORD_HEADER_BUILD_ID:
return tool->build_id(tool, event, session);
@@ -1083,11 +1101,11 @@ static int perf_session__process_event(struct perf_session *session,
file_offset);
}
-void perf_event_header__bswap(struct perf_event_header *hdr)
+void perf_event_header__bswap(struct perf_event_header *self)
{
- hdr->type = bswap_32(hdr->type);
- hdr->misc = bswap_16(hdr->misc);
- hdr->size = bswap_16(hdr->size);
+ self->type = bswap_32(self->type);
+ self->misc = bswap_16(self->misc);
+ self->size = bswap_16(self->size);
}
struct thread *perf_session__findnew(struct perf_session *session, pid_t pid)
@@ -1095,11 +1113,11 @@ struct thread *perf_session__findnew(struct perf_session *session, pid_t pid)
return machine__findnew_thread(&session->machines.host, 0, pid);
}
-static struct thread *perf_session__register_idle_thread(struct perf_session *session)
+static struct thread *perf_session__register_idle_thread(struct perf_session *self)
{
- struct thread *thread = perf_session__findnew(session, 0);
+ struct thread *thread = perf_session__findnew(self, 0);
- if (thread == NULL || thread__set_comm(thread, "swapper", 0)) {
+ if (thread == NULL || thread__set_comm(thread, "swapper")) {
pr_err("problem inserting idle task.\n");
thread = NULL;
}
@@ -1149,10 +1167,9 @@ static void perf_session__warn_about_errors(const struct perf_session *session,
volatile int session_done;
-static int __perf_session__process_pipe_events(struct perf_session *session,
+static int __perf_session__process_pipe_events(struct perf_session *self,
struct perf_tool *tool)
{
- int fd = perf_data_file__fd(session->file);
union perf_event *event;
uint32_t size, cur_size = 0;
void *buf = NULL;
@@ -1171,7 +1188,7 @@ static int __perf_session__process_pipe_events(struct perf_session *session,
return -errno;
more:
event = buf;
- err = readn(fd, event, sizeof(struct perf_event_header));
+ err = readn(self->fd, event, sizeof(struct perf_event_header));
if (err <= 0) {
if (err == 0)
goto done;
@@ -1180,7 +1197,7 @@ more:
goto out_err;
}
- if (session->header.needs_swap)
+ if (self->header.needs_swap)
perf_event_header__bswap(&event->header);
size = event->header.size;
@@ -1203,7 +1220,7 @@ more:
p += sizeof(struct perf_event_header);
if (size - sizeof(struct perf_event_header)) {
- err = readn(fd, p, size - sizeof(struct perf_event_header));
+ err = readn(self->fd, p, size - sizeof(struct perf_event_header));
if (err <= 0) {
if (err == 0) {
pr_err("unexpected end of event stream\n");
@@ -1215,7 +1232,7 @@ more:
}
}
- if ((skip = perf_session__process_event(session, event, tool, head)) < 0) {
+ if ((skip = perf_session__process_event(self, event, tool, head)) < 0) {
pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n",
head, event->header.size, event->header.type);
err = -EINVAL;
@@ -1230,13 +1247,11 @@ more:
if (!session_done())
goto more;
done:
- /* do the final flush for ordered samples */
- session->ordered_samples.next_flush = ULLONG_MAX;
- err = flush_sample_queue(session, tool);
+ err = 0;
out_err:
free(buf);
- perf_session__warn_about_errors(session, tool);
- perf_session_free_sample_buffers(session);
+ perf_session__warn_about_errors(self, tool);
+ perf_session_free_sample_buffers(self);
return err;
}
@@ -1284,14 +1299,12 @@ int __perf_session__process_events(struct perf_session *session,
u64 data_offset, u64 data_size,
u64 file_size, struct perf_tool *tool)
{
- int fd = perf_data_file__fd(session->file);
- u64 head, page_offset, file_offset, file_pos;
+ u64 head, page_offset, file_offset, file_pos, progress_next;
int err, mmap_prot, mmap_flags, map_idx = 0;
size_t mmap_size;
char *buf, *mmaps[NUM_MMAPS];
union perf_event *event;
uint32_t size;
- struct ui_progress prog;
perf_tool__fill_defaults(tool);
@@ -1302,7 +1315,7 @@ int __perf_session__process_events(struct perf_session *session,
if (data_size && (data_offset + data_size < file_size))
file_size = data_offset + data_size;
- ui_progress__init(&prog, file_size, "Processing events...");
+ progress_next = file_size / 16;
mmap_size = MMAP_SIZE;
if (mmap_size > file_size)
@@ -1318,7 +1331,7 @@ int __perf_session__process_events(struct perf_session *session,
mmap_flags = MAP_PRIVATE;
}
remap:
- buf = mmap(NULL, mmap_size, mmap_prot, mmap_flags, fd,
+ buf = mmap(NULL, mmap_size, mmap_prot, mmap_flags, session->fd,
file_offset);
if (buf == MAP_FAILED) {
pr_err("failed to mmap file\n");
@@ -1357,15 +1370,19 @@ more:
head += size;
file_pos += size;
- ui_progress__update(&prog, size);
+ if (file_pos >= progress_next) {
+ progress_next += file_size / 16;
+ ui_progress__update(file_pos, file_size,
+ "Processing events...");
+ }
+ err = 0;
if (session_done())
- goto out;
+ goto out_err;
if (file_pos < file_size)
goto more;
-out:
/* do the final flush for ordered samples */
session->ordered_samples.next_flush = ULLONG_MAX;
err = flush_sample_queue(session, tool);
@@ -1376,22 +1393,21 @@ out_err:
return err;
}
-int perf_session__process_events(struct perf_session *session,
+int perf_session__process_events(struct perf_session *self,
struct perf_tool *tool)
{
- u64 size = perf_data_file__size(session->file);
int err;
- if (perf_session__register_idle_thread(session) == NULL)
+ if (perf_session__register_idle_thread(self) == NULL)
return -ENOMEM;
- if (!perf_data_file__is_pipe(session->file))
- err = __perf_session__process_events(session,
- session->header.data_offset,
- session->header.data_size,
- size, tool);
+ if (!self->fd_pipe)
+ err = __perf_session__process_events(self,
+ self->header.data_offset,
+ self->header.data_size,
+ self->size, tool);
else
- err = __perf_session__process_pipe_events(session, tool);
+ err = __perf_session__process_pipe_events(self, tool);
return err;
}
@@ -1440,15 +1456,15 @@ int maps__set_kallsyms_ref_reloc_sym(struct map **maps,
return 0;
}
-size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp)
+size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp)
{
- return machines__fprintf_dsos(&session->machines, fp);
+ return machines__fprintf_dsos(&self->machines, fp);
}
-size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp,
+size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp,
bool (skip)(struct dso *dso, int parm), int parm)
{
- return machines__fprintf_dsos_buildid(&session->machines, fp, skip, parm);
+ return machines__fprintf_dsos_buildid(&self->machines, fp, skip, parm);
}
size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp)
@@ -1509,8 +1525,7 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, union perf_event *event,
if (symbol_conf.use_callchain && sample->callchain) {
if (machine__resolve_callchain(machine, evsel, al.thread,
- sample, NULL, NULL,
- PERF_MAX_STACK_DEPTH) != 0) {
+ sample, NULL, NULL) != 0) {
if (verbose)
error("Failed to resolve callchain. Skipping\n");
return;
@@ -1614,14 +1629,13 @@ int perf_session__cpu_bitmap(struct perf_session *session,
void perf_session__fprintf_info(struct perf_session *session, FILE *fp,
bool full)
{
- int fd = perf_data_file__fd(session->file);
struct stat st;
int ret;
if (session == NULL || fp == NULL)
return;
- ret = fstat(fd, &st);
+ ret = fstat(session->fd, &st);
if (ret == -1)
return;
@@ -1650,9 +1664,9 @@ int __perf_session__set_tracepoints_handlers(struct perf_session *session,
continue;
err = -EEXIST;
- if (evsel->handler != NULL)
+ if (evsel->handler.func != NULL)
goto out;
- evsel->handler = assocs[i].handler;
+ evsel->handler.func = assocs[i].handler;
}
err = 0;
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 50f6409..04bf737 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -7,7 +7,6 @@
#include "machine.h"
#include "symbol.h"
#include "thread.h"
-#include "data.h"
#include <linux/rbtree.h>
#include <linux/perf_event.h>
@@ -30,13 +29,16 @@ struct ordered_samples {
struct perf_session {
struct perf_header header;
+ unsigned long size;
struct machines machines;
struct perf_evlist *evlist;
struct pevent *pevent;
struct events_stats stats;
+ int fd;
+ bool fd_pipe;
bool repipe;
struct ordered_samples ordered_samples;
- struct perf_data_file *file;
+ char filename[1];
};
#define PRINT_IP_OPT_IP (1<<0)
@@ -47,16 +49,17 @@ struct perf_session {
struct perf_tool;
-struct perf_session *perf_session__new(struct perf_data_file *file,
- bool repipe, struct perf_tool *tool);
+struct perf_session *perf_session__new(const char *filename, int mode,
+ bool force, bool repipe,
+ struct perf_tool *tool);
void perf_session__delete(struct perf_session *session);
-void perf_event_header__bswap(struct perf_event_header *hdr);
+void perf_event_header__bswap(struct perf_event_header *self);
-int __perf_session__process_events(struct perf_session *session,
+int __perf_session__process_events(struct perf_session *self,
u64 data_offset, u64 data_size, u64 size,
struct perf_tool *tool);
-int perf_session__process_events(struct perf_session *session,
+int perf_session__process_events(struct perf_session *self,
struct perf_tool *tool);
int perf_session_queue_event(struct perf_session *s, union perf_event *event,
@@ -64,38 +67,37 @@ int perf_session_queue_event(struct perf_session *s, union perf_event *event,
void perf_tool__fill_defaults(struct perf_tool *tool);
-int perf_session__resolve_callchain(struct perf_session *session,
- struct perf_evsel *evsel,
+int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel *evsel,
struct thread *thread,
struct ip_callchain *chain,
struct symbol **parent);
-bool perf_session__has_traces(struct perf_session *session, const char *msg);
+bool perf_session__has_traces(struct perf_session *self, const char *msg);
void mem_bswap_64(void *src, int byte_size);
void mem_bswap_32(void *src, int byte_size);
void perf_event__attr_swap(struct perf_event_attr *attr);
-int perf_session__create_kernel_maps(struct perf_session *session);
+int perf_session__create_kernel_maps(struct perf_session *self);
void perf_session__set_id_hdr_size(struct perf_session *session);
static inline
-struct machine *perf_session__find_machine(struct perf_session *session, pid_t pid)
+struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid)
{
- return machines__find(&session->machines, pid);
+ return machines__find(&self->machines, pid);
}
static inline
-struct machine *perf_session__findnew_machine(struct perf_session *session, pid_t pid)
+struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid)
{
- return machines__findnew(&session->machines, pid);
+ return machines__findnew(&self->machines, pid);
}
-struct thread *perf_session__findnew(struct perf_session *session, pid_t pid);
-size_t perf_session__fprintf(struct perf_session *session, FILE *fp);
+struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
+size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
-size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp);
+size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp);
size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp,
bool (fn)(struct dso *dso, int parm), int parm);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 8b0bb1f..5f118a0 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1,6 +1,5 @@
#include "sort.h"
#include "hist.h"
-#include "comm.h"
#include "symbol.h"
regex_t parent_regex;
@@ -43,7 +42,7 @@ static int repsep_snprintf(char *bf, size_t size, const char *fmt, ...)
return n;
}
-static int64_t cmp_null(const void *l, const void *r)
+static int64_t cmp_null(void *l, void *r)
{
if (!l && !r)
return 0;
@@ -61,12 +60,11 @@ sort__thread_cmp(struct hist_entry *left, struct hist_entry *right)
return right->thread->tid - left->thread->tid;
}
-static int hist_entry__thread_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__thread_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
- const char *comm = thread__comm_str(he->thread);
return repsep_snprintf(bf, size, "%*s:%5d", width - 6,
- comm ?: "", he->thread->tid);
+ self->thread->comm ?: "", self->thread->tid);
}
struct sort_entry sort_thread = {
@@ -81,21 +79,25 @@ struct sort_entry sort_thread = {
static int64_t
sort__comm_cmp(struct hist_entry *left, struct hist_entry *right)
{
- /* Compare the addr that should be unique among comm */
- return comm__str(right->comm) - comm__str(left->comm);
+ return right->thread->tid - left->thread->tid;
}
static int64_t
sort__comm_collapse(struct hist_entry *left, struct hist_entry *right)
{
- /* Compare the addr that should be unique among comm */
- return comm__str(right->comm) - comm__str(left->comm);
+ char *comm_l = left->thread->comm;
+ char *comm_r = right->thread->comm;
+
+ if (!comm_l || !comm_r)
+ return cmp_null(comm_l, comm_r);
+
+ return strcmp(comm_l, comm_r);
}
-static int hist_entry__comm_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__comm_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
- return repsep_snprintf(bf, size, "%*s", width, comm__str(he->comm));
+ return repsep_snprintf(bf, size, "%*s", width, self->thread->comm);
}
struct sort_entry sort_comm = {
@@ -146,10 +148,10 @@ static int _hist_entry__dso_snprintf(struct map *map, char *bf,
return repsep_snprintf(bf, size, "%-*s", width, "[unknown]");
}
-static int hist_entry__dso_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__dso_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
- return _hist_entry__dso_snprintf(he->ms.map, bf, size, width);
+ return _hist_entry__dso_snprintf(self->ms.map, bf, size, width);
}
struct sort_entry sort_dso = {
@@ -180,19 +182,9 @@ static int64_t _sort__sym_cmp(struct symbol *sym_l, struct symbol *sym_r)
static int64_t
sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
{
- int64_t ret;
-
if (!left->ms.sym && !right->ms.sym)
return right->level - left->level;
- /*
- * comparing symbol address alone is not enough since it's a
- * relative address within a dso.
- */
- ret = sort__dso_cmp(left, right);
- if (ret != 0)
- return ret;
-
return _sort__sym_cmp(left->ms.sym, right->ms.sym);
}
@@ -232,11 +224,11 @@ static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym,
return ret;
}
-static int hist_entry__sym_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__sym_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
- return _hist_entry__sym_snprintf(he->ms.map, he->ms.sym, he->ip,
- he->level, bf, size, width);
+ return _hist_entry__sym_snprintf(self->ms.map, self->ms.sym, self->ip,
+ self->level, bf, size, width);
}
struct sort_entry sort_sym = {
@@ -251,32 +243,50 @@ struct sort_entry sort_sym = {
static int64_t
sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right)
{
- if (!left->srcline) {
- if (!left->ms.map)
- left->srcline = SRCLINE_UNKNOWN;
- else {
- struct map *map = left->ms.map;
- left->srcline = get_srcline(map->dso,
- map__rip_2objdump(map, left->ip));
- }
- }
- if (!right->srcline) {
- if (!right->ms.map)
- right->srcline = SRCLINE_UNKNOWN;
- else {
- struct map *map = right->ms.map;
- right->srcline = get_srcline(map->dso,
- map__rip_2objdump(map, right->ip));
- }
- }
- return strcmp(left->srcline, right->srcline);
+ return (int64_t)(right->ip - left->ip);
}
-static int hist_entry__srcline_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf,
size_t size,
unsigned int width __maybe_unused)
{
- return repsep_snprintf(bf, size, "%s", he->srcline);
+ FILE *fp = NULL;
+ char cmd[PATH_MAX + 2], *path = self->srcline, *nl;
+ size_t line_len;
+
+ if (path != NULL)
+ goto out_path;
+
+ if (!self->ms.map)
+ goto out_ip;
+
+ if (!strncmp(self->ms.map->dso->long_name, "/tmp/perf-", 10))
+ goto out_ip;
+
+ snprintf(cmd, sizeof(cmd), "addr2line -e %s %016" PRIx64,
+ self->ms.map->dso->long_name, self->ip);
+ fp = popen(cmd, "r");
+ if (!fp)
+ goto out_ip;
+
+ if (getline(&path, &line_len, fp) < 0 || !line_len)
+ goto out_ip;
+ self->srcline = strdup(path);
+ if (self->srcline == NULL)
+ goto out_ip;
+
+ nl = strchr(self->srcline, '\n');
+ if (nl != NULL)
+ *nl = '\0';
+ path = self->srcline;
+out_path:
+ if (fp)
+ pclose(fp);
+ return repsep_snprintf(bf, size, "%s", path);
+out_ip:
+ if (fp)
+ pclose(fp);
+ return repsep_snprintf(bf, size, "%-#*llx", BITS_PER_LONG / 4, self->ip);
}
struct sort_entry sort_srcline = {
@@ -300,11 +310,11 @@ sort__parent_cmp(struct hist_entry *left, struct hist_entry *right)
return strcmp(sym_l->name, sym_r->name);
}
-static int hist_entry__parent_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__parent_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
return repsep_snprintf(bf, size, "%-*s", width,
- he->parent ? he->parent->name : "[other]");
+ self->parent ? self->parent->name : "[other]");
}
struct sort_entry sort_parent = {
@@ -322,10 +332,10 @@ sort__cpu_cmp(struct hist_entry *left, struct hist_entry *right)
return right->cpu - left->cpu;
}
-static int hist_entry__cpu_snprintf(struct hist_entry *he, char *bf,
- size_t size, unsigned int width)
+static int hist_entry__cpu_snprintf(struct hist_entry *self, char *bf,
+ size_t size, unsigned int width)
{
- return repsep_snprintf(bf, size, "%*d", width, he->cpu);
+ return repsep_snprintf(bf, size, "%*d", width, self->cpu);
}
struct sort_entry sort_cpu = {
@@ -344,10 +354,10 @@ sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right)
right->branch_info->from.map);
}
-static int hist_entry__dso_from_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__dso_from_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
- return _hist_entry__dso_snprintf(he->branch_info->from.map,
+ return _hist_entry__dso_snprintf(self->branch_info->from.map,
bf, size, width);
}
@@ -358,10 +368,10 @@ sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right)
right->branch_info->to.map);
}
-static int hist_entry__dso_to_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__dso_to_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
- return _hist_entry__dso_snprintf(he->branch_info->to.map,
+ return _hist_entry__dso_snprintf(self->branch_info->to.map,
bf, size, width);
}
@@ -389,21 +399,21 @@ sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right)
return _sort__sym_cmp(to_l->sym, to_r->sym);
}
-static int hist_entry__sym_from_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__sym_from_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
- struct addr_map_symbol *from = &he->branch_info->from;
+ struct addr_map_symbol *from = &self->branch_info->from;
return _hist_entry__sym_snprintf(from->map, from->sym, from->addr,
- he->level, bf, size, width);
+ self->level, bf, size, width);
}
-static int hist_entry__sym_to_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__sym_to_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
- struct addr_map_symbol *to = &he->branch_info->to;
+ struct addr_map_symbol *to = &self->branch_info->to;
return _hist_entry__sym_snprintf(to->map, to->sym, to->addr,
- he->level, bf, size, width);
+ self->level, bf, size, width);
}
@@ -446,13 +456,13 @@ sort__mispredict_cmp(struct hist_entry *left, struct hist_entry *right)
return mp || p;
}
-static int hist_entry__mispredict_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__mispredict_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width){
static const char *out = "N/A";
- if (he->branch_info->flags.predicted)
+ if (self->branch_info->flags.predicted)
out = "N";
- else if (he->branch_info->flags.mispred)
+ else if (self->branch_info->flags.mispred)
out = "Y";
return repsep_snprintf(bf, size, "%-*s", width, out);
@@ -472,19 +482,19 @@ sort__daddr_cmp(struct hist_entry *left, struct hist_entry *right)
return (int64_t)(r - l);
}
-static int hist_entry__daddr_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__daddr_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
uint64_t addr = 0;
struct map *map = NULL;
struct symbol *sym = NULL;
- if (he->mem_info) {
- addr = he->mem_info->daddr.addr;
- map = he->mem_info->daddr.map;
- sym = he->mem_info->daddr.sym;
+ if (self->mem_info) {
+ addr = self->mem_info->daddr.addr;
+ map = self->mem_info->daddr.map;
+ sym = self->mem_info->daddr.sym;
}
- return _hist_entry__sym_snprintf(map, sym, addr, he->level, bf, size,
+ return _hist_entry__sym_snprintf(map, sym, addr, self->level, bf, size,
width);
}
@@ -502,13 +512,13 @@ sort__dso_daddr_cmp(struct hist_entry *left, struct hist_entry *right)
return _sort__dso_cmp(map_l, map_r);
}
-static int hist_entry__dso_daddr_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__dso_daddr_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
struct map *map = NULL;
- if (he->mem_info)
- map = he->mem_info->daddr.map;
+ if (self->mem_info)
+ map = self->mem_info->daddr.map;
return _hist_entry__dso_snprintf(map, bf, size, width);
}
@@ -532,14 +542,14 @@ sort__locked_cmp(struct hist_entry *left, struct hist_entry *right)
return (int64_t)(data_src_r.mem_lock - data_src_l.mem_lock);
}
-static int hist_entry__locked_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__locked_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
const char *out;
u64 mask = PERF_MEM_LOCK_NA;
- if (he->mem_info)
- mask = he->mem_info->data_src.mem_lock;
+ if (self->mem_info)
+ mask = self->mem_info->data_src.mem_lock;
if (mask & PERF_MEM_LOCK_NA)
out = "N/A";
@@ -581,7 +591,7 @@ static const char * const tlb_access[] = {
};
#define NUM_TLB_ACCESS (sizeof(tlb_access)/sizeof(const char *))
-static int hist_entry__tlb_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__tlb_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
char out[64];
@@ -592,8 +602,8 @@ static int hist_entry__tlb_snprintf(struct hist_entry *he, char *bf,
out[0] = '\0';
- if (he->mem_info)
- m = he->mem_info->data_src.mem_dtlb;
+ if (self->mem_info)
+ m = self->mem_info->data_src.mem_dtlb;
hit = m & PERF_MEM_TLB_HIT;
miss = m & PERF_MEM_TLB_MISS;
@@ -658,7 +668,7 @@ static const char * const mem_lvl[] = {
};
#define NUM_MEM_LVL (sizeof(mem_lvl)/sizeof(const char *))
-static int hist_entry__lvl_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__lvl_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
char out[64];
@@ -667,8 +677,8 @@ static int hist_entry__lvl_snprintf(struct hist_entry *he, char *bf,
u64 m = PERF_MEM_LVL_NA;
u64 hit, miss;
- if (he->mem_info)
- m = he->mem_info->data_src.mem_lvl;
+ if (self->mem_info)
+ m = self->mem_info->data_src.mem_lvl;
out[0] = '\0';
@@ -726,7 +736,7 @@ static const char * const snoop_access[] = {
};
#define NUM_SNOOP_ACCESS (sizeof(snoop_access)/sizeof(const char *))
-static int hist_entry__snoop_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__snoop_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
char out[64];
@@ -736,8 +746,8 @@ static int hist_entry__snoop_snprintf(struct hist_entry *he, char *bf,
out[0] = '\0';
- if (he->mem_info)
- m = he->mem_info->data_src.mem_snoop;
+ if (self->mem_info)
+ m = self->mem_info->data_src.mem_snoop;
for (i = 0; m && i < NUM_SNOOP_ACCESS; i++, m >>= 1) {
if (!(m & 0x1))
@@ -774,10 +784,10 @@ sort__local_weight_cmp(struct hist_entry *left, struct hist_entry *right)
return he_weight(left) - he_weight(right);
}
-static int hist_entry__local_weight_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__local_weight_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
- return repsep_snprintf(bf, size, "%-*llu", width, he_weight(he));
+ return repsep_snprintf(bf, size, "%-*llu", width, he_weight(self));
}
struct sort_entry sort_local_weight = {
@@ -793,10 +803,10 @@ sort__global_weight_cmp(struct hist_entry *left, struct hist_entry *right)
return left->stat.weight - right->stat.weight;
}
-static int hist_entry__global_weight_snprintf(struct hist_entry *he, char *bf,
+static int hist_entry__global_weight_snprintf(struct hist_entry *self, char *bf,
size_t size, unsigned int width)
{
- return repsep_snprintf(bf, size, "%-*llu", width, he->stat.weight);
+ return repsep_snprintf(bf, size, "%-*llu", width, self->stat.weight);
}
struct sort_entry sort_global_weight = {
@@ -848,127 +858,6 @@ struct sort_entry sort_mem_snoop = {
.se_width_idx = HISTC_MEM_SNOOP,
};
-static int64_t
-sort__abort_cmp(struct hist_entry *left, struct hist_entry *right)
-{
- return left->branch_info->flags.abort !=
- right->branch_info->flags.abort;
-}
-
-static int hist_entry__abort_snprintf(struct hist_entry *he, char *bf,
- size_t size, unsigned int width)
-{
- static const char *out = ".";
-
- if (he->branch_info->flags.abort)
- out = "A";
- return repsep_snprintf(bf, size, "%-*s", width, out);
-}
-
-struct sort_entry sort_abort = {
- .se_header = "Transaction abort",
- .se_cmp = sort__abort_cmp,
- .se_snprintf = hist_entry__abort_snprintf,
- .se_width_idx = HISTC_ABORT,
-};
-
-static int64_t
-sort__in_tx_cmp(struct hist_entry *left, struct hist_entry *right)
-{
- return left->branch_info->flags.in_tx !=
- right->branch_info->flags.in_tx;
-}
-
-static int hist_entry__in_tx_snprintf(struct hist_entry *he, char *bf,
- size_t size, unsigned int width)
-{
- static const char *out = ".";
-
- if (he->branch_info->flags.in_tx)
- out = "T";
-
- return repsep_snprintf(bf, size, "%-*s", width, out);
-}
-
-struct sort_entry sort_in_tx = {
- .se_header = "Branch in transaction",
- .se_cmp = sort__in_tx_cmp,
- .se_snprintf = hist_entry__in_tx_snprintf,
- .se_width_idx = HISTC_IN_TX,
-};
-
-static int64_t
-sort__transaction_cmp(struct hist_entry *left, struct hist_entry *right)
-{
- return left->transaction - right->transaction;
-}
-
-static inline char *add_str(char *p, const char *str)
-{
- strcpy(p, str);
- return p + strlen(str);
-}
-
-static struct txbit {
- unsigned flag;
- const char *name;
- int skip_for_len;
-} txbits[] = {
- { PERF_TXN_ELISION, "EL ", 0 },
- { PERF_TXN_TRANSACTION, "TX ", 1 },
- { PERF_TXN_SYNC, "SYNC ", 1 },
- { PERF_TXN_ASYNC, "ASYNC ", 0 },
- { PERF_TXN_RETRY, "RETRY ", 0 },
- { PERF_TXN_CONFLICT, "CON ", 0 },
- { PERF_TXN_CAPACITY_WRITE, "CAP-WRITE ", 1 },
- { PERF_TXN_CAPACITY_READ, "CAP-READ ", 0 },
- { 0, NULL, 0 }
-};
-
-int hist_entry__transaction_len(void)
-{
- int i;
- int len = 0;
-
- for (i = 0; txbits[i].name; i++) {
- if (!txbits[i].skip_for_len)
- len += strlen(txbits[i].name);
- }
- len += 4; /* :XX<space> */
- return len;
-}
-
-static int hist_entry__transaction_snprintf(struct hist_entry *he, char *bf,
- size_t size, unsigned int width)
-{
- u64 t = he->transaction;
- char buf[128];
- char *p = buf;
- int i;
-
- buf[0] = 0;
- for (i = 0; txbits[i].name; i++)
- if (txbits[i].flag & t)
- p = add_str(p, txbits[i].name);
- if (t && !(t & (PERF_TXN_SYNC|PERF_TXN_ASYNC)))
- p = add_str(p, "NEITHER ");
- if (t & PERF_TXN_ABORT_MASK) {
- sprintf(p, ":%" PRIx64,
- (t & PERF_TXN_ABORT_MASK) >>
- PERF_TXN_ABORT_SHIFT);
- p += strlen(p);
- }
-
- return repsep_snprintf(bf, size, "%-*s", width, buf);
-}
-
-struct sort_entry sort_transaction = {
- .se_header = "Transaction ",
- .se_cmp = sort__transaction_cmp,
- .se_snprintf = hist_entry__transaction_snprintf,
- .se_width_idx = HISTC_TRANSACTION,
-};
-
struct sort_dimension {
const char *name;
struct sort_entry *entry;
@@ -987,7 +876,6 @@ static struct sort_dimension common_sort_dimensions[] = {
DIM(SORT_SRCLINE, "srcline", sort_srcline),
DIM(SORT_LOCAL_WEIGHT, "local_weight", sort_local_weight),
DIM(SORT_GLOBAL_WEIGHT, "weight", sort_global_weight),
- DIM(SORT_TRANSACTION, "transaction", sort_transaction),
};
#undef DIM
@@ -1000,8 +888,6 @@ static struct sort_dimension bstack_sort_dimensions[] = {
DIM(SORT_SYM_FROM, "symbol_from", sort_sym_from),
DIM(SORT_SYM_TO, "symbol_to", sort_sym_to),
DIM(SORT_MISPREDICT, "mispredict", sort_mispredict),
- DIM(SORT_IN_TX, "in_tx", sort_in_tx),
- DIM(SORT_ABORT, "abort", sort_abort),
};
#undef DIM
@@ -1123,7 +1009,7 @@ int setup_sorting(void)
return ret;
}
-static void sort_entry__setup_elide(struct sort_entry *se,
+static void sort_entry__setup_elide(struct sort_entry *self,
struct strlist *list,
const char *list_name, FILE *fp)
{
@@ -1131,14 +1017,12 @@ static void sort_entry__setup_elide(struct sort_entry *se,
if (fp != NULL)
fprintf(fp, "# %s: %s\n", list_name,
strlist__entry(list, 0)->s);
- se->elide = true;
+ self->elide = true;
}
}
void sort__setup_elide(FILE *output)
{
- struct sort_entry *se;
-
sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
"dso", output);
sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list,
@@ -1174,15 +1058,4 @@ void sort__setup_elide(FILE *output)
"snoop", output);
}
- /*
- * It makes no sense to elide all of sort entries.
- * Just revert them to show up again.
- */
- list_for_each_entry(se, &hist_entry__sort_list, list) {
- if (!se->elide)
- return;
- }
-
- list_for_each_entry(se, &hist_entry__sort_list, list)
- se->elide = false;
}
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 43e5ff4..4e80dbd 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -22,6 +22,7 @@
#include "parse-events.h"
#include "thread.h"
+#include "sort.h"
extern regex_t parent_regex;
extern const char *sort_order;
@@ -83,9 +84,7 @@ struct hist_entry {
struct he_stat stat;
struct map_symbol ms;
struct thread *thread;
- struct comm *comm;
u64 ip;
- u64 transaction;
s32 cpu;
struct hist_entry_diff diff;
@@ -146,7 +145,6 @@ enum sort_type {
SORT_SRCLINE,
SORT_LOCAL_WEIGHT,
SORT_GLOBAL_WEIGHT,
- SORT_TRANSACTION,
/* branch stack specific sort keys */
__SORT_BRANCH_STACK,
@@ -155,8 +153,6 @@ enum sort_type {
SORT_SYM_FROM,
SORT_SYM_TO,
SORT_MISPREDICT,
- SORT_ABORT,
- SORT_IN_TX,
/* memory mode specific sort keys */
__SORT_MEMORY_MODE,
@@ -179,7 +175,7 @@ struct sort_entry {
int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *);
int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *);
- int (*se_snprintf)(struct hist_entry *he, char *bf, size_t size,
+ int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size,
unsigned int width);
u8 se_width_idx;
bool elide;
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
deleted file mode 100644
index d11aefb..0000000
--- a/tools/perf/util/srcline.c
+++ /dev/null
@@ -1,265 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <linux/kernel.h>
-
-#include "util/dso.h"
-#include "util/util.h"
-#include "util/debug.h"
-
-#ifdef HAVE_LIBBFD_SUPPORT
-
-/*
- * Implement addr2line using libbfd.
- */
-#define PACKAGE "perf"
-#include <bfd.h>
-
-struct a2l_data {
- const char *input;
- unsigned long addr;
-
- bool found;
- const char *filename;
- const char *funcname;
- unsigned line;
-
- bfd *abfd;
- asymbol **syms;
-};
-
-static int bfd_error(const char *string)
-{
- const char *errmsg;
-
- errmsg = bfd_errmsg(bfd_get_error());
- fflush(stdout);
-
- if (string)
- pr_debug("%s: %s\n", string, errmsg);
- else
- pr_debug("%s\n", errmsg);
-
- return -1;
-}
-
-static int slurp_symtab(bfd *abfd, struct a2l_data *a2l)
-{
- long storage;
- long symcount;
- asymbol **syms;
- bfd_boolean dynamic = FALSE;
-
- if ((bfd_get_file_flags(abfd) & HAS_SYMS) == 0)
- return bfd_error(bfd_get_filename(abfd));
-
- storage = bfd_get_symtab_upper_bound(abfd);
- if (storage == 0L) {
- storage = bfd_get_dynamic_symtab_upper_bound(abfd);
- dynamic = TRUE;
- }
- if (storage < 0L)
- return bfd_error(bfd_get_filename(abfd));
-
- syms = malloc(storage);
- if (dynamic)
- symcount = bfd_canonicalize_dynamic_symtab(abfd, syms);
- else
- symcount = bfd_canonicalize_symtab(abfd, syms);
-
- if (symcount < 0) {
- free(syms);
- return bfd_error(bfd_get_filename(abfd));
- }
-
- a2l->syms = syms;
- return 0;
-}
-
-static void find_address_in_section(bfd *abfd, asection *section, void *data)
-{
- bfd_vma pc, vma;
- bfd_size_type size;
- struct a2l_data *a2l = data;
-
- if (a2l->found)
- return;
-
- if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
- return;
-
- pc = a2l->addr;
- vma = bfd_get_section_vma(abfd, section);
- size = bfd_get_section_size(section);
-
- if (pc < vma || pc >= vma + size)
- return;
-
- a2l->found = bfd_find_nearest_line(abfd, section, a2l->syms, pc - vma,
- &a2l->filename, &a2l->funcname,
- &a2l->line);
-}
-
-static struct a2l_data *addr2line_init(const char *path)
-{
- bfd *abfd;
- struct a2l_data *a2l = NULL;
-
- abfd = bfd_openr(path, NULL);
- if (abfd == NULL)
- return NULL;
-
- if (!bfd_check_format(abfd, bfd_object))
- goto out;
-
- a2l = zalloc(sizeof(*a2l));
- if (a2l == NULL)
- goto out;
-
- a2l->abfd = abfd;
- a2l->input = strdup(path);
- if (a2l->input == NULL)
- goto out;
-
- if (slurp_symtab(abfd, a2l))
- goto out;
-
- return a2l;
-
-out:
- if (a2l) {
- free((void *)a2l->input);
- free(a2l);
- }
- bfd_close(abfd);
- return NULL;
-}
-
-static void addr2line_cleanup(struct a2l_data *a2l)
-{
- if (a2l->abfd)
- bfd_close(a2l->abfd);
- free((void *)a2l->input);
- free(a2l->syms);
- free(a2l);
-}
-
-static int addr2line(const char *dso_name, unsigned long addr,
- char **file, unsigned int *line)
-{
- int ret = 0;
- struct a2l_data *a2l;
-
- a2l = addr2line_init(dso_name);
- if (a2l == NULL) {
- pr_warning("addr2line_init failed for %s\n", dso_name);
- return 0;
- }
-
- a2l->addr = addr;
- bfd_map_over_sections(a2l->abfd, find_address_in_section, a2l);
-
- if (a2l->found && a2l->filename) {
- *file = strdup(a2l->filename);
- *line = a2l->line;
-
- if (*file)
- ret = 1;
- }
-
- addr2line_cleanup(a2l);
- return ret;
-}
-
-#else /* HAVE_LIBBFD_SUPPORT */
-
-static int addr2line(const char *dso_name, unsigned long addr,
- char **file, unsigned int *line_nr)
-{
- FILE *fp;
- char cmd[PATH_MAX];
- char *filename = NULL;
- size_t len;
- char *sep;
- int ret = 0;
-
- scnprintf(cmd, sizeof(cmd), "addr2line -e %s %016"PRIx64,
- dso_name, addr);
-
- fp = popen(cmd, "r");
- if (fp == NULL) {
- pr_warning("popen failed for %s\n", dso_name);
- return 0;
- }
-
- if (getline(&filename, &len, fp) < 0 || !len) {
- pr_warning("addr2line has no output for %s\n", dso_name);
- goto out;
- }
-
- sep = strchr(filename, '\n');
- if (sep)
- *sep = '\0';
-
- if (!strcmp(filename, "??:0")) {
- pr_debug("no debugging info in %s\n", dso_name);
- free(filename);
- goto out;
- }
-
- sep = strchr(filename, ':');
- if (sep) {
- *sep++ = '\0';
- *file = filename;
- *line_nr = strtoul(sep, NULL, 0);
- ret = 1;
- }
-out:
- pclose(fp);
- return ret;
-}
-#endif /* HAVE_LIBBFD_SUPPORT */
-
-char *get_srcline(struct dso *dso, unsigned long addr)
-{
- char *file = NULL;
- unsigned line = 0;
- char *srcline;
- char *dso_name = dso->long_name;
- size_t size;
-
- if (!dso->has_srcline)
- return SRCLINE_UNKNOWN;
-
- if (dso_name[0] == '[')
- goto out;
-
- if (!strncmp(dso_name, "/tmp/perf-", 10))
- goto out;
-
- if (!addr2line(dso_name, addr, &file, &line))
- goto out;
-
- /* just calculate actual length */
- size = snprintf(NULL, 0, "%s:%u", file, line) + 1;
-
- srcline = malloc(size);
- if (srcline)
- snprintf(srcline, size, "%s:%u", file, line);
- else
- srcline = SRCLINE_UNKNOWN;
-
- free(file);
- return srcline;
-
-out:
- dso->has_srcline = 0;
- return SRCLINE_UNKNOWN;
-}
-
-void free_srcline(char *srcline)
-{
- if (srcline && strcmp(srcline, SRCLINE_UNKNOWN) != 0)
- free(srcline);
-}
diff --git a/tools/perf/util/strfilter.c b/tools/perf/util/strfilter.c
index 3edd053..834c8eb 100644
--- a/tools/perf/util/strfilter.c
+++ b/tools/perf/util/strfilter.c
@@ -10,22 +10,22 @@ static const char *OP_not = "!"; /* Logical NOT */
#define is_operator(c) ((c) == '|' || (c) == '&' || (c) == '!')
#define is_separator(c) (is_operator(c) || (c) == '(' || (c) == ')')
-static void strfilter_node__delete(struct strfilter_node *node)
+static void strfilter_node__delete(struct strfilter_node *self)
{
- if (node) {
- if (node->p && !is_operator(*node->p))
- free((char *)node->p);
- strfilter_node__delete(node->l);
- strfilter_node__delete(node->r);
- free(node);
+ if (self) {
+ if (self->p && !is_operator(*self->p))
+ free((char *)self->p);
+ strfilter_node__delete(self->l);
+ strfilter_node__delete(self->r);
+ free(self);
}
}
-void strfilter__delete(struct strfilter *filter)
+void strfilter__delete(struct strfilter *self)
{
- if (filter) {
- strfilter_node__delete(filter->root);
- free(filter);
+ if (self) {
+ strfilter_node__delete(self->root);
+ free(self);
}
}
@@ -62,15 +62,15 @@ static struct strfilter_node *strfilter_node__alloc(const char *op,
struct strfilter_node *l,
struct strfilter_node *r)
{
- struct strfilter_node *node = zalloc(sizeof(*node));
+ struct strfilter_node *ret = zalloc(sizeof(struct strfilter_node));
- if (node) {
- node->p = op;
- node->l = l;
- node->r = r;
+ if (ret) {
+ ret->p = op;
+ ret->l = l;
+ ret->r = r;
}
- return node;
+ return ret;
}
static struct strfilter_node *strfilter_node__new(const char *s,
@@ -154,46 +154,46 @@ error:
*/
struct strfilter *strfilter__new(const char *rules, const char **err)
{
- struct strfilter *filter = zalloc(sizeof(*filter));
+ struct strfilter *ret = zalloc(sizeof(struct strfilter));
const char *ep = NULL;
- if (filter)
- filter->root = strfilter_node__new(rules, &ep);
+ if (ret)
+ ret->root = strfilter_node__new(rules, &ep);
- if (!filter || !filter->root || *ep != '\0') {
+ if (!ret || !ret->root || *ep != '\0') {
if (err)
*err = ep;
- strfilter__delete(filter);
- filter = NULL;
+ strfilter__delete(ret);
+ ret = NULL;
}
- return filter;
+ return ret;
}
-static bool strfilter_node__compare(struct strfilter_node *node,
+static bool strfilter_node__compare(struct strfilter_node *self,
const char *str)
{
- if (!node || !node->p)
+ if (!self || !self->p)
return false;
- switch (*node->p) {
+ switch (*self->p) {
case '|': /* OR */
- return strfilter_node__compare(node->l, str) ||
- strfilter_node__compare(node->r, str);
+ return strfilter_node__compare(self->l, str) ||
+ strfilter_node__compare(self->r, str);
case '&': /* AND */
- return strfilter_node__compare(node->l, str) &&
- strfilter_node__compare(node->r, str);
+ return strfilter_node__compare(self->l, str) &&
+ strfilter_node__compare(self->r, str);
case '!': /* NOT */
- return !strfilter_node__compare(node->r, str);
+ return !strfilter_node__compare(self->r, str);
default:
- return strglobmatch(str, node->p);
+ return strglobmatch(str, self->p);
}
}
/* Return true if STR matches the filter rules */
-bool strfilter__compare(struct strfilter *filter, const char *str)
+bool strfilter__compare(struct strfilter *self, const char *str)
{
- if (!filter)
+ if (!self)
return false;
- return strfilter_node__compare(filter->root, str);
+ return strfilter_node__compare(self->root, str);
}
diff --git a/tools/perf/util/strfilter.h b/tools/perf/util/strfilter.h
index fe611f3..00f58a7 100644
--- a/tools/perf/util/strfilter.h
+++ b/tools/perf/util/strfilter.h
@@ -30,19 +30,19 @@ struct strfilter *strfilter__new(const char *rules, const char **err);
/**
* strfilter__compare - compare given string and a string filter
- * @filter: String filter
+ * @self: String filter
* @str: target string
*
- * Compare @str and @filter. Return true if the str match the rule
+ * Compare @str and @self. Return true if the str match the rule
*/
-bool strfilter__compare(struct strfilter *filter, const char *str);
+bool strfilter__compare(struct strfilter *self, const char *str);
/**
* strfilter__delete - delete a string filter
- * @filter: String filter to delete
+ * @self: String filter to delete
*
- * Delete @filter.
+ * Delete @self.
*/
-void strfilter__delete(struct strfilter *filter);
+void strfilter__delete(struct strfilter *self);
#endif
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index eed0b96..a9c829b 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -8,7 +8,7 @@
#include "symbol.h"
#include "debug.h"
-#ifndef HAVE_ELF_GETPHDRNUM_SUPPORT
+#ifndef HAVE_ELF_GETPHDRNUM
static int elf_getphdrnum(Elf *elf, size_t *dst)
{
GElf_Ehdr gehdr;
@@ -487,27 +487,27 @@ int filename__read_debuglink(const char *filename, char *debuglink,
ek = elf_kind(elf);
if (ek != ELF_K_ELF)
- goto out_elf_end;
+ goto out_close;
if (gelf_getehdr(elf, &ehdr) == NULL) {
pr_err("%s: cannot get elf header.\n", __func__);
- goto out_elf_end;
+ goto out_close;
}
sec = elf_section_by_name(elf, &ehdr, &shdr,
".gnu_debuglink", NULL);
if (sec == NULL)
- goto out_elf_end;
+ goto out_close;
data = elf_getdata(sec, NULL);
if (data == NULL)
- goto out_elf_end;
+ goto out_close;
/* the start of this section is a zero-terminated string */
strncpy(debuglink, data->d_buf, size);
-out_elf_end:
elf_end(elf);
+
out_close:
close(fd);
out:
@@ -1018,601 +1018,6 @@ int file__read_maps(int fd, bool exe, mapfn_t mapfn, void *data,
return err;
}
-static int copy_bytes(int from, off_t from_offs, int to, off_t to_offs, u64 len)
-{
- ssize_t r;
- size_t n;
- int err = -1;
- char *buf = malloc(page_size);
-
- if (buf == NULL)
- return -1;
-
- if (lseek(to, to_offs, SEEK_SET) != to_offs)
- goto out;
-
- if (lseek(from, from_offs, SEEK_SET) != from_offs)
- goto out;
-
- while (len) {
- n = page_size;
- if (len < n)
- n = len;
- /* Use read because mmap won't work on proc files */
- r = read(from, buf, n);
- if (r < 0)
- goto out;
- if (!r)
- break;
- n = r;
- r = write(to, buf, n);
- if (r < 0)
- goto out;
- if ((size_t)r != n)
- goto out;
- len -= n;
- }
-
- err = 0;
-out:
- free(buf);
- return err;
-}
-
-struct kcore {
- int fd;
- int elfclass;
- Elf *elf;
- GElf_Ehdr ehdr;
-};
-
-static int kcore__open(struct kcore *kcore, const char *filename)
-{
- GElf_Ehdr *ehdr;
-
- kcore->fd = open(filename, O_RDONLY);
- if (kcore->fd == -1)
- return -1;
-
- kcore->elf = elf_begin(kcore->fd, ELF_C_READ, NULL);
- if (!kcore->elf)
- goto out_close;
-
- kcore->elfclass = gelf_getclass(kcore->elf);
- if (kcore->elfclass == ELFCLASSNONE)
- goto out_end;
-
- ehdr = gelf_getehdr(kcore->elf, &kcore->ehdr);
- if (!ehdr)
- goto out_end;
-
- return 0;
-
-out_end:
- elf_end(kcore->elf);
-out_close:
- close(kcore->fd);
- return -1;
-}
-
-static int kcore__init(struct kcore *kcore, char *filename, int elfclass,
- bool temp)
-{
- GElf_Ehdr *ehdr;
-
- kcore->elfclass = elfclass;
-
- if (temp)
- kcore->fd = mkstemp(filename);
- else
- kcore->fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0400);
- if (kcore->fd == -1)
- return -1;
-
- kcore->elf = elf_begin(kcore->fd, ELF_C_WRITE, NULL);
- if (!kcore->elf)
- goto out_close;
-
- if (!gelf_newehdr(kcore->elf, elfclass))
- goto out_end;
-
- ehdr = gelf_getehdr(kcore->elf, &kcore->ehdr);
- if (!ehdr)
- goto out_end;
-
- return 0;
-
-out_end:
- elf_end(kcore->elf);
-out_close:
- close(kcore->fd);
- unlink(filename);
- return -1;
-}
-
-static void kcore__close(struct kcore *kcore)
-{
- elf_end(kcore->elf);
- close(kcore->fd);
-}
-
-static int kcore__copy_hdr(struct kcore *from, struct kcore *to, size_t count)
-{
- GElf_Ehdr *ehdr = &to->ehdr;
- GElf_Ehdr *kehdr = &from->ehdr;
-
- memcpy(ehdr->e_ident, kehdr->e_ident, EI_NIDENT);
- ehdr->e_type = kehdr->e_type;
- ehdr->e_machine = kehdr->e_machine;
- ehdr->e_version = kehdr->e_version;
- ehdr->e_entry = 0;
- ehdr->e_shoff = 0;
- ehdr->e_flags = kehdr->e_flags;
- ehdr->e_phnum = count;
- ehdr->e_shentsize = 0;
- ehdr->e_shnum = 0;
- ehdr->e_shstrndx = 0;
-
- if (from->elfclass == ELFCLASS32) {
- ehdr->e_phoff = sizeof(Elf32_Ehdr);
- ehdr->e_ehsize = sizeof(Elf32_Ehdr);
- ehdr->e_phentsize = sizeof(Elf32_Phdr);
- } else {
- ehdr->e_phoff = sizeof(Elf64_Ehdr);
- ehdr->e_ehsize = sizeof(Elf64_Ehdr);
- ehdr->e_phentsize = sizeof(Elf64_Phdr);
- }
-
- if (!gelf_update_ehdr(to->elf, ehdr))
- return -1;
-
- if (!gelf_newphdr(to->elf, count))
- return -1;
-
- return 0;
-}
-
-static int kcore__add_phdr(struct kcore *kcore, int idx, off_t offset,
- u64 addr, u64 len)
-{
- GElf_Phdr gphdr;
- GElf_Phdr *phdr;
-
- phdr = gelf_getphdr(kcore->elf, idx, &gphdr);
- if (!phdr)
- return -1;
-
- phdr->p_type = PT_LOAD;
- phdr->p_flags = PF_R | PF_W | PF_X;
- phdr->p_offset = offset;
- phdr->p_vaddr = addr;
- phdr->p_paddr = 0;
- phdr->p_filesz = len;
- phdr->p_memsz = len;
- phdr->p_align = page_size;
-
- if (!gelf_update_phdr(kcore->elf, idx, phdr))
- return -1;
-
- return 0;
-}
-
-static off_t kcore__write(struct kcore *kcore)
-{
- return elf_update(kcore->elf, ELF_C_WRITE);
-}
-
-struct phdr_data {
- off_t offset;
- u64 addr;
- u64 len;
-};
-
-struct kcore_copy_info {
- u64 stext;
- u64 etext;
- u64 first_symbol;
- u64 last_symbol;
- u64 first_module;
- u64 last_module_symbol;
- struct phdr_data kernel_map;
- struct phdr_data modules_map;
-};
-
-static int kcore_copy__process_kallsyms(void *arg, const char *name, char type,
- u64 start)
-{
- struct kcore_copy_info *kci = arg;
-
- if (!symbol_type__is_a(type, MAP__FUNCTION))
- return 0;
-
- if (strchr(name, '[')) {
- if (start > kci->last_module_symbol)
- kci->last_module_symbol = start;
- return 0;
- }
-
- if (!kci->first_symbol || start < kci->first_symbol)
- kci->first_symbol = start;
-
- if (!kci->last_symbol || start > kci->last_symbol)
- kci->last_symbol = start;
-
- if (!strcmp(name, "_stext")) {
- kci->stext = start;
- return 0;
- }
-
- if (!strcmp(name, "_etext")) {
- kci->etext = start;
- return 0;
- }
-
- return 0;
-}
-
-static int kcore_copy__parse_kallsyms(struct kcore_copy_info *kci,
- const char *dir)
-{
- char kallsyms_filename[PATH_MAX];
-
- scnprintf(kallsyms_filename, PATH_MAX, "%s/kallsyms", dir);
-
- if (symbol__restricted_filename(kallsyms_filename, "/proc/kallsyms"))
- return -1;
-
- if (kallsyms__parse(kallsyms_filename, kci,
- kcore_copy__process_kallsyms) < 0)
- return -1;
-
- return 0;
-}
-
-static int kcore_copy__process_modules(void *arg,
- const char *name __maybe_unused,
- u64 start)
-{
- struct kcore_copy_info *kci = arg;
-
- if (!kci->first_module || start < kci->first_module)
- kci->first_module = start;
-
- return 0;
-}
-
-static int kcore_copy__parse_modules(struct kcore_copy_info *kci,
- const char *dir)
-{
- char modules_filename[PATH_MAX];
-
- scnprintf(modules_filename, PATH_MAX, "%s/modules", dir);
-
- if (symbol__restricted_filename(modules_filename, "/proc/modules"))
- return -1;
-
- if (modules__parse(modules_filename, kci,
- kcore_copy__process_modules) < 0)
- return -1;
-
- return 0;
-}
-
-static void kcore_copy__map(struct phdr_data *p, u64 start, u64 end, u64 pgoff,
- u64 s, u64 e)
-{
- if (p->addr || s < start || s >= end)
- return;
-
- p->addr = s;
- p->offset = (s - start) + pgoff;
- p->len = e < end ? e - s : end - s;
-}
-
-static int kcore_copy__read_map(u64 start, u64 len, u64 pgoff, void *data)
-{
- struct kcore_copy_info *kci = data;
- u64 end = start + len;
-
- kcore_copy__map(&kci->kernel_map, start, end, pgoff, kci->stext,
- kci->etext);
-
- kcore_copy__map(&kci->modules_map, start, end, pgoff, kci->first_module,
- kci->last_module_symbol);
-
- return 0;
-}
-
-static int kcore_copy__read_maps(struct kcore_copy_info *kci, Elf *elf)
-{
- if (elf_read_maps(elf, true, kcore_copy__read_map, kci) < 0)
- return -1;
-
- return 0;
-}
-
-static int kcore_copy__calc_maps(struct kcore_copy_info *kci, const char *dir,
- Elf *elf)
-{
- if (kcore_copy__parse_kallsyms(kci, dir))
- return -1;
-
- if (kcore_copy__parse_modules(kci, dir))
- return -1;
-
- if (kci->stext)
- kci->stext = round_down(kci->stext, page_size);
- else
- kci->stext = round_down(kci->first_symbol, page_size);
-
- if (kci->etext) {
- kci->etext = round_up(kci->etext, page_size);
- } else if (kci->last_symbol) {
- kci->etext = round_up(kci->last_symbol, page_size);
- kci->etext += page_size;
- }
-
- kci->first_module = round_down(kci->first_module, page_size);
-
- if (kci->last_module_symbol) {
- kci->last_module_symbol = round_up(kci->last_module_symbol,
- page_size);
- kci->last_module_symbol += page_size;
- }
-
- if (!kci->stext || !kci->etext)
- return -1;
-
- if (kci->first_module && !kci->last_module_symbol)
- return -1;
-
- return kcore_copy__read_maps(kci, elf);
-}
-
-static int kcore_copy__copy_file(const char *from_dir, const char *to_dir,
- const char *name)
-{
- char from_filename[PATH_MAX];
- char to_filename[PATH_MAX];
-
- scnprintf(from_filename, PATH_MAX, "%s/%s", from_dir, name);
- scnprintf(to_filename, PATH_MAX, "%s/%s", to_dir, name);
-
- return copyfile_mode(from_filename, to_filename, 0400);
-}
-
-static int kcore_copy__unlink(const char *dir, const char *name)
-{
- char filename[PATH_MAX];
-
- scnprintf(filename, PATH_MAX, "%s/%s", dir, name);
-
- return unlink(filename);
-}
-
-static int kcore_copy__compare_fds(int from, int to)
-{
- char *buf_from;
- char *buf_to;
- ssize_t ret;
- size_t len;
- int err = -1;
-
- buf_from = malloc(page_size);
- buf_to = malloc(page_size);
- if (!buf_from || !buf_to)
- goto out;
-
- while (1) {
- /* Use read because mmap won't work on proc files */
- ret = read(from, buf_from, page_size);
- if (ret < 0)
- goto out;
-
- if (!ret)
- break;
-
- len = ret;
-
- if (readn(to, buf_to, len) != (int)len)
- goto out;
-
- if (memcmp(buf_from, buf_to, len))
- goto out;
- }
-
- err = 0;
-out:
- free(buf_to);
- free(buf_from);
- return err;
-}
-
-static int kcore_copy__compare_files(const char *from_filename,
- const char *to_filename)
-{
- int from, to, err = -1;
-
- from = open(from_filename, O_RDONLY);
- if (from < 0)
- return -1;
-
- to = open(to_filename, O_RDONLY);
- if (to < 0)
- goto out_close_from;
-
- err = kcore_copy__compare_fds(from, to);
-
- close(to);
-out_close_from:
- close(from);
- return err;
-}
-
-static int kcore_copy__compare_file(const char *from_dir, const char *to_dir,
- const char *name)
-{
- char from_filename[PATH_MAX];
- char to_filename[PATH_MAX];
-
- scnprintf(from_filename, PATH_MAX, "%s/%s", from_dir, name);
- scnprintf(to_filename, PATH_MAX, "%s/%s", to_dir, name);
-
- return kcore_copy__compare_files(from_filename, to_filename);
-}
-
-/**
- * kcore_copy - copy kallsyms, modules and kcore from one directory to another.
- * @from_dir: from directory
- * @to_dir: to directory
- *
- * This function copies kallsyms, modules and kcore files from one directory to
- * another. kallsyms and modules are copied entirely. Only code segments are
- * copied from kcore. It is assumed that two segments suffice: one for the
- * kernel proper and one for all the modules. The code segments are determined
- * from kallsyms and modules files. The kernel map starts at _stext or the
- * lowest function symbol, and ends at _etext or the highest function symbol.
- * The module map starts at the lowest module address and ends at the highest
- * module symbol. Start addresses are rounded down to the nearest page. End
- * addresses are rounded up to the nearest page. An extra page is added to the
- * highest kernel symbol and highest module symbol to, hopefully, encompass that
- * symbol too. Because it contains only code sections, the resulting kcore is
- * unusual. One significant peculiarity is that the mapping (start -> pgoff)
- * is not the same for the kernel map and the modules map. That happens because
- * the data is copied adjacently whereas the original kcore has gaps. Finally,
- * kallsyms and modules files are compared with their copies to check that
- * modules have not been loaded or unloaded while the copies were taking place.
- *
- * Return: %0 on success, %-1 on failure.
- */
-int kcore_copy(const char *from_dir, const char *to_dir)
-{
- struct kcore kcore;
- struct kcore extract;
- size_t count = 2;
- int idx = 0, err = -1;
- off_t offset = page_size, sz, modules_offset = 0;
- struct kcore_copy_info kci = { .stext = 0, };
- char kcore_filename[PATH_MAX];
- char extract_filename[PATH_MAX];
-
- if (kcore_copy__copy_file(from_dir, to_dir, "kallsyms"))
- return -1;
-
- if (kcore_copy__copy_file(from_dir, to_dir, "modules"))
- goto out_unlink_kallsyms;
-
- scnprintf(kcore_filename, PATH_MAX, "%s/kcore", from_dir);
- scnprintf(extract_filename, PATH_MAX, "%s/kcore", to_dir);
-
- if (kcore__open(&kcore, kcore_filename))
- goto out_unlink_modules;
-
- if (kcore_copy__calc_maps(&kci, from_dir, kcore.elf))
- goto out_kcore_close;
-
- if (kcore__init(&extract, extract_filename, kcore.elfclass, false))
- goto out_kcore_close;
-
- if (!kci.modules_map.addr)
- count -= 1;
-
- if (kcore__copy_hdr(&kcore, &extract, count))
- goto out_extract_close;
-
- if (kcore__add_phdr(&extract, idx++, offset, kci.kernel_map.addr,
- kci.kernel_map.len))
- goto out_extract_close;
-
- if (kci.modules_map.addr) {
- modules_offset = offset + kci.kernel_map.len;
- if (kcore__add_phdr(&extract, idx, modules_offset,
- kci.modules_map.addr, kci.modules_map.len))
- goto out_extract_close;
- }
-
- sz = kcore__write(&extract);
- if (sz < 0 || sz > offset)
- goto out_extract_close;
-
- if (copy_bytes(kcore.fd, kci.kernel_map.offset, extract.fd, offset,
- kci.kernel_map.len))
- goto out_extract_close;
-
- if (modules_offset && copy_bytes(kcore.fd, kci.modules_map.offset,
- extract.fd, modules_offset,
- kci.modules_map.len))
- goto out_extract_close;
-
- if (kcore_copy__compare_file(from_dir, to_dir, "modules"))
- goto out_extract_close;
-
- if (kcore_copy__compare_file(from_dir, to_dir, "kallsyms"))
- goto out_extract_close;
-
- err = 0;
-
-out_extract_close:
- kcore__close(&extract);
- if (err)
- unlink(extract_filename);
-out_kcore_close:
- kcore__close(&kcore);
-out_unlink_modules:
- if (err)
- kcore_copy__unlink(to_dir, "modules");
-out_unlink_kallsyms:
- if (err)
- kcore_copy__unlink(to_dir, "kallsyms");
-
- return err;
-}
-
-int kcore_extract__create(struct kcore_extract *kce)
-{
- struct kcore kcore;
- struct kcore extract;
- size_t count = 1;
- int idx = 0, err = -1;
- off_t offset = page_size, sz;
-
- if (kcore__open(&kcore, kce->kcore_filename))
- return -1;
-
- strcpy(kce->extract_filename, PERF_KCORE_EXTRACT);
- if (kcore__init(&extract, kce->extract_filename, kcore.elfclass, true))
- goto out_kcore_close;
-
- if (kcore__copy_hdr(&kcore, &extract, count))
- goto out_extract_close;
-
- if (kcore__add_phdr(&extract, idx, offset, kce->addr, kce->len))
- goto out_extract_close;
-
- sz = kcore__write(&extract);
- if (sz < 0 || sz > offset)
- goto out_extract_close;
-
- if (copy_bytes(kcore.fd, kce->offs, extract.fd, offset, kce->len))
- goto out_extract_close;
-
- err = 0;
-
-out_extract_close:
- kcore__close(&extract);
- if (err)
- unlink(kce->extract_filename);
-out_kcore_close:
- kcore__close(&kcore);
-
- return err;
-}
-
-void kcore_extract__delete(struct kcore_extract *kce)
-{
- unlink(kce->extract_filename);
-}
-
void symbol__elf_init(void)
{
elf_version(EV_CURRENT);
diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c
index 2d2dd05..3a802c3 100644
--- a/tools/perf/util/symbol-minimal.c
+++ b/tools/perf/util/symbol-minimal.c
@@ -308,21 +308,6 @@ int file__read_maps(int fd __maybe_unused, bool exe __maybe_unused,
return -1;
}
-int kcore_extract__create(struct kcore_extract *kce __maybe_unused)
-{
- return -1;
-}
-
-void kcore_extract__delete(struct kcore_extract *kce __maybe_unused)
-{
-}
-
-int kcore_copy(const char *from_dir __maybe_unused,
- const char *to_dir __maybe_unused)
-{
- return -1;
-}
-
void symbol__elf_init(void)
{
}
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index c0c3696..7eb0362 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -51,7 +51,6 @@ static enum dso_binary_type binary_type_symtab[] = {
DSO_BINARY_TYPE__SYSTEM_PATH_DSO,
DSO_BINARY_TYPE__GUEST_KMODULE,
DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE,
- DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
DSO_BINARY_TYPE__NOT_FOUND,
};
@@ -160,12 +159,10 @@ again:
if (choose_best_symbol(curr, next) == SYMBOL_A) {
rb_erase(&next->rb_node, symbols);
- symbol__delete(next);
goto again;
} else {
nd = rb_next(&curr->rb_node);
rb_erase(&curr->rb_node, symbols);
- symbol__delete(curr);
}
}
}
@@ -502,64 +499,6 @@ out_failure:
return -1;
}
-int modules__parse(const char *filename, void *arg,
- int (*process_module)(void *arg, const char *name,
- u64 start))
-{
- char *line = NULL;
- size_t n;
- FILE *file;
- int err = 0;
-
- file = fopen(filename, "r");
- if (file == NULL)
- return -1;
-
- while (1) {
- char name[PATH_MAX];
- u64 start;
- char *sep;
- ssize_t line_len;
-
- line_len = getline(&line, &n, file);
- if (line_len < 0) {
- if (feof(file))
- break;
- err = -1;
- goto out;
- }
-
- if (!line) {
- err = -1;
- goto out;
- }
-
- line[--line_len] = '\0'; /* \n */
-
- sep = strrchr(line, 'x');
- if (sep == NULL)
- continue;
-
- hex2u64(sep + 1, &start);
-
- sep = strchr(line, ' ');
- if (sep == NULL)
- continue;
-
- *sep = '\0';
-
- scnprintf(name, sizeof(name), "[%s]", line);
-
- err = process_module(arg, name, start);
- if (err)
- break;
- }
-out:
- free(line);
- fclose(file);
- return err;
-}
-
struct process_kallsyms_args {
struct map *map;
struct dso *dso;
@@ -800,242 +739,51 @@ bool symbol__restricted_filename(const char *filename,
return restricted;
}
-struct module_info {
- struct rb_node rb_node;
- char *name;
- u64 start;
+struct kcore_mapfn_data {
+ struct dso *dso;
+ enum map_type type;
+ struct list_head maps;
};
-static void add_module(struct module_info *mi, struct rb_root *modules)
-{
- struct rb_node **p = &modules->rb_node;
- struct rb_node *parent = NULL;
- struct module_info *m;
-
- while (*p != NULL) {
- parent = *p;
- m = rb_entry(parent, struct module_info, rb_node);
- if (strcmp(mi->name, m->name) < 0)
- p = &(*p)->rb_left;
- else
- p = &(*p)->rb_right;
- }
- rb_link_node(&mi->rb_node, parent, p);
- rb_insert_color(&mi->rb_node, modules);
-}
-
-static void delete_modules(struct rb_root *modules)
-{
- struct module_info *mi;
- struct rb_node *next = rb_first(modules);
-
- while (next) {
- mi = rb_entry(next, struct module_info, rb_node);
- next = rb_next(&mi->rb_node);
- rb_erase(&mi->rb_node, modules);
- free(mi->name);
- free(mi);
- }
-}
-
-static struct module_info *find_module(const char *name,
- struct rb_root *modules)
-{
- struct rb_node *n = modules->rb_node;
-
- while (n) {
- struct module_info *m;
- int cmp;
-
- m = rb_entry(n, struct module_info, rb_node);
- cmp = strcmp(name, m->name);
- if (cmp < 0)
- n = n->rb_left;
- else if (cmp > 0)
- n = n->rb_right;
- else
- return m;
- }
-
- return NULL;
-}
-
-static int __read_proc_modules(void *arg, const char *name, u64 start)
+static int kcore_mapfn(u64 start, u64 len, u64 pgoff, void *data)
{
- struct rb_root *modules = arg;
- struct module_info *mi;
-
- mi = zalloc(sizeof(struct module_info));
- if (!mi)
- return -ENOMEM;
-
- mi->name = strdup(name);
- mi->start = start;
+ struct kcore_mapfn_data *md = data;
+ struct map *map;
- if (!mi->name) {
- free(mi);
+ map = map__new2(start, md->dso, md->type);
+ if (map == NULL)
return -ENOMEM;
- }
-
- add_module(mi, modules);
-
- return 0;
-}
-static int read_proc_modules(const char *filename, struct rb_root *modules)
-{
- if (symbol__restricted_filename(filename, "/proc/modules"))
- return -1;
+ map->end = map->start + len;
+ map->pgoff = pgoff;
- if (modules__parse(filename, modules, __read_proc_modules)) {
- delete_modules(modules);
- return -1;
- }
+ list_add(&map->node, &md->maps);
return 0;
}
-int compare_proc_modules(const char *from, const char *to)
-{
- struct rb_root from_modules = RB_ROOT;
- struct rb_root to_modules = RB_ROOT;
- struct rb_node *from_node, *to_node;
- struct module_info *from_m, *to_m;
- int ret = -1;
-
- if (read_proc_modules(from, &from_modules))
- return -1;
-
- if (read_proc_modules(to, &to_modules))
- goto out_delete_from;
-
- from_node = rb_first(&from_modules);
- to_node = rb_first(&to_modules);
- while (from_node) {
- if (!to_node)
- break;
-
- from_m = rb_entry(from_node, struct module_info, rb_node);
- to_m = rb_entry(to_node, struct module_info, rb_node);
-
- if (from_m->start != to_m->start ||
- strcmp(from_m->name, to_m->name))
- break;
-
- from_node = rb_next(from_node);
- to_node = rb_next(to_node);
- }
-
- if (!from_node && !to_node)
- ret = 0;
-
- delete_modules(&to_modules);
-out_delete_from:
- delete_modules(&from_modules);
-
- return ret;
-}
-
-static int do_validate_kcore_modules(const char *filename, struct map *map,
- struct map_groups *kmaps)
-{
- struct rb_root modules = RB_ROOT;
- struct map *old_map;
- int err;
-
- err = read_proc_modules(filename, &modules);
- if (err)
- return err;
-
- old_map = map_groups__first(kmaps, map->type);
- while (old_map) {
- struct map *next = map_groups__next(old_map);
- struct module_info *mi;
-
- if (old_map == map || old_map->start == map->start) {
- /* The kernel map */
- old_map = next;
- continue;
- }
-
- /* Module must be in memory at the same address */
- mi = find_module(old_map->dso->short_name, &modules);
- if (!mi || mi->start != old_map->start) {
- err = -EINVAL;
- goto out;
- }
-
- old_map = next;
- }
-out:
- delete_modules(&modules);
- return err;
-}
-
/*
- * If kallsyms is referenced by name then we look for filename in the same
+ * If kallsyms is referenced by name then we look for kcore in the same
* directory.
*/
-static bool filename_from_kallsyms_filename(char *filename,
- const char *base_name,
- const char *kallsyms_filename)
+static bool kcore_filename_from_kallsyms_filename(char *kcore_filename,
+ const char *kallsyms_filename)
{
char *name;
- strcpy(filename, kallsyms_filename);
- name = strrchr(filename, '/');
+ strcpy(kcore_filename, kallsyms_filename);
+ name = strrchr(kcore_filename, '/');
if (!name)
return false;
- name += 1;
-
- if (!strcmp(name, "kallsyms")) {
- strcpy(name, base_name);
+ if (!strcmp(name, "/kallsyms")) {
+ strcpy(name, "/kcore");
return true;
}
return false;
}
-static int validate_kcore_modules(const char *kallsyms_filename,
- struct map *map)
-{
- struct map_groups *kmaps = map__kmap(map)->kmaps;
- char modules_filename[PATH_MAX];
-
- if (!filename_from_kallsyms_filename(modules_filename, "modules",
- kallsyms_filename))
- return -EINVAL;
-
- if (do_validate_kcore_modules(modules_filename, map, kmaps))
- return -EINVAL;
-
- return 0;
-}
-
-struct kcore_mapfn_data {
- struct dso *dso;
- enum map_type type;
- struct list_head maps;
-};
-
-static int kcore_mapfn(u64 start, u64 len, u64 pgoff, void *data)
-{
- struct kcore_mapfn_data *md = data;
- struct map *map;
-
- map = map__new2(start, md->dso, md->type);
- if (map == NULL)
- return -ENOMEM;
-
- map->end = map->start + len;
- map->pgoff = pgoff;
-
- list_add(&map->node, &md->maps);
-
- return 0;
-}
-
static int dso__load_kcore(struct dso *dso, struct map *map,
const char *kallsyms_filename)
{
@@ -1052,12 +800,8 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
if (map != machine->vmlinux_maps[map->type])
return -EINVAL;
- if (!filename_from_kallsyms_filename(kcore_filename, "kcore",
- kallsyms_filename))
- return -EINVAL;
-
- /* All modules must be present at their original addresses */
- if (validate_kcore_modules(kallsyms_filename, map))
+ if (!kcore_filename_from_kallsyms_filename(kcore_filename,
+ kallsyms_filename))
return -EINVAL;
md.dso = dso;
@@ -1444,105 +1188,6 @@ out:
return err;
}
-static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz)
-{
- char kallsyms_filename[PATH_MAX];
- struct dirent *dent;
- int ret = -1;
- DIR *d;
-
- d = opendir(dir);
- if (!d)
- return -1;
-
- while (1) {
- dent = readdir(d);
- if (!dent)
- break;
- if (dent->d_type != DT_DIR)
- continue;
- scnprintf(kallsyms_filename, sizeof(kallsyms_filename),
- "%s/%s/kallsyms", dir, dent->d_name);
- if (!validate_kcore_modules(kallsyms_filename, map)) {
- strlcpy(dir, kallsyms_filename, dir_sz);
- ret = 0;
- break;
- }
- }
-
- closedir(d);
-
- return ret;
-}
-
-static char *dso__find_kallsyms(struct dso *dso, struct map *map)
-{
- u8 host_build_id[BUILD_ID_SIZE];
- char sbuild_id[BUILD_ID_SIZE * 2 + 1];
- bool is_host = false;
- char path[PATH_MAX];
-
- if (!dso->has_build_id) {
- /*
- * Last resort, if we don't have a build-id and couldn't find
- * any vmlinux file, try the running kernel kallsyms table.
- */
- goto proc_kallsyms;
- }
-
- if (sysfs__read_build_id("/sys/kernel/notes", host_build_id,
- sizeof(host_build_id)) == 0)
- is_host = dso__build_id_equal(dso, host_build_id);
-
- build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
-
- /* Use /proc/kallsyms if possible */
- if (is_host) {
- DIR *d;
- int fd;
-
- /* If no cached kcore go with /proc/kallsyms */
- scnprintf(path, sizeof(path), "%s/[kernel.kcore]/%s",
- buildid_dir, sbuild_id);
- d = opendir(path);
- if (!d)
- goto proc_kallsyms;
- closedir(d);
-
- /*
- * Do not check the build-id cache, until we know we cannot use
- * /proc/kcore.
- */
- fd = open("/proc/kcore", O_RDONLY);
- if (fd != -1) {
- close(fd);
- /* If module maps match go with /proc/kallsyms */
- if (!validate_kcore_modules("/proc/kallsyms", map))
- goto proc_kallsyms;
- }
-
- /* Find kallsyms in build-id cache with kcore */
- if (!find_matching_kcore(map, path, sizeof(path)))
- return strdup(path);
-
- goto proc_kallsyms;
- }
-
- scnprintf(path, sizeof(path), "%s/[kernel.kallsyms]/%s",
- buildid_dir, sbuild_id);
-
- if (access(path, F_OK)) {
- pr_err("No kallsyms or vmlinux with build-id %s was found\n",
- sbuild_id);
- return NULL;
- }
-
- return strdup(path);
-
-proc_kallsyms:
- return strdup("/proc/kallsyms");
-}
-
static int dso__load_kernel_sym(struct dso *dso, struct map *map,
symbol_filter_t filter)
{
@@ -1569,7 +1214,7 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map,
goto do_kallsyms;
}
- if (!symbol_conf.ignore_vmlinux && symbol_conf.vmlinux_name != NULL) {
+ if (symbol_conf.vmlinux_name != NULL) {
err = dso__load_vmlinux(dso, map,
symbol_conf.vmlinux_name, filter);
if (err > 0) {
@@ -1581,7 +1226,7 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map,
return err;
}
- if (!symbol_conf.ignore_vmlinux && vmlinux_path != NULL) {
+ if (vmlinux_path != NULL) {
err = dso__load_vmlinux_path(dso, map, filter);
if (err > 0)
return err;
@@ -1591,11 +1236,51 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map,
if (symbol_conf.symfs[0] != 0)
return -1;
- kallsyms_allocated_filename = dso__find_kallsyms(dso, map);
- if (!kallsyms_allocated_filename)
- return -1;
+ /*
+ * Say the kernel DSO was created when processing the build-id header table,
+ * we have a build-id, so check if it is the same as the running kernel,
+ * using it if it is.
+ */
+ if (dso->has_build_id) {
+ u8 kallsyms_build_id[BUILD_ID_SIZE];
+ char sbuild_id[BUILD_ID_SIZE * 2 + 1];
+
+ if (sysfs__read_build_id("/sys/kernel/notes", kallsyms_build_id,
+ sizeof(kallsyms_build_id)) == 0) {
+ if (dso__build_id_equal(dso, kallsyms_build_id)) {
+ kallsyms_filename = "/proc/kallsyms";
+ goto do_kallsyms;
+ }
+ }
+ /*
+ * Now look if we have it on the build-id cache in
+ * $HOME/.debug/[kernel.kallsyms].
+ */
+ build_id__sprintf(dso->build_id, sizeof(dso->build_id),
+ sbuild_id);
- kallsyms_filename = kallsyms_allocated_filename;
+ if (asprintf(&kallsyms_allocated_filename,
+ "%s/.debug/[kernel.kallsyms]/%s",
+ getenv("HOME"), sbuild_id) == -1) {
+ pr_err("Not enough memory for kallsyms file lookup\n");
+ return -1;
+ }
+
+ kallsyms_filename = kallsyms_allocated_filename;
+
+ if (access(kallsyms_filename, F_OK)) {
+ pr_err("No kallsyms or vmlinux with build-id %s "
+ "was found\n", sbuild_id);
+ free(kallsyms_allocated_filename);
+ return -1;
+ }
+ } else {
+ /*
+ * Last resort, if we don't have a build-id and couldn't find
+ * any vmlinux file, try the running kernel kallsyms table.
+ */
+ kallsyms_filename = "/proc/kallsyms";
+ }
do_kallsyms:
err = dso__load_kallsyms(dso, kallsyms_filename, map, filter);
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 07de8fe..fd5b70e 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -13,7 +13,7 @@
#include <libgen.h>
#include "build-id.h"
-#ifdef HAVE_LIBELF_SUPPORT
+#ifdef LIBELF_SUPPORT
#include <libelf.h>
#include <gelf.h>
#endif
@@ -21,7 +21,7 @@
#include "dso.h"
-#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
+#ifdef HAVE_CPLUS_DEMANGLE
extern char *cplus_demangle(const char *, int);
static inline char *bfd_demangle(void __maybe_unused *v, const char *c, int i)
@@ -46,7 +46,7 @@ static inline char *bfd_demangle(void __maybe_unused *v,
* libelf 0.8.x and earlier do not support ELF_C_READ_MMAP;
* for newer versions we can use mmap to reduce memory usage:
*/
-#ifdef HAVE_LIBELF_MMAP_SUPPORT
+#ifdef LIBELF_MMAP
# define PERF_ELF_C_READ_MMAP ELF_C_READ_MMAP
#else
# define PERF_ELF_C_READ_MMAP ELF_C_READ
@@ -85,7 +85,6 @@ struct symbol_conf {
unsigned short priv_size;
unsigned short nr_events;
bool try_vmlinux_path,
- ignore_vmlinux,
show_kernel_path,
use_modules,
sort_by_name,
@@ -179,7 +178,7 @@ struct symsrc {
int fd;
enum dso_binary_type type;
-#ifdef HAVE_LIBELF_SUPPORT
+#ifdef LIBELF_SUPPORT
Elf *elf;
GElf_Ehdr ehdr;
@@ -223,9 +222,6 @@ int sysfs__read_build_id(const char *filename, void *bf, size_t size);
int kallsyms__parse(const char *filename, void *arg,
int (*process_symbol)(void *arg, const char *name,
char type, u64 start));
-int modules__parse(const char *filename, void *arg,
- int (*process_module)(void *arg, const char *name,
- u64 start));
int filename__read_debuglink(const char *filename, char *debuglink,
size_t size);
@@ -256,21 +252,4 @@ typedef int (*mapfn_t)(u64 start, u64 len, u64 pgoff, void *data);
int file__read_maps(int fd, bool exe, mapfn_t mapfn, void *data,
bool *is_64_bit);
-#define PERF_KCORE_EXTRACT "/tmp/perf-kcore-XXXXXX"
-
-struct kcore_extract {
- char *kcore_filename;
- u64 addr;
- u64 offs;
- u64 len;
- char extract_filename[sizeof(PERF_KCORE_EXTRACT)];
- int fd;
-};
-
-int kcore_extract__create(struct kcore_extract *kce);
-void kcore_extract__delete(struct kcore_extract *kce);
-
-int kcore_copy(const char *from_dir, const char *to_dir);
-int compare_proc_modules(const char *from, const char *to);
-
#endif /* __PERF_SYMBOL */
diff --git a/tools/perf/util/sysfs.c b/tools/perf/util/sysfs.c
new file mode 100644
index 0000000..f71e9ea
--- /dev/null
+++ b/tools/perf/util/sysfs.c
@@ -0,0 +1,60 @@
+
+#include "util.h"
+#include "sysfs.h"
+
+static const char * const sysfs_known_mountpoints[] = {
+ "/sys",
+ 0,
+};
+
+static int sysfs_found;
+char sysfs_mountpoint[PATH_MAX + 1];
+
+static int sysfs_valid_mountpoint(const char *sysfs)
+{
+ struct statfs st_fs;
+
+ if (statfs(sysfs, &st_fs) < 0)
+ return -ENOENT;
+ else if (st_fs.f_type != (long) SYSFS_MAGIC)
+ return -ENOENT;
+
+ return 0;
+}
+
+const char *sysfs_find_mountpoint(void)
+{
+ const char * const *ptr;
+ char type[100];
+ FILE *fp;
+
+ if (sysfs_found)
+ return (const char *) sysfs_mountpoint;
+
+ ptr = sysfs_known_mountpoints;
+ while (*ptr) {
+ if (sysfs_valid_mountpoint(*ptr) == 0) {
+ sysfs_found = 1;
+ strcpy(sysfs_mountpoint, *ptr);
+ return sysfs_mountpoint;
+ }
+ ptr++;
+ }
+
+ /* give up and parse /proc/mounts */
+ fp = fopen("/proc/mounts", "r");
+ if (fp == NULL)
+ return NULL;
+
+ while (!sysfs_found &&
+ fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n",
+ sysfs_mountpoint, type) == 2) {
+
+ if (strcmp(type, "sysfs") == 0)
+ sysfs_found = 1;
+ }
+
+ fclose(fp);
+
+ return sysfs_found ? sysfs_mountpoint : NULL;
+}
diff --git a/tools/perf/util/sysfs.h b/tools/perf/util/sysfs.h
new file mode 100644
index 0000000..a813b72
--- /dev/null
+++ b/tools/perf/util/sysfs.h
@@ -0,0 +1,6 @@
+#ifndef __SYSFS_H__
+#define __SYSFS_H__
+
+const char *sysfs_find_mountpoint(void);
+
+#endif /* __DEBUGFS_H__ */
diff --git a/tools/perf/util/target.c b/tools/perf/util/target.c
index 3c778a0..065528b 100644
--- a/tools/perf/util/target.c
+++ b/tools/perf/util/target.c
@@ -13,9 +13,9 @@
#include <string.h>
-enum target_errno target__validate(struct target *target)
+enum perf_target_errno perf_target__validate(struct perf_target *target)
{
- enum target_errno ret = TARGET_ERRNO__SUCCESS;
+ enum perf_target_errno ret = PERF_ERRNO_TARGET__SUCCESS;
if (target->pid)
target->tid = target->pid;
@@ -23,42 +23,42 @@ enum target_errno target__validate(struct target *target)
/* CPU and PID are mutually exclusive */
if (target->tid && target->cpu_list) {
target->cpu_list = NULL;
- if (ret == TARGET_ERRNO__SUCCESS)
- ret = TARGET_ERRNO__PID_OVERRIDE_CPU;
+ if (ret == PERF_ERRNO_TARGET__SUCCESS)
+ ret = PERF_ERRNO_TARGET__PID_OVERRIDE_CPU;
}
/* UID and PID are mutually exclusive */
if (target->tid && target->uid_str) {
target->uid_str = NULL;
- if (ret == TARGET_ERRNO__SUCCESS)
- ret = TARGET_ERRNO__PID_OVERRIDE_UID;
+ if (ret == PERF_ERRNO_TARGET__SUCCESS)
+ ret = PERF_ERRNO_TARGET__PID_OVERRIDE_UID;
}
/* UID and CPU are mutually exclusive */
if (target->uid_str && target->cpu_list) {
target->cpu_list = NULL;
- if (ret == TARGET_ERRNO__SUCCESS)
- ret = TARGET_ERRNO__UID_OVERRIDE_CPU;
+ if (ret == PERF_ERRNO_TARGET__SUCCESS)
+ ret = PERF_ERRNO_TARGET__UID_OVERRIDE_CPU;
}
/* PID and SYSTEM are mutually exclusive */
if (target->tid && target->system_wide) {
target->system_wide = false;
- if (ret == TARGET_ERRNO__SUCCESS)
- ret = TARGET_ERRNO__PID_OVERRIDE_SYSTEM;
+ if (ret == PERF_ERRNO_TARGET__SUCCESS)
+ ret = PERF_ERRNO_TARGET__PID_OVERRIDE_SYSTEM;
}
/* UID and SYSTEM are mutually exclusive */
if (target->uid_str && target->system_wide) {
target->system_wide = false;
- if (ret == TARGET_ERRNO__SUCCESS)
- ret = TARGET_ERRNO__UID_OVERRIDE_SYSTEM;
+ if (ret == PERF_ERRNO_TARGET__SUCCESS)
+ ret = PERF_ERRNO_TARGET__UID_OVERRIDE_SYSTEM;
}
return ret;
}
-enum target_errno target__parse_uid(struct target *target)
+enum perf_target_errno perf_target__parse_uid(struct perf_target *target)
{
struct passwd pwd, *result;
char buf[1024];
@@ -66,7 +66,7 @@ enum target_errno target__parse_uid(struct target *target)
target->uid = UINT_MAX;
if (str == NULL)
- return TARGET_ERRNO__SUCCESS;
+ return PERF_ERRNO_TARGET__SUCCESS;
/* Try user name first */
getpwnam_r(str, &pwd, buf, sizeof(buf), &result);
@@ -79,22 +79,22 @@ enum target_errno target__parse_uid(struct target *target)
int uid = strtol(str, &endptr, 10);
if (*endptr != '\0')
- return TARGET_ERRNO__INVALID_UID;
+ return PERF_ERRNO_TARGET__INVALID_UID;
getpwuid_r(uid, &pwd, buf, sizeof(buf), &result);
if (result == NULL)
- return TARGET_ERRNO__USER_NOT_FOUND;
+ return PERF_ERRNO_TARGET__USER_NOT_FOUND;
}
target->uid = result->pw_uid;
- return TARGET_ERRNO__SUCCESS;
+ return PERF_ERRNO_TARGET__SUCCESS;
}
/*
- * This must have a same ordering as the enum target_errno.
+ * This must have a same ordering as the enum perf_target_errno.
*/
-static const char *target__error_str[] = {
+static const char *perf_target__error_str[] = {
"PID/TID switch overriding CPU",
"PID/TID switch overriding UID",
"UID switch overriding CPU",
@@ -104,7 +104,7 @@ static const char *target__error_str[] = {
"Problems obtaining information for user %s",
};
-int target__strerror(struct target *target, int errnum,
+int perf_target__strerror(struct perf_target *target, int errnum,
char *buf, size_t buflen)
{
int idx;
@@ -124,19 +124,21 @@ int target__strerror(struct target *target, int errnum,
return 0;
}
- if (errnum < __TARGET_ERRNO__START || errnum >= __TARGET_ERRNO__END)
+ if (errnum < __PERF_ERRNO_TARGET__START ||
+ errnum >= __PERF_ERRNO_TARGET__END)
return -1;
- idx = errnum - __TARGET_ERRNO__START;
- msg = target__error_str[idx];
+ idx = errnum - __PERF_ERRNO_TARGET__START;
+ msg = perf_target__error_str[idx];
switch (errnum) {
- case TARGET_ERRNO__PID_OVERRIDE_CPU ... TARGET_ERRNO__UID_OVERRIDE_SYSTEM:
+ case PERF_ERRNO_TARGET__PID_OVERRIDE_CPU
+ ... PERF_ERRNO_TARGET__UID_OVERRIDE_SYSTEM:
snprintf(buf, buflen, "%s", msg);
break;
- case TARGET_ERRNO__INVALID_UID:
- case TARGET_ERRNO__USER_NOT_FOUND:
+ case PERF_ERRNO_TARGET__INVALID_UID:
+ case PERF_ERRNO_TARGET__USER_NOT_FOUND:
snprintf(buf, buflen, msg, target->uid_str);
break;
diff --git a/tools/perf/util/target.h b/tools/perf/util/target.h
index 2d0c506..a4be857 100644
--- a/tools/perf/util/target.h
+++ b/tools/perf/util/target.h
@@ -4,7 +4,7 @@
#include <stdbool.h>
#include <sys/types.h>
-struct target {
+struct perf_target {
const char *pid;
const char *tid;
const char *cpu_list;
@@ -12,11 +12,10 @@ struct target {
uid_t uid;
bool system_wide;
bool uses_mmap;
- bool force_per_cpu;
};
-enum target_errno {
- TARGET_ERRNO__SUCCESS = 0,
+enum perf_target_errno {
+ PERF_ERRNO_TARGET__SUCCESS = 0,
/*
* Choose an arbitrary negative big number not to clash with standard
@@ -25,40 +24,42 @@ enum target_errno {
*
* http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
*/
- __TARGET_ERRNO__START = -10000,
+ __PERF_ERRNO_TARGET__START = -10000,
- /* for target__validate() */
- TARGET_ERRNO__PID_OVERRIDE_CPU = __TARGET_ERRNO__START,
- TARGET_ERRNO__PID_OVERRIDE_UID,
- TARGET_ERRNO__UID_OVERRIDE_CPU,
- TARGET_ERRNO__PID_OVERRIDE_SYSTEM,
- TARGET_ERRNO__UID_OVERRIDE_SYSTEM,
- /* for target__parse_uid() */
- TARGET_ERRNO__INVALID_UID,
- TARGET_ERRNO__USER_NOT_FOUND,
+ /* for perf_target__validate() */
+ PERF_ERRNO_TARGET__PID_OVERRIDE_CPU = __PERF_ERRNO_TARGET__START,
+ PERF_ERRNO_TARGET__PID_OVERRIDE_UID,
+ PERF_ERRNO_TARGET__UID_OVERRIDE_CPU,
+ PERF_ERRNO_TARGET__PID_OVERRIDE_SYSTEM,
+ PERF_ERRNO_TARGET__UID_OVERRIDE_SYSTEM,
- __TARGET_ERRNO__END,
+ /* for perf_target__parse_uid() */
+ PERF_ERRNO_TARGET__INVALID_UID,
+ PERF_ERRNO_TARGET__USER_NOT_FOUND,
+
+ __PERF_ERRNO_TARGET__END,
};
-enum target_errno target__validate(struct target *target);
-enum target_errno target__parse_uid(struct target *target);
+enum perf_target_errno perf_target__validate(struct perf_target *target);
+enum perf_target_errno perf_target__parse_uid(struct perf_target *target);
-int target__strerror(struct target *target, int errnum, char *buf, size_t buflen);
+int perf_target__strerror(struct perf_target *target, int errnum, char *buf,
+ size_t buflen);
-static inline bool target__has_task(struct target *target)
+static inline bool perf_target__has_task(struct perf_target *target)
{
return target->tid || target->pid || target->uid_str;
}
-static inline bool target__has_cpu(struct target *target)
+static inline bool perf_target__has_cpu(struct perf_target *target)
{
return target->system_wide || target->cpu_list;
}
-static inline bool target__none(struct target *target)
+static inline bool perf_target__none(struct perf_target *target)
{
- return !target__has_task(target) && !target__has_cpu(target);
+ return !perf_target__has_task(target) && !perf_target__has_cpu(target);
}
#endif /* _PERF_TARGET_H */
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 49eaf1d..e3d4a55 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -6,136 +6,86 @@
#include "thread.h"
#include "util.h"
#include "debug.h"
-#include "comm.h"
struct thread *thread__new(pid_t pid, pid_t tid)
{
- char *comm_str;
- struct comm *comm;
- struct thread *thread = zalloc(sizeof(*thread));
-
- if (thread != NULL) {
- map_groups__init(&thread->mg);
- thread->pid_ = pid;
- thread->tid = tid;
- thread->ppid = -1;
- INIT_LIST_HEAD(&thread->comm_list);
-
- comm_str = malloc(32);
- if (!comm_str)
- goto err_thread;
-
- snprintf(comm_str, 32, ":%d", tid);
- comm = comm__new(comm_str, 0);
- free(comm_str);
- if (!comm)
- goto err_thread;
-
- list_add(&comm->list, &thread->comm_list);
- }
-
- return thread;
-
-err_thread:
- free(thread);
- return NULL;
-}
-
-void thread__delete(struct thread *thread)
-{
- struct comm *comm, *tmp;
-
- map_groups__exit(&thread->mg);
- list_for_each_entry_safe(comm, tmp, &thread->comm_list, list) {
- list_del(&comm->list);
- comm__free(comm);
+ struct thread *self = zalloc(sizeof(*self));
+
+ if (self != NULL) {
+ map_groups__init(&self->mg);
+ self->pid_ = pid;
+ self->tid = tid;
+ self->ppid = -1;
+ self->comm = malloc(32);
+ if (self->comm)
+ snprintf(self->comm, 32, ":%d", self->tid);
}
- free(thread);
+ return self;
}
-struct comm *thread__comm(const struct thread *thread)
+void thread__delete(struct thread *self)
{
- if (list_empty(&thread->comm_list))
- return NULL;
-
- return list_first_entry(&thread->comm_list, struct comm, list);
+ map_groups__exit(&self->mg);
+ free(self->comm);
+ free(self);
}
-/* CHECKME: time should always be 0 if event aren't ordered */
-int thread__set_comm(struct thread *thread, const char *str, u64 timestamp)
+int thread__set_comm(struct thread *self, const char *comm)
{
- struct comm *new, *curr = thread__comm(thread);
-
- /* Override latest entry if it had no specific time coverage */
- if (!curr->start) {
- comm__override(curr, str, timestamp);
- } else {
- new = comm__new(str, timestamp);
- if (!new)
- return -ENOMEM;
- list_add(&new->list, &thread->comm_list);
+ int err;
+
+ if (self->comm)
+ free(self->comm);
+ self->comm = strdup(comm);
+ err = self->comm == NULL ? -ENOMEM : 0;
+ if (!err) {
+ self->comm_set = true;
}
-
- thread->comm_set = true;
-
- return 0;
-}
-
-const char *thread__comm_str(const struct thread *thread)
-{
- const struct comm *comm = thread__comm(thread);
-
- if (!comm)
- return NULL;
-
- return comm__str(comm);
+ return err;
}
-/* CHECKME: it should probably better return the max comm len from its comm list */
-int thread__comm_len(struct thread *thread)
+int thread__comm_len(struct thread *self)
{
- if (!thread->comm_len) {
- const char *comm = thread__comm_str(thread);
- if (!comm)
+ if (!self->comm_len) {
+ if (!self->comm)
return 0;
- thread->comm_len = strlen(comm);
+ self->comm_len = strlen(self->comm);
}
- return thread->comm_len;
+ return self->comm_len;
}
size_t thread__fprintf(struct thread *thread, FILE *fp)
{
- return fprintf(fp, "Thread %d %s\n", thread->tid, thread__comm_str(thread)) +
+ return fprintf(fp, "Thread %d %s\n", thread->tid, thread->comm) +
map_groups__fprintf(&thread->mg, verbose, fp);
}
-void thread__insert_map(struct thread *thread, struct map *map)
+void thread__insert_map(struct thread *self, struct map *map)
{
- map_groups__fixup_overlappings(&thread->mg, map, verbose, stderr);
- map_groups__insert(&thread->mg, map);
+ map_groups__fixup_overlappings(&self->mg, map, verbose, stderr);
+ map_groups__insert(&self->mg, map);
}
-int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp)
+int thread__fork(struct thread *self, struct thread *parent)
{
- int i, err;
+ int i;
if (parent->comm_set) {
- const char *comm = thread__comm_str(parent);
- if (!comm)
+ if (self->comm)
+ free(self->comm);
+ self->comm = strdup(parent->comm);
+ if (!self->comm)
return -ENOMEM;
- err = thread__set_comm(thread, comm, timestamp);
- if (!err)
- return err;
- thread->comm_set = true;
+ self->comm_set = true;
}
for (i = 0; i < MAP__NR_TYPES; ++i)
- if (map_groups__clone(&thread->mg, &parent->mg, i) < 0)
+ if (map_groups__clone(&self->mg, &parent->mg, i) < 0)
return -ENOMEM;
- thread->ppid = parent->tid;
+ self->ppid = parent->tid;
return 0;
}
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 897c1b2..4ebbb40 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -2,7 +2,6 @@
#define __PERF_THREAD_H
#include <linux/rbtree.h>
-#include <linux/list.h>
#include <unistd.h>
#include <sys/types.h>
#include "symbol.h"
@@ -19,34 +18,31 @@ struct thread {
char shortname[3];
bool comm_set;
bool dead; /* if set thread has exited */
- struct list_head comm_list;
+ char *comm;
int comm_len;
void *priv;
};
struct machine;
-struct comm;
struct thread *thread__new(pid_t pid, pid_t tid);
-void thread__delete(struct thread *thread);
+void thread__delete(struct thread *self);
static inline void thread__exited(struct thread *thread)
{
thread->dead = true;
}
-int thread__set_comm(struct thread *thread, const char *comm, u64 timestamp);
-int thread__comm_len(struct thread *thread);
-struct comm *thread__comm(const struct thread *thread);
-const char *thread__comm_str(const struct thread *thread);
-void thread__insert_map(struct thread *thread, struct map *map);
-int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp);
+int thread__set_comm(struct thread *self, const char *comm);
+int thread__comm_len(struct thread *self);
+void thread__insert_map(struct thread *self, struct map *map);
+int thread__fork(struct thread *self, struct thread *parent);
size_t thread__fprintf(struct thread *thread, FILE *fp);
-static inline struct map *thread__find_map(struct thread *thread,
+static inline struct map *thread__find_map(struct thread *self,
enum map_type type, u64 addr)
{
- return thread ? map_groups__find(&thread->mg, type, addr) : NULL;
+ return self ? map_groups__find(&self->mg, type, addr) : NULL;
}
void thread__find_addr_map(struct thread *thread, struct machine *machine,
diff --git a/tools/perf/util/top.c b/tools/perf/util/top.c
index ce793c7..f857b51 100644
--- a/tools/perf/util/top.c
+++ b/tools/perf/util/top.c
@@ -27,7 +27,7 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size)
float ksamples_per_sec;
float esamples_percent;
struct perf_record_opts *opts = &top->record_opts;
- struct target *target = &opts->target;
+ struct perf_target *target = &opts->target;
size_t ret = 0;
if (top->samples) {
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h
index 88cfeaf..b554ffc 100644
--- a/tools/perf/util/top.h
+++ b/tools/perf/util/top.h
@@ -24,7 +24,6 @@ struct perf_top {
u64 exact_samples;
u64 guest_us_samples, guest_kernel_samples;
int print_entries, count_filter, delay_secs;
- int max_stack;
bool hide_kernel_symbols, hide_user_symbols, zero;
bool use_tui, use_stdio;
bool kptr_restrict_warned;
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 6681f71..e9e1c03 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -120,6 +120,42 @@ raw_field_value(struct event_format *event, const char *name, void *data)
return val;
}
+void *raw_field_ptr(struct event_format *event, const char *name, void *data)
+{
+ struct format_field *field;
+
+ field = pevent_find_any_field(event, name);
+ if (!field)
+ return NULL;
+
+ if (field->flags & FIELD_IS_DYNAMIC) {
+ int offset;
+
+ offset = *(int *)(data + field->offset);
+ offset &= 0xffff;
+
+ return data + offset;
+ }
+
+ return data + field->offset;
+}
+
+int trace_parse_common_type(struct pevent *pevent, void *data)
+{
+ struct pevent_record record;
+
+ record.data = data;
+ return pevent_data_type(pevent, &record);
+}
+
+int trace_parse_common_pid(struct pevent *pevent, void *data)
+{
+ struct pevent_record record;
+
+ record.data = data;
+ return pevent_data_pid(pevent, &record);
+}
+
unsigned long long read_size(struct event_format *event, void *ptr, int size)
{
return pevent_read_number(event->pevent, ptr, size);
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index 04df631..fafe1a4 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -11,6 +11,8 @@ union perf_event;
struct perf_tool;
struct thread;
+extern struct pevent *perf_pevent;
+
int bigendian(void);
struct pevent *read_trace_init(int file_bigendian, int host_bigendian);
@@ -21,19 +23,26 @@ int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size);
int parse_event_file(struct pevent *pevent,
char *buf, unsigned long size, char *sys);
+struct pevent_record *trace_peek_data(struct pevent *pevent, int cpu);
+
unsigned long long
raw_field_value(struct event_format *event, const char *name, void *data);
+void *raw_field_ptr(struct event_format *event, const char *name, void *data);
void parse_proc_kallsyms(struct pevent *pevent, char *file, unsigned int size);
void parse_ftrace_printk(struct pevent *pevent, char *file, unsigned int size);
ssize_t trace_report(int fd, struct pevent **pevent, bool repipe);
+int trace_parse_common_type(struct pevent *pevent, void *data);
+int trace_parse_common_pid(struct pevent *pevent, void *data);
+
struct event_format *trace_find_next_event(struct pevent *pevent,
struct event_format *event);
unsigned long long read_size(struct event_format *event, void *ptr, int size);
unsigned long long eval_flag(const char *flag);
+struct pevent_record *trace_read_data(struct pevent *pevent, int cpu);
int read_tracing_data(int fd, struct list_head *pattrs);
struct tracing_data {
diff --git a/tools/perf/util/unwind.c b/tools/perf/util/unwind.c
index 0efd539..2f891f7 100644
--- a/tools/perf/util/unwind.c
+++ b/tools/perf/util/unwind.c
@@ -39,15 +39,6 @@ UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
-extern int
-UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
- unw_word_t ip,
- unw_word_t segbase,
- const char *obj_name, unw_word_t start,
- unw_word_t end);
-
-#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
-
#define DW_EH_PE_FORMAT_MASK 0x0f /* format of the encoded value */
#define DW_EH_PE_APPL_MASK 0x70 /* how the value is to be applied */
@@ -254,9 +245,8 @@ static int unwind_spec_ehframe(struct dso *dso, struct machine *machine,
return 0;
}
-static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine,
- u64 *table_data, u64 *segbase,
- u64 *fde_count)
+static int read_unwind_spec(struct dso *dso, struct machine *machine,
+ u64 *table_data, u64 *segbase, u64 *fde_count)
{
int ret = -EINVAL, fd;
u64 offset;
@@ -265,7 +255,6 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine,
if (fd < 0)
return -EINVAL;
- /* Check the .eh_frame section for unwinding info */
offset = elf_section_offset(fd, ".eh_frame_hdr");
close(fd);
@@ -274,29 +263,10 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine,
table_data, segbase,
fde_count);
+ /* TODO .debug_frame check if eh_frame_hdr fails */
return ret;
}
-#ifndef NO_LIBUNWIND_DEBUG_FRAME
-static int read_unwind_spec_debug_frame(struct dso *dso,
- struct machine *machine, u64 *offset)
-{
- int fd = dso__data_fd(dso, machine);
-
- if (fd < 0)
- return -EINVAL;
-
- /* Check the .debug_frame section for unwinding info */
- *offset = elf_section_offset(fd, ".debug_frame");
- close(fd);
-
- if (*offset)
- return 0;
-
- return -EINVAL;
-}
-#endif
-
static struct map *find_map(unw_word_t ip, struct unwind_info *ui)
{
struct addr_location al;
@@ -321,33 +291,20 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
pr_debug("unwind: find_proc_info dso %s\n", map->dso->name);
- /* Check the .eh_frame section for unwinding info */
- if (!read_unwind_spec_eh_frame(map->dso, ui->machine,
- &table_data, &segbase, &fde_count)) {
- memset(&di, 0, sizeof(di));
- di.format = UNW_INFO_FORMAT_REMOTE_TABLE;
- di.start_ip = map->start;
- di.end_ip = map->end;
- di.u.rti.segbase = map->start + segbase;
- di.u.rti.table_data = map->start + table_data;
- di.u.rti.table_len = fde_count * sizeof(struct table_entry)
- / sizeof(unw_word_t);
- return dwarf_search_unwind_table(as, ip, &di, pi,
- need_unwind_info, arg);
- }
-
-#ifndef NO_LIBUNWIND_DEBUG_FRAME
- /* Check the .debug_frame section for unwinding info */
- if (!read_unwind_spec_debug_frame(map->dso, ui->machine, &segbase)) {
- memset(&di, 0, sizeof(di));
- dwarf_find_debug_frame(0, &di, ip, 0, map->dso->name,
- map->start, map->end);
- return dwarf_search_unwind_table(as, ip, &di, pi,
- need_unwind_info, arg);
- }
-#endif
+ if (read_unwind_spec(map->dso, ui->machine,
+ &table_data, &segbase, &fde_count))
+ return -EINVAL;
- return -EINVAL;
+ memset(&di, 0, sizeof(di));
+ di.format = UNW_INFO_FORMAT_REMOTE_TABLE;
+ di.start_ip = map->start;
+ di.end_ip = map->end;
+ di.u.rti.segbase = map->start + segbase;
+ di.u.rti.table_data = map->start + table_data;
+ di.u.rti.table_len = fde_count * sizeof(struct table_entry)
+ / sizeof(unw_word_t);
+ return dwarf_search_unwind_table(as, ip, &di, pi,
+ need_unwind_info, arg);
}
static int access_fpreg(unw_addr_space_t __maybe_unused as,
@@ -559,7 +516,7 @@ static unw_accessors_t accessors = {
};
static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
- void *arg, int max_stack)
+ void *arg)
{
unw_addr_space_t addr_space;
unw_cursor_t c;
@@ -575,7 +532,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
if (ret)
display_error(ret);
- while (!ret && (unw_step(&c) > 0) && max_stack--) {
+ while (!ret && (unw_step(&c) > 0)) {
unw_word_t ip;
unw_get_reg(&c, UNW_REG_IP, &ip);
@@ -588,8 +545,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct machine *machine, struct thread *thread,
- u64 sample_uregs, struct perf_sample *data,
- int max_stack)
+ u64 sample_uregs, struct perf_sample *data)
{
unw_word_t ip;
struct unwind_info ui = {
@@ -611,5 +567,5 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
if (ret)
return -ENOMEM;
- return get_entries(&ui, cb, arg, max_stack);
+ return get_entries(&ui, cb, arg);
}
diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
index d5966f49..cb6bc50 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -13,12 +13,12 @@ struct unwind_entry {
typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg);
-#ifdef HAVE_LIBUNWIND_SUPPORT
+#ifdef LIBUNWIND_SUPPORT
int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct machine *machine,
struct thread *thread,
u64 sample_uregs,
- struct perf_sample *data, int max_stack);
+ struct perf_sample *data);
int unwind__arch_reg_id(int regnum);
#else
static inline int
@@ -27,10 +27,9 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
struct machine *machine __maybe_unused,
struct thread *thread __maybe_unused,
u64 sample_uregs __maybe_unused,
- struct perf_sample *data __maybe_unused,
- int max_stack __maybe_unused)
+ struct perf_sample *data __maybe_unused)
{
return 0;
}
-#endif /* HAVE_LIBUNWIND_SUPPORT */
+#endif /* LIBUNWIND_SUPPORT */
#endif /* __UNWIND_H */
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 28a0a89..6d17b18 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -1,7 +1,7 @@
#include "../perf.h"
#include "util.h"
#include <sys/mman.h>
-#ifdef HAVE_BACKTRACE_SUPPORT
+#ifdef BACKTRACE_SUPPORT
#include <execinfo.h>
#endif
#include <stdio.h>
@@ -55,20 +55,17 @@ int mkdir_p(char *path, mode_t mode)
return (stat(path, &st) && mkdir(path, mode)) ? -1 : 0;
}
-static int slow_copyfile(const char *from, const char *to, mode_t mode)
+static int slow_copyfile(const char *from, const char *to)
{
- int err = -1;
+ int err = 0;
char *line = NULL;
size_t n;
FILE *from_fp = fopen(from, "r"), *to_fp;
- mode_t old_umask;
if (from_fp == NULL)
goto out;
- old_umask = umask(mode ^ 0777);
to_fp = fopen(to, "w");
- umask(old_umask);
if (to_fp == NULL)
goto out_fclose_from;
@@ -85,7 +82,7 @@ out:
return err;
}
-int copyfile_mode(const char *from, const char *to, mode_t mode)
+int copyfile(const char *from, const char *to)
{
int fromfd, tofd;
struct stat st;
@@ -96,13 +93,13 @@ int copyfile_mode(const char *from, const char *to, mode_t mode)
goto out;
if (st.st_size == 0) /* /proc? do it slowly... */
- return slow_copyfile(from, to, mode);
+ return slow_copyfile(from, to);
fromfd = open(from, O_RDONLY);
if (fromfd < 0)
goto out;
- tofd = creat(to, mode);
+ tofd = creat(to, 0755);
if (tofd < 0)
goto out_close_from;
@@ -124,11 +121,6 @@ out:
return err;
}
-int copyfile(const char *from, const char *to)
-{
- return copyfile_mode(from, to, 0755);
-}
-
unsigned long convert_unit(unsigned long value, char *unit)
{
*unit = ' ';
@@ -212,7 +204,7 @@ int hex2u64(const char *ptr, u64 *long_val)
}
/* Obtain a backtrace and print it to stdout. */
-#ifdef HAVE_BACKTRACE_SUPPORT
+#ifdef BACKTRACE_SUPPORT
void dump_stack(void)
{
void *array[16];
@@ -369,47 +361,3 @@ int parse_nsec_time(const char *str, u64 *ptime)
*ptime = time_sec * NSEC_PER_SEC + time_nsec;
return 0;
}
-
-unsigned long parse_tag_value(const char *str, struct parse_tag *tags)
-{
- struct parse_tag *i = tags;
-
- while (i->tag) {
- char *s;
-
- s = strchr(str, i->tag);
- if (s) {
- unsigned long int value;
- char *endptr;
-
- value = strtoul(str, &endptr, 10);
- if (s != endptr)
- break;
-
- if (value > ULONG_MAX / i->mult)
- break;
- value *= i->mult;
- return value;
- }
- i++;
- }
-
- return (unsigned long) -1;
-}
-
-int filename__read_int(const char *filename, int *value)
-{
- char line[64];
- int fd = open(filename, O_RDONLY), err = -1;
-
- if (fd < 0)
- return -1;
-
- if (read(fd, line, sizeof(line)) > 0) {
- *value = atoi(line);
- err = 0;
- }
-
- close(fd);
- return err;
-}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index c8f362d..a535359 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -128,8 +128,6 @@ void put_tracing_file(char *file);
#endif
#endif
-#define PERF_GTK_DSO "libperf-gtk.so"
-
/* General helper functions */
extern void usage(const char *err) NORETURN;
extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2)));
@@ -243,7 +241,6 @@ static inline int sane_case(int x, int high)
int mkdir_p(char *path, mode_t mode);
int copyfile(const char *from, const char *to);
-int copyfile_mode(const char *from, const char *to, mode_t mode);
s64 perf_atoll(const char *str);
char **argv_split(const char *str, int *argcp);
@@ -273,13 +270,6 @@ bool is_power_of_2(unsigned long n)
return (n != 0 && ((n & (n - 1)) == 0));
}
-static inline unsigned next_pow2(unsigned x)
-{
- if (!x)
- return 1;
- return 1ULL << (32 - __builtin_clz(x - 1));
-}
-
size_t hex_width(u64 v);
int hex2u64(const char *ptr, u64 *val);
@@ -291,20 +281,4 @@ void dump_stack(void);
extern unsigned int page_size;
void get_term_dimensions(struct winsize *ws);
-
-struct parse_tag {
- char tag;
- int mult;
-};
-
-unsigned long parse_tag_value(const char *str, struct parse_tag *tags);
-
-#define SRCLINE_UNKNOWN ((char *) "??:0")
-
-struct dso;
-
-char *get_srcline(struct dso *dso, unsigned long addr);
-void free_srcline(char *srcline);
-
-int filename__read_int(const char *filename, int *value);
#endif /* GIT_COMPAT_UTIL_H */
diff --git a/tools/power/cpupower/man/cpupower-idle-info.1 b/tools/power/cpupower/man/cpupower-idle-info.1
index 7b3646a..4178eff 100644
--- a/tools/power/cpupower/man/cpupower-idle-info.1
+++ b/tools/power/cpupower/man/cpupower-idle-info.1
@@ -87,5 +87,4 @@ Thomas Renninger <trenn@suse.de>
.fi
.SH "SEE ALSO"
.LP
-cpupower(1), cpupower\-monitor(1), cpupower\-info(1), cpupower\-set(1),
-cpupower\-idle\-set(1)
+cpupower(1), cpupower\-monitor(1), cpupower\-info(1), cpupower\-set(1)
diff --git a/tools/power/cpupower/man/cpupower-idle-set.1 b/tools/power/cpupower/man/cpupower-idle-set.1
deleted file mode 100644
index 6b16072..0000000
--- a/tools/power/cpupower/man/cpupower-idle-set.1
+++ /dev/null
@@ -1,71 +0,0 @@
-.TH "CPUPOWER-IDLE-SET" "1" "0.1" "" "cpupower Manual"
-.SH "NAME"
-.LP
-cpupower idle\-set \- Utility to set cpu idle state specific kernel options
-.SH "SYNTAX"
-.LP
-cpupower [ \-c cpulist ] idle\-info [\fIoptions\fP]
-.SH "DESCRIPTION"
-.LP
-The cpupower idle\-set subcommand allows to set cpu idle, also called cpu
-sleep state, specific options offered by the kernel. One example is disabling
-sleep states. This can be handy for power vs performance tuning.
-.SH "OPTIONS"
-.LP
-.TP
-\fB\-d\fR \fB\-\-disable\fR
-Disable a specific processor sleep state.
-.TP
-\fB\-e\fR \fB\-\-enable\fR
-Enable a specific processor sleep state.
-
-.SH "REMARKS"
-.LP
-Cpuidle Governors Policy on Disabling Sleep States
-
-.RS 4
-Depending on the used cpuidle governor, implementing the kernel policy
-how to choose sleep states, subsequent sleep states on this core, might get
-disabled as well.
-
-There are two cpuidle governors ladder and menu. While the ladder
-governor is always available, if CONFIG_CPU_IDLE is selected, the
-menu governor additionally requires CONFIG_NO_HZ.
-
-The behavior and the effect of the disable variable depends on the
-implementation of a particular governor. In the ladder governor, for
-example, it is not coherent, i.e. if one is disabling a light state,
-then all deeper states are disabled as well. Likewise, if one enables a
-deep state but a lighter state still is disabled, then this has no effect.
-.RE
-.LP
-Disabling the Lightest Sleep State may not have any Affect
-
-.RS 4
-If criteria are not met to enter deeper sleep states and the lightest sleep
-state is chosen when idle, the kernel may still enter this sleep state,
-irrespective of whether it is disabled or not. This is also reflected in
-the usage count of the disabled sleep state when using the cpupower idle-info
-command.
-.RE
-.LP
-Selecting specific CPU Cores
-
-.RS 4
-By default processor sleep states of all CPU cores are set. Please refer
-to the cpupower(1) manpage in the \-\-cpu option section how to disable
-C-states of specific cores.
-.RE
-.SH "FILES"
-.nf
-\fI/sys/devices/system/cpu/cpu*/cpuidle/state*\fP
-\fI/sys/devices/system/cpu/cpuidle/*\fP
-.fi
-.SH "AUTHORS"
-.nf
-Thomas Renninger <trenn@suse.de>
-.fi
-.SH "SEE ALSO"
-.LP
-cpupower(1), cpupower\-monitor(1), cpupower\-info(1), cpupower\-set(1),
-cpupower\-idle\-info(1)
diff --git a/tools/power/cpupower/utils/helpers/sysfs.c b/tools/power/cpupower/utils/helpers/sysfs.c
index 851c7a1..5cdc600 100644
--- a/tools/power/cpupower/utils/helpers/sysfs.c
+++ b/tools/power/cpupower/utils/helpers/sysfs.c
@@ -278,7 +278,7 @@ static char *sysfs_idlestate_get_one_string(unsigned int cpu,
int sysfs_is_idlestate_disabled(unsigned int cpu,
unsigned int idlestate)
{
- if (sysfs_get_idlestate_count(cpu) <= idlestate)
+ if (sysfs_get_idlestate_count(cpu) < idlestate)
return -1;
if (!sysfs_idlestate_file_exists(cpu, idlestate,
@@ -303,7 +303,7 @@ int sysfs_idlestate_disable(unsigned int cpu,
char value[SYSFS_PATH_MAX];
int bytes_written;
- if (sysfs_get_idlestate_count(cpu) <= idlestate)
+ if (sysfs_get_idlestate_count(cpu) < idlestate)
return -1;
if (!sysfs_idlestate_file_exists(cpu, idlestate,
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 9d77f13..fe70207 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -2,7 +2,7 @@
* turbostat -- show CPU frequency and C-state residency
* on modern Intel turbo-capable processors.
*
- * Copyright (c) 2013 Intel Corporation.
+ * Copyright (c) 2012 Intel Corporation.
* Len Brown <len.brown@intel.com>
*
* This program is free software; you can redistribute it and/or modify it
@@ -47,8 +47,6 @@ unsigned int skip_c1;
unsigned int do_nhm_cstates;
unsigned int do_snb_cstates;
unsigned int do_c8_c9_c10;
-unsigned int do_slm_cstates;
-unsigned int use_c1_residency_msr;
unsigned int has_aperf;
unsigned int has_epb;
unsigned int units = 1000000000; /* Ghz etc */
@@ -83,8 +81,6 @@ double rapl_joule_counter_range;
#define RAPL_DRAM (1 << 3)
#define RAPL_PKG_PERF_STATUS (1 << 4)
#define RAPL_DRAM_PERF_STATUS (1 << 5)
-#define RAPL_PKG_POWER_INFO (1 << 6)
-#define RAPL_CORE_POLICY (1 << 7)
#define TJMAX_DEFAULT 100
#define MAX(a, b) ((a) > (b) ? (a) : (b))
@@ -100,7 +96,7 @@ struct thread_data {
unsigned long long tsc;
unsigned long long aperf;
unsigned long long mperf;
- unsigned long long c1;
+ unsigned long long c1; /* derived */
unsigned long long extra_msr64;
unsigned long long extra_delta64;
unsigned long long extra_msr32;
@@ -270,7 +266,7 @@ void print_header(void)
outp += sprintf(outp, " MSR 0x%03X", extra_msr_offset64);
if (do_nhm_cstates)
outp += sprintf(outp, " %%c1");
- if (do_nhm_cstates && !do_slm_cstates)
+ if (do_nhm_cstates)
outp += sprintf(outp, " %%c3");
if (do_nhm_cstates)
outp += sprintf(outp, " %%c6");
@@ -284,9 +280,9 @@ void print_header(void)
if (do_snb_cstates)
outp += sprintf(outp, " %%pc2");
- if (do_nhm_cstates && !do_slm_cstates)
+ if (do_nhm_cstates)
outp += sprintf(outp, " %%pc3");
- if (do_nhm_cstates && !do_slm_cstates)
+ if (do_nhm_cstates)
outp += sprintf(outp, " %%pc6");
if (do_snb_cstates)
outp += sprintf(outp, " %%pc7");
@@ -484,7 +480,7 @@ int format_counters(struct thread_data *t, struct core_data *c,
if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE))
goto done;
- if (do_nhm_cstates && !do_slm_cstates)
+ if (do_nhm_cstates)
outp += sprintf(outp, " %6.2f", 100.0 * c->c3/t->tsc);
if (do_nhm_cstates)
outp += sprintf(outp, " %6.2f", 100.0 * c->c6/t->tsc);
@@ -503,9 +499,9 @@ int format_counters(struct thread_data *t, struct core_data *c,
if (do_snb_cstates)
outp += sprintf(outp, " %6.2f", 100.0 * p->pc2/t->tsc);
- if (do_nhm_cstates && !do_slm_cstates)
+ if (do_nhm_cstates)
outp += sprintf(outp, " %6.2f", 100.0 * p->pc3/t->tsc);
- if (do_nhm_cstates && !do_slm_cstates)
+ if (do_nhm_cstates)
outp += sprintf(outp, " %6.2f", 100.0 * p->pc6/t->tsc);
if (do_snb_cstates)
outp += sprintf(outp, " %6.2f", 100.0 * p->pc7/t->tsc);
@@ -652,24 +648,17 @@ delta_thread(struct thread_data *new, struct thread_data *old,
}
- if (use_c1_residency_msr) {
- /*
- * Some models have a dedicated C1 residency MSR,
- * which should be more accurate than the derivation below.
- */
- } else {
- /*
- * As counter collection is not atomic,
- * it is possible for mperf's non-halted cycles + idle states
- * to exceed TSC's all cycles: show c1 = 0% in that case.
- */
- if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > old->tsc)
- old->c1 = 0;
- else {
- /* normal case, derive c1 */
- old->c1 = old->tsc - old->mperf - core_delta->c3
+ /*
+ * As counter collection is not atomic,
+ * it is possible for mperf's non-halted cycles + idle states
+ * to exceed TSC's all cycles: show c1 = 0% in that case.
+ */
+ if ((old->mperf + core_delta->c3 + core_delta->c6 + core_delta->c7) > old->tsc)
+ old->c1 = 0;
+ else {
+ /* normal case, derive c1 */
+ old->c1 = old->tsc - old->mperf - core_delta->c3
- core_delta->c6 - core_delta->c7;
- }
}
if (old->mperf == 0) {
@@ -883,21 +872,13 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
if (get_msr(cpu, extra_msr_offset64, &t->extra_msr64))
return -5;
- if (use_c1_residency_msr) {
- if (get_msr(cpu, MSR_CORE_C1_RES, &t->c1))
- return -6;
- }
-
/* collect core counters only for 1st thread in core */
if (!(t->flags & CPU_IS_FIRST_THREAD_IN_CORE))
return 0;
- if (do_nhm_cstates && !do_slm_cstates) {
+ if (do_nhm_cstates) {
if (get_msr(cpu, MSR_CORE_C3_RESIDENCY, &c->c3))
return -6;
- }
-
- if (do_nhm_cstates) {
if (get_msr(cpu, MSR_CORE_C6_RESIDENCY, &c->c6))
return -7;
}
@@ -917,7 +898,7 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE))
return 0;
- if (do_nhm_cstates && !do_slm_cstates) {
+ if (do_nhm_cstates) {
if (get_msr(cpu, MSR_PKG_C3_RESIDENCY, &p->pc3))
return -9;
if (get_msr(cpu, MSR_PKG_C6_RESIDENCY, &p->pc6))
@@ -996,7 +977,7 @@ void print_verbose_header(void)
ratio, bclk, ratio * bclk);
get_msr(0, MSR_IA32_POWER_CTL, &msr);
- fprintf(stderr, "cpu0: MSR_IA32_POWER_CTL: 0x%08llx (C1E auto-promotion: %sabled)\n",
+ fprintf(stderr, "cpu0: MSR_IA32_POWER_CTL: 0x%08llx (C1E: %sabled)\n",
msr, msr & 0x2 ? "EN" : "DIS");
if (!do_ivt_turbo_ratio_limit)
@@ -1065,28 +1046,25 @@ print_nhm_turbo_ratio_limits:
switch(msr & 0x7) {
case 0:
- fprintf(stderr, do_slm_cstates ? "no pkg states" : "pc0");
+ fprintf(stderr, "pc0");
break;
case 1:
- fprintf(stderr, do_slm_cstates ? "no pkg states" : do_snb_cstates ? "pc2" : "pc0");
+ fprintf(stderr, do_snb_cstates ? "pc2" : "pc0");
break;
case 2:
- fprintf(stderr, do_slm_cstates ? "invalid" : do_snb_cstates ? "pc6-noret" : "pc3");
+ fprintf(stderr, do_snb_cstates ? "pc6-noret" : "pc3");
break;
case 3:
- fprintf(stderr, do_slm_cstates ? "invalid" : "pc6");
+ fprintf(stderr, "pc6");
break;
case 4:
- fprintf(stderr, do_slm_cstates ? "pc4" : "pc7");
+ fprintf(stderr, "pc7");
break;
case 5:
- fprintf(stderr, do_slm_cstates ? "invalid" : do_snb_cstates ? "pc7s" : "invalid");
- break;
- case 6:
- fprintf(stderr, do_slm_cstates ? "pc6" : "invalid");
+ fprintf(stderr, do_snb_cstates ? "pc7s" : "invalid");
break;
case 7:
- fprintf(stderr, do_slm_cstates ? "pc7" : "unlimited");
+ fprintf(stderr, "unlimited");
break;
default:
fprintf(stderr, "invalid");
@@ -1482,8 +1460,6 @@ int has_nehalem_turbo_ratio_limit(unsigned int family, unsigned int model)
case 0x3F: /* HSW */
case 0x45: /* HSW */
case 0x46: /* HSW */
- case 0x37: /* BYT */
- case 0x4D: /* AVN */
return 1;
case 0x2E: /* Nehalem-EX Xeon - Beckton */
case 0x2F: /* Westmere-EX Xeon - Eagleton */
@@ -1556,33 +1532,14 @@ int print_epb(struct thread_data *t, struct core_data *c, struct pkg_data *p)
#define RAPL_POWER_GRANULARITY 0x7FFF /* 15 bit power granularity */
#define RAPL_TIME_GRANULARITY 0x3F /* 6 bit time granularity */
-double get_tdp(model)
-{
- unsigned long long msr;
-
- if (do_rapl & RAPL_PKG_POWER_INFO)
- if (!get_msr(0, MSR_PKG_POWER_INFO, &msr))
- return ((msr >> 0) & RAPL_POWER_GRANULARITY) * rapl_power_units;
-
- switch (model) {
- case 0x37:
- case 0x4D:
- return 30.0;
- default:
- return 135.0;
- }
-}
-
-
/*
* rapl_probe()
*
- * sets do_rapl, rapl_power_units, rapl_energy_units, rapl_time_units
+ * sets do_rapl
*/
void rapl_probe(unsigned int family, unsigned int model)
{
unsigned long long msr;
- unsigned int time_unit;
double tdp;
if (!genuine_intel)
@@ -1598,15 +1555,11 @@ void rapl_probe(unsigned int family, unsigned int model)
case 0x3F: /* HSW */
case 0x45: /* HSW */
case 0x46: /* HSW */
- do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_GFX | RAPL_PKG_POWER_INFO;
+ do_rapl = RAPL_PKG | RAPL_CORES | RAPL_GFX;
break;
case 0x2D:
case 0x3E:
- do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_DRAM | RAPL_PKG_PERF_STATUS | RAPL_DRAM_PERF_STATUS | RAPL_PKG_POWER_INFO;
- break;
- case 0x37: /* BYT */
- case 0x4D: /* AVN */
- do_rapl = RAPL_PKG | RAPL_CORES ;
+ do_rapl = RAPL_PKG | RAPL_CORES | RAPL_DRAM | RAPL_PKG_PERF_STATUS | RAPL_DRAM_PERF_STATUS;
break;
default:
return;
@@ -1617,22 +1570,19 @@ void rapl_probe(unsigned int family, unsigned int model)
return;
rapl_power_units = 1.0 / (1 << (msr & 0xF));
- if (model == 0x37)
- rapl_energy_units = 1.0 * (1 << (msr >> 8 & 0x1F)) / 1000000;
- else
- rapl_energy_units = 1.0 / (1 << (msr >> 8 & 0x1F));
-
- time_unit = msr >> 16 & 0xF;
- if (time_unit == 0)
- time_unit = 0xA;
+ rapl_energy_units = 1.0 / (1 << (msr >> 8 & 0x1F));
+ rapl_time_units = 1.0 / (1 << (msr >> 16 & 0xF));
- rapl_time_units = 1.0 / (1 << (time_unit));
+ /* get TDP to determine energy counter range */
+ if (get_msr(0, MSR_PKG_POWER_INFO, &msr))
+ return;
- tdp = get_tdp(model);
+ tdp = ((msr >> 0) & RAPL_POWER_GRANULARITY) * rapl_power_units;
rapl_joule_counter_range = 0xFFFFFFFF * rapl_energy_units / tdp;
+
if (verbose)
- fprintf(stderr, "RAPL: %.0f sec. Joule Counter Range, at %.0f Watts\n", rapl_joule_counter_range, tdp);
+ fprintf(stderr, "RAPL: %.0f sec. Joule Counter Range\n", rapl_joule_counter_range);
return;
}
@@ -1718,6 +1668,7 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p)
{
unsigned long long msr;
int cpu;
+ double local_rapl_power_units, local_rapl_energy_units, local_rapl_time_units;
if (!do_rapl)
return 0;
@@ -1735,13 +1686,23 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p)
if (get_msr(cpu, MSR_RAPL_POWER_UNIT, &msr))
return -1;
+ local_rapl_power_units = 1.0 / (1 << (msr & 0xF));
+ local_rapl_energy_units = 1.0 / (1 << (msr >> 8 & 0x1F));
+ local_rapl_time_units = 1.0 / (1 << (msr >> 16 & 0xF));
+
+ if (local_rapl_power_units != rapl_power_units)
+ fprintf(stderr, "cpu%d, ERROR: Power units mis-match\n", cpu);
+ if (local_rapl_energy_units != rapl_energy_units)
+ fprintf(stderr, "cpu%d, ERROR: Energy units mis-match\n", cpu);
+ if (local_rapl_time_units != rapl_time_units)
+ fprintf(stderr, "cpu%d, ERROR: Time units mis-match\n", cpu);
+
if (verbose) {
fprintf(stderr, "cpu%d: MSR_RAPL_POWER_UNIT: 0x%08llx "
"(%f Watts, %f Joules, %f sec.)\n", cpu, msr,
- rapl_power_units, rapl_energy_units, rapl_time_units);
+ local_rapl_power_units, local_rapl_energy_units, local_rapl_time_units);
}
- if (do_rapl & RAPL_PKG_POWER_INFO) {
-
+ if (do_rapl & RAPL_PKG) {
if (get_msr(cpu, MSR_PKG_POWER_INFO, &msr))
return -5;
@@ -1753,9 +1714,6 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p)
((msr >> 32) & RAPL_POWER_GRANULARITY) * rapl_power_units,
((msr >> 48) & RAPL_TIME_GRANULARITY) * rapl_time_units);
- }
- if (do_rapl & RAPL_PKG) {
-
if (get_msr(cpu, MSR_PKG_POWER_LIMIT, &msr))
return -9;
@@ -1791,16 +1749,12 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p)
print_power_limit_msr(cpu, msr, "DRAM Limit");
}
- if (do_rapl & RAPL_CORE_POLICY) {
+ if (do_rapl & RAPL_CORES) {
if (verbose) {
if (get_msr(cpu, MSR_PP0_POLICY, &msr))
return -7;
fprintf(stderr, "cpu%d: MSR_PP0_POLICY: %lld\n", cpu, msr & 0xF);
- }
- }
- if (do_rapl & RAPL_CORES) {
- if (verbose) {
if (get_msr(cpu, MSR_PP0_POWER_LIMIT, &msr))
return -9;
@@ -1859,48 +1813,10 @@ int has_c8_c9_c10(unsigned int family, unsigned int model)
}
-int is_slm(unsigned int family, unsigned int model)
-{
- if (!genuine_intel)
- return 0;
- switch (model) {
- case 0x37: /* BYT */
- case 0x4D: /* AVN */
- return 1;
- }
- return 0;
-}
-
-#define SLM_BCLK_FREQS 5
-double slm_freq_table[SLM_BCLK_FREQS] = { 83.3, 100.0, 133.3, 116.7, 80.0};
-
-double slm_bclk(void)
-{
- unsigned long long msr = 3;
- unsigned int i;
- double freq;
-
- if (get_msr(0, MSR_FSB_FREQ, &msr))
- fprintf(stderr, "SLM BCLK: unknown\n");
-
- i = msr & 0xf;
- if (i >= SLM_BCLK_FREQS) {
- fprintf(stderr, "SLM BCLK[%d] invalid\n", i);
- msr = 3;
- }
- freq = slm_freq_table[i];
-
- fprintf(stderr, "SLM BCLK: %.1f Mhz\n", freq);
-
- return freq;
-}
-
double discover_bclk(unsigned int family, unsigned int model)
{
if (is_snb(family, model))
return 100.00;
- else if (is_slm(family, model))
- return slm_bclk();
else
return 133.33;
}
@@ -1957,7 +1873,7 @@ int set_temperature_target(struct thread_data *t, struct core_data *c, struct pk
fprintf(stderr, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C)\n",
cpu, msr, target_c_local);
- if (target_c_local < 85 || target_c_local > 127)
+ if (target_c_local < 85 || target_c_local > 120)
goto guess;
tcc_activation_temp = target_c_local;
@@ -2054,7 +1970,6 @@ void check_cpuid()
do_smi = do_nhm_cstates;
do_snb_cstates = is_snb(family, model);
do_c8_c9_c10 = has_c8_c9_c10(family, model);
- do_slm_cstates = is_slm(family, model);
bclk = discover_bclk(family, model);
do_nehalem_turbo_ratio_limit = has_nehalem_turbo_ratio_limit(family, model);
@@ -2416,7 +2331,7 @@ int main(int argc, char **argv)
cmdline(argc, argv);
if (verbose)
- fprintf(stderr, "turbostat v3.5 April 26, 2013"
+ fprintf(stderr, "turbostat v3.4 April 17, 2013"
" - Len Brown <lenb@kernel.org>\n");
turbostat_init();
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index ee76544..0d0506d 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -59,22 +59,21 @@ QUIET_SUBDIR0 = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
QUIET_SUBDIR1 =
ifneq ($(findstring $(MAKEFLAGS),s),s)
- ifneq ($(V),1)
- QUIET_CC = @echo ' CC '$@;
- QUIET_AR = @echo ' AR '$@;
- QUIET_LINK = @echo ' LINK '$@;
- QUIET_MKDIR = @echo ' MKDIR '$@;
- QUIET_GEN = @echo ' GEN '$@;
+ifneq ($(V),1)
+ QUIET_CC = @echo ' ' CC $@;
+ QUIET_AR = @echo ' ' AR $@;
+ QUIET_LINK = @echo ' ' LINK $@;
+ QUIET_MKDIR = @echo ' ' MKDIR $@;
+ QUIET_GEN = @echo ' ' GEN $@;
QUIET_SUBDIR0 = +@subdir=
- QUIET_SUBDIR1 = ;$(NO_SUBDIR) \
- echo ' SUBDIR '$$subdir; \
+ QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
$(MAKE) $(PRINT_DIR) -C $$subdir
- QUIET_FLEX = @echo ' FLEX '$@;
- QUIET_BISON = @echo ' BISON '$@;
+ QUIET_FLEX = @echo ' ' FLEX $@;
+ QUIET_BISON = @echo ' ' BISON $@;
descend = \
- +@echo ' DESCEND '$(1); \
+ +@echo ' ' DESCEND $(1); \
mkdir -p $(OUTPUT)$(1) && \
$(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
- endif
+endif
endif
diff --git a/tools/testing/ktest/examples/crosstests.conf b/tools/testing/ktest/examples/crosstests.conf
index a1203148..4673660 100644
--- a/tools/testing/ktest/examples/crosstests.conf
+++ b/tools/testing/ktest/examples/crosstests.conf
@@ -133,6 +133,12 @@ CROSS = frv-linux
ARCH = frv
GCC_VER = 4.5.1
+# h8300 - failed make defconfig??
+TEST_START IF ${RUN} == h8300 || ${DO_FAILED}
+CROSS = h8300-elf
+ARCH = h8300
+GCC_VER = 4.5.1
+
# m68k fails with error?
TEST_START IF ${RUN} == m68k || ${DO_DEFAULT}
CROSS = m68k-linux
diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile
deleted file mode 100644
index 4473211..0000000
--- a/tools/thermal/tmon/Makefile
+++ /dev/null
@@ -1,47 +0,0 @@
-VERSION = 1.0
-
-BINDIR=usr/bin
-WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int
-CFLAGS= -O1 ${WARNFLAGS} -fstack-protector
-CC=gcc
-
-CFLAGS+=-D VERSION=\"$(VERSION)\"
-LDFLAGS+=
-TARGET=tmon
-
-INSTALL_PROGRAM=install -m 755 -p
-DEL_FILE=rm -f
-
-INSTALL_CONFIGFILE=install -m 644 -p
-CONFIG_FILE=
-CONFIG_PATH=
-
-
-OBJS = tmon.o tui.o sysfs.o pid.o
-OBJS +=
-
-tmon: $(OBJS) Makefile tmon.h
- $(CC) ${CFLAGS} $(LDFLAGS) $(OBJS) -o $(TARGET) -lm -lpanel -lncursesw -lpthread
-
-valgrind: tmon
- sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null
-
-install:
- - mkdir -p $(INSTALL_ROOT)/$(BINDIR)
- - $(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
- - mkdir -p $(INSTALL_ROOT)/$(CONFIG_PATH)
- - $(INSTALL_CONFIGFILE) "$(CONFIG_FILE)" "$(INSTALL_ROOT)/$(CONFIG_PATH)"
-
-uninstall:
- $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
- $(CONFIG_FILE) "$(CONFIG_PATH)"
-
-
-clean:
- find . -name "*.o" | xargs $(DEL_FILE)
- rm -f $(TARGET)
-
-dist:
- git tag v$(VERSION)
- git archive --format=tar --prefix="$(TARGET)-$(VERSION)/" v$(VERSION) | \
- gzip > $(TARGET)-$(VERSION).tar.gz
diff --git a/tools/thermal/tmon/README b/tools/thermal/tmon/README
deleted file mode 100644
index 4579498..0000000
--- a/tools/thermal/tmon/README
+++ /dev/null
@@ -1,50 +0,0 @@
-TMON - A Monitoring and Testing Tool for Linux kernel thermal subsystem
-
-Why TMON?
-==========
-Increasingly, Linux is running on thermally constrained devices. The simple
-thermal relationship between processor and fan has become past for modern
-computers.
-
-As hardware vendors cope with the thermal constraints on their products, more
-and more sensors are added, new cooling capabilities are introduced. The
-complexity of the thermal relationship can grow exponentially among cooling
-devices, zones, sensors, and trip points. They can also change dynamically.
-
-To expose such relationship to the userspace, Linux generic thermal layer
-introduced sysfs entry at /sys/class/thermal with a matrix of symbolic
-links, trip point bindings, and device instances. To traverse such
-matrix by hand is not a trivial task. Testing is also difficult in that
-thermal conditions are often exception cases that hard to reach in
-normal operations.
-
-TMON is conceived as a tool to help visualize, tune, and test the
-complex thermal subsystem.
-
-Files
-=====
- tmon.c : main function for set up and configurations.
- tui.c : handles ncurses based user interface
- sysfs.c : access to the generic thermal sysfs
- pid.c : a proportional-integral-derivative (PID) controller
- that can be used for thermal relationship training.
-
-Requirements
-============
-Depends on ncurses
-
-Build
-=========
-$ make
-$ sudo ./tmon -h
-Usage: tmon [OPTION...]
- -c, --control cooling device in control
- -d, --daemon run as daemon, no TUI
- -l, --log log data to /var/tmp/tmon.log
- -h, --help show this help message
- -t, --time-interval set time interval for sampling
- -v, --version show version
- -g, --debug debug message in syslog
-
-1. For monitoring only:
-$ sudo ./tmon
diff --git a/tools/thermal/tmon/pid.c b/tools/thermal/tmon/pid.c
deleted file mode 100644
index fd7e9e9..0000000
--- a/tools/thermal/tmon/pid.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * pid.c PID controller for testing cooling devices
- *
- *
- *
- * Copyright (C) 2012 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version
- * 2 or later 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.
- *
- * Author Name Jacob Pan <jacob.jun.pan@linux.intel.com>
- *
- */
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <libintl.h>
-#include <ctype.h>
-#include <assert.h>
-#include <time.h>
-#include <limits.h>
-#include <math.h>
-#include <sys/stat.h>
-#include <syslog.h>
-
-#include "tmon.h"
-
-/**************************************************************************
- * PID (Proportional-Integral-Derivative) controller is commonly used in
- * linear control system, consider the the process.
- * G(s) = U(s)/E(s)
- * kp = proportional gain
- * ki = integral gain
- * kd = derivative gain
- * Ts
- * We use type C Alan Bradley equation which takes set point off the
- * output dependency in P and D term.
- *
- * y[k] = y[k-1] - kp*(x[k] - x[k-1]) + Ki*Ts*e[k] - Kd*(x[k]
- * - 2*x[k-1]+x[k-2])/Ts
- *
- *
- ***********************************************************************/
-struct pid_params p_param;
-/* cached data from previous loop */
-static double xk_1, xk_2; /* input temperature x[k-#] */
-
-/*
- * TODO: make PID parameters tuned automatically,
- * 1. use CPU burn to produce open loop unit step response
- * 2. calculate PID based on Ziegler-Nichols rule
- *
- * add a flag for tuning PID
- */
-int init_thermal_controller(void)
-{
- int ret = 0;
-
- /* init pid params */
- p_param.ts = ticktime;
- /* TODO: get it from TUI tuning tab */
- p_param.kp = .36;
- p_param.ki = 5.0;
- p_param.kd = 0.19;
-
- p_param.t_target = target_temp_user;
-
- return ret;
-}
-
-void controller_reset(void)
-{
- /* TODO: relax control data when not over thermal limit */
- syslog(LOG_DEBUG, "TC inactive, relax p-state\n");
- p_param.y_k = 0.0;
- xk_1 = 0.0;
- xk_2 = 0.0;
- set_ctrl_state(0);
-}
-
-/* To be called at time interval Ts. Type C PID controller.
- * y[k] = y[k-1] - kp*(x[k] - x[k-1]) + Ki*Ts*e[k] - Kd*(x[k]
- * - 2*x[k-1]+x[k-2])/Ts
- * TODO: add low pass filter for D term
- */
-#define GUARD_BAND (2)
-void controller_handler(const double xk, double *yk)
-{
- double ek;
- double p_term, i_term, d_term;
-
- ek = p_param.t_target - xk; /* error */
- if (ek >= 3.0) {
- syslog(LOG_DEBUG, "PID: %3.1f Below set point %3.1f, stop\n",
- xk, p_param.t_target);
- controller_reset();
- *yk = 0.0;
- return;
- }
- /* compute intermediate PID terms */
- p_term = -p_param.kp * (xk - xk_1);
- i_term = p_param.kp * p_param.ki * p_param.ts * ek;
- d_term = -p_param.kp * p_param.kd * (xk - 2 * xk_1 + xk_2) / p_param.ts;
- /* compute output */
- *yk += p_term + i_term + d_term;
- /* update sample data */
- xk_1 = xk;
- xk_2 = xk_1;
-
- /* clamp output adjustment range */
- if (*yk < -LIMIT_HIGH)
- *yk = -LIMIT_HIGH;
- else if (*yk > -LIMIT_LOW)
- *yk = -LIMIT_LOW;
-
- p_param.y_k = *yk;
-
- set_ctrl_state(lround(fabs(p_param.y_k)));
-
-}
diff --git a/tools/thermal/tmon/sysfs.c b/tools/thermal/tmon/sysfs.c
deleted file mode 100644
index dfe4548..0000000
--- a/tools/thermal/tmon/sysfs.c
+++ /dev/null
@@ -1,596 +0,0 @@
-/*
- * sysfs.c sysfs ABI access functions for TMON program
- *
- * Copyright (C) 2013 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version
- * 2 or later 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.
- *
- * Author: Jacob Pan <jacob.jun.pan@linux.intel.com>
- *
- */
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <dirent.h>
-#include <libintl.h>
-#include <ctype.h>
-#include <time.h>
-#include <syslog.h>
-#include <sys/time.h>
-#include <errno.h>
-
-#include "tmon.h"
-
-struct tmon_platform_data ptdata;
-const char *trip_type_name[] = {
- "critical",
- "hot",
- "passive",
- "active",
-};
-
-int sysfs_set_ulong(char *path, char *filename, unsigned long val)
-{
- FILE *fd;
- int ret = -1;
- char filepath[256];
-
- snprintf(filepath, 256, "%s/%s", path, filename);
-
- fd = fopen(filepath, "w");
- if (!fd) {
- syslog(LOG_ERR, "Err: open %s: %s\n", __func__, filepath);
- return ret;
- }
- ret = fprintf(fd, "%lu", val);
- fclose(fd);
-
- return 0;
-}
-
-/* history of thermal data, used for control algo */
-#define NR_THERMAL_RECORDS 3
-struct thermal_data_record trec[NR_THERMAL_RECORDS];
-int cur_thermal_record; /* index to the trec array */
-
-static int sysfs_get_ulong(char *path, char *filename, unsigned long *p_ulong)
-{
- FILE *fd;
- int ret = -1;
- char filepath[256];
-
- snprintf(filepath, 256, "%s/%s", path, filename);
-
- fd = fopen(filepath, "r");
- if (!fd) {
- syslog(LOG_ERR, "Err: open %s: %s\n", __func__, filepath);
- return ret;
- }
- ret = fscanf(fd, "%lu", p_ulong);
- fclose(fd);
-
- return 0;
-}
-
-static int sysfs_get_string(char *path, char *filename, char *str)
-{
- FILE *fd;
- int ret = -1;
- char filepath[256];
-
- snprintf(filepath, 256, "%s/%s", path, filename);
-
- fd = fopen(filepath, "r");
- if (!fd) {
- syslog(LOG_ERR, "Err: open %s: %s\n", __func__, filepath);
- return ret;
- }
- ret = fscanf(fd, "%256s", str);
- fclose(fd);
-
- return ret;
-}
-
-/* get states of the cooling device instance */
-static int probe_cdev(struct cdev_info *cdi, char *path)
-{
- sysfs_get_string(path, "type", cdi->type);
- sysfs_get_ulong(path, "max_state", &cdi->max_state);
- sysfs_get_ulong(path, "cur_state", &cdi->cur_state);
-
- syslog(LOG_INFO, "%s: %s: type %s, max %lu, curr %lu inst %d\n",
- __func__, path,
- cdi->type, cdi->max_state, cdi->cur_state, cdi->instance);
-
- return 0;
-}
-
-static int str_to_trip_type(char *name)
-{
- int i;
-
- for (i = 0; i < NR_THERMAL_TRIP_TYPE; i++) {
- if (!strcmp(name, trip_type_name[i]))
- return i;
- }
-
- return -ENOENT;
-}
-
-/* scan and fill in trip point info for a thermal zone and trip point id */
-static int get_trip_point_data(char *tz_path, int tzid, int tpid)
-{
- char filename[256];
- char temp_str[256];
- int trip_type;
-
- if (tpid >= MAX_NR_TRIP)
- return -EINVAL;
- /* check trip point type */
- snprintf(filename, sizeof(filename), "trip_point_%d_type", tpid);
- sysfs_get_string(tz_path, filename, temp_str);
- trip_type = str_to_trip_type(temp_str);
- if (trip_type < 0) {
- syslog(LOG_ERR, "%s:%s no matching type\n", __func__, temp_str);
- return -ENOENT;
- }
- ptdata.tzi[tzid].tp[tpid].type = trip_type;
- syslog(LOG_INFO, "%s:tz:%d tp:%d:type:%s type id %d\n", __func__, tzid,
- tpid, temp_str, trip_type);
-
- /* TODO: check attribute */
-
- return 0;
-}
-
-/* return instance id for file format such as trip_point_4_temp */
-static int get_instance_id(char *name, int pos, int skip)
-{
- char *ch;
- int i = 0;
-
- ch = strtok(name, "_");
- while (ch != NULL) {
- ++i;
- syslog(LOG_INFO, "%s:%s:%s:%d", __func__, name, ch, i);
- ch = strtok(NULL, "_");
- if (pos == i)
- return atol(ch + skip);
- }
-
- return -1;
-}
-
-/* Find trip point info of a thermal zone */
-static int find_tzone_tp(char *tz_name, char *d_name, struct tz_info *tzi,
- int tz_id)
-{
- int tp_id;
- unsigned long temp_ulong;
-
- if (strstr(d_name, "trip_point") &&
- strstr(d_name, "temp")) {
- /* check if trip point temp is non-zero
- * ignore 0/invalid trip points
- */
- sysfs_get_ulong(tz_name, d_name, &temp_ulong);
- if (temp_ulong < MAX_TEMP_KC) {
- tzi->nr_trip_pts++;
- /* found a valid trip point */
- tp_id = get_instance_id(d_name, 2, 0);
- syslog(LOG_DEBUG, "tzone %s trip %d temp %lu tpnode %s",
- tz_name, tp_id, temp_ulong, d_name);
- if (tp_id < 0 || tp_id >= MAX_NR_TRIP) {
- syslog(LOG_ERR, "Failed to find TP inst %s\n",
- d_name);
- return -1;
- }
- get_trip_point_data(tz_name, tz_id, tp_id);
- tzi->tp[tp_id].temp = temp_ulong;
- }
- }
-
- return 0;
-}
-
-/* check cooling devices for binding info. */
-static int find_tzone_cdev(struct dirent *nl, char *tz_name,
- struct tz_info *tzi, int tz_id, int cid)
-{
- unsigned long trip_instance = 0;
- char cdev_name_linked[256];
- char cdev_name[256];
- char cdev_trip_name[256];
- int cdev_id;
-
- if (nl->d_type == DT_LNK) {
- syslog(LOG_DEBUG, "TZ%d: cdev: %s cid %d\n", tz_id, nl->d_name,
- cid);
- tzi->nr_cdev++;
- if (tzi->nr_cdev > ptdata.nr_cooling_dev) {
- syslog(LOG_ERR, "Err: Too many cdev? %d\n",
- tzi->nr_cdev);
- return -EINVAL;
- }
- /* find the link to real cooling device record binding */
- snprintf(cdev_name, 256, "%s/%s", tz_name, nl->d_name);
- memset(cdev_name_linked, 0, sizeof(cdev_name_linked));
- if (readlink(cdev_name, cdev_name_linked,
- sizeof(cdev_name_linked) - 1) != -1) {
- cdev_id = get_instance_id(cdev_name_linked, 1,
- sizeof("device") - 1);
- syslog(LOG_DEBUG, "cdev %s linked to %s : %d\n",
- cdev_name, cdev_name_linked, cdev_id);
- tzi->cdev_binding |= (1 << cdev_id);
-
- /* find the trip point in which the cdev is binded to
- * in this tzone
- */
- snprintf(cdev_trip_name, 256, "%s%s", nl->d_name,
- "_trip_point");
- sysfs_get_ulong(tz_name, cdev_trip_name,
- &trip_instance);
- /* validate trip point range, e.g. trip could return -1
- * when passive is enabled
- */
- if (trip_instance > MAX_NR_TRIP)
- trip_instance = 0;
- tzi->trip_binding[cdev_id] |= 1 << trip_instance;
- syslog(LOG_DEBUG, "cdev %s -> trip:%lu: 0x%lx %d\n",
- cdev_name, trip_instance,
- tzi->trip_binding[cdev_id],
- cdev_id);
-
-
- }
- return 0;
- }
-
- return -ENODEV;
-}
-
-
-
-/*****************************************************************************
- * Before calling scan_tzones, thermal sysfs must be probed to determine
- * the number of thermal zones and cooling devices.
- * We loop through each thermal zone and fill in tz_info struct, i.e.
- * ptdata.tzi[]
-root@jacob-chiefriver:~# tree -d /sys/class/thermal/thermal_zone0
-/sys/class/thermal/thermal_zone0
-|-- cdev0 -> ../cooling_device4
-|-- cdev1 -> ../cooling_device3
-|-- cdev10 -> ../cooling_device7
-|-- cdev11 -> ../cooling_device6
-|-- cdev12 -> ../cooling_device5
-|-- cdev2 -> ../cooling_device2
-|-- cdev3 -> ../cooling_device1
-|-- cdev4 -> ../cooling_device0
-|-- cdev5 -> ../cooling_device12
-|-- cdev6 -> ../cooling_device11
-|-- cdev7 -> ../cooling_device10
-|-- cdev8 -> ../cooling_device9
-|-- cdev9 -> ../cooling_device8
-|-- device -> ../../../LNXSYSTM:00/device:62/LNXTHERM:00
-|-- power
-`-- subsystem -> ../../../../class/thermal
-*****************************************************************************/
-static int scan_tzones(void)
-{
- DIR *dir;
- struct dirent **namelist;
- char tz_name[256];
- int i, j, n, k = 0;
-
- if (!ptdata.nr_tz_sensor)
- return -1;
-
- for (i = 0; i <= ptdata.max_tz_instance; i++) {
- memset(tz_name, 0, sizeof(tz_name));
- snprintf(tz_name, 256, "%s/%s%d", THERMAL_SYSFS, TZONE, i);
-
- dir = opendir(tz_name);
- if (!dir) {
- syslog(LOG_INFO, "Thermal zone %s skipped\n", tz_name);
- continue;
- }
- /* keep track of valid tzones */
- n = scandir(tz_name, &namelist, 0, alphasort);
- if (n < 0)
- syslog(LOG_ERR, "scandir failed in %s", tz_name);
- else {
- sysfs_get_string(tz_name, "type", ptdata.tzi[k].type);
- ptdata.tzi[k].instance = i;
- /* detect trip points and cdev attached to this tzone */
- j = 0; /* index for cdev */
- ptdata.tzi[k].nr_cdev = 0;
- ptdata.tzi[k].nr_trip_pts = 0;
- while (n--) {
- char *temp_str;
-
- if (find_tzone_tp(tz_name, namelist[n]->d_name,
- &ptdata.tzi[k], k))
- break;
- temp_str = strstr(namelist[n]->d_name, "cdev");
- if (!temp_str) {
- free(namelist[n]);
- continue;
- }
- if (!find_tzone_cdev(namelist[n], tz_name,
- &ptdata.tzi[k], i, j))
- j++; /* increment cdev index */
- free(namelist[n]);
- }
- free(namelist);
- }
- /*TODO: reverse trip points */
- closedir(dir);
- syslog(LOG_INFO, "TZ %d has %d cdev\n", i,
- ptdata.tzi[k].nr_cdev);
- k++;
- }
-
- return 0;
-}
-
-static int scan_cdevs(void)
-{
- DIR *dir;
- struct dirent **namelist;
- char cdev_name[256];
- int i, n, k = 0;
-
- if (!ptdata.nr_cooling_dev) {
- fprintf(stderr, "No cooling devices found\n");
- return 0;
- }
- for (i = 0; i <= ptdata.max_cdev_instance; i++) {
- memset(cdev_name, 0, sizeof(cdev_name));
- snprintf(cdev_name, 256, "%s/%s%d", THERMAL_SYSFS, CDEV, i);
-
- dir = opendir(cdev_name);
- if (!dir) {
- syslog(LOG_INFO, "Cooling dev %s skipped\n", cdev_name);
- /* there is a gap in cooling device id, check again
- * for the same index.
- */
- continue;
- }
-
- n = scandir(cdev_name, &namelist, 0, alphasort);
- if (n < 0)
- syslog(LOG_ERR, "scandir failed in %s", cdev_name);
- else {
- sysfs_get_string(cdev_name, "type", ptdata.cdi[k].type);
- ptdata.cdi[k].instance = i;
- if (strstr(ptdata.cdi[k].type, ctrl_cdev)) {
- ptdata.cdi[k].flag |= CDEV_FLAG_IN_CONTROL;
- syslog(LOG_DEBUG, "control cdev id %d\n", i);
- }
- while (n--)
- free(namelist[n]);
- free(namelist);
- }
- closedir(dir);
- k++;
- }
- return 0;
-}
-
-
-int probe_thermal_sysfs(void)
-{
- DIR *dir;
- struct dirent **namelist;
- int n;
-
- dir = opendir(THERMAL_SYSFS);
- if (!dir) {
- fprintf(stderr, "\nNo thermal sysfs, exit\n");
- return -1;
- }
- n = scandir(THERMAL_SYSFS, &namelist, 0, alphasort);
- if (n < 0)
- syslog(LOG_ERR, "scandir failed in thermal sysfs");
- else {
- /* detect number of thermal zones and cooling devices */
- while (n--) {
- int inst;
-
- if (strstr(namelist[n]->d_name, CDEV)) {
- inst = get_instance_id(namelist[n]->d_name, 1,
- sizeof("device") - 1);
- /* keep track of the max cooling device since
- * there may be gaps.
- */
- if (inst > ptdata.max_cdev_instance)
- ptdata.max_cdev_instance = inst;
-
- syslog(LOG_DEBUG, "found cdev: %s %d %d\n",
- namelist[n]->d_name,
- ptdata.nr_cooling_dev,
- ptdata.max_cdev_instance);
- ptdata.nr_cooling_dev++;
- } else if (strstr(namelist[n]->d_name, TZONE)) {
- inst = get_instance_id(namelist[n]->d_name, 1,
- sizeof("zone") - 1);
- if (inst > ptdata.max_tz_instance)
- ptdata.max_tz_instance = inst;
-
- syslog(LOG_DEBUG, "found tzone: %s %d %d\n",
- namelist[n]->d_name,
- ptdata.nr_tz_sensor,
- ptdata.max_tz_instance);
- ptdata.nr_tz_sensor++;
- }
- free(namelist[n]);
- }
- free(namelist);
- }
- syslog(LOG_INFO, "found %d tzone(s), %d cdev(s), target zone %d\n",
- ptdata.nr_tz_sensor, ptdata.nr_cooling_dev,
- target_thermal_zone);
- closedir(dir);
-
- if (!ptdata.nr_tz_sensor) {
- fprintf(stderr, "\nNo thermal zones found, exit\n\n");
- return -1;
- }
-
- ptdata.tzi = calloc(sizeof(struct tz_info), ptdata.max_tz_instance+1);
- if (!ptdata.tzi) {
- fprintf(stderr, "Err: allocate tz_info\n");
- return -1;
- }
-
- /* we still show thermal zone information if there is no cdev */
- if (ptdata.nr_cooling_dev) {
- ptdata.cdi = calloc(sizeof(struct cdev_info),
- ptdata.max_cdev_instance + 1);
- if (!ptdata.cdi) {
- free(ptdata.tzi);
- fprintf(stderr, "Err: allocate cdev_info\n");
- return -1;
- }
- }
-
- /* now probe tzones */
- if (scan_tzones())
- return -1;
- if (scan_cdevs())
- return -1;
- return 0;
-}
-
-/* convert sysfs zone instance to zone array index */
-int zone_instance_to_index(int zone_inst)
-{
- int i;
-
- for (i = 0; i < ptdata.nr_tz_sensor; i++)
- if (ptdata.tzi[i].instance == zone_inst)
- return i;
- return -ENOENT;
-}
-
-/* read temperature of all thermal zones */
-int update_thermal_data()
-{
- int i;
- char tz_name[256];
- static unsigned long samples;
-
- if (!ptdata.nr_tz_sensor) {
- syslog(LOG_ERR, "No thermal zones found!\n");
- return -1;
- }
-
- /* circular buffer for keeping historic data */
- if (cur_thermal_record >= NR_THERMAL_RECORDS)
- cur_thermal_record = 0;
- gettimeofday(&trec[cur_thermal_record].tv, NULL);
- if (tmon_log) {
- fprintf(tmon_log, "%lu ", ++samples);
- fprintf(tmon_log, "%3.1f ", p_param.t_target);
- }
- for (i = 0; i < ptdata.nr_tz_sensor; i++) {
- memset(tz_name, 0, sizeof(tz_name));
- snprintf(tz_name, 256, "%s/%s%d", THERMAL_SYSFS, TZONE,
- ptdata.tzi[i].instance);
- sysfs_get_ulong(tz_name, "temp",
- &trec[cur_thermal_record].temp[i]);
- if (tmon_log)
- fprintf(tmon_log, "%lu ",
- trec[cur_thermal_record].temp[i]/1000);
- }
- for (i = 0; i < ptdata.nr_cooling_dev; i++) {
- char cdev_name[256];
- unsigned long val;
-
- snprintf(cdev_name, 256, "%s/%s%d", THERMAL_SYSFS, CDEV,
- ptdata.cdi[i].instance);
- probe_cdev(&ptdata.cdi[i], cdev_name);
- val = ptdata.cdi[i].cur_state;
- if (val > 1000000)
- val = 0;
- if (tmon_log)
- fprintf(tmon_log, "%lu ", val);
- }
-
- if (tmon_log) {
- fprintf(tmon_log, "\n");
- fflush(tmon_log);
- }
-
- return 0;
-}
-
-void set_ctrl_state(unsigned long state)
-{
- char ctrl_cdev_path[256];
- int i;
- unsigned long cdev_state;
-
- if (no_control)
- return;
- /* set all ctrl cdev to the same state */
- for (i = 0; i < ptdata.nr_cooling_dev; i++) {
- if (ptdata.cdi[i].flag & CDEV_FLAG_IN_CONTROL) {
- if (ptdata.cdi[i].max_state < 10) {
- strcpy(ctrl_cdev, "None.");
- return;
- }
- /* scale to percentage of max_state */
- cdev_state = state * ptdata.cdi[i].max_state/100;
- syslog(LOG_DEBUG,
- "ctrl cdev %d set state %lu scaled to %lu\n",
- ptdata.cdi[i].instance, state, cdev_state);
- snprintf(ctrl_cdev_path, 256, "%s/%s%d", THERMAL_SYSFS,
- CDEV, ptdata.cdi[i].instance);
- syslog(LOG_DEBUG, "ctrl cdev path %s", ctrl_cdev_path);
- sysfs_set_ulong(ctrl_cdev_path, "cur_state",
- cdev_state);
- }
- }
-}
-
-void get_ctrl_state(unsigned long *state)
-{
- char ctrl_cdev_path[256];
- int ctrl_cdev_id = -1;
- int i;
-
- /* TODO: take average of all ctrl types. also consider change based on
- * uevent. Take the first reading for now.
- */
- for (i = 0; i < ptdata.nr_cooling_dev; i++) {
- if (ptdata.cdi[i].flag & CDEV_FLAG_IN_CONTROL) {
- ctrl_cdev_id = ptdata.cdi[i].instance;
- syslog(LOG_INFO, "ctrl cdev %d get state\n",
- ptdata.cdi[i].instance);
- break;
- }
- }
- if (ctrl_cdev_id == -1) {
- *state = 0;
- return;
- }
- snprintf(ctrl_cdev_path, 256, "%s/%s%d", THERMAL_SYSFS,
- CDEV, ctrl_cdev_id);
- sysfs_get_ulong(ctrl_cdev_path, "cur_state", state);
-}
-
-void free_thermal_data(void)
-{
- free(ptdata.tzi);
- free(ptdata.cdi);
-}
diff --git a/tools/thermal/tmon/tmon.8 b/tools/thermal/tmon/tmon.8
deleted file mode 100644
index 0be727c..0000000
--- a/tools/thermal/tmon/tmon.8
+++ /dev/null
@@ -1,142 +0,0 @@
-.TH TMON 8
-.SH NAME
-\fBtmon\fP - A monitoring and testing tool for Linux kernel thermal subsystem
-
-.SH SYNOPSIS
-.ft B
-.B tmon
-.RB [ Options ]
-.br
-.SH DESCRIPTION
-\fBtmon \fP can be used to visualize thermal relationship and
-real-time thermal data; tune
-and test cooling devices and sensors; collect thermal data for offline
-analysis and plot. \fBtmon\fP must be run as root in order to control device
-states via sysfs.
-.PP
-\fBFunctions\fP
-.PP
-.nf
-1. Thermal relationships:
-- show thermal zone information
-- show cooling device information
-- show trip point binding within each thermal zone
-- show trip point and cooling device instance bindings
-.PP
-2. Real time data display
-- show temperature of all thermal zones w.r.t. its trip points and types
-- show states of all cooling devices
-.PP
-3. Thermal relationship learning and device tuning
-- with a built-in Proportional Integral Derivative (\fBPID\fP)
-controller, user can pair a cooling device to a thermal sensor for
-testing the effectiveness and learn about the thermal distance between the two
-- allow manual control of cooling device states and target temperature
-.PP
-4. Data logging in /var/tmp/tmon.log
-- contains thermal configuration data, i.e. cooling device, thermal
- zones, and trip points. Can be used for data collection in remote
- debugging.
-- log real-time thermal data into space separated format that can be
- directly consumed by plotting tools such as Rscript.
-
-.SS Options
-.PP
-The \fB-c --control\fP option sets a cooling device type to control temperature
-of a thermal zone
-.PP
-The \fB-d --daemon\fP option runs \fBtmon \fP as daemon without user interface
-.PP
-The \fB-g --debug\fP option allow debug messages to be stored in syslog
-.PP
-The \fB-h --help\fP option shows help message
-.PP
-The \fB-l --log\fP option write data to /var/tmp/tmon.log
-.PP
-The \fB-t --time-interval\fP option sets the polling interval in seconds
-.PP
-The \fB-v --version\fP option shows the version of \fBtmon \fP
-.PP
-The \fB-z --zone\fP option sets the target therma zone instance to be controlled
-.PP
-
-.SH FIELD DESCRIPTIONS
-.nf
-.PP
-\fBP \fP passive cooling trip point type
-\fBA \fP active cooling trip point type (fan)
-\fBC \fP critical trip point type
-\fBA \fP hot trip point type
-\fBkp \fP proportional gain of \fBPID\fP controller
-\fBki \fP integral gain of \fBPID\fP controller
-\fBkd \fP derivative gain of \fBPID\fP controller
-
-.SH REQUIREMENT
-Build depends on ncurses
-.PP
-Runtime depends on window size large enough to show the number of
-devices found on the system.
-
-.PP
-
-.SH INTERACTIVE COMMANDS
-.pp
-.nf
-\fBCtrl-C, q/Q\fP stops \fBtmon\fP
-\fBTAB\fP shows tuning pop up panel, choose a letter to modify
-
-.SH EXAMPLES
-Without any parameters, tmon is in monitoring only mode and refresh
-screen every 1 second.
-.PP
-1. For monitoring only:
-.nf
-$ sudo ./tmon
-
-2. Use Processor cooling device to control thermal zone 0 at default 65C.
-$ sudo ./tmon -c Processor -z 0
-
-3. Use intel_powerclamp(idle injection) cooling device to control thermal zone 1
-$ sudo ./tmon -c intel_powerclamp -z 1
-
-4. Turn on debug and collect data log at /var/tmp/tmon.log
-$ sudo ./tmon -g -l
-
-For example, the log below shows PID controller was adjusting current states
-for all cooling devices with "Processor" type such that thermal zone 0
-can stay below 65 dC.
-
-#---------- THERMAL DATA LOG STARTED -----------
-Samples TargetTemp acpitz0 acpitz1 Fan0 Fan1 Fan2 Fan3 Fan4 Fan5
-Fan6 Fan7 Fan8 Fan9 Processor10 Processor11 Processor12 Processor13
-LCD14 intel_powerclamp15 1 65.0 65 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 2
-65.0 66 65 0 0 0 0 0 0 0 0 0 0 4 4 4 4 6 0 3 65.0 60 54 0 0 0 0 0 0 0 0
-0 0 4 4 4 4 6 0 4 65.0 53 53 0 0 0 0 0 0 0 0 0 0 4 4 4 4 6 0
-5 65.0 52 52 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0
-6 65.0 53 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0
-7 65.0 68 70 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0
-8 65.0 68 68 0 0 0 0 0 0 0 0 0 0 5 5 5 5 6 0
-9 65.0 68 68 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 0
-10 65.0 67 67 0 0 0 0 0 0 0 0 0 0 7 7 7 7 6 0
-11 65.0 67 67 0 0 0 0 0 0 0 0 0 0 8 8 8 8 6 0
-12 65.0 67 67 0 0 0 0 0 0 0 0 0 0 8 8 8 8 6 0
-13 65.0 67 67 0 0 0 0 0 0 0 0 0 0 9 9 9 9 6 0
-14 65.0 66 66 0 0 0 0 0 0 0 0 0 0 10 10 10 10 6 0
-15 65.0 66 67 0 0 0 0 0 0 0 0 0 0 10 10 10 10 6 0
-16 65.0 66 66 0 0 0 0 0 0 0 0 0 0 11 11 11 11 6 0
-17 65.0 66 66 0 0 0 0 0 0 0 0 0 0 11 11 11 11 6 0
-18 65.0 64 61 0 0 0 0 0 0 0 0 0 0 11 11 11 11 6 0
-19 65.0 60 59 0 0 0 0 0 0 0 0 0 0 12 12 12 12 6 0
-
-Data can be read directly into an array by an example R-script below:
-
-#!/usr/bin/Rscript
-tdata <- read.table("/var/tmp/tmon.log", header=T, comment.char="#")
-attach(tdata)
-jpeg("tmon.jpg")
-X11()
-g_range <- range(0, intel_powerclamp15, TargetTemp, acpitz0)
-plot( Samples, intel_powerclamp15, col="blue", ylim=g_range, axes=FALSE, ann=FALSE)
-par(new=TRUE)
-lines(TargetTemp, type="o", pch=22, lty=2, col="red")
-dev.off()
diff --git a/tools/thermal/tmon/tmon.c b/tools/thermal/tmon/tmon.c
deleted file mode 100644
index b30f531..0000000
--- a/tools/thermal/tmon/tmon.c
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * tmon.c Thermal Monitor (TMON) main function and entry point
- *
- * Copyright (C) 2012 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version
- * 2 or later 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.
- *
- * Author: Jacob Pan <jacob.jun.pan@linux.intel.com>
- *
- */
-
-#include <getopt.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <ncurses.h>
-#include <ctype.h>
-#include <time.h>
-#include <signal.h>
-#include <limits.h>
-#include <sys/time.h>
-#include <pthread.h>
-#include <math.h>
-#include <stdarg.h>
-#include <syslog.h>
-
-#include "tmon.h"
-
-unsigned long ticktime = 1; /* seconds */
-unsigned long no_control = 1; /* monitoring only or use cooling device for
- * temperature control.
- */
-double time_elapsed = 0.0;
-unsigned long target_temp_user = 65; /* can be select by tui later */
-int dialogue_on;
-int tmon_exit;
-static short daemon_mode;
-static int logging; /* for recording thermal data to a file */
-static int debug_on;
-FILE *tmon_log;
-/*cooling device used for the PID controller */
-char ctrl_cdev[CDEV_NAME_SIZE] = "None";
-int target_thermal_zone; /* user selected target zone instance */
-static void start_daemon_mode(void);
-
-pthread_t event_tid;
-pthread_mutex_t input_lock;
-void usage()
-{
- printf("Usage: tmon [OPTION...]\n");
- printf(" -c, --control cooling device in control\n");
- printf(" -d, --daemon run as daemon, no TUI\n");
- printf(" -g, --debug debug message in syslog\n");
- printf(" -h, --help show this help message\n");
- printf(" -l, --log log data to /var/tmp/tmon.log\n");
- printf(" -t, --time-interval sampling time interval, > 1 sec.\n");
- printf(" -v, --version show version\n");
- printf(" -z, --zone target thermal zone id\n");
-
- exit(0);
-}
-
-void version()
-{
- printf("TMON version %s\n", VERSION);
- exit(EXIT_SUCCESS);
-}
-
-static void tmon_cleanup(void)
-{
-
- syslog(LOG_INFO, "TMON exit cleanup\n");
- fflush(stdout);
- refresh();
- if (tmon_log)
- fclose(tmon_log);
- if (event_tid) {
- pthread_mutex_lock(&input_lock);
- pthread_cancel(event_tid);
- pthread_mutex_unlock(&input_lock);
- pthread_mutex_destroy(&input_lock);
- }
- closelog();
- /* relax control knobs, undo throttling */
- set_ctrl_state(0);
-
- keypad(stdscr, FALSE);
- echo();
- nocbreak();
- close_windows();
- endwin();
- free_thermal_data();
-
- exit(1);
-}
-
-
-static void tmon_sig_handler(int sig)
-{
- syslog(LOG_INFO, "TMON caught signal %d\n", sig);
- refresh();
- switch (sig) {
- case SIGTERM:
- printf("sigterm, exit and clean up\n");
- fflush(stdout);
- break;
- case SIGKILL:
- printf("sigkill, exit and clean up\n");
- fflush(stdout);
- break;
- case SIGINT:
- printf("ctrl-c, exit and clean up\n");
- fflush(stdout);
- break;
- default:
- break;
- }
- tmon_exit = true;
-}
-
-
-static void start_syslog(void)
-{
- if (debug_on)
- setlogmask(LOG_UPTO(LOG_DEBUG));
- else
- setlogmask(LOG_UPTO(LOG_ERR));
- openlog("tmon.log", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL0);
- syslog(LOG_NOTICE, "TMON started by User %d", getuid());
-}
-
-static void prepare_logging(void)
-{
- int i;
-
- if (!logging)
- return;
- /* open local data log file */
- tmon_log = fopen(TMON_LOG_FILE, "w+");
- if (!tmon_log) {
- syslog(LOG_ERR, "failed to open log file %s\n", TMON_LOG_FILE);
- return;
- }
-
- fprintf(tmon_log, "#----------- THERMAL SYSTEM CONFIG -------------\n");
- for (i = 0; i < ptdata.nr_tz_sensor; i++) {
- char binding_str[33]; /* size of long + 1 */
- int j;
-
- memset(binding_str, 0, sizeof(binding_str));
- for (j = 0; j < 32; j++)
- binding_str[j] = (ptdata.tzi[i].cdev_binding & 1<<j) ?
- '1' : '0';
-
- fprintf(tmon_log, "#thermal zone %s%02d cdevs binding: %32s\n",
- ptdata.tzi[i].type,
- ptdata.tzi[i].instance,
- binding_str);
- for (j = 0; j < ptdata.tzi[i].nr_trip_pts; j++) {
- fprintf(tmon_log, "#\tTP%02d type:%s, temp:%lu\n", j,
- trip_type_name[ptdata.tzi[i].tp[j].type],
- ptdata.tzi[i].tp[j].temp);
- }
-
- }
-
- for (i = 0; i < ptdata.nr_cooling_dev; i++)
- fprintf(tmon_log, "#cooling devices%02d: %s\n",
- i, ptdata.cdi[i].type);
-
- fprintf(tmon_log, "#---------- THERMAL DATA LOG STARTED -----------\n");
- fprintf(tmon_log, "Samples TargetTemp ");
- for (i = 0; i < ptdata.nr_tz_sensor; i++) {
- fprintf(tmon_log, "%s%d ", ptdata.tzi[i].type,
- ptdata.tzi[i].instance);
- }
- for (i = 0; i < ptdata.nr_cooling_dev; i++)
- fprintf(tmon_log, "%s%d ", ptdata.cdi[i].type,
- ptdata.cdi[i].instance);
-
- fprintf(tmon_log, "\n");
-}
-
-static struct option opts[] = {
- { "control", 1, NULL, 'c' },
- { "daemon", 0, NULL, 'd' },
- { "time-interval", 1, NULL, 't' },
- { "log", 0, NULL, 'l' },
- { "help", 0, NULL, 'h' },
- { "version", 0, NULL, 'v' },
- { "debug", 0, NULL, 'g' },
- { 0, 0, NULL, 0 }
-};
-
-
-int main(int argc, char **argv)
-{
- int err = 0;
- int id2 = 0, c;
- double yk = 0.0; /* controller output */
- int target_tz_index;
-
- if (geteuid() != 0) {
- printf("TMON needs to be run as root\n");
- exit(EXIT_FAILURE);
- }
-
- while ((c = getopt_long(argc, argv, "c:dlht:vgz:", opts, &id2)) != -1) {
- switch (c) {
- case 'c':
- no_control = 0;
- strncpy(ctrl_cdev, optarg, CDEV_NAME_SIZE);
- break;
- case 'd':
- start_daemon_mode();
- printf("Run TMON in daemon mode\n");
- break;
- case 't':
- ticktime = strtod(optarg, NULL);
- if (ticktime < 1)
- ticktime = 1;
- break;
- case 'l':
- printf("Logging data to /var/tmp/tmon.log\n");
- logging = 1;
- break;
- case 'h':
- usage();
- break;
- case 'v':
- version();
- break;
- case 'g':
- debug_on = 1;
- break;
- case 'z':
- target_thermal_zone = strtod(optarg, NULL);
- break;
- default:
- break;
- }
- }
- if (pthread_mutex_init(&input_lock, NULL) != 0) {
- fprintf(stderr, "\n mutex init failed, exit\n");
- return 1;
- }
- start_syslog();
- if (signal(SIGINT, tmon_sig_handler) == SIG_ERR)
- syslog(LOG_DEBUG, "Cannot handle SIGINT\n");
- if (signal(SIGTERM, tmon_sig_handler) == SIG_ERR)
- syslog(LOG_DEBUG, "Cannot handle SIGINT\n");
-
- if (probe_thermal_sysfs()) {
- pthread_mutex_destroy(&input_lock);
- closelog();
- return -1;
- }
- initialize_curses();
- setup_windows();
- signal(SIGWINCH, resize_handler);
- show_title_bar();
- show_sensors_w();
- show_cooling_device();
- update_thermal_data();
- show_data_w();
- prepare_logging();
- init_thermal_controller();
-
- nodelay(stdscr, TRUE);
- err = pthread_create(&event_tid, NULL, &handle_tui_events, NULL);
- if (err != 0) {
- printf("\ncan't create thread :[%s]", strerror(err));
- tmon_cleanup();
- exit(EXIT_FAILURE);
- }
-
- /* validate range of user selected target zone, default to the first
- * instance if out of range
- */
- target_tz_index = zone_instance_to_index(target_thermal_zone);
- if (target_tz_index < 0) {
- target_thermal_zone = ptdata.tzi[0].instance;
- syslog(LOG_ERR, "target zone is not found, default to %d\n",
- target_thermal_zone);
- }
- while (1) {
- sleep(ticktime);
- show_title_bar();
- show_sensors_w();
- update_thermal_data();
- if (!dialogue_on) {
- show_data_w();
- show_cooling_device();
- }
- cur_thermal_record++;
- time_elapsed += ticktime;
- controller_handler(trec[0].temp[target_tz_index] / 1000,
- &yk);
- trec[0].pid_out_pct = yk;
- if (!dialogue_on)
- show_control_w();
- if (tmon_exit)
- break;
- }
- tmon_cleanup();
- return 0;
-}
-
-static void start_daemon_mode()
-{
- daemon_mode = 1;
- /* fork */
- pid_t sid, pid = fork();
- if (pid < 0) {
- exit(EXIT_FAILURE);
- } else if (pid > 0)
- /* kill parent */
- exit(EXIT_SUCCESS);
-
- /* disable TUI, it may not be necessary, but saves some resource */
- disable_tui();
-
- /* change the file mode mask */
- umask(0);
-
- /* new SID for the daemon process */
- sid = setsid();
- if (sid < 0)
- exit(EXIT_FAILURE);
-
- /* change working directory */
- if ((chdir("/")) < 0)
- exit(EXIT_FAILURE);
-
-
- sleep(10);
-
- close(STDIN_FILENO);
- close(STDOUT_FILENO);
- close(STDERR_FILENO);
-
-}
diff --git a/tools/thermal/tmon/tmon.h b/tools/thermal/tmon/tmon.h
deleted file mode 100644
index 9e3c49c..0000000
--- a/tools/thermal/tmon/tmon.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * tmon.h contains data structures and constants used by TMON
- *
- * Copyright (C) 2012 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version
- * 2 or later 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.
- *
- * Author Name Jacob Pan <jacob.jun.pan@linux.intel.com>
- *
- */
-
-#ifndef TMON_H
-#define TMON_H
-
-#define MAX_DISP_TEMP 125
-#define MAX_CTRL_TEMP 105
-#define MIN_CTRL_TEMP 40
-#define MAX_NR_TZONE 16
-#define MAX_NR_CDEV 32
-#define MAX_NR_TRIP 16
-#define MAX_NR_CDEV_TRIP 12 /* number of cooling devices that can bind
- * to a thermal zone trip.
- */
-#define MAX_TEMP_KC 140000
-/* starting char position to draw sensor data, such as tz names
- * trip point list, etc.
- */
-#define DATA_LEFT_ALIGN 10
-#define NR_LINES_TZDATA 1
-#define TMON_LOG_FILE "/var/tmp/tmon.log"
-
-extern unsigned long ticktime;
-extern double time_elapsed;
-extern unsigned long target_temp_user;
-extern int dialogue_on;
-extern char ctrl_cdev[];
-extern pthread_mutex_t input_lock;
-extern int tmon_exit;
-extern int target_thermal_zone;
-/* use fixed size record to simplify data processing and transfer
- * TBD: more info to be added, e.g. programmable trip point data.
-*/
-struct thermal_data_record {
- struct timeval tv;
- unsigned long temp[MAX_NR_TZONE];
- double pid_out_pct;
-};
-
-struct cdev_info {
- char type[64];
- int instance;
- unsigned long max_state;
- unsigned long cur_state;
- unsigned long flag;
-};
-
-enum trip_type {
- THERMAL_TRIP_CRITICAL,
- THERMAL_TRIP_HOT,
- THERMAL_TRIP_PASSIVE,
- THERMAL_TRIP_ACTIVE,
- NR_THERMAL_TRIP_TYPE,
-};
-
-struct trip_point {
- enum trip_type type;
- unsigned long temp;
- unsigned long hysteresis;
- int attribute; /* programmability etc. */
-};
-
-/* thermal zone configuration information, binding with cooling devices could
- * change at runtime.
- */
-struct tz_info {
- char type[256]; /* e.g. acpitz */
- int instance;
- int passive; /* active zone has passive node to force passive mode */
- int nr_cdev; /* number of cooling device binded */
- int nr_trip_pts;
- struct trip_point tp[MAX_NR_TRIP];
- unsigned long cdev_binding; /* bitmap for attached cdevs */
- /* cdev bind trip points, allow one cdev bind to multiple trips */
- unsigned long trip_binding[MAX_NR_CDEV];
-};
-
-struct tmon_platform_data {
- int nr_tz_sensor;
- int nr_cooling_dev;
- /* keep track of instance ids since there might be gaps */
- int max_tz_instance;
- int max_cdev_instance;
- struct tz_info *tzi;
- struct cdev_info *cdi;
-};
-
-struct control_ops {
- void (*set_ratio)(unsigned long ratio);
- unsigned long (*get_ratio)(unsigned long ratio);
-
-};
-
-enum cdev_types {
- CDEV_TYPE_PROC,
- CDEV_TYPE_FAN,
- CDEV_TYPE_MEM,
- CDEV_TYPE_NR,
-};
-
-/* REVISIT: the idea is to group sensors if possible, e.g. on intel mid
- * we have "skin0", "skin1", "sys", "msicdie"
- * on DPTF enabled systems, we might have PCH, TSKN, TAMB, etc.
- */
-enum tzone_types {
- TZONE_TYPE_ACPI,
- TZONE_TYPE_PCH,
- TZONE_TYPE_NR,
-};
-
-/* limit the output of PID controller adjustment */
-#define LIMIT_HIGH (95)
-#define LIMIT_LOW (2)
-
-struct pid_params {
- double kp; /* Controller gain from Dialog Box */
- double ki; /* Time-constant for I action from Dialog Box */
- double kd; /* Time-constant for D action from Dialog Box */
- double ts;
- double k_lpf;
-
- double t_target;
- double y_k;
-};
-
-extern int init_thermal_controller(void);
-extern void controller_handler(const double xk, double *yk);
-
-extern struct tmon_platform_data ptdata;
-extern struct pid_params p_param;
-
-extern FILE *tmon_log;
-extern int cur_thermal_record; /* index to the trec array */
-extern struct thermal_data_record trec[];
-extern const char *trip_type_name[];
-extern unsigned long no_control;
-
-extern void initialize_curses(void);
-extern void show_controller_stats(char *line);
-extern void show_title_bar(void);
-extern void setup_windows(void);
-extern void disable_tui(void);
-extern void show_sensors_w(void);
-extern void show_data_w(void);
-extern void write_status_bar(int x, char *line);
-extern void show_control_w();
-
-extern void show_cooling_device(void);
-extern void show_dialogue(void);
-extern int update_thermal_data(void);
-
-extern int probe_thermal_sysfs(void);
-extern void free_thermal_data(void);
-extern void resize_handler(int sig);
-extern void set_ctrl_state(unsigned long state);
-extern void get_ctrl_state(unsigned long *state);
-extern void *handle_tui_events(void *arg);
-extern int sysfs_set_ulong(char *path, char *filename, unsigned long val);
-extern int zone_instance_to_index(int zone_inst);
-extern void close_windows(void);
-
-#define PT_COLOR_DEFAULT 1
-#define PT_COLOR_HEADER_BAR 2
-#define PT_COLOR_ERROR 3
-#define PT_COLOR_RED 4
-#define PT_COLOR_YELLOW 5
-#define PT_COLOR_GREEN 6
-#define PT_COLOR_BRIGHT 7
-#define PT_COLOR_BLUE 8
-
-/* each thermal zone uses 12 chars, 8 for name, 2 for instance, 2 space
- * also used to list trip points in forms of AAAC, which represents
- * A: Active
- * C: Critical
- */
-#define TZONE_RECORD_SIZE 12
-#define TZ_LEFT_ALIGN 32
-#define CDEV_NAME_SIZE 20
-#define CDEV_FLAG_IN_CONTROL (1 << 0)
-
-/* dialogue box starts */
-#define DIAG_X 48
-#define DIAG_Y 8
-#define THERMAL_SYSFS "/sys/class/thermal"
-#define CDEV "cooling_device"
-#define TZONE "thermal_zone"
-#define TDATA_LEFT 16
-#endif /* TMON_H */
diff --git a/tools/thermal/tmon/tui.c b/tools/thermal/tmon/tui.c
deleted file mode 100644
index 89f8ef0..0000000
--- a/tools/thermal/tmon/tui.c
+++ /dev/null
@@ -1,638 +0,0 @@
-/*
- * tui.c ncurses text user interface for TMON program
- *
- * Copyright (C) 2013 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version
- * 2 or later 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.
- *
- * Author: Jacob Pan <jacob.jun.pan@linux.intel.com>
- *
- */
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <ncurses.h>
-#include <time.h>
-#include <syslog.h>
-#include <panel.h>
-#include <pthread.h>
-#include <signal.h>
-
-#include "tmon.h"
-
-static PANEL *data_panel;
-static PANEL *dialogue_panel;
-static PANEL *top;
-
-static WINDOW *title_bar_window;
-static WINDOW *tz_sensor_window;
-static WINDOW *cooling_device_window;
-static WINDOW *control_window;
-static WINDOW *status_bar_window;
-static WINDOW *thermal_data_window;
-static WINDOW *dialogue_window;
-
-char status_bar_slots[10][40];
-static void draw_hbar(WINDOW *win, int y, int start, int len,
- unsigned long pattern, bool end);
-
-static int maxx, maxy;
-static int maxwidth = 200;
-
-#define TITLE_BAR_HIGHT 1
-#define SENSOR_WIN_HIGHT 4 /* one row for tz name, one for trip points */
-
-
-/* daemon mode flag (set by startup parameter -d) */
-static int tui_disabled;
-
-static void close_panel(PANEL *p)
-{
- if (p) {
- del_panel(p);
- p = NULL;
- }
-}
-
-static void close_window(WINDOW *win)
-{
- if (win) {
- delwin(win);
- win = NULL;
- }
-}
-
-void close_windows(void)
-{
- if (tui_disabled)
- return;
- /* must delete panels before their attached windows */
- if (dialogue_window)
- close_panel(dialogue_panel);
- if (cooling_device_window)
- close_panel(data_panel);
-
- close_window(title_bar_window);
- close_window(tz_sensor_window);
- close_window(status_bar_window);
- close_window(cooling_device_window);
- close_window(control_window);
- close_window(thermal_data_window);
- close_window(dialogue_window);
-
-}
-
-void write_status_bar(int x, char *line)
-{
- mvwprintw(status_bar_window, 0, x, "%s", line);
- wrefresh(status_bar_window);
-}
-
-void setup_windows(void)
-{
- int y_begin = 1;
-
- if (tui_disabled)
- return;
-
- getmaxyx(stdscr, maxy, maxx);
- resizeterm(maxy, maxx);
-
- title_bar_window = subwin(stdscr, TITLE_BAR_HIGHT, maxx, 0, 0);
- y_begin += TITLE_BAR_HIGHT;
-
- tz_sensor_window = subwin(stdscr, SENSOR_WIN_HIGHT, maxx, y_begin, 0);
- y_begin += SENSOR_WIN_HIGHT;
-
- cooling_device_window = subwin(stdscr, ptdata.nr_cooling_dev + 3, maxx,
- y_begin, 0);
- y_begin += ptdata.nr_cooling_dev + 3; /* 2 lines for border */
- /* two lines to show borders, one line per tz show trip point position
- * and value.
- * dialogue window is a pop-up, when needed it lays on top of cdev win
- */
-
- dialogue_window = subwin(stdscr, ptdata.nr_cooling_dev+5, maxx-50,
- DIAG_Y, DIAG_X);
-
- thermal_data_window = subwin(stdscr, ptdata.nr_tz_sensor *
- NR_LINES_TZDATA + 3, maxx, y_begin, 0);
- y_begin += ptdata.nr_tz_sensor * NR_LINES_TZDATA + 3;
- control_window = subwin(stdscr, 4, maxx, y_begin, 0);
-
- scrollok(cooling_device_window, TRUE);
- maxwidth = maxx - 18;
- status_bar_window = subwin(stdscr, 1, maxx, maxy-1, 0);
-
- strcpy(status_bar_slots[0], " Ctrl-c - Quit ");
- strcpy(status_bar_slots[1], " TAB - Tuning ");
- wmove(status_bar_window, 1, 30);
-
- /* prepare panels for dialogue, if panel already created then we must
- * be doing resizing, so just replace windows with new ones, old ones
- * should have been deleted by close_window
- */
- data_panel = new_panel(cooling_device_window);
- if (!data_panel)
- syslog(LOG_DEBUG, "No data panel\n");
- else {
- if (dialogue_window) {
- dialogue_panel = new_panel(dialogue_window);
- if (!dialogue_panel)
- syslog(LOG_DEBUG, "No dialogue panel\n");
- else {
- /* Set up the user pointer to the next panel*/
- set_panel_userptr(data_panel, dialogue_panel);
- set_panel_userptr(dialogue_panel, data_panel);
- top = data_panel;
- }
- } else
- syslog(LOG_INFO, "no dialogue win, term too small\n");
- }
- doupdate();
- werase(stdscr);
- refresh();
-}
-
-void resize_handler(int sig)
-{
- /* start over when term gets resized, but first we clean up */
- close_windows();
- endwin();
- refresh();
- clear();
- getmaxyx(stdscr, maxy, maxx); /* get the new screen size */
- setup_windows();
- /* rate limit */
- sleep(1);
- syslog(LOG_DEBUG, "SIG %d, term resized to %d x %d\n",
- sig, maxy, maxx);
- signal(SIGWINCH, resize_handler);
-}
-
-const char cdev_title[] = " COOLING DEVICES ";
-void show_cooling_device(void)
-{
- int i, j, x, y = 0;
-
- if (tui_disabled || !cooling_device_window)
- return;
-
- werase(cooling_device_window);
- wattron(cooling_device_window, A_BOLD);
- mvwprintw(cooling_device_window, 1, 1,
- "ID Cooling Dev Cur Max Thermal Zone Binding");
- wattroff(cooling_device_window, A_BOLD);
- for (j = 0; j < ptdata.nr_cooling_dev; j++) {
- /* draw cooling device list on the left in the order of
- * cooling device instances. skip unused idr.
- */
- mvwprintw(cooling_device_window, j + 2, 1,
- "%02d %12.12s%6d %6d",
- ptdata.cdi[j].instance,
- ptdata.cdi[j].type,
- ptdata.cdi[j].cur_state,
- ptdata.cdi[j].max_state);
- }
-
- /* show cdev binding, y is the global cooling device instance */
- for (i = 0; i < ptdata.nr_tz_sensor; i++) {
- int tz_inst = ptdata.tzi[i].instance;
- for (j = 0; j < ptdata.nr_cooling_dev; j++) {
- int cdev_inst;
- y = j;
- x = tz_inst * TZONE_RECORD_SIZE + TZ_LEFT_ALIGN;
-
- draw_hbar(cooling_device_window, y+2, x,
- TZONE_RECORD_SIZE-1, ACS_VLINE, false);
-
- /* draw a column of spaces to separate thermal zones */
- mvwprintw(cooling_device_window, y+2, x-1, " ");
- if (ptdata.tzi[i].cdev_binding) {
- cdev_inst = ptdata.cdi[j].instance;
- unsigned long trip_binding =
- ptdata.tzi[i].trip_binding[cdev_inst];
- int k = 0; /* per zone trip point id that
- * binded to this cdev, one to
- * many possible based on the
- * binding bitmask.
- */
- syslog(LOG_DEBUG,
- "bind tz%d cdev%d tp%lx %d cdev%lx\n",
- i, j, trip_binding, y,
- ptdata.tzi[i].cdev_binding);
- /* draw each trip binding for the cdev */
- while (trip_binding >>= 1) {
- k++;
- if (!(trip_binding & 1))
- continue;
- /* draw '*' to show binding */
- mvwprintw(cooling_device_window,
- y + 2,
- x + ptdata.tzi[i].nr_trip_pts -
- k - 1, "*");
- }
- }
- }
- }
- /* draw border after data so that border will not be messed up
- * even there is not enough space for all the data to be shown
- */
- wborder(cooling_device_window, 0, 0, 0, 0, 0, 0, 0, 0);
- wattron(cooling_device_window, A_BOLD);
- mvwprintw(cooling_device_window, 0, maxx/2 - sizeof(cdev_title),
- cdev_title);
- wattroff(cooling_device_window, A_BOLD);
-
- wrefresh(cooling_device_window);
-}
-
-const char DIAG_TITLE[] = "[ TUNABLES ]";
-#define DIAG_DEV_ROWS 5
-void show_dialogue(void)
-{
- int j, x = 0, y = 0;
- WINDOW *w = dialogue_window;
-
- if (tui_disabled || !w)
- return;
-
- werase(w);
- box(w, 0, 0);
- mvwprintw(w, 0, maxx/4, DIAG_TITLE);
- /* list all the available tunables */
- for (j = 0; j <= ptdata.nr_cooling_dev; j++) {
- y = j % DIAG_DEV_ROWS;
- if (y == 0 && j != 0)
- x += 20;
- if (j == ptdata.nr_cooling_dev)
- /* save last choice for target temp */
- mvwprintw(w, y+1, x+1, "%C-%.12s", 'A'+j, "Set Temp");
- else
- mvwprintw(w, y+1, x+1, "%C-%.10s-%2d", 'A'+j,
- ptdata.cdi[j].type, ptdata.cdi[j].instance);
- }
- wattron(w, A_BOLD);
- mvwprintw(w, DIAG_DEV_ROWS+1, 1, "Enter Choice [A-Z]?");
- wattroff(w, A_BOLD);
- /* y size of dialogue win is nr cdev + 5, so print legend
- * at the bottom line
- */
- mvwprintw(w, ptdata.nr_cooling_dev+3, 1,
- "Legend: A=Active, P=Passive, C=Critical");
-
- wrefresh(dialogue_window);
-}
-
-void write_dialogue_win(char *buf, int y, int x)
-{
- WINDOW *w = dialogue_window;
-
- mvwprintw(w, y, x, "%s", buf);
-}
-
-const char control_title[] = " CONTROLS ";
-void show_control_w(void)
-{
- unsigned long state;
-
- get_ctrl_state(&state);
-
- if (tui_disabled || !control_window)
- return;
-
- werase(control_window);
- mvwprintw(control_window, 1, 1,
- "PID gain: kp=%2.2f ki=%2.2f kd=%2.2f Output %2.2f",
- p_param.kp, p_param.ki, p_param.kd, p_param.y_k);
-
- mvwprintw(control_window, 2, 1,
- "Target Temp: %2.1fC, Zone: %d, Control Device: %.12s",
- p_param.t_target, target_thermal_zone, ctrl_cdev);
-
- /* draw border last such that everything is within boundary */
- wborder(control_window, 0, 0, 0, 0, 0, 0, 0, 0);
- wattron(control_window, A_BOLD);
- mvwprintw(control_window, 0, maxx/2 - sizeof(control_title),
- control_title);
- wattroff(control_window, A_BOLD);
-
- wrefresh(control_window);
-}
-
-void initialize_curses(void)
-{
- if (tui_disabled)
- return;
-
- initscr();
- start_color();
- keypad(stdscr, TRUE); /* enable keyboard mapping */
- nonl(); /* tell curses not to do NL->CR/NL on output */
- cbreak(); /* take input chars one at a time */
- noecho(); /* dont echo input */
- curs_set(0); /* turn off cursor */
- use_default_colors();
-
- init_pair(PT_COLOR_DEFAULT, COLOR_WHITE, COLOR_BLACK);
- init_pair(PT_COLOR_HEADER_BAR, COLOR_BLACK, COLOR_WHITE);
- init_pair(PT_COLOR_ERROR, COLOR_BLACK, COLOR_RED);
- init_pair(PT_COLOR_RED, COLOR_WHITE, COLOR_RED);
- init_pair(PT_COLOR_YELLOW, COLOR_WHITE, COLOR_YELLOW);
- init_pair(PT_COLOR_GREEN, COLOR_WHITE, COLOR_GREEN);
- init_pair(PT_COLOR_BLUE, COLOR_WHITE, COLOR_BLUE);
- init_pair(PT_COLOR_BRIGHT, COLOR_WHITE, COLOR_BLACK);
-
-}
-
-void show_title_bar(void)
-{
- int i;
- int x = 0;
-
- if (tui_disabled || !title_bar_window)
- return;
-
- wattrset(title_bar_window, COLOR_PAIR(PT_COLOR_HEADER_BAR));
- wbkgd(title_bar_window, COLOR_PAIR(PT_COLOR_HEADER_BAR));
- werase(title_bar_window);
-
- mvwprintw(title_bar_window, 0, 0,
- " TMON v%s", VERSION);
-
- wrefresh(title_bar_window);
-
- werase(status_bar_window);
-
- for (i = 0; i < 10; i++) {
- if (strlen(status_bar_slots[i]) == 0)
- continue;
- wattron(status_bar_window, A_REVERSE);
- mvwprintw(status_bar_window, 0, x, "%s", status_bar_slots[i]);
- wattroff(status_bar_window, A_REVERSE);
- x += strlen(status_bar_slots[i]) + 1;
- }
- wrefresh(status_bar_window);
-}
-
-static void handle_input_val(int ch)
-{
- char buf[32];
- int val;
- char path[256];
- WINDOW *w = dialogue_window;
-
- echo();
- keypad(w, TRUE);
- wgetnstr(w, buf, 31);
- val = atoi(buf);
-
- if (ch == ptdata.nr_cooling_dev) {
- snprintf(buf, 31, "Invalid Temp %d! %d-%d", val,
- MIN_CTRL_TEMP, MAX_CTRL_TEMP);
- if (val < MIN_CTRL_TEMP || val > MAX_CTRL_TEMP)
- write_status_bar(40, buf);
- else {
- p_param.t_target = val;
- snprintf(buf, 31, "Set New Target Temp %d", val);
- write_status_bar(40, buf);
- }
- } else {
- snprintf(path, 256, "%s/%s%d", THERMAL_SYSFS,
- CDEV, ptdata.cdi[ch].instance);
- sysfs_set_ulong(path, "cur_state", val);
- }
- noecho();
- dialogue_on = 0;
- show_data_w();
- show_control_w();
-
- top = (PANEL *)panel_userptr(top);
- top_panel(top);
-}
-
-static void handle_input_choice(int ch)
-{
- char buf[48];
- int base = 0;
- int cdev_id = 0;
-
- if ((ch >= 'A' && ch <= 'A' + ptdata.nr_cooling_dev) ||
- (ch >= 'a' && ch <= 'a' + ptdata.nr_cooling_dev)) {
- base = (ch < 'a') ? 'A' : 'a';
- cdev_id = ch - base;
- if (ptdata.nr_cooling_dev == cdev_id)
- snprintf(buf, sizeof(buf), "New Target Temp:");
- else
- snprintf(buf, sizeof(buf), "New Value for %.10s-%2d: ",
- ptdata.cdi[cdev_id].type,
- ptdata.cdi[cdev_id].instance);
- write_dialogue_win(buf, DIAG_DEV_ROWS+2, 2);
- handle_input_val(cdev_id);
- } else {
- snprintf(buf, sizeof(buf), "Invalid selection %d", ch);
- write_dialogue_win(buf, 8, 2);
- }
-}
-
-void *handle_tui_events(void *arg)
-{
- int ch;
-
- keypad(cooling_device_window, TRUE);
- while ((ch = wgetch(cooling_device_window)) != EOF) {
- if (tmon_exit)
- break;
- /* when term size is too small, no dialogue panels are set.
- * we need to filter out such cases.
- */
- if (!data_panel || !dialogue_panel ||
- !cooling_device_window ||
- !dialogue_window) {
-
- continue;
- }
- pthread_mutex_lock(&input_lock);
- if (dialogue_on) {
- handle_input_choice(ch);
- /* top panel filter */
- if (ch == 'q' || ch == 'Q')
- ch = 0;
- }
- switch (ch) {
- case KEY_LEFT:
- box(cooling_device_window, 10, 0);
- break;
- case 9: /* TAB */
- top = (PANEL *)panel_userptr(top);
- top_panel(top);
- if (top == dialogue_panel) {
- dialogue_on = 1;
- show_dialogue();
- } else {
- dialogue_on = 0;
- /* force refresh */
- show_data_w();
- show_control_w();
- }
- break;
- case 'q':
- case 'Q':
- tmon_exit = 1;
- break;
- }
- update_panels();
- doupdate();
- pthread_mutex_unlock(&input_lock);
- }
-
- if (arg)
- *(int *)arg = 0; /* make gcc happy */
-
- return NULL;
-}
-
-/* draw a horizontal bar in given pattern */
-static void draw_hbar(WINDOW *win, int y, int start, int len, unsigned long ptn,
- bool end)
-{
- mvwaddch(win, y, start, ptn);
- whline(win, ptn, len);
- if (end)
- mvwaddch(win, y, MAX_DISP_TEMP+TDATA_LEFT, ']');
-}
-
-static char trip_type_to_char(int type)
-{
- switch (type) {
- case THERMAL_TRIP_CRITICAL: return 'C';
- case THERMAL_TRIP_HOT: return 'H';
- case THERMAL_TRIP_PASSIVE: return 'P';
- case THERMAL_TRIP_ACTIVE: return 'A';
- default:
- return '?';
- }
-}
-
-/* fill a string with trip point type and value in one line
- * e.g. P(56) C(106)
- * maintain the distance one degree per char
- */
-static void draw_tp_line(int tz, int y)
-{
- int j;
- int x;
-
- for (j = 0; j < ptdata.tzi[tz].nr_trip_pts; j++) {
- x = ptdata.tzi[tz].tp[j].temp / 1000;
- mvwprintw(thermal_data_window, y + 0, x + TDATA_LEFT,
- "%c%d", trip_type_to_char(ptdata.tzi[tz].tp[j].type),
- x);
- syslog(LOG_INFO, "%s:tz %d tp %d temp = %lu\n", __func__,
- tz, j, ptdata.tzi[tz].tp[j].temp);
- }
-}
-
-const char data_win_title[] = " THERMAL DATA ";
-void show_data_w(void)
-{
- int i;
-
-
- if (tui_disabled || !thermal_data_window)
- return;
-
- werase(thermal_data_window);
- wattron(thermal_data_window, A_BOLD);
- mvwprintw(thermal_data_window, 0, maxx/2 - sizeof(data_win_title),
- data_win_title);
- wattroff(thermal_data_window, A_BOLD);
- /* draw a line as ruler */
- for (i = 10; i < MAX_DISP_TEMP; i += 10)
- mvwprintw(thermal_data_window, 1, i+TDATA_LEFT, "%2d", i);
-
- for (i = 0; i < ptdata.nr_tz_sensor; i++) {
- int temp = trec[cur_thermal_record].temp[i] / 1000;
- int y = 0;
-
- y = i * NR_LINES_TZDATA + 2;
- /* y at tz temp data line */
- mvwprintw(thermal_data_window, y, 1, "%6.6s%2d:[%3d][",
- ptdata.tzi[i].type,
- ptdata.tzi[i].instance, temp);
- draw_hbar(thermal_data_window, y, TDATA_LEFT, temp, ACS_RARROW,
- true);
- draw_tp_line(i, y);
- }
- wborder(thermal_data_window, 0, 0, 0, 0, 0, 0, 0, 0);
- wrefresh(thermal_data_window);
-}
-
-const char tz_title[] = "THERMAL ZONES(SENSORS)";
-
-void show_sensors_w(void)
-{
- int i, j;
- char buffer[512];
-
- if (tui_disabled || !tz_sensor_window)
- return;
-
- werase(tz_sensor_window);
-
- memset(buffer, 0, sizeof(buffer));
- wattron(tz_sensor_window, A_BOLD);
- mvwprintw(tz_sensor_window, 1, 1, "Thermal Zones:");
- wattroff(tz_sensor_window, A_BOLD);
-
- mvwprintw(tz_sensor_window, 1, TZ_LEFT_ALIGN, "%s", buffer);
- /* fill trip points for each tzone */
- wattron(tz_sensor_window, A_BOLD);
- mvwprintw(tz_sensor_window, 2, 1, "Trip Points:");
- wattroff(tz_sensor_window, A_BOLD);
-
- /* draw trip point from low to high for each tz */
- for (i = 0; i < ptdata.nr_tz_sensor; i++) {
- int inst = ptdata.tzi[i].instance;
-
- mvwprintw(tz_sensor_window, 1,
- TZ_LEFT_ALIGN+TZONE_RECORD_SIZE * inst, "%.9s%02d",
- ptdata.tzi[i].type, ptdata.tzi[i].instance);
- for (j = ptdata.tzi[i].nr_trip_pts - 1; j >= 0; j--) {
- /* loop through all trip points */
- char type;
- int tp_pos;
- /* reverse the order here since trips are sorted
- * in ascending order in terms of temperature.
- */
- tp_pos = ptdata.tzi[i].nr_trip_pts - j - 1;
-
- type = trip_type_to_char(ptdata.tzi[i].tp[j].type);
- mvwaddch(tz_sensor_window, 2,
- inst * TZONE_RECORD_SIZE + TZ_LEFT_ALIGN +
- tp_pos, type);
- syslog(LOG_DEBUG, "draw tz %d tp %d ch:%c\n",
- inst, j, type);
- }
- }
- wborder(tz_sensor_window, 0, 0, 0, 0, 0, 0, 0, 0);
- wattron(tz_sensor_window, A_BOLD);
- mvwprintw(tz_sensor_window, 0, maxx/2 - sizeof(tz_title), tz_title);
- wattroff(tz_sensor_window, A_BOLD);
- wrefresh(tz_sensor_window);
-}
-
-void disable_tui(void)
-{
- tui_disabled = 1;
-}
diff --git a/tools/usb/Makefile b/tools/usb/Makefile
index acf2165..396d6c4 100644
--- a/tools/usb/Makefile
+++ b/tools/usb/Makefile
@@ -3,12 +3,11 @@
CC = $(CROSS_COMPILE)gcc
PTHREAD_LIBS = -lpthread
WARNINGS = -Wall -Wextra
-CFLAGS = $(WARNINGS) -g -I../include
-LDFLAGS = $(PTHREAD_LIBS)
+CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) -I../include
all: testusb ffs-test
%: %.c
- $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
+ $(CC) $(CFLAGS) -o $@ $^
clean:
$(RM) testusb ffs-test
diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
index bdb71a2..da7a195 100644
--- a/tools/virtio/virtio_test.c
+++ b/tools/virtio/virtio_test.c
@@ -41,14 +41,13 @@ struct vdev_info {
struct vhost_memory *mem;
};
-bool vq_notify(struct virtqueue *vq)
+void vq_notify(struct virtqueue *vq)
{
struct vq_info *info = vq->priv;
unsigned long long v = 1;
int r;
r = write(info->kick, &v, sizeof v);
assert(r == sizeof v);
- return true;
}
void vq_callback(struct virtqueue *vq)
@@ -172,8 +171,7 @@ static void run_test(struct vdev_info *dev, struct vq_info *vq,
GFP_ATOMIC);
if (likely(r == 0)) {
++started;
- if (unlikely(!virtqueue_kick(vq->vq))
- r = -1;
+ virtqueue_kick(vq->vq);
}
} else
r = -1;
diff --git a/tools/virtio/vringh_test.c b/tools/virtio/vringh_test.c
index 14a4f4c..d053ea4 100644
--- a/tools/virtio/vringh_test.c
+++ b/tools/virtio/vringh_test.c
@@ -22,7 +22,7 @@ static u64 user_addr_offset;
#define RINGSIZE 256
#define ALIGN 4096
-static bool never_notify_host(struct virtqueue *vq)
+static void never_notify_host(struct virtqueue *vq)
{
abort();
}
@@ -65,22 +65,17 @@ struct guest_virtio_device {
unsigned long notifies;
};
-static bool parallel_notify_host(struct virtqueue *vq)
+static void parallel_notify_host(struct virtqueue *vq)
{
- int rc;
struct guest_virtio_device *gvdev;
gvdev = container_of(vq->vdev, struct guest_virtio_device, vdev);
- rc = write(gvdev->to_host_fd, "", 1);
- if (rc < 0)
- return false;
+ write(gvdev->to_host_fd, "", 1);
gvdev->notifies++;
- return true;
}
-static bool no_notify_host(struct virtqueue *vq)
+static void no_notify_host(struct virtqueue *vq)
{
- return true;
}
#define NUM_XFERS (10000000)
diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c
index d5e9d6d..71c9c25 100644
--- a/tools/vm/page-types.c
+++ b/tools/vm/page-types.c
@@ -59,14 +59,12 @@
#define PM_PSHIFT_BITS 6
#define PM_PSHIFT_OFFSET (PM_STATUS_OFFSET - PM_PSHIFT_BITS)
#define PM_PSHIFT_MASK (((1LL << PM_PSHIFT_BITS) - 1) << PM_PSHIFT_OFFSET)
-#define __PM_PSHIFT(x) (((uint64_t) (x) << PM_PSHIFT_OFFSET) & PM_PSHIFT_MASK)
+#define PM_PSHIFT(x) (((u64) (x) << PM_PSHIFT_OFFSET) & PM_PSHIFT_MASK)
#define PM_PFRAME_MASK ((1LL << PM_PSHIFT_OFFSET) - 1)
#define PM_PFRAME(x) ((x) & PM_PFRAME_MASK)
-#define __PM_SOFT_DIRTY (1LL)
#define PM_PRESENT PM_STATUS(4LL)
#define PM_SWAP PM_STATUS(2LL)
-#define PM_SOFT_DIRTY __PM_PSHIFT(__PM_SOFT_DIRTY)
/*
@@ -85,7 +83,6 @@
#define KPF_OWNER_PRIVATE 37
#define KPF_ARCH 38
#define KPF_UNCACHED 39
-#define KPF_SOFTDIRTY 40
/* [48-] take some arbitrary free slots for expanding overloaded flags
* not part of kernel API
@@ -135,7 +132,6 @@ static const char * const page_flag_names[] = {
[KPF_OWNER_PRIVATE] = "O:owner_private",
[KPF_ARCH] = "h:arch",
[KPF_UNCACHED] = "c:uncached",
- [KPF_SOFTDIRTY] = "f:softdirty",
[KPF_READAHEAD] = "I:readahead",
[KPF_SLOB_FREE] = "P:slob_free",
@@ -421,7 +417,7 @@ static int bit_mask_ok(uint64_t flags)
return 1;
}
-static uint64_t expand_overloaded_flags(uint64_t flags, uint64_t pme)
+static uint64_t expand_overloaded_flags(uint64_t flags)
{
/* SLOB/SLUB overload several page flags */
if (flags & BIT(SLAB)) {
@@ -437,9 +433,6 @@ static uint64_t expand_overloaded_flags(uint64_t flags, uint64_t pme)
if ((flags & (BIT(RECLAIM) | BIT(WRITEBACK))) == BIT(RECLAIM))
flags ^= BIT(RECLAIM) | BIT(READAHEAD);
- if (pme & PM_SOFT_DIRTY)
- flags |= BIT(SOFTDIRTY);
-
return flags;
}
@@ -455,11 +448,11 @@ static uint64_t well_known_flags(uint64_t flags)
return flags;
}
-static uint64_t kpageflags_flags(uint64_t flags, uint64_t pme)
+static uint64_t kpageflags_flags(uint64_t flags)
{
- if (opt_raw)
- flags = expand_overloaded_flags(flags, pme);
- else
+ flags = expand_overloaded_flags(flags);
+
+ if (!opt_raw)
flags = well_known_flags(flags);
return flags;
@@ -552,9 +545,9 @@ static size_t hash_slot(uint64_t flags)
}
static void add_page(unsigned long voffset,
- unsigned long offset, uint64_t flags, uint64_t pme)
+ unsigned long offset, uint64_t flags)
{
- flags = kpageflags_flags(flags, pme);
+ flags = kpageflags_flags(flags);
if (!bit_mask_ok(flags))
return;
@@ -576,8 +569,7 @@ static void add_page(unsigned long voffset,
#define KPAGEFLAGS_BATCH (64 << 10) /* 64k pages */
static void walk_pfn(unsigned long voffset,
unsigned long index,
- unsigned long count,
- uint64_t pme)
+ unsigned long count)
{
uint64_t buf[KPAGEFLAGS_BATCH];
unsigned long batch;
@@ -591,7 +583,7 @@ static void walk_pfn(unsigned long voffset,
break;
for (i = 0; i < pages; i++)
- add_page(voffset + i, index + i, buf[i], pme);
+ add_page(voffset + i, index + i, buf[i]);
index += pages;
count -= pages;
@@ -616,7 +608,7 @@ static void walk_vma(unsigned long index, unsigned long count)
for (i = 0; i < pages; i++) {
pfn = pagemap_pfn(buf[i]);
if (pfn)
- walk_pfn(index + i, pfn, 1, buf[i]);
+ walk_pfn(index + i, pfn, 1);
}
index += pages;
@@ -667,7 +659,7 @@ static void walk_addr_ranges(void)
for (i = 0; i < nr_addr_ranges; i++)
if (!opt_pid)
- walk_pfn(0, opt_offset[i], opt_size[i], 0);
+ walk_pfn(0, opt_offset[i], opt_size[i]);
else
walk_task(opt_offset[i], opt_size[i]);