From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17E33C28CC3 for ; Fri, 7 Jun 2019 07:44:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E0BFF208C3 for ; Fri, 7 Jun 2019 07:44:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="1S7ljWD5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727873AbfFGHoY (ORCPT ); Fri, 7 Jun 2019 03:44:24 -0400 Received: from merlin.infradead.org ([205.233.59.134]:47308 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725497AbfFGHoX (ORCPT ); Fri, 7 Jun 2019 03:44:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JShvpN7WursRgWDXz41S2caRK10woHUgD4tuDRKgTsc=; b=1S7ljWD5ClCiKXft78kkDXYzu BR5E9SvvKZIxdJe1mhQhdLj/GwLRgpPtPTkqFWmg9yqjwQNhVjrPRSIeL/OoZlxczwx//D68q1XJs FfByu9/q4FNFB5MXMSXJOJgnvL+2AJsWyK9lsq/Ah8896IEYsL9RTqGpSzTSuB3kfr8fec3EzuxQ/ 65SeGDN5iK4k08dfXCNFi4ombF+WbCqRMUKIS3vXBM5VM3WBfBI8n3Yv55ZdItHAuZ42Kr9bR+wpr j2D8T94McWzfsRBDWW4DzC7eThiUDI9XwBhKlICynz4wC6UJFeY7+mKw6hOTG2CA3XB8AR1FgneV1 THzrvW5Mw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hZ9X3-0002X3-7w; Fri, 07 Jun 2019 07:43:25 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 394D5202CD6B2; Fri, 7 Jun 2019 09:43:22 +0200 (CEST) Date: Fri, 7 Jun 2019 09:43:22 +0200 From: Peter Zijlstra 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 , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin Subject: Re: [PATCH v7 18/27] mm: Introduce do_mmap_locked() Message-ID: <20190607074322.GP3419@hirez.programming.kicks-ass.net> References: <20190606200646.3951-1-yu-cheng.yu@intel.com> <20190606200646.3951-19-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190606200646.3951-19-yu-cheng.yu@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; > +}