[PATCH V2 1/4] vmalloc: introduce vfree_atomic()

Lai Jiangshan
2008-11-18T08:54:31Z

fdtable and sysipc use vfree() in RCU callback. this patch
introduce vfree_atomic() for them.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index 307b885..195379a 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -60,6 +60,7 @@ extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
extern void *__vmalloc_area(struct vm_struct *area, gfp_t gfp_mask,
pgprot_t prot);
extern void vfree(const void *addr);
+extern void vfree_atomic(void *addr);

extern void *vmap(struct page **pages, unsigned int count,
unsigned long flags, pgprot_t prot);
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index ba6b0f5..39c164e 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -23,6 +23,7 @@
#include <linux/rbtree.h>
#include <linux/radix-tree.h>
#include <linux/rcupdate.h>
+#include <linux/workqueue.h>

#include <asm/atomic.h>
#include <asm/uaccess.h>
@@ -1177,6 +1178,21 @@ void vfree(const void *addr)
}
EXPORT_SYMBOL(vfree);

+static void vfree_defer(struct work_struct *work)
+{
+ vfree(work);
+}
+
+void vfree_atomic(void *ptr)
+{
+ if (ptr) {
+ struct work_struct *work = ptr;
+ INIT_WORK(work, vfree_defer);
+ schedule_work(work);
+ }
+}
+EXPORT_SYMBOL_GPL(vfree_atomic);
+
/**
* vunmap - release virtual mapping obtained by vmap()
* @addr: memory base address