From 0076600734ad5ba63ccdb80483364ccd51ad51ea Mon Sep 17 00:00:00 2001 From: Laurent Dufour Date: Tue, 17 Apr 2018 16:33:13 +0200 Subject: [PATCH] FROMLIST: mm: introduce INIT_VMA() Some VMA struct fields need to be initialized once the VMA structure is allocated. Currently this only concerns anon_vma_chain field but some other will be added to support the speculative page fault. Instead of spreading the initialization calls all over the code, let's introduce a dedicated inline function. Change-Id: I9f6b29dc74055354318b548e2b6b22c37d4c61bb Signed-off-by: Laurent Dufour Link: https://lore.kernel.org/lkml/1523975611-15978-8-git-send-email-ldufour@linux.vnet.ibm.com/ Bug: 161210518 Signed-off-by: Vinayak Menon Signed-off-by: Charan Teja Reddy --- include/linux/mm.h | 7 ++++++- kernel/fork.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 471acc25b9fd..cfb64a602a53 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -625,6 +625,11 @@ struct vm_operations_struct { unsigned long addr); }; +static inline void INIT_VMA(struct vm_area_struct *vma) +{ + INIT_LIST_HEAD(&vma->anon_vma_chain); +} + static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm) { static const struct vm_operations_struct dummy_vm_ops = {}; @@ -632,7 +637,7 @@ static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm) memset(vma, 0, sizeof(*vma)); vma->vm_mm = mm; vma->vm_ops = &dummy_vm_ops; - INIT_LIST_HEAD(&vma->anon_vma_chain); + INIT_VMA(vma); } static inline void vma_set_anonymous(struct vm_area_struct *vma) diff --git a/kernel/fork.c b/kernel/fork.c index a7a21836812f..8ba76a608d79 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -365,7 +365,7 @@ struct vm_area_struct *vm_area_dup(struct vm_area_struct *orig) * will be reinitialized. */ *new = data_race(*orig); - INIT_LIST_HEAD(&new->anon_vma_chain); + INIT_VMA(new); new->vm_next = new->vm_prev = NULL; } return new;