diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-02-20 02:02:07 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-02-21 17:48:24 +0100 |
commit | faa5c5c36ec50bf43e39c7798ce9701e6b002db3 (patch) | |
tree | bd021ed5888ad9d264418c5d3acba4a3f757d57c /tools/perf/util/thread.c | |
parent | perf symbols: Fix up map end too on modular kernels with no modules installed (diff) | |
download | linux-faa5c5c36ec50bf43e39c7798ce9701e6b002db3.tar.xz linux-faa5c5c36ec50bf43e39c7798ce9701e6b002db3.zip |
perf tools: Don't use parent comm if not set at fork time
As the parent comm then is worthless, confusing users about the
thread where the sample really happened, leading to think that
the sample happened in the parent, not where it really happened,
in the children of a thread for which a PERF_RECORD_COMM event
was not received.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1266627727-19715-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/thread.c')
-rw-r--r-- | tools/perf/util/thread.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 634b7f7140d5..9e8995eaf2b6 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -36,7 +36,10 @@ int thread__set_comm(struct thread *self, const char *comm) if (self->comm) free(self->comm); self->comm = strdup(comm); - return self->comm ? 0 : -ENOMEM; + if (self->comm == NULL) + return -ENOMEM; + self->comm_set = true; + return 0; } int thread__comm_len(struct thread *self) @@ -255,11 +258,14 @@ int thread__fork(struct thread *self, struct thread *parent) { int i; - if (self->comm) - free(self->comm); - self->comm = strdup(parent->comm); - if (!self->comm) - return -ENOMEM; + if (parent->comm_set) { + if (self->comm) + free(self->comm); + self->comm = strdup(parent->comm); + if (!self->comm) + return -ENOMEM; + self->comm_set = true; + } for (i = 0; i < MAP__NR_TYPES; ++i) if (map_groups__clone(&self->mg, &parent->mg, i) < 0) |