Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1102400yba; Thu, 18 Apr 2019 15:23:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmrDbTIDnGvq8lw72M+Ov+LzBSYaXeof73QHrlrptTWBgmuG0SAejty5UWSUxnPTrZ3qVc X-Received: by 2002:a17:902:106:: with SMTP id 6mr123988plb.98.1555626209921; Thu, 18 Apr 2019 15:23:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555626209; cv=none; d=google.com; s=arc-20160816; b=0cJl4zzoBIb2CShKANcqIAywbUw+QhivjmGMCXICQsYvnrGL2s94mVT92UZgaruwjv S+xEhOt2QikwiDglWtafT9sCDaCAPTn0QV94WuyjaxeuCkAUR9LidvJG2ugEY7cL3WW2 FA0a5gF6Jckx2N6dqXtSEdmvBgKJ/XQjBTOkJN0Yg2HLhHBEL/i3Ed313+X0tK7D13Gd TqgiH8NgwwAkfVTG4zo+i2NienPqYU2K9+xSsYGbkBv8D/sRkybUvbor2g0f34Cvsiej HZf9mou6iaEzzc6/4jPRyEkiZb2PD/TzECK3SuR4x8qHG9iCUViZLaGd0PmwxMPB8uoz wePQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=4sXQaNqlRRTRdxOjRFxaauId6kyfzqxGAIe1B5ze7PQ=; b=F3IbcVLHb8ZLg+k7ZwX5AC1AU1tHeFyqOEcoP3MIWQUzQVFsaq/cTxQ3Lzm0Vig/E4 ucPnD5PK2z1/6/3LHaXQvSn9RH8E1q7+TS5IONltrn5/3WW+8CfDuNmSSpzO897rXruc d4ACygIP/tCGOKJ1xYpgzwulOfzranlfQdggblAePPwnwfkNfNGdK151vW7gWJJ2rO44 gPlbporF3V1nOXXfl0jxffzBrYfyCm75LIxNvmT8p9MNCJYATry8/8b3PanHHaTEEdRn RbsQKAjwYBCOy3ND4RL1nidWJ+ePpdZ8YrYcV5KILTQeFBILufzK2I3TrpG6u+0CwK2G AS8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si3399292pff.3.2019.04.18.15.23.14; Thu, 18 Apr 2019 15:23:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726082AbfDRWWU (ORCPT + 99 others); Thu, 18 Apr 2019 18:22:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52012 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725853AbfDRWWU (ORCPT ); Thu, 18 Apr 2019 18:22:20 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 05FE4C066462; Thu, 18 Apr 2019 22:22:19 +0000 (UTC) Received: from redhat.com (unknown [10.20.6.236]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ED5475D9CC; Thu, 18 Apr 2019 22:22:14 +0000 (UTC) Date: Thu, 18 Apr 2019 18:22:13 -0400 From: Jerome Glisse To: Laurent Dufour Cc: akpm@linux-foundation.org, mhocko@kernel.org, peterz@infradead.org, kirill@shutemov.name, ak@linux.intel.com, dave@stgolabs.net, jack@suse.cz, Matthew Wilcox , aneesh.kumar@linux.ibm.com, benh@kernel.crashing.org, mpe@ellerman.id.au, paulus@samba.org, Thomas Gleixner , Ingo Molnar , hpa@zytor.com, Will Deacon , Sergey Senozhatsky , sergey.senozhatsky.work@gmail.com, Andrea Arcangeli , Alexei Starovoitov , kemi.wang@intel.com, Daniel Jordan , David Rientjes , Ganesh Mahendran , Minchan Kim , Punit Agrawal , vinayak menon , Yang Shi , zhong jiang , Haiyan Song , Balbir Singh , sj38.park@gmail.com, Michel Lespinasse , Mike Rapoport , linux-kernel@vger.kernel.org, linux-mm@kvack.org, haren@linux.vnet.ibm.com, npiggin@gmail.com, paulmck@linux.vnet.ibm.com, Tim Chen , linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: Re: [PATCH v12 08/31] mm: introduce INIT_VMA() Message-ID: <20190418222212.GH11645@redhat.com> References: <20190416134522.17540-1-ldufour@linux.ibm.com> <20190416134522.17540-9-ldufour@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190416134522.17540-9-ldufour@linux.ibm.com> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 18 Apr 2019 22:22:19 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 16, 2019 at 03:44:59PM +0200, Laurent Dufour wrote: > 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. > > Signed-off-by: Laurent Dufour > --- > fs/exec.c | 1 + > include/linux/mm.h | 5 +++++ > kernel/fork.c | 2 +- > mm/mmap.c | 3 +++ > mm/nommu.c | 1 + > 5 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/fs/exec.c b/fs/exec.c > index 2e0033348d8e..9762e060295c 100644 > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -266,6 +266,7 @@ static int __bprm_mm_init(struct linux_binprm *bprm) > vma->vm_start = vma->vm_end - PAGE_SIZE; > vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP; > vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); > + INIT_VMA(vma); > > err = insert_vm_struct(mm, vma); > if (err) > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 4ba2f53f9d60..2ceb1d2869a6 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1407,6 +1407,11 @@ struct zap_details { > pgoff_t last_index; /* Highest page->index to unmap */ > }; > > +static inline void INIT_VMA(struct vm_area_struct *vma) Can we leave capital names for macro ? Also i prefer vma_init_struct() (the one thing i like in C++ is namespace and thus i like namespace_action() for function name). Also why not doing a coccinelle patch for this: @@ struct vm_area_struct *vma; @@ -INIT_LIST_HEAD(&vma->anon_vma_chain); +vma_init_struct(vma); Untested ... > +{ > + INIT_LIST_HEAD(&vma->anon_vma_chain); > +} > + > struct page *_vm_normal_page(struct vm_area_struct *vma, unsigned long addr, > pte_t pte, bool with_public_device); > #define vm_normal_page(vma, addr, pte) _vm_normal_page(vma, addr, pte, false) > diff --git a/kernel/fork.c b/kernel/fork.c > index 915be4918a2b..f8dae021c2e5 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -341,7 +341,7 @@ struct vm_area_struct *vm_area_dup(struct vm_area_struct *orig) > > if (new) { > *new = *orig; > - INIT_LIST_HEAD(&new->anon_vma_chain); > + INIT_VMA(new); > } > return new; > } > diff --git a/mm/mmap.c b/mm/mmap.c > index bd7b9f293b39..5ad3a3228d76 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -1765,6 +1765,7 @@ unsigned long mmap_region(struct file *file, unsigned long addr, > vma->vm_flags = vm_flags; > vma->vm_page_prot = vm_get_page_prot(vm_flags); > vma->vm_pgoff = pgoff; > + INIT_VMA(vma); > > if (file) { > if (vm_flags & VM_DENYWRITE) { > @@ -3037,6 +3038,7 @@ static int do_brk_flags(unsigned long addr, unsigned long len, unsigned long fla > } > > vma_set_anonymous(vma); > + INIT_VMA(vma); > vma->vm_start = addr; > vma->vm_end = addr + len; > vma->vm_pgoff = pgoff; > @@ -3395,6 +3397,7 @@ static struct vm_area_struct *__install_special_mapping( > if (unlikely(vma == NULL)) > return ERR_PTR(-ENOMEM); > > + INIT_VMA(vma); > vma->vm_start = addr; > vma->vm_end = addr + len; > > diff --git a/mm/nommu.c b/mm/nommu.c > index 749276beb109..acf7ca72ca90 100644 > --- a/mm/nommu.c > +++ b/mm/nommu.c > @@ -1210,6 +1210,7 @@ unsigned long do_mmap(struct file *file, > region->vm_flags = vm_flags; > region->vm_pgoff = pgoff; > > + INIT_VMA(vma); > vma->vm_flags = vm_flags; > vma->vm_pgoff = pgoff; > > -- > 2.21.0 >