Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1516371ybl; Tue, 13 Aug 2019 14:07:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxC6EEV5sfmE0a1PAdk15K7LKscV5dgZYfdQrsRM+Oz6l48RllBOAcSP9L1LzTbi1M2SmW8 X-Received: by 2002:a17:902:4643:: with SMTP id o61mr39256720pld.101.1565730444456; Tue, 13 Aug 2019 14:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730444; cv=none; d=google.com; s=arc-20160816; b=ZSlAuE7ecEOethF3rBKr00anmzkGmtYEx/dxuaSl29viFAUSIo8ku8dtqc9aXhz293 ZMq/hyJPdFKI7A+h9+yi8299oEvE8xEl/jNOcJijktBqvj1Nsrq4bgogQm/VnI+xKgH3 wR2slzjNoEDLRUSDU2MlZXvuIXiTUl8GMBUm6Z3CLPRSXYQNYe8kP466lA65ob11Sz2x VwhVrd7/mjKir5X+JeHihBMTrmROT78Tqq/d6pl1KqQyI1tMqfAAbejoVxbr/7FAiEv5 kXXK4LckRTxefejY4B0J/aKFyU9+wTQZkTCMPKguGZ+3pGboMt1seaF+ppFAnlztaIjM psYQ== 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=snL0hf6dn2O7aYSGQUCLQld/DPidPeD5acHhL5Q/A/E=; b=e1cn7EVL0JXsB2zgqCvkvjlI38+POQCC6Ii1CXddfG1lXKsHRPHy3uSxtafqTUuXBH cn+i5wXZIvCHnd+Ku76eV/qFY8NI80kO+CapQTiVzkAGwp7w79yRoKNibH+i5WfoEeso sKRho3DQ3LagyYvg8lOZ0mPQ/shO40BapUFI+uoD6T/HyvPkJBaX0Ulfsvw4HHsL/Aa6 aKlGmodwIlaeDVdj7Zs/Dirg9fitMSZGpUJut3Tak7ArR1rASnPtKhzJdbmYjRODfb7d 3yi1xRynFFTPxsp2KGTRRrHlzukXNaILxV4Wuk3PyMjKJ/fPAA3t21RivplAW3iIA9xV dIUQ== 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 b3si65017649pfa.89.2019.08.13.14.07.09; Tue, 13 Aug 2019 14:07:24 -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 S1727024AbfHMVFI (ORCPT + 99 others); Tue, 13 Aug 2019 17:05:08 -0400 Received: from mga06.intel.com ([134.134.136.31]:16076 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726819AbfHMVC6 (ORCPT ); Tue, 13 Aug 2019 17:02:58 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Aug 2019 14:02:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,382,1559545200"; d="scan'208";a="187901444" Received: from yyu32-desk1.sc.intel.com ([10.144.153.205]) by orsmga002.jf.intel.com with ESMTP; 13 Aug 2019 14:02:56 -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 , 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 , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin Cc: Yu-cheng Yu Subject: [PATCH v8 18/27] mm: Introduce do_mmap_locked() Date: Tue, 13 Aug 2019 13:52:16 -0700 Message-Id: <20190813205225.12032-19-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190813205225.12032-1-yu-cheng.yu@intel.com> References: <20190813205225.12032-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 bc58585014c9..275c385f53c6 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2394,6 +2394,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(struct file *file, + unsigned long addr, unsigned long len, unsigned long prot, + unsigned long flags, vm_flags_t vm_flags, struct list_head *uf) +{ + struct mm_struct *mm = current->mm; + unsigned long populate; + + down_write(&mm->mmap_sem); + addr = do_mmap(file, addr, len, prot, flags, vm_flags, 0, + &populate, uf); + 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