perf machine: Optimize a bit the machine__findnew_thread() methods

In some cases we already have calculated the hash bucket, so reuse it.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@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/n/tip-800zehjsyy03er4s4jf0e99v@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 91e467bc
...@@ -399,10 +399,10 @@ static void machine__update_thread_pid(struct machine *machine, ...@@ -399,10 +399,10 @@ static void machine__update_thread_pid(struct machine *machine,
* lookup/new thread inserted. * lookup/new thread inserted.
*/ */
static struct thread *____machine__findnew_thread(struct machine *machine, static struct thread *____machine__findnew_thread(struct machine *machine,
struct threads *threads,
pid_t pid, pid_t tid, pid_t pid, pid_t tid,
bool create) bool create)
{ {
struct threads *threads = machine__threads(machine, tid);
struct rb_node **p = &threads->entries.rb_node; struct rb_node **p = &threads->entries.rb_node;
struct rb_node *parent = NULL; struct rb_node *parent = NULL;
struct thread *th; struct thread *th;
...@@ -473,7 +473,7 @@ static struct thread *____machine__findnew_thread(struct machine *machine, ...@@ -473,7 +473,7 @@ static struct thread *____machine__findnew_thread(struct machine *machine,
struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid) struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid)
{ {
return ____machine__findnew_thread(machine, pid, tid, true); return ____machine__findnew_thread(machine, machine__threads(machine, tid), pid, tid, true);
} }
struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, struct thread *machine__findnew_thread(struct machine *machine, pid_t pid,
...@@ -495,7 +495,7 @@ struct thread *machine__find_thread(struct machine *machine, pid_t pid, ...@@ -495,7 +495,7 @@ struct thread *machine__find_thread(struct machine *machine, pid_t pid,
struct thread *th; struct thread *th;
pthread_rwlock_rdlock(&threads->lock); pthread_rwlock_rdlock(&threads->lock);
th = ____machine__findnew_thread(machine, pid, tid, false); th = ____machine__findnew_thread(machine, threads, pid, tid, false);
pthread_rwlock_unlock(&threads->lock); pthread_rwlock_unlock(&threads->lock);
return th; return th;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册