Received: by 10.223.176.5 with SMTP id f5csp1993635wra; Sun, 4 Feb 2018 17:41:15 -0800 (PST) X-Google-Smtp-Source: AH8x225gMS7f+2V7Y3WXPgwss1BOswDahaWnMgy0kenRj8tGG3j3Y/CPz2VL5zT9kk5ZtJNZ/y8f X-Received: by 10.99.53.203 with SMTP id c194mr30129144pga.12.1517794874937; Sun, 04 Feb 2018 17:41:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517794874; cv=none; d=google.com; s=arc-20160816; b=lVkZycaxDITs4xIrxTD6zMOzGRvNXQcYdlOpzWhfomRRC8da3bBddj1j/KTj7DeSbR moOhZzsA034ypIlHRTVepDwxalObxIK4vYg+J6degmn5wzy29D+niq1h7VEUCY+n8KT/ d+Gn4UK8/BjcWfj2UzbVZHimgcCmD6EaL34IOn5pSVcSjphNX7+X5F9hf04XH695iz7H 5g8WJAUxNM8ZC8UUyBILrFXzop1As4afOR9iJQubluGP2dFqNrwBjESzVX022q94YlbC p8XHlxlviNB0iW1elQKqEv1Ujz8tPYW0pQfm2k7+N3wwzIYGtkO98EYOO4OyLhmYWddL 4VCg== 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=Y1Bm5my+1Y8zHc2KIp8VHFH0Ste7wejVawTtwiHYELY=; b=W48d/cUr8+iDHLj/7czYJYKhk2z6mlKj/raBvhiMBWTumjMqaZDaWjTcP8aGa1cxEL l3nxIqMk87HvH7wEgLxzLW+/ymaECet5VYOC2Cev+nxDpuNsl0icbmRwTcROU5DHFr9T VE8/1wko8u6KXjch2VudAmgclAbq0IkstBm7y+xplaKrfPh9ZQkHEI+i/ToJ17fiUCHY 5Siq1lC2rPihLL1xLSSqYyOx0q9xXLN12onqIuDFyMYQ/RluudtmcJ9VYFENU2XpyoKr PQcNdlU3udbEgvuqPKRSlRoqmRHKiUO2g+eR2rvxQoSzref0r6/ENRbve9PM5lFz0WBW lqSQ== 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 x16-v6si6238491pll.736.2018.02.04.17.41.00; Sun, 04 Feb 2018 17:41:14 -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 S1752712AbeBEBit (ORCPT + 99 others); Sun, 4 Feb 2018 20:38:49 -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 S1752719AbeBEB2a (ORCPT ); Sun, 4 Feb 2018 20:28:30 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A935AADFD; Mon, 5 Feb 2018 01:28:00 +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 31/64] arch/sparc: use mm locking wrappers Date: Mon, 5 Feb 2018 02:27:21 +0100 Message-Id: <20180205012754.23615-32-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/sparc/mm/fault_32.c | 18 +++++++++--------- arch/sparc/mm/fault_64.c | 12 ++++++------ arch/sparc/vdso/vma.c | 5 +++-- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c index ebb2406dbe7c..1f63a37b6f81 100644 --- a/arch/sparc/mm/fault_32.c +++ b/arch/sparc/mm/fault_32.c @@ -204,7 +204,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); retry: - down_read(&mm->mmap_sem); + mm_read_lock(mm, &mmrange); if (!from_user && address >= PAGE_OFFSET) goto bad_area; @@ -281,7 +281,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, } } - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); return; /* @@ -289,7 +289,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int 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 */ @@ -338,7 +338,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, * us unable to handle the page fault gracefully. */ out_of_memory: - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); if (from_user) { pagefault_out_of_memory(); return; @@ -346,7 +346,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, goto no_context; do_sigbus: - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); do_fault_siginfo(BUS_ADRERR, SIGBUS, regs, text_fault); if (!from_user) goto no_context; @@ -394,7 +394,7 @@ static void force_user_fault(unsigned long address, int write) code = SEGV_MAPERR; - down_read(&mm->mmap_sem); + mm_read_lock(mm, &mmrange); vma = find_vma(mm, address); if (!vma) goto bad_area; @@ -419,15 +419,15 @@ static void force_user_fault(unsigned long address, int write) case VM_FAULT_OOM: goto do_sigbus; } - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); return; bad_area: - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); __do_fault_siginfo(code, SIGSEGV, tsk->thread.kregs, address); return; do_sigbus: - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); __do_fault_siginfo(BUS_ADRERR, SIGBUS, tsk->thread.kregs, address); } diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c index e0a3c36b0fa1..d674c2d6b51a 100644 --- a/arch/sparc/mm/fault_64.c +++ b/arch/sparc/mm/fault_64.c @@ -335,7 +335,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); - if (!down_read_trylock(&mm->mmap_sem)) { + if (!mm_read_trylock(mm, &mmrange)) { if ((regs->tstate & TSTATE_PRIV) && !search_exception_tables(regs->tpc)) { insn = get_fault_insn(regs, insn); @@ -343,7 +343,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) } retry: - down_read(&mm->mmap_sem); + mm_read_lock(mm, &mmrange); } if (fault_code & FAULT_CODE_BAD_RA) @@ -476,7 +476,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) goto retry; } } - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); mm_rss = get_mm_rss(mm); #if defined(CONFIG_TRANSPARENT_HUGEPAGE) @@ -507,7 +507,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) */ bad_area: insn = get_fault_insn(regs, insn); - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); handle_kernel_fault: do_kernel_fault(regs, si_code, fault_code, insn, address); @@ -519,7 +519,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) */ out_of_memory: insn = get_fault_insn(regs, insn); - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); if (!(regs->tstate & TSTATE_PRIV)) { pagefault_out_of_memory(); goto exit_exception; @@ -532,7 +532,7 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) do_sigbus: insn = get_fault_insn(regs, insn); - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); /* * Send a sigbus, regardless of whether we were in kernel diff --git a/arch/sparc/vdso/vma.c b/arch/sparc/vdso/vma.c index f51595f861b8..35b888bc2f54 100644 --- a/arch/sparc/vdso/vma.c +++ b/arch/sparc/vdso/vma.c @@ -178,8 +178,9 @@ static int map_vdso(const struct vdso_image *image, struct vm_area_struct *vma; unsigned long text_start, addr = 0; int ret = 0; + DEFINE_RANGE_LOCK_FULL(mmrange); - down_write(&mm->mmap_sem); + mm_write_lock(mm, &mmrange); /* * First, get an unmapped region: then randomize it, and make sure that @@ -235,7 +236,7 @@ static int map_vdso(const struct vdso_image *image, if (ret) current->mm->context.vdso = NULL; - up_write(&mm->mmap_sem); + mm_write_unlock(mm, &mmrange); return ret; } -- 2.13.6