Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp779350imm; Fri, 21 Sep 2018 08:10:31 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYGUYoHplmH3TfEHG3lf7qs9TyblFwfCl5IREJzmhkL6FfxuK676oHL5bWkVMUPnIzbWbkX X-Received: by 2002:a63:a319:: with SMTP id s25-v6mr40832958pge.199.1537542631099; Fri, 21 Sep 2018 08:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537542631; cv=none; d=google.com; s=arc-20160816; b=Lkz+4Yj/w0RdUvw2oT/qPZqy3MUoOX0jidlim6X9n0B9XRmK8bc5jiP9EU6Hgxn2N2 e4u1rJRVjUxLNCwmwZsuWPRstl8Nz3XXnHea5V2Wfk6cmrPu0EBveFUhumb4UzuG87ca Z318HQRgFU0ybpxePNyF/FC5rNyVw9SoWxJIDzznLe7wN+IQ6V2yWoPz0ErWAeGHnmmD XmKj/RmGFjerUOyqnhzzP0ZVJEj4VyeMBvV16Uhiy2nxZcjdvs+983efSS5bYyrmb+wf b7Ezdks8RQdsJPkJa3CXFbsSZrvm/ynwI2fAoAX/NRM3n+9ACsd2arQZtGwjtiunuryk lZBw== 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; bh=nuX3QM8HX4YtIzApwaJeEjWpSb/A/OxmLnTA/JbU0aQ=; b=Ce8Vv8F9/bM9dicg7HMD047Dh0uKktesTRlByoGRzyD4LVEdVJxA0uTRMbX+G9oqzF /BK2nfOXiqrbryazDezkhE0eJOkUj28JC/k79zozeHkZpDzZEcK6B0WHwL1Ty0005L79 u/nuNTuWJcVgWYjsLBks7KfbhXLZuZDdEXrLM4nwZgCRAnB4nsHLqYE6ch7VHwhOo3Kz b3M4HNEWB16Lat9dCMmdkS6qhkusfU1YL9cN7zVBTfo23BoTWSmug76bsyvs3pZ8GrBJ 6UK9e+X8oZFRHnX5wFOdG2Mm5+aG0ClMgk21Pksbalvg7bZ3si6ii0snE2pFMFc+duAH QiFw== 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 k11-v6si27726008pgi.328.2018.09.21.08.10.15; Fri, 21 Sep 2018 08:10:31 -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 S2390620AbeIUU6w (ORCPT + 99 others); Fri, 21 Sep 2018 16:58:52 -0400 Received: from mga05.intel.com ([192.55.52.43]:27306 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390456AbeIUU6J (ORCPT ); Fri, 21 Sep 2018 16:58:09 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2018 08:08:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,285,1534834800"; d="scan'208";a="71856580" Received: from 2b52.sc.intel.com ([143.183.136.51]) by fmsmga007.fm.intel.com with ESMTP; 21 Sep 2018 08:08:50 -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 , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue Cc: Yu-cheng Yu Subject: [RFC PATCH v4 17/27] mm: Introduce do_mmap_locked() Date: Fri, 21 Sep 2018 08:03:41 -0700 Message-Id: <20180921150351.20898-18-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921150351.20898-1-yu-cheng.yu@intel.com> References: <20180921150351.20898-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