summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhunt <hunt>2006-11-15 17:52:23 +0000
committerhunt <hunt>2006-11-15 17:52:23 +0000
commit132c23b4b9134b9e8969fb57484f9fcdad1d46f5 (patch)
tree48d8da3e2d81b34c2438dc4b2631c1781e042bdf
parent2698d4879f43304658c327860c5b803e10c99c10 (diff)
downloadsystemtap-steved-132c23b4b9134b9e8969fb57484f9fcdad1d46f5.tar.gz
systemtap-steved-132c23b4b9134b9e8969fb57484f9fcdad1d46f5.tar.xz
systemtap-steved-132c23b4b9134b9e8969fb57484f9fcdad1d46f5.zip
2006-11-15 Martin Hunt <hunt@redhat.com>
* alloc.c (STP_ALLOC_FLAGS): Define. Cleanup ifdefs. * map.c: Use STP_ALLOC_FLAGS. * stat.c: ditto.
-rw-r--r--runtime/ChangeLog7
-rw-r--r--runtime/alloc.c29
-rw-r--r--runtime/map.c18
-rw-r--r--runtime/runtime.h2
-rw-r--r--runtime/stat.c4
5 files changed, 34 insertions, 26 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog
index e0cf15b7..d15343e9 100644
--- a/runtime/ChangeLog
+++ b/runtime/ChangeLog
@@ -1,3 +1,10 @@
+2006-11-15 Martin Hunt <hunt@redhat.com>
+
+ * alloc.c (STP_ALLOC_FLAGS): Define.
+ Cleanup ifdefs.
+ * map.c: Use STP_ALLOC_FLAGS.
+ * stat.c: ditto.
+
2006-11-10 Li Guanglei <guanglei@cn.ibm.com>
* transport/procfs.c: bugfix of the obsolete buf_info
diff --git a/runtime/alloc.c b/runtime/alloc.c
index ad291f2d..4aecd5a8 100644
--- a/runtime/alloc.c
+++ b/runtime/alloc.c
@@ -11,6 +11,10 @@
#ifndef _ALLOC_C_
#define _ALLOC_C_
+
+#define STP_ALLOC_FLAGS (GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN)
+#define _stp_vmalloc(size) __vmalloc(size, STP_ALLOC_FLAGS, PAGE_KERNEL)
+
/* This file exists because all the NUMA-compatible allocators keep
changing in 2.6 */
@@ -19,20 +23,16 @@
#endif /* LINUX_VERSION_CODE */
#ifdef CONFIG_SMP
-#define _stp_free_percpu(ptr) free_percpu(ptr)
-#else
-#define _stp_free_percpu(ptr) kfree(ptr)
-#endif
-
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
#define _stp_alloc_percpu(size) __alloc_percpu(size, 8)
-#else
-#ifdef CONFIG_SMP
+#define _stp_free_percpu(ptr) free_percpu(ptr)
+#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) */
+
/* This is like alloc_percpu() except it simply takes a size, instead of a type. */
void *_stp_alloc_percpu(size_t size)
{
int i;
- struct percpu_data *pdata = kmalloc(sizeof (*pdata), GFP_KERNEL);
+ struct percpu_data *pdata = kmalloc(sizeof (*pdata), STP_ALLOC_FLAGS);
if (!pdata)
return NULL;
@@ -41,9 +41,9 @@ void *_stp_alloc_percpu(size_t size)
int node = cpu_to_node(i);
if (node_online(node))
- pdata->ptrs[i] = kmalloc_node(size, GFP_KERNEL, node);
+ pdata->ptrs[i] = kmalloc_node(size, STP_ALLOC_FLAGS, node);
else
- pdata->ptrs[i] = kmalloc(size, GFP_KERNEL);
+ pdata->ptrs[i] = kmalloc(size, STP_ALLOC_FLAGS);
if (!pdata->ptrs[i])
goto unwind_oom;
@@ -72,14 +72,17 @@ void _stp_free_percpu(const void *objp)
kfree(p->ptrs[i]);
kfree(p);
}
-#else
+#endif /* LINUX_VERSION_CODE */
+
+#else /* CONFIG_SMP */
+#define _stp_free_percpu(ptr) kfree(ptr)
void *_stp_alloc_percpu(size_t size)
{
- void *ret = kmalloc(size, GFP_KERNEL);
+ void *ret = kmalloc(size, STP_ALLOC_FLAGS);
if (ret)
memset(ret, 0, size);
return ret;
}
#endif /* CONFIG_SMP */
-#endif /* LINUX_VERSION_CODE */
+
#endif /* _ALLOC_C_ */
diff --git a/runtime/map.c b/runtime/map.c
index 326f95aa..843a8543 100644
--- a/runtime/map.c
+++ b/runtime/map.c
@@ -187,8 +187,8 @@ static int _stp_map_init(MAP m, unsigned max_entries, int type, int key_size, in
return -1;
}
if (max_entries) {
- void *tmp;
int i;
+ void *tmp;
/* size is the size of the map_node. */
/* add space for the value. */
@@ -202,14 +202,12 @@ static int _stp_map_init(MAP m, unsigned max_entries, int type, int key_size, in
for (i = 0; i < max_entries; i++) {
if (cpu < 0)
- tmp = kmalloc(size, GFP_KERNEL);
+ tmp = kmalloc(size, STP_ALLOC_FLAGS);
else
- tmp = kmalloc_node(size, GFP_KERNEL, cpu);
+ tmp = kmalloc_node(size, STP_ALLOC_FLAGS, cpu);
- if (!tmp) {
- _stp_error("Allocating memory while creating map failed.\n");
- return -1;
- }
+ if (!tmp)
+ return -1;;
dbug ("allocated %lx\n", (long)tmp);
list_add((struct list_head *)tmp, &m->pool);
@@ -219,12 +217,12 @@ static int _stp_map_init(MAP m, unsigned max_entries, int type, int key_size, in
if (type == STAT)
m->hist.type = HIST_NONE;
return 0;
- }
+}
static MAP _stp_map_new(unsigned max_entries, int type, int key_size, int data_size)
{
- MAP m = (MAP) kmalloc(sizeof(struct map_root), GFP_KERNEL);
+ MAP m = (MAP) kmalloc(sizeof(struct map_root), STP_ALLOC_FLAGS);
if (m == NULL)
return NULL;
@@ -243,7 +241,7 @@ static PMAP _stp_pmap_new(unsigned max_entries, int type, int key_size, int data
int i;
MAP map, m;
- PMAP pmap = (PMAP) kmalloc(sizeof(struct pmap), GFP_KERNEL);
+ PMAP pmap = (PMAP) kmalloc(sizeof(struct pmap), STP_ALLOC_FLAGS);
if (pmap == NULL)
return NULL;
diff --git a/runtime/runtime.h b/runtime/runtime.h
index d0038903..858ef639 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -71,12 +71,12 @@ static struct
#define TRYLOCKDELAY 100
#endif
+#include "alloc.c"
#include "print.c"
#include "string.c"
#include "arith.c"
#include "copy.c"
#include "sym.h"
-#include "alloc.c"
#ifdef STP_PERFMON
#include "perf.c"
#endif
diff --git a/runtime/stat.c b/runtime/stat.c
index d9eff2c3..c1bf07b1 100644
--- a/runtime/stat.c
+++ b/runtime/stat.c
@@ -96,7 +96,7 @@ Stat _stp_stat_init (int type, ...)
}
va_end (ap);
}
- st = (Stat) kmalloc (sizeof(struct _Stat), GFP_KERNEL);
+ st = (Stat) kmalloc (sizeof(struct _Stat), STP_ALLOC_FLAGS);
if (st == NULL)
return NULL;
@@ -115,7 +115,7 @@ Stat _stp_stat_init (int type, ...)
}
#endif
- agg = (stat *)kmalloc (size, GFP_KERNEL);
+ agg = (stat *)kmalloc (size, STP_ALLOC_FLAGS);
if (agg == NULL)
goto exit2;