Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3391381ybl; Mon, 19 Aug 2019 18:03:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyazGmKttQh9Bxh1Ff64SbVRdqh9IvdA3hcbhXA6egXGS3lNCHu7BqAOb4Ml0oPNZqI8Iaa X-Received: by 2002:a17:90a:5887:: with SMTP id j7mr23367400pji.136.1566262992480; Mon, 19 Aug 2019 18:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566262992; cv=none; d=google.com; s=arc-20160816; b=rt6fg/GYOHccyNiKDa9owtKVODMRrZbgWKSo1AVMcToHUs0+vNU108WziWAQN+cfe0 i4J/VK0RnTTWMIB247hQ1r2WibDVAk4+5a8Rw2o+tpE6kJawq29UjRJWwQvsV00SmBfT yJSW/2vm3cLIqLiMHetYdtOFuTPfuBbOmicZ8Bz4hTokCDRVzdsYjmEwWYr7bec+RWay lXn7HKFsbwP6OlhtuMTlrMDL7uRpRq2x5s1QN3AyF48t1586xy1xL9CgNPPYN3A548Sa TfU4hkZWd7JefI2u7n4mF4eUuhV1QyRiLWqCd5aa/8KoSu6Mz5AuoApYR8cbbEonpjhl hDGg== 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=j6nduq0ndg54Kkvj0Eg+gDl/v8pP0lXMXpGXQcxgQ80=; b=KxPhS1BY9h7SUfk20F2K79AIjC93cs8oihK9f6UJVXP0CaRyuAMlK2MQY4b/HAqPv2 b0yHAtSjAPQBM/kNvg3jz1Mv2drjdhuSoIri+fFxLDS7atwLElvCUEZ2NoW2gb7uUP1i Tt7M3rozLKNaYkTChegBWafgb1M1r/gAiz49Lw42LDemGjnCKEMrhTjvf0oJ63e/Wd8+ oalO21MixeLXilwGqf+CwsVdQVC5jR/E3jAqP/CoyTH6RcpLdBVU9Cl08eu/z5aWWGom wq67/TGButr64l5uqy6hss5nxDTl0wbQBmbaqZHUh0nq3nlTN5xOQi+UKgyFdxV0K9DH r0FQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o4si10817733pgv.157.2019.08.19.18.02.57; Mon, 19 Aug 2019 18:03:12 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728828AbfHTBCB (ORCPT + 99 others); Mon, 19 Aug 2019 21:02:01 -0400 Received: from mga18.intel.com ([134.134.136.126]:19894 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728682AbfHTBCB (ORCPT ); Mon, 19 Aug 2019 21:02:01 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Aug 2019 18:02:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,407,1559545200"; d="scan'208";a="180537314" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.41]) by orsmga003.jf.intel.com with ESMTP; 19 Aug 2019 18:02:00 -0700 Date: Mon, 19 Aug 2019 18:02:00 -0700 From: Sean Christopherson To: Yu-cheng Yu Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin Subject: Re: [PATCH v8 18/27] mm: Introduce do_mmap_locked() Message-ID: <20190820010200.GI1916@linux.intel.com> References: <20190813205225.12032-1-yu-cheng.yu@intel.com> <20190813205225.12032-19-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190813205225.12032-19-yu-cheng.yu@intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 13, 2019 at 01:52:16PM -0700, Yu-cheng Yu wrote: > There are a few places that need do_mmap() with mm->mmap_sem held. > Create an in-line function for that. > > Signed-off-by: Yu-cheng Yu > --- > include/linux/mm.h | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index bc58585014c9..275c385f53c6 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -2394,6 +2394,24 @@ static inline void mm_populate(unsigned long addr, unsigned long len) > static inline void mm_populate(unsigned long addr, unsigned long len) {} > #endif > > +static inline unsigned long do_mmap_locked(struct file *file, > + unsigned long addr, unsigned long len, unsigned long prot, > + unsigned long flags, vm_flags_t vm_flags, struct list_head *uf) > +{ > + struct mm_struct *mm = current->mm; > + unsigned long populate; > + > + down_write(&mm->mmap_sem); > + addr = do_mmap(file, addr, len, prot, flags, vm_flags, 0, > + &populate, uf); > + up_write(&mm->mmap_sem); > + > + if (populate) > + mm_populate(addr, populate); > + > + return addr; > +} Any reason not to put this in cet.c, as suggested by PeterZ? All of the calls from CET have identical params except for @len, e.g. you can add 'static unsigned long cet_mmap(unsigned long len)' and bury most of the copy-paste code in there. https://lkml.kernel.org/r/20190607074707.GD3463@hirez.programming.kicks-ass.net > + > /* These take the mm semaphore themselves */ > extern int __must_check vm_brk(unsigned long, unsigned long); > extern int __must_check vm_brk_flags(unsigned long, unsigned long, unsigned long); > -- > 2.17.1 >