On Sun, Aug 13, 2006 at 06:22:19PM +0800, Akinobu Mita wrote:
> The idea behind failslab is to demonstrate what really happens if
> slab allocation fails. The idea of failslab is completely taken
> from failmalloc (http://www.nongnu.org/failmalloc/).
I have similar versions for vmalloc() and page_alloc().
But I couldn't find outstanding bugs.
boot options:
failvmalloc=<probability>,<interval>,<times>,<space>
fail_page_alloc=<probability>,<interval>,<times>,<space>
Index: work-failmalloc/mm/vmalloc.c
===================================================================
--- work-failmalloc.orig/mm/vmalloc.c
+++ work-failmalloc/mm/vmalloc.c
@@ -16,6 +16,7 @@
#include <linux/interrupt.h>
#include <linux/vmalloc.h>
+#include <linux/failmalloc.h>
#include <asm/uaccess.h>
#include <asm/tlbflush.h>
@@ -416,12 +417,28 @@ void *vmap(struct page **pages, unsigned
}
EXPORT_SYMBOL(vmap);
+#ifdef CONFIG_FAILMALLOC
+
+struct failmalloc_data failvmalloc;
+
+static int __init setup_failvmalloc(char *str)
+{
+ return setup_failmalloc(&failvmalloc, str);
+}
+
+__setup("failvmalloc=", setup_failvmalloc);
+
+#endif
+
void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
pgprot_t prot, int node)
{
struct page **pages;
unsigned int nr_pages, array_size, i;
+ if (!(gfp_mask & __GFP_NOFAIL) && should_fail(&failvmalloc, area->size))
+ goto fail;
+
nr_pages = (area->size - PAGE_SIZE) >> PAGE_SHIFT;
array_size = (nr_pages * sizeof(struct page *));
Index: work-failmalloc/mm/page_alloc.c
===================================================================
--- work-failmalloc.orig/mm/page_alloc.c
+++ work-failmalloc/mm/page_alloc.c
@@ -37,6 +37,7 @@
#include <linux/vmalloc.h>
#include <linux/mempolicy.h>
#include <linux/stop_machine.h>
+#include <linux/failmalloc.h>
#include <asm/tlbflush.h>
#include <asm/div64.h>
@@ -903,6 +904,19 @@ get_page_from_freelist(gfp_t gfp_mask, u
return page;
}
+#ifdef CONFIG_FAILMALLOC
+
+struct failmalloc_data fail_page_alloc;
+
+static int __init setup_fail_page_alloc(char *str)
+{
+ return setup_failmalloc(&fail_page_alloc, str);
+}
+
+__setup("fail_page_alloc=", setup_fail_page_alloc);
+
+#endif
+
/*
* This is the 'heart' of the zoned buddy allocator.
*/
@@ -921,6 +935,10 @@ __alloc_pages(gfp_t gfp_mask, unsigned i
might_sleep_if(wait);
+ if (!(gfp_mask & __GFP_NOFAIL) &&
+ should_fail(&fail_page_alloc, PAGE_SIZE << order))
+ return NULL;
+
restart:
z = zonelist->zones; /* the list of zones suitable for gfp_mask */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]