summaryrefslogtreecommitdiff
path: root/tools/perf/util/perf_regs.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2014-04-17 19:39:10 +0200
committerJiri Olsa <jolsa@kernel.org>2014-06-12 16:53:19 +0200
commit0c4e774fad0202b91dea8d99c04e9bdf2c2c6647 (patch)
tree9a94e5f06914e70d8093e43ea4f85f0843aaba1c /tools/perf/util/perf_regs.c
parent17314e2385c6627fcab4b8f97bd6668bb63495c0 (diff)
perf tools: Cache register accesses for unwind processing
Caching registers value into an array. Got about 4% speed up of perf_reg_value function for report command processing dwarf unwind stacks. Output from report over 1.5 GB data with DWARF unwind stacks: (TODO fix perf diff) current code: 5.84% perf perf [.] perf_reg_value change: 1.94% perf perf [.] perf_reg_value And little bit of overall speed up: (perf stat -r 5 -e '{cycles,instructions}:u' ...) current code: 310,298,611,754 cycles ( +- 0.33% ) 439,669,689,341 instructions ( +- 0.03% ) 188.656753166 seconds time elapsed ( +- 0.82% ) change: 291,315,329,878 cycles ( +- 0.22% ) 391,763,485,304 instructions ( +- 0.03% ) 180.742249687 seconds time elapsed ( +- 0.64% ) Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jean Pihet <jean.pihet@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1401892622-30848-2-git-send-email-jolsa@kernel.org Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools/perf/util/perf_regs.c')
-rw-r--r--tools/perf/util/perf_regs.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c
index a3539ef30b15..43168fb0d9a2 100644
--- a/tools/perf/util/perf_regs.c
+++ b/tools/perf/util/perf_regs.c
@@ -1,11 +1,15 @@
#include <errno.h>
#include "perf_regs.h"
+#include "event.h"
int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
{
int i, idx = 0;
u64 mask = regs->mask;
+ if (regs->cache_mask & (1 << id))
+ goto out;
+
if (!(mask & (1 << id)))
return -EINVAL;
@@ -14,6 +18,10 @@ int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
idx++;
}
- *valp = regs->regs[idx];
+ regs->cache_mask |= (1 << id);
+ regs->cache_regs[id] = regs->regs[idx];
+
+out:
+ *valp = regs->cache_regs[id];
return 0;
}