Re: __vmalloc with GFP_ATOMIC causes 'sleeping from invalid context'

From: Giridhar Pemmasani
Date: Mon May 22 2006 - 02:00:55 EST

On Mon, 22 May 2006 11:53:55 +1000, Nick Piggin <nickpiggin@xxxxxxxxxxxx> said:

> Giridhar Pemmasani wrote:
>> If __vmalloc is called in atomic context with GFP_ATOMIC flags,
>> __get_vm_area_node is called, which calls kmalloc_node with
>> GFP_KERNEL flags. This causes 'sleeping function called from
>> invalid context at mm/slab.c:2729' with 2.6.16-rc4 kernel. A
>> simple solution is to use

> I can't see what would cause this in either 2.6.16-rc4 or
> 2.6.17-rc4. What is the line?

If someone calls __vmalloc in atomic context (with GFP_ATOMIC flags):

with 2.6.17-rc4, in file mm/vmalloc.c,

__vmalloc calls __vmalloc_node on line 484,
__vmalloc_node calls get_vm_area_node on line 474,
get_vm_area_node calls __get_vm_area_node on line 256,
__get_vm_area_node calls kmalloc_node with GFP_KERNEL on line 180

and in include/linux/slab.h,

kmalloc_node calls kmalloc with GFP_KERNEL on line 164,
kmalloc calls kmem_cache_alloc on line 106,

and in mm/slab.c,

kmem_cache_alloc calls __cache_alloc on line 3136,
__cache_alloc calls cache_alloc_debugcheck_before on line 2880,
cache_alloc_debugcheck_before calls might_sleep_if(GFP_KERNEL & GFP_WAIT)
on line 2783

which causes the warning.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at