perf: Fix vmalloc ring buffer pages handling
authorJiri Olsa <jolsa@redhat.com>
Tue, 19 Mar 2013 14:35:09 +0000 (15:35 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 1 May 2013 10:34:46 +0000 (12:34 +0200)
commit5919b30933d7c4fac1f214c59f26c5e990044f09
tree1d719e5fd6534ed0a6dd00927e3b8343bb725e50
parent1b0dac2ac6debdbf1541e15f2cede03613cf4465
perf: Fix vmalloc ring buffer pages handling

If we allocate perf ring buffer with the size of single (user)
page, we will get memory corruption when releasing itin
rb_free_work function (for CONFIG_PERF_USE_VMALLOC option).

For single page sized ring buffer the page_order is -1 (because
nr_pages is 0). This needs to be recognized in the rb_free_work
function to release proper amount of pages.

Adding data_page_nr function that returns number of allocated
data pages. Customizing the rest of the code to use it.

Reported-by: Jan Stancek <jstancek@redhat.com>
Original-patch-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20130319143509.GA1128@krava.brq.redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/events/ring_buffer.c