]> git.baikalelectronics.ru Git - kernel.git/commit
perf callchain: Spare double comparison of callchain first entry
authorFrederic Weisbecker <fweisbec@gmail.com>
Tue, 14 Jan 2014 15:37:15 +0000 (16:37 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 17 Jan 2014 14:11:01 +0000 (11:11 -0300)
commit885474c3dfa05c2878d9bec4fdc9d828af319848
treeef1dd5d78609698145352c1e51d22574dced03df
parente47f11b6152269bc8a05240f1069ffaedb8c49a5
perf callchain: Spare double comparison of callchain first entry

When a new callchain child branch matches an existing one in the rbtree,
the comparison of its first entry is performed twice:

1) From append_chain_children() on branch lookup

2) If 1) reports a match, append_chain() then compares all entries of
the new branch against the matching node in the rbtree, and this
comparison includes the first entry of the new branch again.

Lets shortcut this by performing the whole comparison only from
append_chain() which then returns the result of the comparison between
the first entry of the new branch and the iterating node in the rbtree.
If the first entry matches, the lookup on the current level of siblings
stops and propagates to the children of the matching nodes.

This results in less comparisons performed by the CPU.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1389713836-13375-3-git-send-email-fweisbec@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/callchain.c