From patchwork Mon Feb 24 20:30:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michel Lespinasse X-Patchwork-Id: 11401487 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 01DE914BC for ; Mon, 24 Feb 2020 20:31:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B582B20675 for ; Mon, 24 Feb 2020 20:31:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IyCGj3AQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B582B20675 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 C9D036B0032; Mon, 24 Feb 2020 15:31:08 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C4BAE6B006E; Mon, 24 Feb 2020 15:31:08 -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 B92266B0032; Mon, 24 Feb 2020 15:31:08 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0191.hostedemail.com [216.40.44.191]) by kanga.kvack.org (Postfix) with ESMTP id A19D56B0032 for ; Mon, 24 Feb 2020 15:31:08 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 54EB849961A for ; Mon, 24 Feb 2020 20:31:08 +0000 (UTC) X-FDA: 76526165016.09.snow92_26f999ab9d52a X-Spam-Summary: 2,0,0,3d59658ee711b53a,d41d8cd98f00b204,3ijjuxgykcdkrvgfzibjjbgz.xjhgdips-hhfqvxf.jmb@flex--walken.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:966:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1535:1544:1593:1594:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2693:3138:3139:3140:3141:3142:3152:3355:3865:3866:3867:3868:3870:3872:4118:4250:4321:4385:4605:5007:6119:6120:6261:6299:6653:7875:7901:7903:8660:9036:9969:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12555:12895:12986:13148:13230:13255:14096:14097:14181:14659:14721:21080:21212:21324:21433:21444:21451:21627:21795:21990:30003:30051:30054:30070,0,RBL:209.85.216.73:@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:23,LUA_SUMMARY:none X-HE-Tag: snow92_26f999ab9d52a X-Filterd-Recvd-Size: 7688 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Mon, 24 Feb 2020 20:31:07 +0000 (UTC) Received: by mail-pj1-f73.google.com with SMTP id 14so421437pjo.3 for ; Mon, 24 Feb 2020 12:31:07 -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=TRPcP8ChW7vMaa74wnx4GIN/tKOWrqScAtP9Wk80TE8=; b=IyCGj3AQPjbe5uNdxJdnipTn2TL/MKGp5lhJESWvDLzdoObnx1uXo6cTTij6XFHtxz 6p/bOLlc2q/W0/i5LwLBbMdAGyLEh47kf5RJ0k3uHtGkE+FRDvZb5BcMOjlYNUJBT7qu 7Sik4RhII6geCB0x/0L4XfUci64gTRBEV/8rzTYGrKhkZVqmZg9GVouTf36AnAs9jOKl wX70Mjtfdnx3gTx+qR/JJo+SmG0iUeOpJrby6UFM2zwFbYZOiqzhsRVC8dtc4I42Vbe6 MI4HupN9mmyzI1XV1vK5lWMxag9GhVyzA7V3cO0DVJBBzXBqOiBdvbjQIX0ys7VbO3yb amvQ== 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=TRPcP8ChW7vMaa74wnx4GIN/tKOWrqScAtP9Wk80TE8=; b=q3EgT0ek9ks9FcIwpP44jR8cFQPnZvLHU2nB1wnSIQBRa/ecbeEHM2l1Bjd5NfVimk Ya4FTBQBfHEJ3Ws/ZJLCgVG99ylkJdzIeK41d4Mkyl/VJOJNGQF1Zm2jBrNDeNyCX9jo bOkSh0YtrUEF3hn0Cp6YUJ1telfLOGDRYwOGjmI3aMtMRNZZ4CmqBS9oU2GpzqQTkyBc J2cW5c4L3Gw9yMCJeQS7gVhkvj4N77qSoX8A2bs0MEp2OWhMu4U2jckAexLY5RfVdrtP Hk5qWafcgZ+TtuLYjbZHR9XjmWc+xBhkPwh9jMrk4R7b0LHPsLGzf34kANt7aPCTkXI+ lvuQ== X-Gm-Message-State: APjAAAU3KYmOCi5hviSzTVXF7sP+CcC16WCL+iFbdRbIFbDRmSebWFju sf+ncuGEUhuO2dKypfL0gU75dYwMf2g= X-Google-Smtp-Source: APXvYqxHIPI8eQQKnkCy9jrtv1MuX1a5xxQRJDZcNzPikJGtbM2KldJtnPoLe4cpBBNNZjKWRSUNMjnZvNA= X-Received: by 2002:a63:e755:: with SMTP id j21mr54941973pgk.330.1582576266863; Mon, 24 Feb 2020 12:31:06 -0800 (PST) Date: Mon, 24 Feb 2020 12:30:36 -0800 In-Reply-To: <20200224203057.162467-1-walken@google.com> Message-Id: <20200224203057.162467-4-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 03/24] MM locking API: manual conversion of mmap_sem call sites missed by coccinelle 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: Convert the last few remaining mmap_sem rwsem calls to use the new MM 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 --- arch/mips/mm/fault.c | 10 +++++----- arch/x86/kvm/mmu/paging_tmpl.h | 8 ++++---- drivers/android/binder_alloc.c | 4 ++-- fs/proc/base.c | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git arch/mips/mm/fault.c arch/mips/mm/fault.c index 1e8d00793784..58cfc3f5f659 100644 --- arch/mips/mm/fault.c +++ 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); + mm_read_lock(mm); vma = find_vma(mm, address); if (!vma) goto bad_area; @@ -191,7 +191,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write, } } - up_read(&mm->mmap_sem); + mm_read_unlock(mm); return; /* @@ -199,7 +199,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); + mm_read_unlock(mm); bad_area_nosemaphore: /* User mode accesses just cause a SIGSEGV */ @@ -251,14 +251,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); + mm_read_unlock(mm); if (!user_mode(regs)) goto no_context; pagefault_out_of_memory(); return; do_sigbus: - up_read(&mm->mmap_sem); + mm_read_unlock(mm); /* Kernel mode? Handle exceptions or die */ if (!user_mode(regs)) diff --git arch/x86/kvm/mmu/paging_tmpl.h arch/x86/kvm/mmu/paging_tmpl.h index 97b21e7fd013..01b633e800b9 100644 --- arch/x86/kvm/mmu/paging_tmpl.h +++ arch/x86/kvm/mmu/paging_tmpl.h @@ -150,22 +150,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); + mm_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); + mm_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); + mm_read_unlock(current->mm); return -EFAULT; } ret = CMPXCHG(&table[index], orig_pte, new_pte); memunmap(table); - up_read(¤t->mm->mmap_sem); + mm_read_unlock(current->mm); } return (ret != orig_pte); diff --git drivers/android/binder_alloc.c drivers/android/binder_alloc.c index caddf155fcab..f607fa2d00c3 100644 --- drivers/android/binder_alloc.c +++ 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 (!mm_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); + mm_read_unlock(mm); mmput(mm); trace_binder_unmap_kernel_start(alloc, index); diff --git fs/proc/base.c fs/proc/base.c index 31c56a08af0f..33ab92802834 100644 --- fs/proc/base.c +++ fs/proc/base.c @@ -2189,7 +2189,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 = mm_read_lock_killable(mm); if (ret) { mmput(mm); goto out_put_task; @@ -2216,7 +2216,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); + mm_read_unlock(mm); mmput(mm); goto out_put_task; } @@ -2225,7 +2225,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); + mm_read_unlock(mm); mmput(mm); for (i = 0; i < nr_files; i++) {