Skip to content

Commit

Permalink
mm: introduce vma_init()
Browse files Browse the repository at this point in the history
Not all VMAs allocated with vm_area_alloc().  Some of them allocated on
stack or in data segment.

The new helper can be use to initialize VMA properly regardless where it
was allocated.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Kirill A. Shutemov <[email protected]>
Acked-by: Linus Torvalds <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
kiryl authored and torvalds committed Jul 27, 2018
1 parent 31c5bda commit 027232d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 6 additions & 0 deletions include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,12 @@ struct vm_operations_struct {
unsigned long addr);
};

static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm)
{
vma->vm_mm = mm;
INIT_LIST_HEAD(&vma->anon_vma_chain);
}

struct mmu_gather;
struct inode;

Expand Down
6 changes: 2 additions & 4 deletions kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,8 @@ struct vm_area_struct *vm_area_alloc(struct mm_struct *mm)
{
struct vm_area_struct *vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);

if (vma) {
vma->vm_mm = mm;
INIT_LIST_HEAD(&vma->anon_vma_chain);
}
if (vma)
vma_init(vma, mm);
return vma;
}

Expand Down

0 comments on commit 027232d

Please sign in to comment.