From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Borislav Petkov <bp@suse.de>, David Ahern <dsahern@gmail.com>,
Don Zickus <dzickus@redhat.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
Namhyung Kim <namhyung@kernel.org>,
Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <peterz@infradead.org>,
Stephane Eranian <eranian@google.com>
Subject: [PATCH 15/18] perf tools: Make the mmap length autotuning more robust
Date: Tue, 16 Dec 2014 13:57:17 -0300 [thread overview]
Message-ID: <1418749040-31807-16-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1418749040-31807-1-git-send-email-acme@kernel.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
If /proc/sys/kernel/perf_event_mlock_kb is not (power of 2 + PAGE_SIZE_in_kb)
and we let the perf tools do mmap length autosizing based on that, then, for
non-CAP_IPC_LOCK users when /proc/sys/kernel/perf_event_paranoid is > -1, then
we get an -EINVAL that ends up in:
[acme@ssdandy linux]$ trace usleep 1
Invalid argument
[acme@ssdandy linux]$ perf record usleep 1
failed to mmap with 22 (Invalid argument)
After this fix:
[acme@ssdandy linux]$ trace usleep 1
<SNIP>
0.806 ( 0.006 ms): munmap(addr: 0x7f7e4740a000, len: 66467) = 0
0.869 ( 0.002 ms): brk( ) = 0x7bb000
0.873 ( 0.003 ms): brk(brk: 0x7dc000 ) = 0x7dc000
0.877 ( 0.001 ms): brk( ) = 0x7dc000
0.953 ( 0.058 ms): nanosleep(rqtp: 0x7fff26ab9420 ) = 0
0.959 ( 0.000 ms): exit_group(
[acme@ssdandy linux]$ perf record usleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.017 MB perf.data (~759 samples) ]
[acme@ssdandy linux]$
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-6p6l5ou6jev6o7ymc4nn1n2a@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/evlist.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 8eb92cf5d552..7d88327d94a9 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -909,6 +909,8 @@ static size_t perf_evlist__mmap_size(unsigned long pages)
}
pages = (max * 1024) / page_size;
+ if (!is_power_of_2(pages))
+ pages = rounddown_pow_of_two(pages);
} else if (!is_power_of_2(pages))
return 0;
--
1.9.3
next prev parent reply other threads:[~2014-12-16 16:58 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-16 16:57 [GIT PULL 00/18] perf/core improvements and fixes Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 01/18] perf evlist: Fixup brown paper bag on "hint" for --mmap-pages cmdline arg Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 02/18] perf evlist: Clarify sterror_mmap variable names Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 03/18] perf evlist: Improve the strerror_mmap method Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 04/18] perf trace: Let the perf_evlist__mmap autosize the number of pages to use Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 05/18] perf evlist: Do not use hard coded value for a mmap_pages default Arnaldo Carvalho de Melo
2014-12-17 13:23 ` Jiri Olsa
2014-12-17 14:00 ` Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 06/18] tools: Move __ffs implementation to tools/include/asm-generic/bitops/__ffs.h Arnaldo Carvalho de Melo
2014-12-17 13:27 ` Jiri Olsa
2014-12-16 16:57 ` [PATCH 07/18] tools: Move code originally from linux/log2.h to tools/include/linux/ Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 08/18] tools: Move code originally from asm-generic/atomic.h into tools/include/asm-generic/ Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 09/18] tools: Whitespace prep patches for moving bitops.h Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 10/18] tools lib: Move asm-generic/bitops/find.h code to tools/include and tools/lib Arnaldo Carvalho de Melo
2014-12-17 13:41 ` Jiri Olsa
2014-12-17 14:04 ` Arnaldo Carvalho de Melo
2014-12-17 13:42 ` Jiri Olsa
2014-12-17 14:02 ` Arnaldo Carvalho de Melo
2014-12-17 14:48 ` Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 11/18] tools: Introduce asm-generic/bitops.h Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 12/18] tools: Move bitops.h from tools/perf/util to tools/ Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 13/18] tools: Adopt fls_long and deps Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 14/18] tools: Adopt rounddown_pow_of_two " Arnaldo Carvalho de Melo
2014-12-16 16:57 ` Arnaldo Carvalho de Melo [this message]
2014-12-17 13:48 ` [PATCH 15/18] perf tools: Make the mmap length autotuning more robust Jiri Olsa
2014-12-16 16:57 ` [PATCH 16/18] tools: Adopt roundup_pow_of_two Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 17/18] perf evlist: Use roundup_pow_of_two Arnaldo Carvalho de Melo
2014-12-16 16:57 ` [PATCH 18/18] perf symbols: Fix use after free in filename__read_build_id Arnaldo Carvalho de Melo
2014-12-17 14:50 ` [GIT PULL 00/18] perf/core improvements and fixes Arnaldo Carvalho de Melo
2014-12-18 6:24 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1418749040-31807-16-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=bp@suse.de \
--cc=dsahern@gmail.com \
--cc=dzickus@redhat.com \
--cc=efault@gmx.de \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).