vmalloc might sleep
Subsystems (2)
PATCH 1/1 vmalloc might sleep
So let's whack people upside the head when they misuse it.
vmalloc-might-sleep.diff:
Index: mm/vmalloc.c
===================================================================
RCS file: /var/cvs/linux-2.6/mm/vmalloc.c,v
retrieving revision 1.2
mm/vmalloc.c +3 -1
@@ -438,7 +438,8 @@ fail:*/ void *vmalloc (unsigned long size) { -return __vmalloc (size,GFP_KERNEL | __GFP_HIGHMEM,PAGE_KERNEL ); +might_sleep (); +return __vmalloc (size,GFP_KERNEL | __GFP_HIGHMEM,PAGE_KERNEL ); }/**
@@ -451,6 +452,7 @@ void *vmalloc(unsigned long size)*/ void *vmalloc_32 (unsigned long size) { +might_sleep ();return __vmalloc (size,GFP_KERNEL ,PAGE_KERNEL ); }
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
Quoted 13 lines · Matthew Wilcox
So let's whack people upside the head when they misuse it.
vmalloc-might-sleep.diff:
Index:
mm/vmalloc.c
===================================================================
RCS file:/var/cvs/linux-2.6/mm/vmalloc.c,v
retrieving revision 1.2
diff -u -p -r1.2vmalloc.c
mm/vmalloc.c fail: · line 442
Quoted 6 lines
mm/vmalloc.c +2
-1@@ -438,7 +438,8 @@ fail:*/ void *vmalloc (unsigned long size) { -return __vmalloc (size,GFP_KERNEL | __GFP_HIGHMEM,PAGE_KERNEL ); +might_sleep (); +return __vmalloc (size,GFP_KERNEL | __GFP_HIGHMEM,PAGE_KERNEL );
__vmalloc() goes kmalloc() to get an array of struct page pointers. And both for vmalloc() and vmalloc_32() kmalloc() will be called with GFP_KERNEL as gfp_mask. Which already has might_sleep().