Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp144497ybz; Tue, 21 Apr 2020 17:16:10 -0700 (PDT) X-Google-Smtp-Source: APiQypIfT4zFbS1v9UQ79P926b3h4CZM9nux75zAfFruGFX3a2/SBi4Tx2Bwms11qU+zuWcQp4sS X-Received: by 2002:a17:907:1199:: with SMTP id uz25mr23646947ejb.131.1587514570540; Tue, 21 Apr 2020 17:16:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587514570; cv=none; d=google.com; s=arc-20160816; b=It4w/9wZHuAOR0G5I9iIn9BmJ6/b+7eERDLuYw+6XYHuk8DL0MX3qmJcToOv5ubvRx mgB6TxZrQr0d78BfTLZ+fqwYzzQziAdx14dZYZG5yRJ0ItK9bNZ+Tw3uKbjMExWpCKjS jjdA+9BMvu2XywsCsfNBreOuuRpO/PQV5EMZMEVJNqtaWDsiMTrrssyY7FEmU9eNo/OG jFdp5Fh8N+OiQg36qFk9iy+nohIgAhJOG4YQPyim7SX/K0G0oxC0uAOfHu6axTGSXZU6 CpN1YXbkc28i79+lfPmqEwFyDpfTo5nOzjKcX4O9Rp56MZts+lKI4knRqSJYx2NfZKHk US5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=8FnslH4tR73JosMxXTOPIZuRsegD1R4BjGmc4H1Efbk=; b=zaZ38g3YBjmPCaP5rzGIQsoszJtOw+SfAIM2inEFhkf6goAu5OXR5xI7Gv7aiAqO/W fYnJPj8+ZYO3T6WE/OB3A4d5KVRshalsl+Xl2N7/TRX4DD3BuPtweBBlnujhv0DTarEA bEtu9LvC6jikhxOY+wkNcmnoERm9Hw6vpjjCU9lf2P/PqSe7d4eD1vbaPL1Ji6HGiCRg 49Kmyno7tDxZKfiYT6LwO6GKaB//MBT6r7kBVXeoM9zpzVk/ME6ir2fsFOP+u5II6dmQ WDJ79di4yvTcG6N/H113fTWKpyKpnQUy29BMEZj93o8H8aK8X5tb/0hTI/StxJgT7Q0B 0XTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JWU5WHFa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn21si2981850ejc.379.2020.04.21.17.15.47; Tue, 21 Apr 2020 17:16:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JWU5WHFa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726424AbgDVAOk (ORCPT + 99 others); Tue, 21 Apr 2020 20:14:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726409AbgDVAOh (ORCPT ); Tue, 21 Apr 2020 20:14:37 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58D58C061BD3 for ; Tue, 21 Apr 2020 17:14:37 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id j21so209699pgh.12 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=Ry61/s5wKJz5ss3SC6FcBE3LlaDJlKrFQdCz1WlL6/UwgtTtsoRft7vAAkXZHAv8B7 NC5r1W3zoRHHnigmJh099mNV8tzdEwCpu9YEN1zCW7IDFlh17V8MjRztcntgM1S7wTfE nodarDziSD1r5CXmWFRUwEe4qwbMW7Rfer0q72LQwA/KAUbIzigdtErZuAc38hTh0FrR 0kdcJrJgRh9pA5NPYhBW1yC3I+1d6J5OV0wv9LCvSidgs1wtgNus/FigS1mzLCRccZ6B 14uiMF39yuEeSnaob/fzkykNzupUpIlcqP/ePIqllGpCtGPCW+Jb+fbV1HejVEL7I6qe Cpow== X-Gm-Message-State: AGi0PuZTr/C+xKIxAVDXEVDiL/htWARDh/WvCFOMUkTsNUpV41oLgcGu bIiiytU+O1YWsPQlviiOJKYEjCLar8U= 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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++) { -- 2.26.1.301.g55bc3eb7cb9-goog