Skip to content

Commit f8b2ebb

Browse files
olsajiriacmel
authored andcommitted
perf machine: Add threads__get_last_match function
Separating threads::last_match cache read/check into separate threads__get_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 e8fedff commit f8b2ebb

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

tools/perf/util/machine.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -408,23 +408,16 @@ static void machine__update_thread_pid(struct machine *machine,
408408
}
409409

410410
/*
411-
* Caller must eventually drop thread->refcnt returned with a successful
412-
* lookup/new thread inserted.
411+
* Front-end cache - TID lookups come in blocks,
412+
* so most of the time we dont have to look up
413+
* the full rbtree:
413414
*/
414-
static struct thread *____machine__findnew_thread(struct machine *machine,
415-
struct threads *threads,
416-
pid_t pid, pid_t tid,
417-
bool create)
415+
static struct thread*
416+
threads__get_last_match(struct threads *threads, struct machine *machine,
417+
int pid, int tid)
418418
{
419-
struct rb_node **p = &threads->entries.rb_node;
420-
struct rb_node *parent = NULL;
421419
struct thread *th;
422420

423-
/*
424-
* Front-end cache - TID lookups come in blocks,
425-
* so most of the time we dont have to look up
426-
* the full rbtree:
427-
*/
428421
th = threads->last_match;
429422
if (th != NULL) {
430423
if (th->tid == tid) {
@@ -435,6 +428,26 @@ static struct thread *____machine__findnew_thread(struct machine *machine,
435428
threads->last_match = NULL;
436429
}
437430

431+
return NULL;
432+
}
433+
434+
/*
435+
* Caller must eventually drop thread->refcnt returned with a successful
436+
* lookup/new thread inserted.
437+
*/
438+
static struct thread *____machine__findnew_thread(struct machine *machine,
439+
struct threads *threads,
440+
pid_t pid, pid_t tid,
441+
bool create)
442+
{
443+
struct rb_node **p = &threads->entries.rb_node;
444+
struct rb_node *parent = NULL;
445+
struct thread *th;
446+
447+
th = threads__get_last_match(threads, machine, pid, tid);
448+
if (th)
449+
return th;
450+
438451
while (*p != NULL) {
439452
parent = *p;
440453
th = rb_entry(parent, struct thread, rb_node);

0 commit comments

Comments
 (0)