From 75e45e432052c7b1a5da866cff88192db8be1445 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 14 Sep 2017 16:16:34 -0300 Subject: [PATCH] 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 Cc: Andi Kleen Cc: David Ahern Cc: Jiri Olsa Cc: Kan Liang Cc: Lukasz Odzioba Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-800zehjsyy03er4s4jf0e99v@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index f4f926753209..ddeea05eae86 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -399,10 +399,10 @@ static void machine__update_thread_pid(struct machine *machine, * lookup/new thread inserted. */ static struct thread *____machine__findnew_thread(struct machine *machine, + struct threads *threads, pid_t pid, pid_t tid, bool create) { - struct threads *threads = machine__threads(machine, tid); struct rb_node **p = &threads->entries.rb_node; struct rb_node *parent = NULL; struct thread *th; @@ -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) { - 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, @@ -495,7 +495,7 @@ struct thread *machine__find_thread(struct machine *machine, pid_t pid, struct thread *th; 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); return th; } -- GitLab