diff options
author | Ingo Molnar <mingo@kernel.org> | 2015-08-31 04:25:46 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-08-31 04:25:46 -0400 |
commit | bac2e4a96d1c0bcce5e9654dcc902f75576b9b03 (patch) | |
tree | 1ca98d982c8cbcf25db713fc8439d7772fe97383 | |
parent | 02b643b643254ec79b5f9aaa143e10be68eabdab (diff) | |
parent | 2c07144dfce366e21465cc7b0ada9f0b6dc7b7ed (diff) |
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvement and fixes from Arnaldo Carvalho de Melo:
User visible changes:
- Add new compaction-times python script. (Tony Jones)
- Make the --[no-]-demangle/--[no-]-demangle-kernel command line
options available in 'perf script' too. (Mark Drayton)
- Allow for negative numbers in libtraceevent's print format,
fixing up misformatting in some tracepoints. (Steven Rostedt)
Infrastructure changes:
- perf_env/perf_evlist changes to allow accessing the data
structure with the environment where some perf data was
collected in functions not necessarily related to perf.data
file processing. (Kan Liang)
- Cleanups for the tracepoint definition location paths routines. (Jiri Olsa)
- Introduce sysfs/filename__sprintf_build_id, removing code
duplication. (Masami Hiramatsu)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
29 files changed, 433 insertions, 102 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 5c1867a13ef2..4d885934b919 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c | |||
@@ -4828,6 +4828,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event | |||
4828 | case 'z': | 4828 | case 'z': |
4829 | case 'Z': | 4829 | case 'Z': |
4830 | case '0' ... '9': | 4830 | case '0' ... '9': |
4831 | case '-': | ||
4831 | goto cont_process; | 4832 | goto cont_process; |
4832 | case 'p': | 4833 | case 'p': |
4833 | if (pevent->long_size == 4) | 4834 | if (pevent->long_size == 4) |
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt index c0d24791a7f3..614b2c7b0293 100644 --- a/tools/perf/Documentation/perf-script.txt +++ b/tools/perf/Documentation/perf-script.txt | |||
@@ -226,6 +226,13 @@ OPTIONS | |||
226 | Display context switch events i.e. events of type PERF_RECORD_SWITCH or | 226 | Display context switch events i.e. events of type PERF_RECORD_SWITCH or |
227 | PERF_RECORD_SWITCH_CPU_WIDE. | 227 | PERF_RECORD_SWITCH_CPU_WIDE. |
228 | 228 | ||
229 | --demangle:: | ||
230 | Demangle symbol names to human readable form. It's enabled by default, | ||
231 | disable with --no-demangle. | ||
232 | |||
233 | --demangle-kernel:: | ||
234 | Demangle kernel symbol names to human readable form (for C++ kernels). | ||
235 | |||
229 | --header | 236 | --header |
230 | Show perf.data header. | 237 | Show perf.data header. |
231 | 238 | ||
diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c index b7bb42c44694..b00dfd92ea73 100644 --- a/tools/perf/arch/common.c +++ b/tools/perf/arch/common.c | |||
@@ -128,7 +128,7 @@ static const char *normalize_arch(char *arch) | |||
128 | return arch; | 128 | return arch; |
129 | } | 129 | } |
130 | 130 | ||
131 | static int perf_session_env__lookup_binutils_path(struct perf_session_env *env, | 131 | static int perf_session_env__lookup_binutils_path(struct perf_env *env, |
132 | const char *name, | 132 | const char *name, |
133 | const char **path) | 133 | const char **path) |
134 | { | 134 | { |
@@ -206,7 +206,7 @@ out_error: | |||
206 | return -1; | 206 | return -1; |
207 | } | 207 | } |
208 | 208 | ||
209 | int perf_session_env__lookup_objdump(struct perf_session_env *env) | 209 | int perf_session_env__lookup_objdump(struct perf_env *env) |
210 | { | 210 | { |
211 | /* | 211 | /* |
212 | * For live mode, env->arch will be NULL and we can use | 212 | * For live mode, env->arch will be NULL and we can use |
diff --git a/tools/perf/arch/common.h b/tools/perf/arch/common.h index ede246eda9be..20176df69fc8 100644 --- a/tools/perf/arch/common.h +++ b/tools/perf/arch/common.h | |||
@@ -5,6 +5,6 @@ | |||
5 | 5 | ||
6 | extern const char *objdump_path; | 6 | extern const char *objdump_path; |
7 | 7 | ||
8 | int perf_session_env__lookup_objdump(struct perf_session_env *env); | 8 | int perf_session_env__lookup_objdump(struct perf_env *env); |
9 | 9 | ||
10 | #endif /* ARCH_PERF_COMMON_H */ | 10 | #endif /* ARCH_PERF_COMMON_H */ |
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index 65b4835309c7..7b8450cd33c2 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c | |||
@@ -25,8 +25,6 @@ | |||
25 | static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid) | 25 | static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid) |
26 | { | 26 | { |
27 | char root_dir[PATH_MAX]; | 27 | char root_dir[PATH_MAX]; |
28 | char notes[PATH_MAX]; | ||
29 | u8 build_id[BUILD_ID_SIZE]; | ||
30 | char *p; | 28 | char *p; |
31 | 29 | ||
32 | strlcpy(root_dir, proc_dir, sizeof(root_dir)); | 30 | strlcpy(root_dir, proc_dir, sizeof(root_dir)); |
@@ -35,15 +33,7 @@ static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid) | |||
35 | if (!p) | 33 | if (!p) |
36 | return -1; | 34 | return -1; |
37 | *p = '\0'; | 35 | *p = '\0'; |
38 | 36 | return sysfs__sprintf_build_id(root_dir, sbuildid); | |
39 | scnprintf(notes, sizeof(notes), "%s/sys/kernel/notes", root_dir); | ||
40 | |||
41 | if (sysfs__read_build_id(notes, build_id, sizeof(build_id))) | ||
42 | return -1; | ||
43 | |||
44 | build_id__sprintf(build_id, sizeof(build_id), sbuildid); | ||
45 | |||
46 | return 0; | ||
47 | } | 37 | } |
48 | 38 | ||
49 | static int build_id_cache__kcore_dir(char *dir, size_t sz) | 39 | static int build_id_cache__kcore_dir(char *dir, size_t sz) |
@@ -138,7 +128,7 @@ static int build_id_cache__add_kcore(const char *filename, bool force) | |||
138 | return -1; | 128 | return -1; |
139 | *p = '\0'; | 129 | *p = '\0'; |
140 | 130 | ||
141 | if (build_id_cache__kcore_buildid(from_dir, sbuildid)) | 131 | if (build_id_cache__kcore_buildid(from_dir, sbuildid) < 0) |
142 | return -1; | 132 | return -1; |
143 | 133 | ||
144 | scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s", | 134 | scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s", |
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index b5ca988ebfbe..918b4de29de4 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c | |||
@@ -19,29 +19,25 @@ | |||
19 | 19 | ||
20 | static int sysfs__fprintf_build_id(FILE *fp) | 20 | static int sysfs__fprintf_build_id(FILE *fp) |
21 | { | 21 | { |
22 | u8 kallsyms_build_id[BUILD_ID_SIZE]; | ||
23 | char sbuild_id[SBUILD_ID_SIZE]; | 22 | char sbuild_id[SBUILD_ID_SIZE]; |
23 | int ret; | ||
24 | 24 | ||
25 | if (sysfs__read_build_id("/sys/kernel/notes", kallsyms_build_id, | 25 | ret = sysfs__sprintf_build_id("/", sbuild_id); |
26 | sizeof(kallsyms_build_id)) != 0) | 26 | if (ret != sizeof(sbuild_id)) |
27 | return -1; | 27 | return ret < 0 ? ret : -EINVAL; |
28 | 28 | ||
29 | build_id__sprintf(kallsyms_build_id, sizeof(kallsyms_build_id), | 29 | return fprintf(fp, "%s\n", sbuild_id); |
30 | sbuild_id); | ||
31 | fprintf(fp, "%s\n", sbuild_id); | ||
32 | return 0; | ||
33 | } | 30 | } |
34 | 31 | ||
35 | static int filename__fprintf_build_id(const char *name, FILE *fp) | 32 | static int filename__fprintf_build_id(const char *name, FILE *fp) |
36 | { | 33 | { |
37 | u8 build_id[BUILD_ID_SIZE]; | ||
38 | char sbuild_id[SBUILD_ID_SIZE]; | 34 | char sbuild_id[SBUILD_ID_SIZE]; |
35 | int ret; | ||
39 | 36 | ||
40 | if (filename__read_build_id(name, build_id, | 37 | ret = filename__sprintf_build_id(name, sbuild_id); |
41 | sizeof(build_id)) != sizeof(build_id)) | 38 | if (ret != sizeof(sbuild_id)) |
42 | return 0; | 39 | return ret < 0 ? ret : -EINVAL; |
43 | 40 | ||
44 | build_id__sprintf(build_id, sizeof(build_id), sbuild_id); | ||
45 | return fprintf(fp, "%s\n", sbuild_id); | 41 | return fprintf(fp, "%s\n", sbuild_id); |
46 | } | 42 | } |
47 | 43 | ||
@@ -63,7 +59,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits) | |||
63 | /* | 59 | /* |
64 | * See if this is an ELF file first: | 60 | * See if this is an ELF file first: |
65 | */ | 61 | */ |
66 | if (filename__fprintf_build_id(input_name, stdout)) | 62 | if (filename__fprintf_build_id(input_name, stdout) > 0) |
67 | goto out; | 63 | goto out; |
68 | 64 | ||
69 | session = perf_session__new(&file, false, &build_id__mark_dso_hit_ops); | 65 | session = perf_session__new(&file, false, &build_id__mark_dso_hit_ops); |
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 105332e950a9..4430340292c0 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -1671,6 +1671,11 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) | |||
1671 | itrace_parse_synth_opts), | 1671 | itrace_parse_synth_opts), |
1672 | OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename, | 1672 | OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename, |
1673 | "Show full source file name path for source lines"), | 1673 | "Show full source file name path for source lines"), |
1674 | OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle, | ||
1675 | "Enable symbol demangling"), | ||
1676 | OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel, | ||
1677 | "Enable kernel symbol demangling"), | ||
1678 | |||
1674 | OPT_END() | 1679 | OPT_END() |
1675 | }; | 1680 | }; |
1676 | const char * const script_subcommands[] = { "record", "report", NULL }; | 1681 | const char * const script_subcommands[] = { "record", "report", NULL }; |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 2f1162daa3c5..4e3abba03062 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -1,3 +1,21 @@ | |||
1 | /* | ||
2 | * builtin-trace.c | ||
3 | * | ||
4 | * Builtin 'trace' command: | ||
5 | * | ||
6 | * Display a continuously updated trace of any workload, CPU, specific PID, | ||
7 | * system wide, etc. Default format is loosely strace like, but any other | ||
8 | * event may be specified using --event. | ||
9 | * | ||
10 | * Copyright (C) 2012, 2013, 2014, 2015 Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com> | ||
11 | * | ||
12 | * Initially based on the 'trace' prototype by Thomas Gleixner: | ||
13 | * | ||
14 | * http://lwn.net/Articles/415728/ ("Announcing a new utility: 'trace'") | ||
15 | * | ||
16 | * Released under the GPL v2. (and only v2, not any later version) | ||
17 | */ | ||
18 | |||
1 | #include <traceevent/event-parse.h> | 19 | #include <traceevent/event-parse.h> |
2 | #include "builtin.h" | 20 | #include "builtin.h" |
3 | #include "util/color.h" | 21 | #include "util/color.h" |
@@ -27,6 +45,7 @@ | |||
27 | 45 | ||
28 | #ifndef MADV_HWPOISON | 46 | #ifndef MADV_HWPOISON |
29 | # define MADV_HWPOISON 100 | 47 | # define MADV_HWPOISON 100 |
48 | |||
30 | #endif | 49 | #endif |
31 | 50 | ||
32 | #ifndef MADV_MERGEABLE | 51 | #ifndef MADV_MERGEABLE |
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index b857fcbd00cf..07dbff5c0e60 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -231,7 +231,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) | |||
231 | (*argc)--; | 231 | (*argc)--; |
232 | } else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) { | 232 | } else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) { |
233 | perf_debugfs_set_path(cmd + strlen(CMD_DEBUGFS_DIR)); | 233 | perf_debugfs_set_path(cmd + strlen(CMD_DEBUGFS_DIR)); |
234 | fprintf(stderr, "dir: %s\n", debugfs_mountpoint); | 234 | fprintf(stderr, "dir: %s\n", tracing_path); |
235 | if (envchanged) | 235 | if (envchanged) |
236 | *envchanged = 1; | 236 | *envchanged = 1; |
237 | } else if (!strcmp(cmd, "--list-cmds")) { | 237 | } else if (!strcmp(cmd, "--list-cmds")) { |
diff --git a/tools/perf/scripts/python/bin/compaction-times-record b/tools/perf/scripts/python/bin/compaction-times-record new file mode 100644 index 000000000000..6edcd40e14e8 --- /dev/null +++ b/tools/perf/scripts/python/bin/compaction-times-record | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | perf record -e compaction:mm_compaction_begin -e compaction:mm_compaction_end -e compaction:mm_compaction_migratepages -e compaction:mm_compaction_isolate_migratepages -e compaction:mm_compaction_isolate_freepages $@ | ||
diff --git a/tools/perf/scripts/python/bin/compaction-times-report b/tools/perf/scripts/python/bin/compaction-times-report new file mode 100644 index 000000000000..3dc13897cfde --- /dev/null +++ b/tools/perf/scripts/python/bin/compaction-times-report | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/bash | ||
2 | #description: display time taken by mm compaction | ||
3 | #args: [-h] [-u] [-p|-pv] [-t | [-m] [-fs] [-ms]] [pid|pid-range|comm-regex] | ||
4 | perf script -s "$PERF_EXEC_PATH"/scripts/python/compaction-times.py $@ | ||
diff --git a/tools/perf/scripts/python/compaction-times.py b/tools/perf/scripts/python/compaction-times.py new file mode 100644 index 000000000000..239cb0568ec3 --- /dev/null +++ b/tools/perf/scripts/python/compaction-times.py | |||
@@ -0,0 +1,311 @@ | |||
1 | # report time spent in compaction | ||
2 | # Licensed under the terms of the GNU GPL License version 2 | ||
3 | |||
4 | # testing: | ||
5 | # 'echo 1 > /proc/sys/vm/compact_memory' to force compaction of all zones | ||
6 | |||
7 | import os | ||
8 | import sys | ||
9 | import re | ||
10 | |||
11 | import signal | ||
12 | signal.signal(signal.SIGPIPE, signal.SIG_DFL) | ||
13 | |||
14 | usage = "usage: perf script report compaction-times.py -- [-h] [-u] [-p|-pv] [-t | [-m] [-fs] [-ms]] [pid|pid-range|comm-regex]\n" | ||
15 | |||
16 | class popt: | ||
17 | DISP_DFL = 0 | ||
18 | DISP_PROC = 1 | ||
19 | DISP_PROC_VERBOSE=2 | ||
20 | |||
21 | class topt: | ||
22 | DISP_TIME = 0 | ||
23 | DISP_MIG = 1 | ||
24 | DISP_ISOLFREE = 2 | ||
25 | DISP_ISOLMIG = 4 | ||
26 | DISP_ALL = 7 | ||
27 | |||
28 | class comm_filter: | ||
29 | def __init__(self, re): | ||
30 | self.re = re | ||
31 | |||
32 | def filter(self, pid, comm): | ||
33 | m = self.re.search(comm) | ||
34 | return m == None or m.group() == "" | ||
35 | |||
36 | class pid_filter: | ||
37 | def __init__(self, low, high): | ||
38 | self.low = (0 if low == "" else int(low)) | ||
39 | self.high = (0 if high == "" else int(high)) | ||
40 | |||
41 | def filter(self, pid, comm): | ||
42 | return not (pid >= self.low and (self.high == 0 or pid <= self.high)) | ||
43 | |||
44 | def set_type(t): | ||
45 | global opt_disp | ||
46 | opt_disp = (t if opt_disp == topt.DISP_ALL else opt_disp|t) | ||
47 | |||
48 | def ns(sec, nsec): | ||
49 | return (sec * 1000000000) + nsec | ||
50 | |||
51 | def time(ns): | ||
52 | return "%dns" % ns if opt_ns else "%dus" % (round(ns, -3) / 1000) | ||
53 | |||
54 | class pair: | ||
55 | def __init__(self, aval, bval, alabel = None, blabel = None): | ||
56 | self.alabel = alabel | ||
57 | self.blabel = blabel | ||
58 | self.aval = aval | ||
59 | self.bval = bval | ||
60 | |||
61 | def __add__(self, rhs): | ||
62 | self.aval += rhs.aval | ||
63 | self.bval += rhs.bval | ||
64 | return self | ||
65 | |||
66 | def __str__(self): | ||
67 | return "%s=%d %s=%d" % (self.alabel, self.aval, self.blabel, self.bval) | ||
68 | |||
69 | class cnode: | ||
70 | def __init__(self, ns): | ||
71 | self.ns = ns | ||
72 | self.migrated = pair(0, 0, "moved", "failed") | ||
73 | self.fscan = pair(0,0, "scanned", "isolated") | ||
74 | self.mscan = pair(0,0, "scanned", "isolated") | ||
75 | |||
76 | def __add__(self, rhs): | ||
77 | self.ns += rhs.ns | ||
78 | self.migrated += rhs.migrated | ||
79 | self.fscan += rhs.fscan | ||
80 | self.mscan += rhs.mscan | ||
81 | return self | ||
82 | |||
83 | def __str__(self): | ||
84 | prev = 0 | ||
85 | s = "%s " % time(self.ns) | ||
86 | if (opt_disp & topt.DISP_MIG): | ||
87 | s += "migration: %s" % self.migrated | ||
88 | prev = 1 | ||
89 | if (opt_disp & topt.DISP_ISOLFREE): | ||
90 | s += "%sfree_scanner: %s" % (" " if prev else "", self.fscan) | ||
91 | prev = 1 | ||
92 | if (opt_disp & topt.DISP_ISOLMIG): | ||
93 | s += "%smigration_scanner: %s" % (" " if prev else "", self.mscan) | ||
94 | return s | ||
95 | |||
96 | def complete(self, secs, nsecs): | ||
97 | self.ns = ns(secs, nsecs) - self.ns | ||
98 | |||
99 | def increment(self, migrated, fscan, mscan): | ||
100 | if (migrated != None): | ||
101 | self.migrated += migrated | ||
102 | if (fscan != None): | ||
103 | self.fscan += fscan | ||
104 | if (mscan != None): | ||
105 | self.mscan += mscan | ||
106 | |||
107 | |||
108 | class chead: | ||
109 | heads = {} | ||
110 | val = cnode(0); | ||
111 | fobj = None | ||
112 | |||
113 | @classmethod | ||
114 | def add_filter(cls, filter): | ||
115 | cls.fobj = filter | ||
116 | |||
117 | @classmethod | ||
118 | def create_pending(cls, pid, comm, start_secs, start_nsecs): | ||
119 | filtered = 0 | ||
120 | try: | ||
121 | head = cls.heads[pid] | ||
122 | filtered = head.is_filtered() | ||
123 | except KeyError: | ||
124 | if cls.fobj != None: | ||
125 | filtered = cls.fobj.filter(pid, comm) | ||
126 | head = cls.heads[pid] = chead(comm, pid, filtered) | ||
127 | |||
128 | if not filtered: | ||
129 | head.mark_pending(start_secs, start_nsecs) | ||
130 | |||
131 | @classmethod | ||
132 | def increment_pending(cls, pid, migrated, fscan, mscan): | ||
133 | head = cls.heads[pid] | ||
134 | if not head.is_filtered(): | ||
135 | if head.is_pending(): | ||
136 | head.do_increment(migrated, fscan, mscan) | ||
137 | else: | ||
138 | sys.stderr.write("missing start compaction event for pid %d\n" % pid) | ||
139 | |||
140 | @classmethod | ||
141 | def complete_pending(cls, pid, secs, nsecs): | ||
142 | head = cls.heads[pid] | ||
143 | if not head.is_filtered(): | ||
144 | if head.is_pending(): | ||
145 | head.make_complete(secs, nsecs) | ||
146 | else: | ||
147 | sys.stderr.write("missing start compaction event for pid %d\n" % pid) | ||
148 | |||
149 | @classmethod | ||
150 | def gen(cls): | ||
151 | if opt_proc != popt.DISP_DFL: | ||
152 | for i in cls.heads: | ||
153 | yield cls.heads[i] | ||
154 | |||
155 | @classmethod | ||
156 | def str(cls): | ||
157 | return cls.val | ||
158 | |||
159 | def __init__(self, comm, pid, filtered): | ||
160 | self.comm = comm | ||
161 | self.pid = pid | ||
162 | self.val = cnode(0) | ||
163 | self.pending = None | ||
164 | self.filtered = filtered | ||
165 | self.list = [] | ||
166 | |||
167 | def __add__(self, rhs): | ||
168 | self.ns += rhs.ns | ||
169 | self.val += rhs.val | ||
170 | return self | ||
171 | |||
172 | def mark_pending(self, secs, nsecs): | ||
173 | self.pending = cnode(ns(secs, nsecs)) | ||
174 | |||
175 | def do_increment(self, migrated, fscan, mscan): | ||
176 | self.pending.increment(migrated, fscan, mscan) | ||
177 | |||
178 | def make_complete(self, secs, nsecs): | ||
179 | self.pending.complete(secs, nsecs) | ||
180 | chead.val += self.pending | ||
181 | |||
182 | if opt_proc != popt.DISP_DFL: | ||
183 | self.val += self.pending | ||
184 | |||
185 | if opt_proc == popt.DISP_PROC_VERBOSE: | ||
186 | self.list.append(self.pending) | ||
187 | self.pending = None | ||
188 | |||
189 | def enumerate(self): | ||
190 | if opt_proc == popt.DISP_PROC_VERBOSE and not self.is_filtered(): | ||
191 | for i, pelem in enumerate(self.list): | ||
192 | sys.stdout.write("%d[%s].%d: %s\n" % (self.pid, self.comm, i+1, pelem)) | ||
193 | |||
194 | def is_pending(self): | ||
195 | return self.pending != None | ||
196 | |||
197 | def is_filtered(self): | ||
198 | return self.filtered | ||
199 | |||
200 | def display(self): | ||
201 | if not self.is_filtered(): | ||
202 | sys.stdout.write("%d[%s]: %s\n" % (self.pid, self.comm, self.val)) | ||
203 | |||
204 | |||
205 | def trace_end(): | ||
206 | sys.stdout.write("total: %s\n" % chead.str()) | ||
207 | for i in chead.gen(): | ||
208 | i.display(), | ||
209 | i.enumerate() | ||
210 | |||
211 | def compaction__mm_compaction_migratepages(event_name, context, common_cpu, | ||
212 | common_secs, common_nsecs, common_pid, common_comm, | ||
213 | common_callchain, nr_migrated, nr_failed): | ||
214 | |||
215 | chead.increment_pending(common_pid, | ||
216 | pair(nr_migrated, nr_failed), None, None) | ||
217 | |||
218 | def compaction__mm_compaction_isolate_freepages(event_name, context, common_cpu, | ||
219 | common_secs, common_nsecs, common_pid, common_comm, | ||
220 | common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken): | ||
221 | |||
222 | chead.increment_pending(common_pid, | ||
223 | None, pair(nr_scanned, nr_taken), None) | ||
224 | |||
225 | def compaction__mm_compaction_isolate_migratepages(event_name, context, common_cpu, | ||
226 | common_secs, common_nsecs, common_pid, common_comm, | ||
227 | common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken): | ||
228 | |||
229 | chead.increment_pending(common_pid, | ||
230 | None, None, pair(nr_scanned, nr_taken)) | ||
231 | |||
232 | def compaction__mm_compaction_end(event_name, context, common_cpu, | ||
233 | common_secs, common_nsecs, common_pid, common_comm, | ||
234 | common_callchain, zone_start, migrate_start, free_start, zone_end, | ||
235 | sync, status): | ||
236 | |||
237 | chead.complete_pending(common_pid, common_secs, common_nsecs) | ||
238 | |||
239 | def compaction__mm_compaction_begin(event_name, context, common_cpu, | ||
240 | common_secs, common_nsecs, common_pid, common_comm, | ||
241 | common_callchain, zone_start, migrate_start, free_start, zone_end, | ||
242 | sync): | ||
243 | |||
244 | chead.create_pending(common_pid, common_comm, common_secs, common_nsecs) | ||
245 | |||
246 | def pr_help(): | ||
247 | global usage | ||
248 | |||
249 | sys.stdout.write(usage) | ||
250 | sys.stdout.write("\n") | ||
251 | sys.stdout.write("-h display this help\n") | ||
252 | sys.stdout.write("-p display by process\n") | ||
253 | sys.stdout.write("-pv display by process (verbose)\n") | ||
254 | sys.stdout.write("-t display stall times only\n") | ||
255 | sys.stdout.write("-m display stats for migration\n") | ||
256 | sys.stdout.write("-fs display stats for free scanner\n") | ||
257 | sys.stdout.write("-ms display stats for migration scanner\n") | ||
258 | sys.stdout.write("-u display results in microseconds (default nanoseconds)\n") | ||
259 | |||
260 | |||
261 | comm_re = None | ||
262 | pid_re = None | ||
263 | pid_regex = "^(\d*)-(\d*)$|^(\d*)$" | ||
264 | |||
265 | opt_proc = popt.DISP_DFL | ||
266 | opt_disp = topt.DISP_ALL | ||
267 | |||
268 | opt_ns = True | ||
269 | |||
270 | argc = len(sys.argv) - 1 | ||
271 | if argc >= 1: | ||
272 | pid_re = re.compile(pid_regex) | ||
273 | |||
274 | for i, opt in enumerate(sys.argv[1:]): | ||
275 | if opt[0] == "-": | ||
276 | if opt == "-h": | ||
277 | pr_help() | ||
278 | exit(0); | ||
279 | elif opt == "-p": | ||
280 | opt_proc = popt.DISP_PROC | ||
281 | elif opt == "-pv": | ||
282 | opt_proc = popt.DISP_PROC_VERBOSE | ||
283 | elif opt == '-u': | ||
284 | opt_ns = False | ||
285 | elif opt == "-t": | ||
286 | set_type(topt.DISP_TIME) | ||
287 | elif opt == "-m": | ||
288 | set_type(topt.DISP_MIG) | ||
289 | elif opt == "-fs": | ||
290 | set_type(topt.DISP_ISOLFREE) | ||
291 | elif opt == "-ms": | ||
292 | set_type(topt.DISP_ISOLMIG) | ||
293 | else: | ||
294 | sys.exit(usage) | ||
295 | |||
296 | elif i == argc - 1: | ||
297 | m = pid_re.search(opt) | ||
298 | if m != None and m.group() != "": | ||
299 | if m.group(3) != None: | ||
300 | f = pid_filter(m.group(3), m.group(3)) | ||
301 | else: | ||
302 | f = pid_filter(m.group(1), m.group(2)) | ||
303 | else: | ||
304 | try: | ||
305 | comm_re=re.compile(opt) | ||
306 | except: | ||
307 | sys.stderr.write("invalid regex '%s'" % opt) | ||
308 | sys.exit(usage) | ||
309 | f = comm_filter(comm_re) | ||
310 | |||
311 | chead.add_filter(f) | ||
diff --git a/tools/perf/ui/browser.h b/tools/perf/ui/browser.h index 52be87125def..f3cef564de02 100644 --- a/tools/perf/ui/browser.h +++ b/tools/perf/ui/browser.h | |||
@@ -61,8 +61,8 @@ int ui_browser__help_window(struct ui_browser *browser, const char *text); | |||
61 | bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text); | 61 | bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text); |
62 | int ui_browser__input_window(const char *title, const char *text, char *input, | 62 | int ui_browser__input_window(const char *title, const char *text, char *input, |
63 | const char *exit_msg, int delay_sec); | 63 | const char *exit_msg, int delay_sec); |
64 | struct perf_session_env; | 64 | struct perf_env; |
65 | int tui__header_window(struct perf_session_env *env); | 65 | int tui__header_window(struct perf_env *env); |
66 | 66 | ||
67 | void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence); | 67 | void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence); |
68 | unsigned int ui_browser__argv_refresh(struct ui_browser *browser); | 68 | unsigned int ui_browser__argv_refresh(struct ui_browser *browser); |
diff --git a/tools/perf/ui/browsers/header.c b/tools/perf/ui/browsers/header.c index f10681717f93..edbeaaf31ace 100644 --- a/tools/perf/ui/browsers/header.c +++ b/tools/perf/ui/browsers/header.c | |||
@@ -91,7 +91,7 @@ static int ui__list_menu(int argc, char * const argv[]) | |||
91 | return list_menu__run(&menu); | 91 | return list_menu__run(&menu); |
92 | } | 92 | } |
93 | 93 | ||
94 | int tui__header_window(struct perf_session_env *env) | 94 | int tui__header_window(struct perf_env *env) |
95 | { | 95 | { |
96 | int i, argc = 0; | 96 | int i, argc = 0; |
97 | char **argv; | 97 | char **argv; |
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 10c7ec041039..cf86f2d3a5e7 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -26,7 +26,7 @@ struct hist_browser { | |||
26 | struct map_symbol *selection; | 26 | struct map_symbol *selection; |
27 | struct hist_browser_timer *hbt; | 27 | struct hist_browser_timer *hbt; |
28 | struct pstack *pstack; | 28 | struct pstack *pstack; |
29 | struct perf_session_env *env; | 29 | struct perf_env *env; |
30 | int print_seq; | 30 | int print_seq; |
31 | bool show_dso; | 31 | bool show_dso; |
32 | bool show_headers; | 32 | bool show_headers; |
@@ -1214,7 +1214,7 @@ static int hist_browser__dump(struct hist_browser *browser) | |||
1214 | 1214 | ||
1215 | static struct hist_browser *hist_browser__new(struct hists *hists, | 1215 | static struct hist_browser *hist_browser__new(struct hists *hists, |
1216 | struct hist_browser_timer *hbt, | 1216 | struct hist_browser_timer *hbt, |
1217 | struct perf_session_env *env) | 1217 | struct perf_env *env) |
1218 | { | 1218 | { |
1219 | struct hist_browser *browser = zalloc(sizeof(*browser)); | 1219 | struct hist_browser *browser = zalloc(sizeof(*browser)); |
1220 | 1220 | ||
@@ -1695,7 +1695,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
1695 | bool left_exits, | 1695 | bool left_exits, |
1696 | struct hist_browser_timer *hbt, | 1696 | struct hist_browser_timer *hbt, |
1697 | float min_pcnt, | 1697 | float min_pcnt, |
1698 | struct perf_session_env *env) | 1698 | struct perf_env *env) |
1699 | { | 1699 | { |
1700 | struct hists *hists = evsel__hists(evsel); | 1700 | struct hists *hists = evsel__hists(evsel); |
1701 | struct hist_browser *browser = hist_browser__new(hists, hbt, env); | 1701 | struct hist_browser *browser = hist_browser__new(hists, hbt, env); |
@@ -2016,7 +2016,7 @@ struct perf_evsel_menu { | |||
2016 | struct perf_evsel *selection; | 2016 | struct perf_evsel *selection; |
2017 | bool lost_events, lost_events_warned; | 2017 | bool lost_events, lost_events_warned; |
2018 | float min_pcnt; | 2018 | float min_pcnt; |
2019 | struct perf_session_env *env; | 2019 | struct perf_env *env; |
2020 | }; | 2020 | }; |
2021 | 2021 | ||
2022 | static void perf_evsel_menu__write(struct ui_browser *browser, | 2022 | static void perf_evsel_menu__write(struct ui_browser *browser, |
@@ -2169,7 +2169,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, | |||
2169 | int nr_entries, const char *help, | 2169 | int nr_entries, const char *help, |
2170 | struct hist_browser_timer *hbt, | 2170 | struct hist_browser_timer *hbt, |
2171 | float min_pcnt, | 2171 | float min_pcnt, |
2172 | struct perf_session_env *env) | 2172 | struct perf_env *env) |
2173 | { | 2173 | { |
2174 | struct perf_evsel *pos; | 2174 | struct perf_evsel *pos; |
2175 | struct perf_evsel_menu menu = { | 2175 | struct perf_evsel_menu menu = { |
@@ -2202,7 +2202,7 @@ static int __perf_evlist__tui_browse_hists(struct perf_evlist *evlist, | |||
2202 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, | 2202 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, |
2203 | struct hist_browser_timer *hbt, | 2203 | struct hist_browser_timer *hbt, |
2204 | float min_pcnt, | 2204 | float min_pcnt, |
2205 | struct perf_session_env *env) | 2205 | struct perf_env *env) |
2206 | { | 2206 | { |
2207 | int nr_entries = evlist->nr_entries; | 2207 | int nr_entries = evlist->nr_entries; |
2208 | 2208 | ||
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 4a2c2f0ead41..d909459fb54c 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c | |||
@@ -93,6 +93,38 @@ int build_id__sprintf(const u8 *build_id, int len, char *bf) | |||
93 | return raw - build_id; | 93 | return raw - build_id; |
94 | } | 94 | } |
95 | 95 | ||
96 | int sysfs__sprintf_build_id(const char *root_dir, char *sbuild_id) | ||
97 | { | ||
98 | char notes[PATH_MAX]; | ||
99 | u8 build_id[BUILD_ID_SIZE]; | ||
100 | int ret; | ||
101 | |||
102 | if (!root_dir) | ||
103 | root_dir = ""; | ||
104 | |||
105 | scnprintf(notes, sizeof(notes), "%s/sys/kernel/notes", root_dir); | ||
106 | |||
107 | ret = sysfs__read_build_id(notes, build_id, sizeof(build_id)); | ||
108 | if (ret < 0) | ||
109 | return ret; | ||
110 | |||
111 | return build_id__sprintf(build_id, sizeof(build_id), sbuild_id); | ||
112 | } | ||
113 | |||
114 | int filename__sprintf_build_id(const char *pathname, char *sbuild_id) | ||
115 | { | ||
116 | u8 build_id[BUILD_ID_SIZE]; | ||
117 | int ret; | ||
118 | |||
119 | ret = filename__read_build_id(pathname, build_id, sizeof(build_id)); | ||
120 | if (ret < 0) | ||
121 | return ret; | ||
122 | else if (ret != sizeof(build_id)) | ||
123 | return -EINVAL; | ||
124 | |||
125 | return build_id__sprintf(build_id, sizeof(build_id), sbuild_id); | ||
126 | } | ||
127 | |||
96 | /* asnprintf consolidates asprintf and snprintf */ | 128 | /* asnprintf consolidates asprintf and snprintf */ |
97 | static int asnprintf(char **strp, size_t size, const char *fmt, ...) | 129 | static int asnprintf(char **strp, size_t size, const char *fmt, ...) |
98 | { | 130 | { |
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index ce2f493f057a..27a14a8a945b 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h | |||
@@ -12,6 +12,9 @@ extern struct perf_tool build_id__mark_dso_hit_ops; | |||
12 | struct dso; | 12 | struct dso; |
13 | 13 | ||
14 | int build_id__sprintf(const u8 *build_id, int len, char *bf); | 14 | int build_id__sprintf(const u8 *build_id, int len, char *bf); |
15 | int sysfs__sprintf_build_id(const char *root_dir, char *sbuild_id); | ||
16 | int filename__sprintf_build_id(const char *pathname, char *sbuild_id); | ||
17 | |||
15 | char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size); | 18 | char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size); |
16 | 19 | ||
17 | int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, | 20 | int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index e9a5d432902c..8d00039d6a20 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -98,6 +98,7 @@ static void perf_evlist__purge(struct perf_evlist *evlist) | |||
98 | 98 | ||
99 | evlist__for_each_safe(evlist, n, pos) { | 99 | evlist__for_each_safe(evlist, n, pos) { |
100 | list_del_init(&pos->node); | 100 | list_del_init(&pos->node); |
101 | pos->evlist = NULL; | ||
101 | perf_evsel__delete(pos); | 102 | perf_evsel__delete(pos); |
102 | } | 103 | } |
103 | 104 | ||
@@ -125,6 +126,7 @@ void perf_evlist__delete(struct perf_evlist *evlist) | |||
125 | 126 | ||
126 | void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry) | 127 | void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *entry) |
127 | { | 128 | { |
129 | entry->evlist = evlist; | ||
128 | list_add_tail(&entry->node, &evlist->entries); | 130 | list_add_tail(&entry->node, &evlist->entries); |
129 | entry->idx = evlist->nr_entries; | 131 | entry->idx = evlist->nr_entries; |
130 | entry->tracking = !entry->idx; | 132 | entry->tracking = !entry->idx; |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 436e358300b1..b39a6198f4ac 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -56,6 +56,7 @@ struct perf_evlist { | |||
56 | struct cpu_map *cpus; | 56 | struct cpu_map *cpus; |
57 | struct perf_evsel *selected; | 57 | struct perf_evsel *selected; |
58 | struct events_stats stats; | 58 | struct events_stats stats; |
59 | struct perf_env *env; | ||
59 | }; | 60 | }; |
60 | 61 | ||
61 | struct perf_evsel_str_handler { | 62 | struct perf_evsel_str_handler { |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index b096ef7a240c..bac25f41a751 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -206,6 +206,7 @@ void perf_evsel__init(struct perf_evsel *evsel, | |||
206 | evsel->leader = evsel; | 206 | evsel->leader = evsel; |
207 | evsel->unit = ""; | 207 | evsel->unit = ""; |
208 | evsel->scale = 1.0; | 208 | evsel->scale = 1.0; |
209 | evsel->evlist = NULL; | ||
209 | INIT_LIST_HEAD(&evsel->node); | 210 | INIT_LIST_HEAD(&evsel->node); |
210 | INIT_LIST_HEAD(&evsel->config_terms); | 211 | INIT_LIST_HEAD(&evsel->config_terms); |
211 | perf_evsel__object.init(evsel); | 212 | perf_evsel__object.init(evsel); |
@@ -1026,6 +1027,7 @@ void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads) | |||
1026 | void perf_evsel__exit(struct perf_evsel *evsel) | 1027 | void perf_evsel__exit(struct perf_evsel *evsel) |
1027 | { | 1028 | { |
1028 | assert(list_empty(&evsel->node)); | 1029 | assert(list_empty(&evsel->node)); |
1030 | assert(evsel->evlist == NULL); | ||
1029 | perf_evsel__free_fd(evsel); | 1031 | perf_evsel__free_fd(evsel); |
1030 | perf_evsel__free_id(evsel); | 1032 | perf_evsel__free_id(evsel); |
1031 | perf_evsel__free_config_terms(evsel); | 1033 | perf_evsel__free_config_terms(evsel); |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 93ac6b128149..298e6bbca200 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -60,6 +60,9 @@ struct perf_evsel_config_term { | |||
60 | 60 | ||
61 | /** struct perf_evsel - event selector | 61 | /** struct perf_evsel - event selector |
62 | * | 62 | * |
63 | * @evlist - evlist this evsel is in, if it is in one. | ||
64 | * @node - To insert it into evlist->entries or in other list_heads, say in | ||
65 | * the event parsing routines. | ||
63 | * @name - Can be set to retain the original event name passed by the user, | 66 | * @name - Can be set to retain the original event name passed by the user, |
64 | * so that when showing results in tools such as 'perf stat', we | 67 | * so that when showing results in tools such as 'perf stat', we |
65 | * show the name used, not some alias. | 68 | * show the name used, not some alias. |
@@ -73,6 +76,7 @@ struct perf_evsel_config_term { | |||
73 | */ | 76 | */ |
74 | struct perf_evsel { | 77 | struct perf_evsel { |
75 | struct list_head node; | 78 | struct list_head node; |
79 | struct perf_evlist *evlist; | ||
76 | struct perf_event_attr attr; | 80 | struct perf_event_attr attr; |
77 | char *filter; | 81 | char *filter; |
78 | struct xyarray *fd; | 82 | struct xyarray *fd; |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 179b2bdd157d..41814547da15 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -2514,6 +2514,7 @@ int perf_session__read_header(struct perf_session *session) | |||
2514 | if (session->evlist == NULL) | 2514 | if (session->evlist == NULL) |
2515 | return -ENOMEM; | 2515 | return -ENOMEM; |
2516 | 2516 | ||
2517 | session->evlist->env = &header->env; | ||
2517 | if (perf_data_file__is_pipe(file)) | 2518 | if (perf_data_file__is_pipe(file)) |
2518 | return perf_header__read_pipe(session); | 2519 | return perf_header__read_pipe(session); |
2519 | 2520 | ||
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index 9b53b6525ce8..396e4965f0c9 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h | |||
@@ -66,7 +66,7 @@ struct perf_header; | |||
66 | int perf_file_header__read(struct perf_file_header *header, | 66 | int perf_file_header__read(struct perf_file_header *header, |
67 | struct perf_header *ph, int fd); | 67 | struct perf_header *ph, int fd); |
68 | 68 | ||
69 | struct perf_session_env { | 69 | struct perf_env { |
70 | char *hostname; | 70 | char *hostname; |
71 | char *os_release; | 71 | char *os_release; |
72 | char *version; | 72 | char *version; |
@@ -98,7 +98,7 @@ struct perf_header { | |||
98 | u64 data_size; | 98 | u64 data_size; |
99 | u64 feat_offset; | 99 | u64 feat_offset; |
100 | DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); | 100 | DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS); |
101 | struct perf_session_env env; | 101 | struct perf_env env; |
102 | }; | 102 | }; |
103 | 103 | ||
104 | struct perf_evlist; | 104 | struct perf_evlist; |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index bc528d54e457..de6d58e7f0d5 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -313,7 +313,7 @@ int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel, | |||
313 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, | 313 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, |
314 | struct hist_browser_timer *hbt, | 314 | struct hist_browser_timer *hbt, |
315 | float min_pcnt, | 315 | float min_pcnt, |
316 | struct perf_session_env *env); | 316 | struct perf_env *env); |
317 | int script_browse(const char *script_opt); | 317 | int script_browse(const char *script_opt); |
318 | #else | 318 | #else |
319 | static inline | 319 | static inline |
@@ -321,7 +321,7 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __maybe_unused, | |||
321 | const char *help __maybe_unused, | 321 | const char *help __maybe_unused, |
322 | struct hist_browser_timer *hbt __maybe_unused, | 322 | struct hist_browser_timer *hbt __maybe_unused, |
323 | float min_pcnt __maybe_unused, | 323 | float min_pcnt __maybe_unused, |
324 | struct perf_session_env *env __maybe_unused) | 324 | struct perf_env *env __maybe_unused) |
325 | { | 325 | { |
326 | return 0; | 326 | return 0; |
327 | } | 327 | } |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 18722e774a69..8a4537ee9bc3 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -170,7 +170,7 @@ static void perf_session__delete_threads(struct perf_session *session) | |||
170 | machine__delete_threads(&session->machines.host); | 170 | machine__delete_threads(&session->machines.host); |
171 | } | 171 | } |
172 | 172 | ||
173 | static void perf_session_env__exit(struct perf_session_env *env) | 173 | static void perf_session_env__exit(struct perf_env *env) |
174 | { | 174 | { |
175 | zfree(&env->hostname); | 175 | zfree(&env->hostname); |
176 | zfree(&env->os_release); | 176 | zfree(&env->os_release); |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 46ae0532a8a6..1f97ffb158a6 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1853,7 +1853,7 @@ static void vmlinux_path__exit(void) | |||
1853 | zfree(&vmlinux_path); | 1853 | zfree(&vmlinux_path); |
1854 | } | 1854 | } |
1855 | 1855 | ||
1856 | static int vmlinux_path__init(struct perf_session_env *env) | 1856 | static int vmlinux_path__init(struct perf_env *env) |
1857 | { | 1857 | { |
1858 | struct utsname uts; | 1858 | struct utsname uts; |
1859 | char bf[PATH_MAX]; | 1859 | char bf[PATH_MAX]; |
@@ -1964,7 +1964,7 @@ static bool symbol__read_kptr_restrict(void) | |||
1964 | return value; | 1964 | return value; |
1965 | } | 1965 | } |
1966 | 1966 | ||
1967 | int symbol__init(struct perf_session_env *env) | 1967 | int symbol__init(struct perf_env *env) |
1968 | { | 1968 | { |
1969 | const char *symfs; | 1969 | const char *symfs; |
1970 | 1970 | ||
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index a4cde92afbad..440ba8ae888f 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -252,8 +252,8 @@ int modules__parse(const char *filename, void *arg, | |||
252 | int filename__read_debuglink(const char *filename, char *debuglink, | 252 | int filename__read_debuglink(const char *filename, char *debuglink, |
253 | size_t size); | 253 | size_t size); |
254 | 254 | ||
255 | struct perf_session_env; | 255 | struct perf_env; |
256 | int symbol__init(struct perf_session_env *env); | 256 | int symbol__init(struct perf_env *env); |
257 | void symbol__exit(void); | 257 | void symbol__exit(void); |
258 | void symbol__elf_init(void); | 258 | void symbol__elf_init(void); |
259 | struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name); | 259 | struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name); |
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index f7adf1203df1..7acafb3c5592 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -34,6 +34,7 @@ bool test_attr__enabled; | |||
34 | bool perf_host = true; | 34 | bool perf_host = true; |
35 | bool perf_guest = false; | 35 | bool perf_guest = false; |
36 | 36 | ||
37 | char tracing_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing"; | ||
37 | char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events"; | 38 | char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events"; |
38 | 39 | ||
39 | void event_attr_init(struct perf_event_attr *attr) | 40 | void event_attr_init(struct perf_event_attr *attr) |
@@ -391,6 +392,8 @@ void set_term_quiet_input(struct termios *old) | |||
391 | 392 | ||
392 | static void set_tracing_events_path(const char *tracing, const char *mountpoint) | 393 | static void set_tracing_events_path(const char *tracing, const char *mountpoint) |
393 | { | 394 | { |
395 | snprintf(tracing_path, sizeof(tracing_path), "%s/%s", | ||
396 | mountpoint, tracing); | ||
394 | snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s", | 397 | snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s", |
395 | mountpoint, tracing, "events"); | 398 | mountpoint, tracing, "events"); |
396 | } | 399 | } |
@@ -436,66 +439,14 @@ const char *perf_debugfs_mount(const char *mountpoint) | |||
436 | 439 | ||
437 | void perf_debugfs_set_path(const char *mntpt) | 440 | void perf_debugfs_set_path(const char *mntpt) |
438 | { | 441 | { |
439 | snprintf(debugfs_mountpoint, strlen(debugfs_mountpoint), "%s", mntpt); | ||
440 | set_tracing_events_path("tracing/", mntpt); | 442 | set_tracing_events_path("tracing/", mntpt); |
441 | } | 443 | } |
442 | 444 | ||
443 | static const char *find_tracefs(void) | ||
444 | { | ||
445 | const char *path = __perf_tracefs_mount(NULL); | ||
446 | |||
447 | return path; | ||
448 | } | ||
449 | |||
450 | static const char *find_debugfs(void) | ||
451 | { | ||
452 | const char *path = __perf_debugfs_mount(NULL); | ||
453 | |||
454 | if (!path) | ||
455 | fprintf(stderr, "Your kernel does not support the debugfs filesystem"); | ||
456 | |||
457 | return path; | ||
458 | } | ||
459 | |||
460 | /* | ||
461 | * Finds the path to the debugfs/tracing | ||
462 | * Allocates the string and stores it. | ||
463 | */ | ||
464 | const char *find_tracing_dir(void) | ||
465 | { | ||
466 | const char *tracing_dir = ""; | ||
467 | static char *tracing; | ||
468 | static int tracing_found; | ||
469 | const char *debugfs; | ||
470 | |||
471 | if (tracing_found) | ||
472 | return tracing; | ||
473 | |||
474 | debugfs = find_tracefs(); | ||
475 | if (!debugfs) { | ||
476 | tracing_dir = "/tracing"; | ||
477 | debugfs = find_debugfs(); | ||
478 | if (!debugfs) | ||
479 | return NULL; | ||
480 | } | ||
481 | |||
482 | if (asprintf(&tracing, "%s%s", debugfs, tracing_dir) < 0) | ||
483 | return NULL; | ||
484 | |||
485 | tracing_found = 1; | ||
486 | return tracing; | ||
487 | } | ||
488 | |||
489 | char *get_tracing_file(const char *name) | 445 | char *get_tracing_file(const char *name) |
490 | { | 446 | { |
491 | const char *tracing; | ||
492 | char *file; | 447 | char *file; |
493 | 448 | ||
494 | tracing = find_tracing_dir(); | 449 | if (asprintf(&file, "%s/%s", tracing_path, name) < 0) |
495 | if (!tracing) | ||
496 | return NULL; | ||
497 | |||
498 | if (asprintf(&file, "%s/%s", tracing, name) < 0) | ||
499 | return NULL; | 450 | return NULL; |
500 | 451 | ||
501 | return file; | 452 | return file; |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 88a891562a47..291be1d84bc3 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -83,10 +83,10 @@ | |||
83 | extern const char *graph_line; | 83 | extern const char *graph_line; |
84 | extern const char *graph_dotted_line; | 84 | extern const char *graph_dotted_line; |
85 | extern char buildid_dir[]; | 85 | extern char buildid_dir[]; |
86 | extern char tracing_path[]; | ||
86 | extern char tracing_events_path[]; | 87 | extern char tracing_events_path[]; |
87 | extern void perf_debugfs_set_path(const char *mountpoint); | 88 | extern void perf_debugfs_set_path(const char *mountpoint); |
88 | const char *perf_debugfs_mount(const char *mountpoint); | 89 | const char *perf_debugfs_mount(const char *mountpoint); |
89 | const char *find_tracing_dir(void); | ||
90 | char *get_tracing_file(const char *name); | 90 | char *get_tracing_file(const char *name); |
91 | void put_tracing_file(char *file); | 91 | void put_tracing_file(char *file); |
92 | 92 | ||