summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/machine.c
diff options
context:
space:
mode:
authorAdrian Hunter2014-07-14 12:02:25 +0200
committerArnaldo Carvalho de Melo2014-07-16 22:57:33 +0200
commit1fcb8768636d38cb6fdfeef83a5ee596c4bd9c56 (patch)
treeffefb332e8e0e035201fbe4b0f4cef9301ac76d1 /tools/perf/util/machine.c
parentperf script: Provide additional sample information on generic events (diff)
downloadkernel-qcow2-linux-1fcb8768636d38cb6fdfeef83a5ee596c4bd9c56.tar.gz
kernel-qcow2-linux-1fcb8768636d38cb6fdfeef83a5ee596c4bd9c56.tar.xz
kernel-qcow2-linux-1fcb8768636d38cb6fdfeef83a5ee596c4bd9c56.zip
perf machine: Fix the value used for unknown pids
The value used for unknown pids cannot be zero because that is used by the "idle" task. Use -1 instead. Also handle the unknown pid case when creating map groups. Note that, threads with an unknown pid should not occur because fork (or synthesized) events precede the thread's existence. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1405332185-4050-2-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/machine.c')
-rw-r--r--tools/perf/util/machine.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index e9b943acaa5e..5b8087728f28 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -34,7 +34,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
return -ENOMEM;
if (pid != HOST_KERNEL_ID) {
- struct thread *thread = machine__findnew_thread(machine, 0,
+ struct thread *thread = machine__findnew_thread(machine, -1,
pid);
char comm[64];
@@ -286,7 +286,7 @@ static struct thread *__machine__findnew_thread(struct machine *machine,
* the full rbtree:
*/
if (machine->last_match && machine->last_match->tid == tid) {
- if (pid && pid != machine->last_match->pid_)
+ if (pid != -1 && pid != machine->last_match->pid_)
machine->last_match->pid_ = pid;
return machine->last_match;
}
@@ -297,7 +297,7 @@ static struct thread *__machine__findnew_thread(struct machine *machine,
if (th->tid == tid) {
machine->last_match = th;
- if (pid && pid != th->pid_)
+ if (pid != -1 && pid != th->pid_)
th->pid_ = pid;
return th;
}