From patchwork Mon Feb 24 20:30:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 11401525 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 983A6924 for ; Mon, 24 Feb 2020 20:31:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5B50D20675 for ; Mon, 24 Feb 2020 20:31:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pzVAZkTU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B50D20675 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D5D1E6B00A7; Mon, 24 Feb 2020 15:31:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D14176B00A9; Mon, 24 Feb 2020 15:31:53 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B63FE6B00AA; Mon, 24 Feb 2020 15:31:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0155.hostedemail.com [216.40.44.155]) by kanga.kvack.org (Postfix) with ESMTP id 9B9D36B00A7 for ; Mon, 24 Feb 2020 15:31:53 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 57FC940C2 for ; Mon, 24 Feb 2020 20:31:53 +0000 (UTC) X-FDA: 76526166906.19.shade48_2d859656a5a55 X-Spam-Summary: 2,0,0,2e3f9a9e99e7dfb0,d41d8cd98f00b204,3tzjuxgykcgyaepoirksskpi.gsqpmryb-qqozego.svk@flex--walken.bounces.google.com,,RULES_HIT:2:41:69:152:355:379:541:800:960:968:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1535:1593:1594:1605:1606:1730:1747:1777:1792:2380:2393:2559:2562:3138:3139:3140:3141:3142:3152:3865:3867:3872:4119:4321:4605:5007:6120:6261:6653:7875:8603:8660:9592:9969:10004:11026:11233:11473:11658:11914:12043:12048:12296:12297:12438:12555:12679:12895:12986:13148:13230:14096:14097:14659:21080:21444:21451:21611:21627:21990:30051:30054:30070,0,RBL:209.85.214.202:@flex--walken.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: shade48_2d859656a5a55 X-Filterd-Recvd-Size: 8084 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Mon, 24 Feb 2020 20:31:52 +0000 (UTC) Received: by mail-pl1-f202.google.com with SMTP id r16so255623pls.5 for ; Mon, 24 Feb 2020 12:31:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=fuzp6eswaJuPdzdHbcnLCLrfHav7oGhP9sVuaGQei4U=; b=pzVAZkTUOAsbvscsdUWhMmdo3CPgBkEEMmSz2CS/ZiYzPlxC5q6w2b5Wi5TXA01t+N GDvBsTvcjyvSPbE9AZ/FW1OnNMry+g3+0FAhyOfuDbc9rp2STK1lnABFYZWMm3gDlQvs hyZksqAAiEoGLlmF+POqXv1gkFduWt+GW8ykvfy4Zxu1gEYKt3bJPATMwVwfIYVzctDC COGCO7hM7Ku0trVBF57Ba33RMEkN1nvUNqIq9tqKF4mF18lMnyt6VXKjgWc+r3THVeMo QT1Fu3hn9t44iL4pDF5GLtjNkZbrWxt00DIhKxw0sBPxA9iLn+zt/GTrGOE1eEFsnYzK K4XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=fuzp6eswaJuPdzdHbcnLCLrfHav7oGhP9sVuaGQei4U=; b=g6XB1JAONKHHIyzemV8D6okBjQWeppX7+nTSv0TWA8WA+llgNffRr7pPLrlEPJQVwL jX1u5oyKzdIhFNWxzecpp1Cqt+WB+3gOQuBI82wiBXj3bOgSvqq1JkELKMc7oALrfL7l fTkZ/HRQ7IVnGI6/VZAvxm/iMzEQ+Hqlu8s0ED3UUUonvugRx4geFJ2IupzuUpnY/9EC VkCwtLwfQd/vi+W1z/xBJR9mnPOuY6KFjXI18Hw7SUdC3+DrwErWPbWhOzKl8EDNb0Yf cfBtujil+FT+5xxlRd91XsCs1YPJMxONqYUWcAx5Oc3+3DkOXU6ENL/2nyNctybaJvtb 4ZYg== X-Gm-Message-State: APjAAAV/fdJNYFoSA9IPXaZLh/ftzaqbf0Lunj31LjGiYnR32Ia0JQIj oP49P7i1p7zbTRuIWhWXqMEEOeFpdWo= X-Google-Smtp-Source: APXvYqz6ie1qxAMuFdeUrNiIJKfn+75x/UR6P8vITuFXAnaydHQ/jMTs5w4syaCqB4af6cnDwKmI8Cs4w00= X-Received: by 2002:a63:7156:: with SMTP id b22mr52920654pgn.16.1582576311745; Mon, 24 Feb 2020 12:31:51 -0800 (PST) Date: Mon, 24 Feb 2020 12:30:54 -0800 In-Reply-To: <20200224203057.162467-1-walken@google.com> Message-Id: <20200224203057.162467-22-walken@google.com> Mime-Version: 1.0 References: <20200224203057.162467-1-walken@google.com> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog Subject: [RFC PATCH 21/24] do_mmap: add locked argument From: Michel Lespinasse To: Peter Zijlstra , Andrew Morton , Laurent Dufour , Vlastimil Babka , Matthew Wilcox , "Liam R . Howlett" , Jerome Glisse , Davidlohr Bueso , David Rientjes Cc: linux-mm , Michel Lespinasse X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Change the do_mmap() prototype to add a "locked" boolean argument. For now all call sites set it to true. Also remove the do_mmap_pgoff() API, which was just wrapping do_mmap() with a forced vm_flags == 0 argument. Signed-off-by: Michel Lespinasse --- arch/x86/mm/mpx.c | 3 ++- fs/aio.c | 6 +++--- include/linux/mm.h | 13 ++----------- ipc/shm.c | 3 ++- mm/mmap.c | 8 ++++---- mm/nommu.c | 1 + mm/util.c | 4 ++-- 7 files changed, 16 insertions(+), 22 deletions(-) diff --git arch/x86/mm/mpx.c arch/x86/mm/mpx.c index 3835c18020b8..f83cdf80f210 100644 --- arch/x86/mm/mpx.c +++ arch/x86/mm/mpx.c @@ -54,7 +54,8 @@ static unsigned long mpx_mmap(unsigned long len) mm_write_lock(mm); addr = do_mmap(NULL, 0, len, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE, VM_MPX, 0, &populate, NULL); + MAP_ANONYMOUS | MAP_PRIVATE, VM_MPX, 0, + true, &populate, NULL); mm_write_unlock(mm); if (populate) mm_populate(addr, populate); diff --git fs/aio.c fs/aio.c index 704766588df4..018bd24d6204 100644 --- fs/aio.c +++ fs/aio.c @@ -525,9 +525,9 @@ static int aio_setup_ring(struct kioctx *ctx, unsigned int nr_events) return -EINTR; } - ctx->mmap_base = do_mmap_pgoff(ctx->aio_ring_file, 0, ctx->mmap_size, - PROT_READ | PROT_WRITE, - MAP_SHARED, 0, &unused, NULL); + ctx->mmap_base = do_mmap(ctx->aio_ring_file, 0, ctx->mmap_size, + PROT_READ | PROT_WRITE, + MAP_SHARED, 0, 0, true, &unused, NULL); mm_write_unlock(mm); if (IS_ERR((void *)ctx->mmap_base)) { ctx->mmap_size = 0; diff --git include/linux/mm.h include/linux/mm.h index 28b6af200214..8427e1d07b59 100644 --- include/linux/mm.h +++ include/linux/mm.h @@ -2361,22 +2361,13 @@ extern unsigned long mmap_region(struct file *file, unsigned long addr, struct list_head *uf); extern unsigned long do_mmap(struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, - vm_flags_t vm_flags, unsigned long pgoff, unsigned long *populate, - struct list_head *uf); + vm_flags_t vm_flags, unsigned long pgoff, bool locked, + unsigned long *populate, struct list_head *uf); extern int __do_munmap(struct mm_struct *, unsigned long, size_t, struct list_head *uf, bool downgrade); extern int do_munmap(struct mm_struct *, unsigned long, size_t, struct list_head *uf); -static inline unsigned long -do_mmap_pgoff(struct file *file, unsigned long addr, - unsigned long len, unsigned long prot, unsigned long flags, - unsigned long pgoff, unsigned long *populate, - struct list_head *uf) -{ - return do_mmap(file, addr, len, prot, flags, 0, pgoff, populate, uf); -} - #ifdef CONFIG_MMU extern int __mm_populate(unsigned long addr, unsigned long len, int ignore_errors); diff --git ipc/shm.c ipc/shm.c index c04fc21cbe46..90d24c4960b9 100644 --- ipc/shm.c +++ ipc/shm.c @@ -1558,7 +1558,8 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, goto invalid; } - addr = do_mmap_pgoff(file, addr, size, prot, flags, 0, &populate, NULL); + addr = do_mmap(file, addr, size, prot, flags, 0, 0, + true, &populate, NULL); *raddr = addr; err = 0; if (IS_ERR_VALUE(addr)) diff --git mm/mmap.c mm/mmap.c index 0f95300c2788..2868e61927a1 100644 --- mm/mmap.c +++ mm/mmap.c @@ -1369,8 +1369,8 @@ static inline bool file_mmap_ok(struct file *file, struct inode *inode, unsigned long do_mmap(struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, vm_flags_t vm_flags, - unsigned long pgoff, unsigned long *populate, - struct list_head *uf) + unsigned long pgoff, bool locked, + unsigned long *populate, struct list_head *uf) { struct mm_struct *mm = current->mm; int pkey = 0; @@ -2954,8 +2954,8 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, } file = get_file(vma->vm_file); - ret = do_mmap_pgoff(vma->vm_file, start, size, - prot, flags, pgoff, &populate, NULL); + ret = do_mmap(vma->vm_file, start, size, + prot, flags, 0, pgoff, true, &populate, NULL); fput(file); out: mm_write_unlock(mm); diff --git mm/nommu.c mm/nommu.c index c137db1923bd..a2c2bf8d7676 100644 --- mm/nommu.c +++ mm/nommu.c @@ -1102,6 +1102,7 @@ unsigned long do_mmap(struct file *file, unsigned long prot, unsigned long flags, vm_flags_t vm_flags, + bool locked, unsigned long pgoff, unsigned long *populate, struct list_head *uf) diff --git mm/util.c mm/util.c index 511e442e7329..337b006aef6d 100644 --- mm/util.c +++ mm/util.c @@ -503,8 +503,8 @@ unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr, if (!ret) { if (mm_write_lock_killable(mm)) return -EINTR; - ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff, - &populate, &uf); + ret = do_mmap(file, addr, len, prot, flag, 0, pgoff, + true, &populate, &uf); mm_write_unlock(mm); userfaultfd_unmap_complete(mm, &uf); if (populate)