diff options
author | David Smith <dsmith@redhat.com> | 2009-11-30 13:24:14 -0600 |
---|---|---|
committer | David Smith <dsmith@redhat.com> | 2009-11-30 13:24:14 -0600 |
commit | ab7236f68712b18656cb82307e6ca5dbe8de9fa7 (patch) | |
tree | b899aaf8af99fdc553fe5b270f4717aa2dd66421 /runtime/alloc.c | |
parent | 6ca3a0049cb5ce1a42b5ee38925d9d25c3d8b28d (diff) | |
download | systemtap-steved-ab7236f68712b18656cb82307e6ca5dbe8de9fa7.tar.gz systemtap-steved-ab7236f68712b18656cb82307e6ca5dbe8de9fa7.tar.xz systemtap-steved-ab7236f68712b18656cb82307e6ca5dbe8de9fa7.zip |
Don't let _stp_alloc_percpu allocate too much memory.
* runtime/alloc.c (_stp_alloc_percpu): Refuses to allocate too much percpu
memory.
Diffstat (limited to 'runtime/alloc.c')
-rw-r--r-- | runtime/alloc.c | 17 |
1 files changed, 15 insertions, 2 deletions
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 <linux/percpu.h> + 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)) { |