]> git.baikalelectronics.ru Git - kernel.git/commit
perf/core: Fix impossible ring-buffer sizes warning
authorIngo Molnar <mingo@kernel.org>
Wed, 13 Feb 2019 06:57:02 +0000 (07:57 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 13 Feb 2019 07:05:02 +0000 (08:05 +0100)
commit3bc5b252f4da000a14bd373fe17f3a18fe33bb94
tree40fffe3693bad8ba2b7284a8cd861116835cfce7
parent736df065a7fd08daff7669c157e454223ebd45cb
perf/core: Fix impossible ring-buffer sizes warning

The following commit:

  b5e17965d883 ("perf/core: Don't WARN() for impossible ring-buffer sizes")

results in perf recording failures with larger mmap areas:

  root@skl:/tmp# perf record -g -a
  failed to mmap with 12 (Cannot allocate memory)

The root cause is that the following condition is buggy:

if (order_base_2(size) >= MAX_ORDER)
goto fail;

The problem is that @size is in bytes and MAX_ORDER is in pages,
so the right test is:

if (order_base_2(size) >= PAGE_SHIFT+MAX_ORDER)
goto fail;

Fix it.

Reported-by: "Jin, Yao" <yao.jin@linux.intel.com>
Bisected-by: Borislav Petkov <bp@alien8.de>
Analyzed-by: Peter Zijlstra <peterz@infradead.org>
Cc: Julien Thierry <julien.thierry@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: <stable@vger.kernel.org>
Fixes: b5e17965d883 ("perf/core: Don't WARN() for impossible ring-buffer sizes")
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/events/ring_buffer.c