Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp38328imm; Thu, 30 Aug 2018 07:49:43 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ8mBzxYS5ZaSajzfX1e4T+QTFQ3Y2GO8ibP+d7dnfhlP6Svyc+DqZVEANkwm//p6jtdjq6 X-Received: by 2002:a17:902:9a01:: with SMTP id v1-v6mr10520619plp.20.1535640583586; Thu, 30 Aug 2018 07:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535640583; cv=none; d=google.com; s=arc-20160816; b=p32p2POVoBLY1pCX7tW9lP0NmvOpr1sGCb20VU2Bu4Wsc/UP65Kd4W9Q1QiS0MW0dC FTL44pZf3aWoIxVzj8XRCLbfVJrXpzNq2j1jnfWK+g3eDG9dcYdty+0Ig8YULVpPLc+p 6G94u4Sq9D6oToDJRyfsAHFDbPsZBHfZ9X5RPxVE9EmAPiPo5F1Az2/+dYE4pmTfb4vc 4JqjLRCqBJX87mhp83fpr6XK6l/uHxhP6yY3YVFI1FcYbrNv3o/+0k9w5FD+ZZ2eeXHO yxKujgLpiKxI8Xxi8WM3agh1QNz7HbL5g5XKMWxbI9A9u4rd0/a+gTRW6/KW2kSRt+jc vddQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=nuX3QM8HX4YtIzApwaJeEjWpSb/A/OxmLnTA/JbU0aQ=; b=aVWFDPV5dVPWXj9gR58JP13+7GhQkO0BMZHbzTy3BLvfqP8q0+pv/RjC4kapvV7W4q okwFkOGymROKEJ1v1fBJxbk8+4/cILrAn8xxlbeLksTlCzsc7/PSuwp7f8gzR7V9GlIZ K+PbHf8I19XUHh3PcdUnxkGcQGers4BqYvaFj/ArWUSLnBOHH5nhjRprjjL6qZX0o0nr vvpVzOk1h8qOL7jAJAepCtxqTPWl+kNpWozKc9oSa8grp1aTRr3Ozr+UpxAq9EqjtEv+ voR1e/yHgTFAIIQEwqe7BVj0RbMvoiDF6aqDdWAMgKqeY6yt4HExfjJxv3iif7lM9GKC VvYg== 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 n8-v6si6750624pgl.101.2018.08.30.07.49.28; Thu, 30 Aug 2018 07:49:43 -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 S1729920AbeH3Ssw (ORCPT + 99 others); Thu, 30 Aug 2018 14:48:52 -0400 Received: from mga01.intel.com ([192.55.52.88]:38430 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729578AbeH3SqS (ORCPT ); Thu, 30 Aug 2018 14:46:18 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Aug 2018 07:43:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,307,1531810800"; d="scan'208";a="67186721" Received: from 2b52.sc.intel.com ([143.183.136.52]) by fmsmga008.fm.intel.com with ESMTP; 30 Aug 2018 07:43:42 -0700 From: Yu-cheng Yu To: 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 , Cyrill Gorcunov , Dave Hansen , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , "Ravi V. Shankar" , Vedvyas Shanbhogue Cc: Yu-cheng Yu Subject: [RFC PATCH v3 17/24] mm: Introduce do_mmap_locked() Date: Thu, 30 Aug 2018 07:38:57 -0700 Message-Id: <20180830143904.3168-18-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180830143904.3168-1-yu-cheng.yu@intel.com> References: <20180830143904.3168-1-yu-cheng.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 f40387ecd920..c4cc07baccda 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2318,6 +2318,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); + up_write(&mm->mmap_sem); + + if (populate) + mm_populate(addr, populate); + + return addr; +} + /* 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