Why is this assertion in __get_vm_area_node
?
static struct vm_struct *__get_vm_area_node(...)
{
// ...
BUG_ON(in_interrupt())
// ...
}
I think the commit that introduced that line explains it pretty well:
If
__vmalloc
is called to allocate memory withGFP_ATOMIC
in atomic context, the chain of calls results in__get_vm_area_node
allocating memory forvm_struct
withGFP_KERNEL
, causing the 'sleeping from invalid context' warning. This patch fixes it by passing the gfp flags along so__get_vm_area_node
allocates memory forvm_struct
with the same flags.
@@ -160,13 +160,15 @@ int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page ***pages)
return err;
}
-struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags,
- unsigned long start, unsigned long end, int node)
+static struct vm_struct *__get_vm_area_node(unsigned long size, unsigned long flags,
+ unsigned long start, unsigned long end,
+ int node, gfp_t gfp_mask)
{
struct vm_struct **p, *tmp, *area;
unsigned long align = 1;
unsigned long addr;
+ BUG_ON(in_interrupt());
if (flags & VM_IOREMAP) {
int bit = fls(size);
In short, the following code in that function could sleep, and sleeping is not allowed in interrupt context. The BUG_ON
is added to prevent this kind of problem.
in_interrupt()
do? What code is in__get_vm_area_node()
that doesn't work from interrupts?