[PATCH/RFC 16/16] perf tools: Skip dso front cache for multi-threaded lookup

From: Namhyung Kim
Date: Thu Dec 10 2015 - 02:54:57 EST


Currently the dso maintains a front cache for faster symbol lookup,
but access to it should be synchronized when multi thread is used.
Also it doesn't help much if data file has callchains since it should
walk through the callchains for each sample so single cache is almost
meaningless.

So skip the cache if mult-thread is enabled.

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/builtin-top.c | 2 ++
tools/perf/util/symbol.c | 3 +++
tools/perf/util/symbol.h | 3 ++-
3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index fc9715b046b3..d69069d57f8c 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1225,6 +1225,8 @@ static int __cmd_top(struct perf_top *top)
if ((int)top->nr_threads > top->evlist->nr_mmaps)
top->nr_threads = top->evlist->nr_mmaps;

+ symbol_conf.multi_thread = (top->nr_threads > 1);
+
nr_idx = top->evlist->nr_mmaps / top->nr_threads;
rem = top->evlist->nr_mmaps % top->nr_threads;

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index d51abd2e7865..d4a966004fa0 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -454,6 +454,9 @@ void dso__reset_find_symbol_cache(struct dso *dso)
struct symbol *dso__find_symbol(struct dso *dso,
enum map_type type, u64 addr)
{
+ if (symbol_conf.multi_thread)
+ return symbols__find(&dso->symbols[type], addr);
+
if (dso->last_find_result[type].addr != addr) {
dso->last_find_result[type].addr = addr;
dso->last_find_result[type].symbol = symbols__find(&dso->symbols[type], addr);
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 857f707ac12b..68c198f64e1d 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -109,7 +109,8 @@ struct symbol_conf {
branch_callstack,
has_filter,
show_ref_callgraph,
- hide_unresolved;
+ hide_unresolved,
+ multi_thread;
const char *vmlinux_name,
*kallsyms_name,
*source_prefix,
--
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/