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 05/18] perf evlist: Do not use hard coded value for a mmap_pages default
Date: Tue, 16 Dec 2014 13:57:07 -0300 [thread overview]
Message-ID: <1418749040-31807-6-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>
So far what is in there by default is what we were using: 512KB + the
control page, but the admin may change that, and if it does to a smaller
value, all calls to tooling for non root users start failing, requiring
that the user manually set --mmap_pages/-m.
Use instead what is in /proc/sys/kernel/perf_event_mlock_kb.
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-2f6mtm8xu3wo5lhkql6jdblh@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/evlist.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 7847f3885081..ac808680e61c 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -893,10 +893,22 @@ out_unmap:
static size_t perf_evlist__mmap_size(unsigned long pages)
{
- /* 512 kiB: default amount of unprivileged mlocked memory */
- if (pages == UINT_MAX)
- pages = (512 * 1024) / page_size;
- else if (!is_power_of_2(pages))
+ if (pages == UINT_MAX) {
+ int max;
+
+ if (sysctl__read_int("kernel/perf_event_mlock_kb", &max) < 0) {
+ /*
+ * Pick a once upon a time good value, i.e. things look
+ * strange since we can't read a sysctl value, but lets not
+ * die yet...
+ */
+ max = 512;
+ } else {
+ max -= (page_size / 1024);
+ }
+
+ pages = (max * 1024) / page_size;
+ } else if (!is_power_of_2(pages))
return 0;
return (pages + 1) * page_size;
--
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 ` Arnaldo Carvalho de Melo [this message]
2014-12-17 13:23 ` [PATCH 05/18] perf evlist: Do not use hard coded value for a mmap_pages default 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 ` [PATCH 15/18] perf tools: Make the mmap length autotuning more robust Arnaldo Carvalho de Melo
2014-12-17 13:48 ` 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-6-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).