aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/machine.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/machine.c')
-rw-r--r--tools/perf/util/machine.c16
1 files changed, 11 insertions, 5 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)