From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on archive.lwn.net X-Spam-Level: X-Spam-Status: No, score=-6.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by archive.lwn.net (Postfix) with ESMTP id 0AECC7D926 for ; Fri, 7 Jun 2019 16:24:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730243AbfFGQY3 (ORCPT ); Fri, 7 Jun 2019 12:24:29 -0400 Received: from mga03.intel.com ([134.134.136.65]:24376 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730446AbfFGQY3 (ORCPT ); Fri, 7 Jun 2019 12:24:29 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2019 09:24:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,563,1557212400"; d="scan'208";a="182719826" Received: from yyu32-desk1.sc.intel.com ([143.183.136.147]) by fmsmga002.fm.intel.com with ESMTP; 07 Jun 2019 09:24:27 -0700 Message-ID: Subject: Re: [PATCH v7 18/27] mm: Introduce do_mmap_locked() From: Yu-cheng Yu To: Peter Zijlstra 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 , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin Date: Fri, 07 Jun 2019 09:16:26 -0700 In-Reply-To: <20190607074707.GD3463@hirez.programming.kicks-ass.net> References: <20190606200646.3951-1-yu-cheng.yu@intel.com> <20190606200646.3951-19-yu-cheng.yu@intel.com> <20190607074322.GP3419@hirez.programming.kicks-ass.net> <20190607074707.GD3463@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Fri, 2019-06-07 at 09:47 +0200, Peter Zijlstra wrote: > On Fri, Jun 07, 2019 at 09:43:22AM +0200, Peter Zijlstra wrote: > > On Thu, Jun 06, 2019 at 01:06:37PM -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 398f1e1c35e5..7cf014604848 100644 > > > --- a/include/linux/mm.h > > > +++ b/include/linux/mm.h > > > @@ -2411,6 +2411,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(unsigned long addr, > > > + unsigned long len, unsigned long prot, unsigned long flags, > > > + vm_flags_t vm_flags) > > > +{ > > > + struct mm_struct *mm = current->mm; > > > + unsigned long populate; > > > + > > > + down_write(&mm->mmap_sem); > > > + addr = do_mmap(NULL, addr, len, prot, flags, vm_flags, 0, > > > + &populate, NULL); > > > > Funny thing how do_mmap() takes a file pointer as first argument and > > this thing explicitly NULLs that. That more or less invalidates the name > > do_mmap_locked(). > > > > > + up_write(&mm->mmap_sem); > > > + > > > + if (populate) > > > + mm_populate(addr, populate); > > > + > > > + return addr; > > > +} > > You also don't retain that last @uf argument. > > I'm thikning you're better off adding a helper to the cet.c file; call > it cet_mmap() or whatever. Ok, I will fix that. Yu-cheng