Received: by 10.223.176.5 with SMTP id f5csp1991219wra; Sun, 4 Feb 2018 17:37:00 -0800 (PST) X-Google-Smtp-Source: AH8x226j7zIHdFF72cE4divhRTlG1L3DDG4vd1cCGryJbMXlVVf24sALRStBlW5mMzhl+y9umN6M X-Received: by 2002:a17:902:4523:: with SMTP id m32-v6mr33883939pld.449.1517794620484; Sun, 04 Feb 2018 17:37:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517794620; cv=none; d=google.com; s=arc-20160816; b=Q1z8nNzsr657lAB7HT0N4zPU9PrIjzx0OT73icWlZFLjJg5H2o0CUCVX52ezMhip3L qiajyJpC08hFcNgYNRW8x/FtMdKAfLRqbCT9WTR+93GpF0Z8mNzvDZ91QDU2zpyc8QnH evEZLWRguMiK3zrYxud4iKzCS7FWMB0eJV5ZkCEYMJd3Xv6sPkC5C8TFdNhAk6mzIUI2 961JAVoBTYhX5gR9xGkUpYoQCAiBsdV0m/Ibb9YtgpKhZ/GSLKKsz4KcsZYaSAntf5rv tdHCuRbAhms/2ytyJlv5k6Ab+X5gnMjBnZ6XUqYVSmxwqskfbvPyneRIjKQXhxOtbUbX haUA== 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:arc-authentication-results; bh=kdR0K4hr8vjcgl3gxsTh8m9rp5ah0gYaMAhyxI0HJUc=; b=fLNPxZq/C0FiDSRtVWrJ1ETKZjGGG4KZUVkIWFrxaCSqKLNxV4B9T5NWFP587vWdqc aKLKWvwn7arwlRqPe31XST5q8AUz4bbogxL7vtBIxiDt67KsUa5WQKKiwQkzezKmTumH ebqPPvKMbqgqVXpvk+BnDHzF9PXibaZfPu5K0P+NmpP04vPsCfVGbqow5WfYWJsbE6uY V61NBONxM4DM9KxWHs0Knozu2dIrQXRRsNMDno+Ox+q1cqrXUMM/FtU1fDe8LbB00vph BQEkHXlQjMqT8y2iqK17CUihBskDkitrYjL2CL0IuuwgvZWnVv0fT++ucayoCdGspcj5 ntIA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si2356892pge.396.2018.02.04.17.36.46; Sun, 04 Feb 2018 17:37:00 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752889AbeBEBel (ORCPT + 99 others); Sun, 4 Feb 2018 20:34:41 -0500 Received: from mx2.suse.de ([195.135.220.15]:43856 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752606AbeBEB3O (ORCPT ); Sun, 4 Feb 2018 20:29:14 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5D618AE16; Mon, 5 Feb 2018 01:28:01 +0000 (UTC) From: Davidlohr Bueso To: akpm@linux-foundation.org, mingo@kernel.org Cc: peterz@infradead.org, ldufour@linux.vnet.ibm.com, jack@suse.cz, mhocko@kernel.org, kirill.shutemov@linux.intel.com, mawilcox@microsoft.com, mgorman@techsingularity.net, dave@stgolabs.net, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: [PATCH 36/64] arch/mips: use mm locking wrappers Date: Mon, 5 Feb 2018 02:27:26 +0100 Message-Id: <20180205012754.23615-37-dbueso@wotan.suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180205012754.23615-1-dbueso@wotan.suse.de> References: <20180205012754.23615-1-dbueso@wotan.suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Davidlohr Bueso This becomes quite straightforward with the mmrange in place. Signed-off-by: Davidlohr Bueso --- arch/mips/kernel/traps.c | 5 +++-- arch/mips/kernel/vdso.c | 4 ++-- arch/mips/mm/c-octeon.c | 5 +++-- arch/mips/mm/c-r4k.c | 5 +++-- arch/mips/mm/fault.c | 10 +++++----- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 0ae4a731cc12..a7d1d2417844 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -746,6 +746,7 @@ int process_fpemu_return(int sig, void __user *fault_addr, unsigned long fcr31) { struct siginfo si; struct vm_area_struct *vma; + DEFINE_RANGE_LOCK_FULL(mmrange); clear_siginfo(&si); switch (sig) { @@ -766,13 +767,13 @@ int process_fpemu_return(int sig, void __user *fault_addr, unsigned long fcr31) case SIGSEGV: si.si_addr = fault_addr; si.si_signo = sig; - down_read(¤t->mm->mmap_sem); + mm_read_lock(current->mm, &mmrange); vma = find_vma(current->mm, (unsigned long)fault_addr); if (vma && (vma->vm_start <= (unsigned long)fault_addr)) si.si_code = SEGV_ACCERR; else si.si_code = SEGV_MAPERR; - up_read(¤t->mm->mmap_sem); + mm_read_unlock(current->mm, &mmrange); force_sig_info(sig, &si, current); return 1; diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c index 56b7c29991db..beaf63864e70 100644 --- a/arch/mips/kernel/vdso.c +++ b/arch/mips/kernel/vdso.c @@ -104,7 +104,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) int ret; DEFINE_RANGE_LOCK_FULL(mmrange); - if (down_write_killable(&mm->mmap_sem)) + if (mm_write_lock_killable(mm, &mmrange)) return -EINTR; /* Map delay slot emulation page */ @@ -177,6 +177,6 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) ret = 0; out: - up_write(&mm->mmap_sem); + mm_write_unlock(mm, &mmrange); return ret; } diff --git a/arch/mips/mm/c-octeon.c b/arch/mips/mm/c-octeon.c index 0e45b061e514..e4f6db4a8755 100644 --- a/arch/mips/mm/c-octeon.c +++ b/arch/mips/mm/c-octeon.c @@ -136,11 +136,12 @@ static void octeon_flush_icache_range(unsigned long start, unsigned long end) static void octeon_flush_cache_sigtramp(unsigned long addr) { struct vm_area_struct *vma; + DEFINE_RANGE_LOCK_FULL(mmrange); - down_read(¤t->mm->mmap_sem); + mm_read_lock(current->mm, &mmrange); vma = find_vma(current->mm, addr); octeon_flush_icache_all_cores(vma); - up_read(¤t->mm->mmap_sem); + mm_read_unlock(current->mm, &mmrange); } diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index 6f534b209971..7f9c9c91dbc1 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c @@ -999,8 +999,9 @@ static void r4k_flush_cache_sigtramp(unsigned long addr) { struct flush_cache_sigtramp_args args; int npages; + DEFINE_RANGE_LOCK_FULL(mmrange); - down_read(¤t->mm->mmap_sem); + mm_read_lock(current->mm, &mmrange); npages = get_user_pages_fast(addr, 1, 0, &args.page); if (npages < 1) @@ -1013,7 +1014,7 @@ static void r4k_flush_cache_sigtramp(unsigned long addr) put_page(args.page); out: - up_read(¤t->mm->mmap_sem); + mm_read_unlock(current->mm, &mmrange); } static void r4k_flush_icache_all(void) diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c index 1433edd01d09..510abb6b433a 100644 --- a/arch/mips/mm/fault.c +++ b/arch/mips/mm/fault.c @@ -98,7 +98,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, &mmrange); vma = find_vma(mm, address); if (!vma) goto bad_area; @@ -192,7 +192,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write, } } - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); return; /* @@ -200,7 +200,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, &mmrange); bad_area_nosemaphore: /* User mode accesses just cause a SIGSEGV */ @@ -256,14 +256,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, &mmrange); if (!user_mode(regs)) goto no_context; pagefault_out_of_memory(); return; do_sigbus: - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); /* Kernel mode? Handle exceptions or die */ if (!user_mode(regs)) -- 2.13.6