Commit 99d725fc authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo

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: default avatarAdrian Hunter <adrian.hunter@intel.com>
Acked-by: default avatarDavid 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 9e9716d1
...@@ -253,7 +253,8 @@ void machines__set_id_hdr_size(struct machines *machines, u16 id_hdr_size) ...@@ -253,7 +253,8 @@ void machines__set_id_hdr_size(struct machines *machines, u16 id_hdr_size)
return; return;
} }
static struct thread *__machine__findnew_thread(struct machine *machine, pid_t tid, static struct thread *__machine__findnew_thread(struct machine *machine,
pid_t pid, pid_t tid,
bool create) bool create)
{ {
struct rb_node **p = &machine->threads.rb_node; 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,8 +266,11 @@ static struct thread *__machine__findnew_thread(struct machine *machine, pid_t t
* so most of the time we dont have to look up * so most of the time we dont have to look up
* the full rbtree: * the full rbtree:
*/ */
if (machine->last_match && machine->last_match->tid == tid) if (machine->last_match && machine->last_match->tid == tid) {
if (pid && pid != machine->last_match->pid_)
machine->last_match->pid_ = pid;
return machine->last_match; return machine->last_match;
}
while (*p != NULL) { while (*p != NULL) {
parent = *p; parent = *p;
...@@ -274,6 +278,8 @@ static struct thread *__machine__findnew_thread(struct machine *machine, pid_t t ...@@ -274,6 +278,8 @@ static struct thread *__machine__findnew_thread(struct machine *machine, pid_t t
if (th->tid == tid) { if (th->tid == tid) {
machine->last_match = th; machine->last_match = th;
if (pid && pid != th->pid_)
th->pid_ = pid;
return th; return th;
} }
...@@ -286,7 +292,7 @@ static struct thread *__machine__findnew_thread(struct machine *machine, pid_t t ...@@ -286,7 +292,7 @@ static struct thread *__machine__findnew_thread(struct machine *machine, pid_t t
if (!create) if (!create)
return NULL; return NULL;
th = thread__new(tid); th = thread__new(pid, tid);
if (th != NULL) { if (th != NULL) {
rb_link_node(&th->rb_node, parent, p); rb_link_node(&th->rb_node, parent, p);
rb_insert_color(&th->rb_node, &machine->threads); 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,12 +304,12 @@ static struct thread *__machine__findnew_thread(struct machine *machine, pid_t t
struct thread *machine__findnew_thread(struct machine *machine, pid_t tid) struct thread *machine__findnew_thread(struct machine *machine, pid_t tid)
{ {
return __machine__findnew_thread(machine, tid, true); return __machine__findnew_thread(machine, 0, tid, true);
} }
struct thread *machine__find_thread(struct machine *machine, pid_t tid) struct thread *machine__find_thread(struct machine *machine, pid_t tid)
{ {
return __machine__findnew_thread(machine, tid, false); return __machine__findnew_thread(machine, 0, tid, false);
} }
int machine__process_comm_event(struct machine *machine, union perf_event *event) int machine__process_comm_event(struct machine *machine, union perf_event *event)
......
...@@ -7,12 +7,13 @@ ...@@ -7,12 +7,13 @@
#include "util.h" #include "util.h"
#include "debug.h" #include "debug.h"
struct thread *thread__new(pid_t tid) struct thread *thread__new(pid_t pid, pid_t tid)
{ {
struct thread *self = zalloc(sizeof(*self)); struct thread *self = zalloc(sizeof(*self));
if (self != NULL) { if (self != NULL) {
map_groups__init(&self->mg); map_groups__init(&self->mg);
self->pid_ = pid;
self->tid = tid; self->tid = tid;
self->ppid = -1; self->ppid = -1;
self->comm = malloc(32); self->comm = malloc(32);
......
...@@ -12,6 +12,7 @@ struct thread { ...@@ -12,6 +12,7 @@ struct thread {
struct list_head node; struct list_head node;
}; };
struct map_groups mg; struct map_groups mg;
pid_t pid_; /* Not all tools update this */
pid_t tid; pid_t tid;
pid_t ppid; pid_t ppid;
char shortname[3]; char shortname[3];
...@@ -25,7 +26,7 @@ struct thread { ...@@ -25,7 +26,7 @@ struct thread {
struct machine; struct machine;
struct thread *thread__new(pid_t tid); struct thread *thread__new(pid_t pid, pid_t tid);
void thread__delete(struct thread *self); void thread__delete(struct thread *self);
static inline void thread__exited(struct thread *thread) static inline void thread__exited(struct thread *thread)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment