Skip to content

Commit 906010b

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
perf_event: Provide vmalloc() based mmap() backing
Some architectures such as Sparc, ARM and MIPS (basically everything with flush_dcache_page()) need to deal with dcache aliases by carefully placing pages in both kernel and user maps. These architectures typically have to use vmalloc_user() for this. However, on other architectures, vmalloc() is not needed and has the downsides of being more restricted and slower than regular allocations. Signed-off-by: Peter Zijlstra <[email protected]> Acked-by: David Miller <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Paul Mackerras <[email protected]> LKML-Reference: <1254830228.21044.272.camel@laptop> Signed-off-by: Ingo Molnar <[email protected]>
1 parent e13dbd7 commit 906010b

File tree

5 files changed

+214
-62
lines changed

5 files changed

+214
-62
lines changed

arch/sparc/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ config SPARC
2626
select RTC_CLASS
2727
select RTC_DRV_M48T59
2828
select HAVE_PERF_EVENTS
29+
select PERF_USE_VMALLOC
2930
select HAVE_DMA_ATTRS
3031
select HAVE_DMA_API_DEBUG
3132

@@ -48,6 +49,7 @@ config SPARC64
4849
select RTC_DRV_SUN4V
4950
select RTC_DRV_STARFIRE
5051
select HAVE_PERF_EVENTS
52+
select PERF_USE_VMALLOC
5153

5254
config ARCH_DEFCONFIG
5355
string

include/linux/perf_event.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ enum perf_callchain_context {
442442
#include <linux/hrtimer.h>
443443
#include <linux/fs.h>
444444
#include <linux/pid_namespace.h>
445+
#include <linux/workqueue.h>
445446
#include <asm/atomic.h>
446447

447448
#define PERF_MAX_STACK_DEPTH 255
@@ -513,6 +514,10 @@ struct file;
513514

514515
struct perf_mmap_data {
515516
struct rcu_head rcu_head;
517+
#ifdef CONFIG_PERF_USE_VMALLOC
518+
struct work_struct work;
519+
#endif
520+
int data_order;
516521
int nr_pages; /* nr of data pages */
517522
int writable; /* are we writable */
518523
int nr_locked; /* nr pages mlocked */

init/Kconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,11 @@ config HAVE_PERF_EVENTS
921921
help
922922
See tools/perf/design.txt for details.
923923

924+
config PERF_USE_VMALLOC
925+
bool
926+
help
927+
See tools/perf/design.txt for details
928+
924929
menu "Kernel Performance Events And Counters"
925930

926931
config PERF_EVENTS
@@ -976,6 +981,19 @@ config PERF_COUNTERS
976981

977982
Say N if unsure.
978983

984+
config DEBUG_PERF_USE_VMALLOC
985+
default n
986+
bool "Debug: use vmalloc to back perf mmap() buffers"
987+
depends on PERF_EVENTS && DEBUG_KERNEL
988+
select PERF_USE_VMALLOC
989+
help
990+
Use vmalloc memory to back perf mmap() buffers.
991+
992+
Mostly useful for debugging the vmalloc code on platforms
993+
that don't require it.
994+
995+
Say N if unsure.
996+
979997
endmenu
980998

981999
config VM_EVENT_COUNTERS

0 commit comments

Comments
 (0)