Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2316701imm; Thu, 11 Oct 2018 08:24:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV6237N/DcFRrAk9u7gGDewEEANNTO4PAiMMKCjxWy3K3rq7iEJePRnHG3oi8p+7oOYO6WGU8 X-Received: by 2002:a17:902:b90c:: with SMTP id bf12-v6mr2014268plb.259.1539271490229; Thu, 11 Oct 2018 08:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539271490; cv=none; d=google.com; s=arc-20160816; b=wRlpSRwTeFYEcBY32rONS/3QnNJ0szQ3bhifQFRN+qAuhxXggg6euUIwQ956wHfTA+ eJzkA7n0nsi/hFiYYqRYDMO38IXoDul4n5qt8hMk7bvGl2RIWzMnOOSyLJWx0hZxXfip tHXrhsxjEIRaovnHU7NhP/tiKkxY792s5bpbEMIS/2WLxU1Jm5DS3nTF9Jrllvbk9sve 1uGKJKGqSnUfCqHfnsYPQJk2nfq3BUv0Z6ioQR+TqpWUKIdrYzEOhYhJvN0O6Cej8pNl uwGukXimcMyb/OE0ekQRxlZ8FF20LlYvPODRKEx5Wlog8+imJCCMsHAlLt+i5lMTxvMP db2Q== 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=0PZbYToGLHKhMY6f2I+7PcGrhLgjeHE3A2EtpGQ9/js=; b=N2muHjEsZue3IedXDB8F7nNRRxDOAP0uVIE+AsrJLG05vbbkPd+buiaHwgtEGCNJeF qL9JuytycfHAiZm2gPafEPC8SO4vYv+ZLweS5ObLBLYdkcPdx+UxjsjlRaOutYW8pP/Q ZSdYPBImPu1y+lmZQ2LyyXkkGSPJGgOS9xvsRXqm0ztF2Z3A3pQaHAmMUhtLMvVeAM+k Azx3pfh1XSSvNz8tX/0FAOfrJHL368TQ/DwAbxYM0Rxh9zG6dQXxYu+HGzwjSOrUDyn2 M3dcoxl8metGMmUjT4quxnNh5I8U0z7R2/Wi5EwPuvsP8JG5b4HRCMMEX0uxW1jj+XEc 4KCw== 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 b11-v6si30351884plb.401.2018.10.11.08.24.35; Thu, 11 Oct 2018 08:24:50 -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 S1729046AbeJKWvJ (ORCPT + 99 others); Thu, 11 Oct 2018 18:51:09 -0400 Received: from mga05.intel.com ([192.55.52.43]:3984 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727503AbeJKWsZ (ORCPT ); Thu, 11 Oct 2018 18:48:25 -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 fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 08:20:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,368,1534834800"; d="scan'208";a="78019146" Received: from 2b52.sc.intel.com ([143.183.136.147]) by fmsmga008.fm.intel.com with ESMTP; 11 Oct 2018 08:20:46 -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 , 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 Cc: Yu-cheng Yu Subject: [PATCH v5 19/27] mm: Introduce do_mmap_locked() Date: Thu, 11 Oct 2018 08:15:15 -0700 Message-Id: <20181011151523.27101-20-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181011151523.27101-1-yu-cheng.yu@intel.com> References: <20181011151523.27101-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 f658923e76ad..de55f367852e 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