mirror of https://gitee.com/openkylin/linux.git
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 <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Lukasz Odzioba <lukasz.odzioba@intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/20180719143345.12963-2-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
e8fedff1cc
commit
f8b2ebb532
|
@ -407,6 +407,30 @@ static void machine__update_thread_pid(struct machine *machine,
|
||||||
goto out_put;
|
goto out_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Front-end cache - TID lookups come in blocks,
|
||||||
|
* so most of the time we dont have to look up
|
||||||
|
* the full rbtree:
|
||||||
|
*/
|
||||||
|
static struct thread*
|
||||||
|
threads__get_last_match(struct threads *threads, struct machine *machine,
|
||||||
|
int pid, int tid)
|
||||||
|
{
|
||||||
|
struct thread *th;
|
||||||
|
|
||||||
|
th = threads->last_match;
|
||||||
|
if (th != NULL) {
|
||||||
|
if (th->tid == tid) {
|
||||||
|
machine__update_thread_pid(machine, th, pid);
|
||||||
|
return thread__get(th);
|
||||||
|
}
|
||||||
|
|
||||||
|
threads->last_match = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Caller must eventually drop thread->refcnt returned with a successful
|
* Caller must eventually drop thread->refcnt returned with a successful
|
||||||
* lookup/new thread inserted.
|
* lookup/new thread inserted.
|
||||||
|
@ -420,20 +444,9 @@ static struct thread *____machine__findnew_thread(struct machine *machine,
|
||||||
struct rb_node *parent = NULL;
|
struct rb_node *parent = NULL;
|
||||||
struct thread *th;
|
struct thread *th;
|
||||||
|
|
||||||
/*
|
th = threads__get_last_match(threads, machine, pid, tid);
|
||||||
* Front-end cache - TID lookups come in blocks,
|
if (th)
|
||||||
* so most of the time we dont have to look up
|
return th;
|
||||||
* the full rbtree:
|
|
||||||
*/
|
|
||||||
th = threads->last_match;
|
|
||||||
if (th != NULL) {
|
|
||||||
if (th->tid == tid) {
|
|
||||||
machine__update_thread_pid(machine, th, pid);
|
|
||||||
return thread__get(th);
|
|
||||||
}
|
|
||||||
|
|
||||||
threads->last_match = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (*p != NULL) {
|
while (*p != NULL) {
|
||||||
parent = *p;
|
parent = *p;
|
||||||
|
|
Loading…
Reference in New Issue