From patchwork Wed Apr 22 00:14:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 11502551 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 4CDD114DD for ; Wed, 22 Apr 2020 00:14:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0B2F320575 for ; Wed, 22 Apr 2020 00:14:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JWU5WHFa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B2F320575 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 BA7608E000A; Tue, 21 Apr 2020 20:14:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B7F818E0003; Tue, 21 Apr 2020 20:14:38 -0400 (EDT) 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 A449B8E000A; Tue, 21 Apr 2020 20:14:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0003.hostedemail.com [216.40.44.3]) by kanga.kvack.org (Postfix) with ESMTP id 8D5278E0003 for ; Tue, 21 Apr 2020 20:14:38 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 46C08181AEF1E for ; Wed, 22 Apr 2020 00:14:38 +0000 (UTC) X-FDA: 76733569836.30.robin72_45886f86c0c39 X-Spam-Summary: 2,0,0,ba52f23e7dc0700b,d41d8cd98f00b204,3biyfxgykcp01fqpjslttlqj.htrqnsz2-rrp0fhp.twl@flex--walken.bounces.google.com,,RULES_HIT:2:41:152:355:379:541:800:960:966:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1535:1593:1594:1605:1606:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2693:3138:3139:3140:3141:3142:3152:3865:3866:3867:3868:3870:3872:4119:4250:4321:4385:4605:5007:6119:6261:6299:6653:6742:7901:7903:8660:9036:9969:10004:11026:11473:11657:11658:11914:12043:12296:12297:12438:12555:12895:12986:13148:13230:13255:14096:14097:14394:14659:21080:21212:21324:21433:21444:21451:21627:21795:21990:30003:30051:30054:30064:30070,0,RBL:209.85.215.201:@flex--walken.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.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:24,LUA_SUMMARY:none X-HE-Tag: robin72_45886f86c0c39 X-Filterd-Recvd-Size: 8594 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Wed, 22 Apr 2020 00:14:37 +0000 (UTC) Received: by mail-pg1-f201.google.com with SMTP id 71so192230pgg.23 for ; Tue, 21 Apr 2020 17:14:37 -0700 (PDT) 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=8FnslH4tR73JosMxXTOPIZuRsegD1R4BjGmc4H1Efbk=; b=JWU5WHFaC45VBv/xrFjMK7OwdpuKWWSegf6NvVAZ6UEABOcKKTcG2oQcKQGx/5Q0dG C41bjPBmBF80jU5649PBGjRPBEEtWj4mRcBSpdiZq0DbZECJjSJR/v/0rc2ML/GcR6br EibBNdDZg9sUGT5UYh1Lq8a7SegYBt6HJvouDcBnHNy0NimkjP3UYjzMnczDDXQgoJsO wXZ7hEbZVKEph3QVNLNxW/oBEXPqiJ+WVJbn46jHkKLvZbh+eA1O+rcBeCW7jTXpQYwD 48CwqB//5AWQ6M0hRZ9VQ/MpalnRFOQ7Hr3MGNwHVu0osB544qPIfo7USYhnP40RziD2 VPkQ== 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=8FnslH4tR73JosMxXTOPIZuRsegD1R4BjGmc4H1Efbk=; b=NNUxuFiLGwz3BzbHsCTE9IcWtqbGzTEafoCmqecRo63LFRFeX711GWBgy8xOMd8nId YVyNeyBCTu7EV/DBAJONhNOj+nPg/38+eT596SOindXiLEIX2DO5QCzK7e5p/uc5QhX6 Su8OXFEOQVXndcVjaTR93HRG/XJ1cMk+kFnmDZ5tvsY+f+f2brx3SlY8zzO+p+M4aUtD QBGSEl5omjW6XQJ57jqHvYD6U3Xdjgu/ACRDLq1IMwW2mXejul51YzePM4W1kgXV/S5b JfJQdoyEYzDt7s1rA73OTxquMjSUSnK3e/UuihxDnHmtk+zCEeire24DQaGtncwKP4TR MfQQ== X-Gm-Message-State: AGi0PuaDonWJQZYlmXRyVNK29AKXnI9WWZVsiyoqjnKHbeEwiNjUinAL mTj7a4w3IMoOom7rdCVVk618M4EjP7s= X-Google-Smtp-Source: APiQypIBKQRhS5e8bQazNSaQQz7nGVHZINlqTrrBi2XxI6F8bbYraDwiumiKajFnM935JXcNODoWe9B04m0= X-Received: by 2002:a17:90b:3444:: with SMTP id lj4mr8239893pjb.37.1587514476777; Tue, 21 Apr 2020 17:14:36 -0700 (PDT) Date: Tue, 21 Apr 2020 17:14:17 -0700 In-Reply-To: <20200422001422.232330-1-walken@google.com> Message-Id: <20200422001422.232330-6-walken@google.com> Mime-Version: 1.0 References: <20200422001422.232330-1-walken@google.com> X-Mailer: git-send-email 2.26.1.301.g55bc3eb7cb9-goog Subject: [PATCH v5 05/10] mmap locking API: convert mmap_sem call sites missed by coccinelle From: Michel Lespinasse To: Andrew Morton , linux-mm Cc: LKML , Peter Zijlstra , Laurent Dufour , Vlastimil Babka , Matthew Wilcox , Liam Howlett , Jerome Glisse , Davidlohr Bueso , David Rientjes , Hugh Dickins , Ying Han , Jason Gunthorpe , Daniel Jordan , 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: Convert the last few remaining mmap_sem rwsem calls to use the new mmap locking API. These were missed by coccinelle for some reason (I think coccinelle does not support some of the preprocessor constructs in these files ?) Signed-off-by: Michel Lespinasse Reviewed-by: Daniel Jordan Reviewed-by: Vlastimil Babka Reviewed-by: Laurent Dufour --- arch/mips/mm/fault.c | 10 +++++----- arch/riscv/mm/pageattr.c | 4 ++-- arch/x86/kvm/mmu/paging_tmpl.h | 8 ++++---- drivers/android/binder_alloc.c | 4 ++-- fs/proc/base.c | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c index f8d62cd83b36..9ef2dd39111e 100644 --- a/arch/mips/mm/fault.c +++ b/arch/mips/mm/fault.c @@ -97,7 +97,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write, if (user_mode(regs)) flags |= FAULT_FLAG_USER; retry: - down_read(&mm->mmap_sem); + mmap_read_lock(mm); vma = find_vma(mm, address); if (!vma) goto bad_area; @@ -190,7 +190,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write, } } - up_read(&mm->mmap_sem); + mmap_read_unlock(mm); return; /* @@ -198,7 +198,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write, * Fix it, but check if it's kernel or user first.. */ bad_area: - up_read(&mm->mmap_sem); + mmap_read_unlock(mm); bad_area_nosemaphore: /* User mode accesses just cause a SIGSEGV */ @@ -250,14 +250,14 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write, * We ran out of memory, call the OOM killer, and return the userspace * (which will retry the fault, or kill us if we got oom-killed). */ - up_read(&mm->mmap_sem); + mmap_read_unlock(mm); if (!user_mode(regs)) goto no_context; pagefault_out_of_memory(); return; do_sigbus: - up_read(&mm->mmap_sem); + mmap_read_unlock(mm); /* Kernel mode? Handle exceptions or die */ if (!user_mode(regs)) diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c index 728759eb530a..b9072c043222 100644 --- a/arch/riscv/mm/pageattr.c +++ b/arch/riscv/mm/pageattr.c @@ -117,10 +117,10 @@ static int __set_memory(unsigned long addr, int numpages, pgprot_t set_mask, if (!numpages) return 0; - down_read(&init_mm.mmap_sem); + mmap_read_lock(&init_mm); ret = walk_page_range_novma(&init_mm, start, end, &pageattr_ops, NULL, &masks); - up_read(&init_mm.mmap_sem); + mmap_read_unlock(&init_mm); flush_tlb_kernel_range(start, end); diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h index 9bdf9b7d9a96..40e5bb67cc09 100644 --- a/arch/x86/kvm/mmu/paging_tmpl.h +++ b/arch/x86/kvm/mmu/paging_tmpl.h @@ -165,22 +165,22 @@ static int FNAME(cmpxchg_gpte)(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long pfn; unsigned long paddr; - down_read(¤t->mm->mmap_sem); + mmap_read_lock(current->mm); vma = find_vma_intersection(current->mm, vaddr, vaddr + PAGE_SIZE); if (!vma || !(vma->vm_flags & VM_PFNMAP)) { - up_read(¤t->mm->mmap_sem); + mmap_read_unlock(current->mm); return -EFAULT; } pfn = ((vaddr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; paddr = pfn << PAGE_SHIFT; table = memremap(paddr, PAGE_SIZE, MEMREMAP_WB); if (!table) { - up_read(¤t->mm->mmap_sem); + mmap_read_unlock(current->mm); return -EFAULT; } ret = CMPXCHG(&table[index], orig_pte, new_pte); memunmap(table); - up_read(¤t->mm->mmap_sem); + mmap_read_unlock(current->mm); } return (ret != orig_pte); diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c index 5e063739a3a8..cbdc43ed0f9f 100644 --- a/drivers/android/binder_alloc.c +++ b/drivers/android/binder_alloc.c @@ -932,7 +932,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item, mm = alloc->vma_vm_mm; if (!mmget_not_zero(mm)) goto err_mmget; - if (!down_read_trylock(&mm->mmap_sem)) + if (!mmap_read_trylock(mm)) goto err_down_read_mmap_sem_failed; vma = binder_alloc_get_vma(alloc); @@ -946,7 +946,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item, trace_binder_unmap_user_end(alloc, index); } - up_read(&mm->mmap_sem); + mmap_read_unlock(mm); mmput(mm); trace_binder_unmap_kernel_start(alloc, index); diff --git a/fs/proc/base.c b/fs/proc/base.c index 8fff3c955530..ebb356434652 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2314,7 +2314,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx) if (!mm) goto out_put_task; - ret = down_read_killable(&mm->mmap_sem); + ret = mmap_read_lock_killable(mm); if (ret) { mmput(mm); goto out_put_task; @@ -2341,7 +2341,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx) p = genradix_ptr_alloc(&fa, nr_files++, GFP_KERNEL); if (!p) { ret = -ENOMEM; - up_read(&mm->mmap_sem); + mmap_read_unlock(mm); mmput(mm); goto out_put_task; } @@ -2350,7 +2350,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx) p->end = vma->vm_end; p->mode = vma->vm_file->f_mode; } - up_read(&mm->mmap_sem); + mmap_read_unlock(mm); mmput(mm); for (i = 0; i < nr_files; i++) {