perf: Better fit max unprivileged mlock pages for tools needs
authorFrederic Weisbecker <fweisbec@gmail.com>
Wed, 23 Mar 2011 18:29:39 +0000 (19:29 +0100)
committerBrad Figg <brad.figg@canonical.com>
Wed, 27 Apr 2011 18:40:24 +0000 (11:40 -0700)
commit6cd6cd762521767d04d3c4ec7ce5d9743a6662f0
treec1401607fca0cf620c3279ccf878d6865575b812
parentceceb382eea70f7aabef0d4b0933bc24733e3eb0
perf: Better fit max unprivileged mlock pages for tools needs

BugLink: http://bugs.launchpad.net/bugs/761134

commit 880f57318450dbead6a03f9e31a1468924d6dd88 upstream.

The maximum kilobytes of locked memory that an unprivileged user
can reserve is of 512 kB = 128 pages by default, scaled to the
number of onlined CPUs, which fits well with the tools that use
128 data pages by default.

However tools actually use 129 pages, because they need one more
for the user control page. Thus the default mlock threshold is
not sufficient for the default tools needs and we always end up
to evaluate the constant mlock rlimit policy, which doesn't have
this scaling with the number of online CPUs.

Hence, on systems that have more than 16 CPUs, we overlap the
rlimit threshold and fail to mmap:

$ perf record ls
Error: failed to mmap with 1 (Operation not permitted)

Just increase the max unprivileged mlock threshold by one page
so that it supports well perf tools even after 16 CPUs.

Reported-by: Han Pingtian <phan@redhat.com>
Reported-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <1300904979-5508-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
kernel/perf_event.c