aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/srccode.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2019-11-20 16:15:11 -0800
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-11-28 08:08:38 -0300
commitd96645821e940bddff3fc5290656f83bf70d4c92 (patch)
tree879409141d525cc6996d212afcfe5c01fe6d77be /tools/perf/util/srccode.c
parentperf regs: Make perf_reg_name() return "unknown" instead of NULL (diff)
downloadlinux-dev-d96645821e940bddff3fc5290656f83bf70d4c92.tar.xz
linux-dev-d96645821e940bddff3fc5290656f83bf70d4c92.zip
perf pmu: Use file system cache to optimize sysfs access
pmu.c does a lot of redundant /sys accesses while parsing aliases and probing for PMUs. On large systems with a lot of PMUs this can get expensive (>2s): % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 27.25 1.227847 8 160888 16976 openat 26.42 1.190481 7 164224 164077 stat Add a cache to remember if specific file names exist or don't exist, which eliminates most of this overhead. Also optimize some stat() calls to be slightly cheaper access() Resulting in: 0.18 0.004166 2 1851 305 open 0.08 0.001970 2 829 622 access Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: http://lore.kernel.org/lkml/20191121001522.180827-2-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/srccode.c')
-rw-r--r--tools/perf/util/srccode.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/tools/perf/util/srccode.c b/tools/perf/util/srccode.c
index d84ed8b6caaa..c29edaaca863 100644
--- a/tools/perf/util/srccode.c
+++ b/tools/perf/util/srccode.c
@@ -16,6 +16,7 @@
#include "srccode.h"
#include "debug.h"
#include <internal/lib.h> // page_size
+#include "fncache.h"
#define MAXSRCCACHE (32*1024*1024)
#define MAXSRCFILES 64
@@ -36,14 +37,6 @@ static LIST_HEAD(srcfile_list);
static long map_total_sz;
static int num_srcfiles;
-static unsigned shash(unsigned char *s)
-{
- unsigned h = 0;
- while (*s)
- h = 65599 * h + *s++;
- return h ^ (h >> 16);
-}
-
static int countlines(char *map, int maplen)
{
int numl;