Skip to content

Commit 67fda0f

Browse files
olsajiriacmel
authored andcommitted
perf machine: Add threads__set_last_match function
Separating threads::last_match cache set into separate threads__set_last_match function. This will be useful in following patch. Signed-off-by: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: David Ahern <[email protected]> Cc: Kan Liang <[email protected]> Cc: Lukasz Odzioba <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent f8b2ebb commit 67fda0f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tools/perf/util/machine.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ threads__get_last_match(struct threads *threads, struct machine *machine,
431431
return NULL;
432432
}
433433

434+
static void
435+
threads__set_last_match(struct threads *threads, struct thread *th)
436+
{
437+
threads->last_match = th;
438+
}
439+
434440
/*
435441
* Caller must eventually drop thread->refcnt returned with a successful
436442
* lookup/new thread inserted.
@@ -453,7 +459,7 @@ static struct thread *____machine__findnew_thread(struct machine *machine,
453459
th = rb_entry(parent, struct thread, rb_node);
454460

455461
if (th->tid == tid) {
456-
threads->last_match = th;
462+
threads__set_last_match(threads, th);
457463
machine__update_thread_pid(machine, th, pid);
458464
return thread__get(th);
459465
}
@@ -490,7 +496,7 @@ static struct thread *____machine__findnew_thread(struct machine *machine,
490496
* It is now in the rbtree, get a ref
491497
*/
492498
thread__get(th);
493-
threads->last_match = th;
499+
threads__set_last_match(threads, th);
494500
++threads->nr;
495501
}
496502

@@ -1648,7 +1654,7 @@ static void __machine__remove_thread(struct machine *machine, struct thread *th,
16481654
struct threads *threads = machine__threads(machine, th->tid);
16491655

16501656
if (threads->last_match == th)
1651-
threads->last_match = NULL;
1657+
threads__set_last_match(threads, NULL);
16521658

16531659
BUG_ON(refcount_read(&th->refcnt) == 0);
16541660
if (lock)

0 commit comments

Comments
 (0)