From ab7236f68712b18656cb82307e6ca5dbe8de9fa7 Mon Sep 17 00:00:00 2001 From: David Smith Date: Mon, 30 Nov 2009 13:24:14 -0600 Subject: Don't let _stp_alloc_percpu allocate too much memory. * runtime/alloc.c (_stp_alloc_percpu): Refuses to allocate too much percpu memory. --- runtime/alloc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'runtime/alloc.c') diff --git a/runtime/alloc.c b/runtime/alloc.c index 439e8a7e..403d20ee 100644 --- a/runtime/alloc.c +++ b/runtime/alloc.c @@ -11,6 +11,8 @@ #ifndef _ALLOC_C_ #define _ALLOC_C_ +#include + static int _stp_allocated_net_memory = 0; #define STP_ALLOC_FLAGS (GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN) @@ -233,12 +235,23 @@ static void *_stp_vmalloc(unsigned long size) } +#ifdef PCPU_MIN_UNIT_SIZE +#define _STP_MAX_PERCPU_SIZE PCPU_MIN_UNIT_SIZE +#else +#define _STP_MAX_PERCPU_SIZE 131072 +#endif + static void *_stp_alloc_percpu(size_t size) { + void *ret; + + if (size > _STP_MAX_PERCPU_SIZE) + return NULL; + #ifdef STAPCONF_ALLOC_PERCPU_ALIGN - void *ret = __alloc_percpu(size, 8); + ret = __alloc_percpu(size, 8); #else - void *ret = __alloc_percpu(size); + ret = __alloc_percpu(size); #endif #ifdef DEBUG_MEM if (likely(ret)) { -- cgit