linux/tools/perf
Stephane Eranian 88b897a30c perf tools: Make perf_event__synthesize_mmap_events() scale
This patch significantly improves the execution time of
perf_event__synthesize_mmap_events() when running perf record on systems
where processes have lots of threads.

It just happens that cat /proc/pid/maps support uses a O(N^2) algorithm to
generate each map line in the maps file.  If you have 1000 threads, then you
have necessarily 1000 stacks.  For each vma, you need to check if it
corresponds to a thread's stack.  With a large number of threads, this can take
a very long time. I have seen latencies >> 10mn.

As of today, perf does not use the fact that a mapping is a stack, therefore we
can work around the issue by using /proc/pid/tasks/pid/maps.  This entry does
not try to map a vma to stack and is thus much faster with no loss of
functonality.

The proc-map-timeout logic is kept in case users still want some upper limit.

In V2, we fix the file path from /proc/pid/tasks/pid/maps to actual
/proc/pid/task/pid/maps, tasks -> task.  Thanks Arnaldo for catching this.

Committer note:

This problem seems to have been elliminated in the kernel since commit :
b18cb64ead ("fs/proc: Stop trying to report thread stacks").

Signed-off-by: Stephane Eranian <eranian@google.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20170315135059.GC2177@redhat.com
Link: http://lkml.kernel.org/r/1489598233-25586-1-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-03-15 17:48:37 -03:00
..
arch perf powerpc: Choose local entry point with kretprobes 2017-03-14 15:17:39 -03:00
bench perf bench numa: Add more comment for -c option 2017-03-06 12:39:30 -03:00
Documentation perf sched timehist: Add --next option 2017-03-14 15:17:38 -03:00
jvmti perf kvmti: Remove unused Makefile file 2016-11-14 12:42:56 -03:00
pmu-events perf vendor events: Add mapping for KnightsMill PMU events 2017-03-03 19:07:13 -03:00
python perf python: Add tracepoint example 2016-07-12 16:23:35 -03:00
scripts perf/core improvements and fixes: 2016-08-04 11:02:38 +02:00
tests perf thread_map: Convert thread_map.refcnt from atomic_t to refcount_t 2017-03-03 19:07:16 -03:00
trace perf trace: Check if MAP_32BIT is defined (again) 2016-12-20 09:37:40 -03:00
ui perf hists browser: Fix typo in function switch_data_file 2017-03-13 11:58:57 -03:00
util perf tools: Make perf_event__synthesize_mmap_events() scale 2017-03-15 17:48:37 -03:00
.gitignore perf tools: Ignore generated files pmu-events/{jevents,pmu-events.c} for git 2017-03-13 10:59:36 -03:00
Build perf ftrace: Introduce new 'ftrace' tool 2017-01-26 11:43:01 -03:00
builtin-annotate.c perf tools: Add PERF_RECORD_NAMESPACES to include namespaces related info 2017-03-14 11:38:23 -03:00
builtin-bench.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-buildid-cache.c tools: Introduce str_error_r() 2016-07-12 15:19:47 -03:00
builtin-buildid-list.c perf subcmd: Create subcmd library 2015-12-17 14:27:14 -03:00
builtin-c2c.c perf c2c: Fix display bug when using pipe 2017-03-07 12:48:46 -03:00
builtin-config.c perf config: Mark where are config items from (user or system) 2016-11-14 13:10:37 -03:00
builtin-data.c perf data ctf: Add '--all' option for 'perf data convert' 2016-06-28 10:54:57 -03:00
builtin-diff.c perf tools: Add PERF_RECORD_NAMESPACES to include namespaces related info 2017-03-14 11:38:23 -03:00
builtin-evlist.c perf evlist: Rename for_each() macros to for_each_entry() 2016-06-23 11:26:15 -03:00
builtin-ftrace.c perf ftrace: Use pager for displaying result 2017-03-03 19:07:17 -03:00
builtin-help.c perf tools: Propagate perf_config() errors 2017-01-27 12:23:33 -03:00
builtin-inject.c perf tools: Add PERF_RECORD_NAMESPACES to include namespaces related info 2017-03-14 11:38:23 -03:00
builtin-kallsyms.c perf kallsyms: Introduce tool to look for extended symbol information on the running kernel 2017-01-11 16:48:01 -03:00
builtin-kmem.c perf tools: Add PERF_RECORD_NAMESPACES to include namespaces related info 2017-03-14 11:38:23 -03:00
builtin-kvm.c perf tools: Add PERF_RECORD_NAMESPACES to include namespaces related info 2017-03-14 11:38:23 -03:00
builtin-list.c perf list: Add debug support for outputing alias string 2017-02-08 08:55:04 -03:00
builtin-lock.c perf tools: Add PERF_RECORD_NAMESPACES to include namespaces related info 2017-03-14 11:38:23 -03:00
builtin-mem.c perf tools: Add PERF_RECORD_NAMESPACES to include namespaces related info 2017-03-14 11:38:23 -03:00
builtin-probe.c perf probe: Add option --symfs 2017-02-08 09:41:10 -03:00
builtin-record.c perf record: Synthesize namespace events for current processes 2017-03-14 15:16:09 -03:00
builtin-report.c perf tools: Add PERF_RECORD_NAMESPACES to include namespaces related info 2017-03-14 11:38:23 -03:00
builtin-sched.c perf sched timehist: Add --next option 2017-03-14 15:17:38 -03:00
builtin-script.c perf script: Add script print support for namespace events 2017-03-14 15:17:36 -03:00
builtin-stat.c perf tools: Force uncore events to system wide monitoring 2017-03-03 19:07:19 -03:00
builtin-timechart.c perf timechart: Use NSEC_PER_U?SEC 2016-08-23 15:37:33 -03:00
builtin-top.c perf utils: Check verbose flag properly 2017-02-20 11:35:54 -03:00
builtin-trace.c perf tools: Add PERF_RECORD_NAMESPACES to include namespaces related info 2017-03-14 11:38:23 -03:00
builtin-version.c perf tools: Move cmd_version() to builtin-version.c 2015-12-09 13:42:03 -03:00
builtin.h perf ftrace: Introduce new 'ftrace' tool 2017-01-26 11:43:01 -03:00
check-headers.sh perf tools: Move headers check into bash script 2016-12-15 16:25:44 -03:00
command-list.txt perf tools: Missing c2c command in command-list 2017-03-13 10:59:31 -03:00
CREDITS
design.txt
Makefile perf build tests: Do parallell builds with 'build-test' 2016-02-04 15:57:00 -03:00
Makefile.config tools build: Add test for sched_getcpu() 2017-03-03 19:07:19 -03:00
Makefile.perf perf build: Add special fixdep cleaning rule 2017-02-17 16:04:38 -03:00
MANIFEST tools include: Adopt kernel's refcount.h 2017-03-03 19:07:14 -03:00
perf-archive.sh
perf-completion.sh
perf-read-vdso.c
perf-sys.h perf powerpc: Fix build-test failure 2016-09-08 13:44:07 -03:00
perf-with-kcore.sh
perf.c perf tools: Propagate perf_config() errors 2017-01-27 12:23:33 -03:00
perf.h perf tools: Add PERF_RECORD_NAMESPACES to include namespaces related info 2017-03-14 11:38:23 -03:00