0

为什么这个断言在__get_vm_area_node

static struct vm_struct *__get_vm_area_node(...)
{
    // ...
    BUG_ON(in_interrupt())
    // ...
} 
4

1 回答 1

0

我认为引入该行的提交很好地解释了它:

如果在原子上下文中__vmalloc调用以分配内存GFP_ATOMIC,则调用链会导致__get_vm_area_nodevm_structwith分配内存GFP_KERNEL,从而导致“从无效上下文中休眠”警告。这个补丁通过传递 gfp 标志来修复它,因此 为相同的标志__get_vm_area_node分配内存。vm_struct

@@ -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);

简而言之,该函数中的以下代码可以 sleep,并且在中断上下文中不允许 sleep 。添加 是为了BUG_ON防止此类问题。

于 2020-10-19T12:10:12.950 回答