2017-11-08 03:32:53

by Andrei Vagin

[permalink] [raw]
Subject: [PATCH 1/2] perf/trace: call machine__exit() at exiting

Otherwise perf trace leaves a temprary file /tmp/perf-vdso.so-XXXXXX.

$ perf trace -o log true
$ ls -l /tmp/perf-vdso.*
-rw------- 1 root root 8192 Nov 8 03:08 /tmp/perf-vdso.so-5bCpD0

Cc: Peter Zijlstra <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Signed-off-by: Andrei Vagin <[email protected]>
---
tools/perf/builtin-trace.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 505b871fdc82..f2757d38c7d7 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1164,6 +1164,14 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
return err;
}

+static void trace__symbols__exit(struct trace *trace)
+{
+ machine__exit(trace->host);
+ trace->host = NULL;
+
+ symbol__exit();
+}
+
static int syscall__alloc_arg_fmts(struct syscall *sc, int nr_args)
{
int idx;
@@ -2508,6 +2516,8 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
}

out_delete_evlist:
+ trace__symbols__exit(trace);
+
perf_evlist__delete(evlist);
trace->evlist = NULL;
trace->live = false;
--
2.13.6


From 1585281679311398891@xxx Tue Nov 28 04:13:41 +0000 2017
X-GM-THRID: 1584805833119531257
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread


2017-11-08 03:32:20

by Andrei Vagin

[permalink] [raw]
Subject: [PATCH 2/2] perf/trace: fix an exit code of trace__symbols_init

Currently if trace_event__register_resolver() fails, we return -errno,
but we can't be sure that errno isn't zero in this case.

Cc: Peter Zijlstra <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Signed-off-by: Andrei Vagin <[email protected]>
---
tools/perf/builtin-trace.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index f2757d38c7d7..84debdbad327 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1152,12 +1152,14 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
if (trace->host == NULL)
return -ENOMEM;

- if (trace_event__register_resolver(trace->host, trace__machine__resolve_kernel_addr) < 0)
- return -errno;
+ err = trace_event__register_resolver(trace->host, trace__machine__resolve_kernel_addr);
+ if (err < 0)
+ goto out;

err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target,
evlist->threads, trace__tool_process, false,
trace->opts.proc_map_timeout, 1);
+out:
if (err)
symbol__exit();

--
2.13.6


From 1583534695092501634@xxx Wed Nov 08 21:26:07 +0000 2017
X-GM-THRID: 1583533777788155626
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread