aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2013-08-26 09:00:19 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-08-27 10:05:53 -0400
commit99d725fc65563a85d4290342c81b00a673c6be66 (patch)
treefde3a103b824d4c60fb8102063495aa176b11e8c /tools
parent9e9716d1b929ddb6955a5954fe1d9a74b233df0d (diff)
perf tools: Add pid to struct thread
Record pid on struct thread. The member is named 'pid_' to avoid confusion with the 'tid' member which was previously named 'pid'. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: David Ahern <dsahern@gmail.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> 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/1377522030-27870-3-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/machine.c16
-rw-r--r--tools/perf/util/thread.c3
-rw-r--r--tools/perf/util/thread.h3
3 files changed, 15 insertions, 7 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 574feb7003ab..59486c180626 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -253,7 +253,8 @@ void machines__set_id_hdr_size(struct machines *machines, u16 id_hdr_size)
253 return; 253 return;
254} 254}
255 255
256static struct thread *__machine__findnew_thread(struct machine *machine, pid_t tid, 256static struct thread *__machine__findnew_thread(struct machine *machine,
257 pid_t pid, pid_t tid,
257 bool create) 258 bool create)
258{ 259{
259 struct rb_node **p = &machine->threads.rb_node; 260 struct rb_node **p = &machine->threads.rb_node;
@@ -265,8 +266,11 @@ static struct thread *__machine__findnew_thread(struct machine *machine, pid_t t
265 * so most of the time we dont have to look up 266 * so most of the time we dont have to look up
266 * the full rbtree: 267 * the full rbtree:
267 */ 268 */
268 if (machine->last_match && machine->last_match->tid == tid) 269 if (machine->last_match && machine->last_match->tid == tid) {
270 if (pid && pid != machine->last_match->pid_)
271 machine->last_match->pid_ = pid;
269 return machine->last_match; 272 return machine->last_match;
273 }
270 274
271 while (*p != NULL) { 275 while (*p != NULL) {
272 parent = *p; 276 parent = *p;
@@ -274,6 +278,8 @@ static struct thread *__machine__findnew_thread(struct machine *machine, pid_t t
274 278
275 if (th->tid == tid) { 279 if (th->tid == tid) {
276 machine->last_match = th; 280 machine->last_match = th;
281 if (pid && pid != th->pid_)
282 th->pid_ = pid;
277 return th; 283 return th;
278 } 284 }
279 285
@@ -286,7 +292,7 @@ static struct thread *__machine__findnew_thread(struct machine *machine, pid_t t
286 if (!create) 292 if (!create)
287 return NULL; 293 return NULL;
288 294
289 th = thread__new(tid); 295 th = thread__new(pid, tid);
290 if (th != NULL) { 296 if (th != NULL) {
291 rb_link_node(&th->rb_node, parent, p); 297 rb_link_node(&th->rb_node, parent, p);
292 rb_insert_color(&th->rb_node, &machine->threads); 298 rb_insert_color(&th->rb_node, &machine->threads);
@@ -298,12 +304,12 @@ static struct thread *__machine__findnew_thread(struct machine *machine, pid_t t
298 304
299struct thread *machine__findnew_thread(struct machine *machine, pid_t tid) 305struct thread *machine__findnew_thread(struct machine *machine, pid_t tid)
300{ 306{
301 return __machine__findnew_thread(machine, tid, true); 307 return __machine__findnew_thread(machine, 0, tid, true);
302} 308}
303 309
304struct thread *machine__find_thread(struct machine *machine, pid_t tid) 310struct thread *machine__find_thread(struct machine *machine, pid_t tid)
305{ 311{
306 return __machine__findnew_thread(machine, tid, false); 312 return __machine__findnew_thread(machine, 0, tid, false);
307} 313}
308 314
309int machine__process_comm_event(struct machine *machine, union perf_event *event) 315int machine__process_comm_event(struct machine *machine, union perf_event *event)
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 6feeb88eb5b0..e3d4a550a703 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -7,12 +7,13 @@
7#include "util.h" 7#include "util.h"
8#include "debug.h" 8#include "debug.h"
9 9
10struct thread *thread__new(pid_t tid) 10struct thread *thread__new(pid_t pid, pid_t tid)
11{ 11{
12 struct thread *self = zalloc(sizeof(*self)); 12 struct thread *self = zalloc(sizeof(*self));
13 13
14 if (self != NULL) { 14 if (self != NULL) {
15 map_groups__init(&self->mg); 15 map_groups__init(&self->mg);
16 self->pid_ = pid;
16 self->tid = tid; 17 self->tid = tid;
17 self->ppid = -1; 18 self->ppid = -1;
18 self->comm = malloc(32); 19 self->comm = malloc(32);
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 32d060164b52..4ebbb40d46d4 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -12,6 +12,7 @@ struct thread {
12 struct list_head node; 12 struct list_head node;
13 }; 13 };
14 struct map_groups mg; 14 struct map_groups mg;
15 pid_t pid_; /* Not all tools update this */
15 pid_t tid; 16 pid_t tid;
16 pid_t ppid; 17 pid_t ppid;
17 char shortname[3]; 18 char shortname[3];
@@ -25,7 +26,7 @@ struct thread {
25 26
26struct machine; 27struct machine;
27 28
28struct thread *thread__new(pid_t tid); 29struct thread *thread__new(pid_t pid, pid_t tid);
29void thread__delete(struct thread *self); 30void thread__delete(struct thread *self);
30static inline void thread__exited(struct thread *thread) 31static inline void thread__exited(struct thread *thread)
31{ 32{