Received: by 10.223.176.5 with SMTP id f5csp1990365wra; Sun, 4 Feb 2018 17:35:35 -0800 (PST) X-Google-Smtp-Source: AH8x225jzWh0BMnF1TuZA1FgLTjT8Wcqy+zB7oIO9HhLZN4zgb63noVjW9yBFLtDyEXezzkfGgBd X-Received: by 10.98.35.14 with SMTP id j14mr47258601pfj.62.1517794535729; Sun, 04 Feb 2018 17:35:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517794535; cv=none; d=google.com; s=arc-20160816; b=ieefqrHtay/3KRRhwWqFuEzheNG+yNyU5dPnA61a+QxpIljgovYQPnrksPmpjn18Du hibcP4nOuMUE7iPIkGwfcgoyYoaya/N6FQZl/ITLTAW7NZllJ4n7PmGIFoVcMrh1xKub w3LLRxztDHFDAhNMSlfhKf6qeHGWHsw+km7Ch2FoasalYdymkJ+WcJrDogicOy50ZtPn YWY9JWsigbknDZeAWd6+3gt70cHrPKpdvTytlUGCai4tuCIYiAWEHuh3RRE3TiE3JeYy 5INW1jFu6NojgcMQ4tvFLsMcN6udCmzN5G2pow30lLJqV4ej+La5UQNAYJIoPjMNcGBO MM2Q== 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=PQ2uHsdSnOkpOc8WSTYrpEudPV5NCSTbHkXlKeAh1Es=; b=TQwm5qGMXzWtXmpaKUdFeOOgq5wwkdT5t6WI9HKgbkkln6yLD2BVeuTzlV5c/I8JDn 6+Skmi2w6xyGQ62VznkxLZHCk5gOLyWb9kd0LCw50VHP5eu5s6nVB0zvWN7scy7PFoGc GIoB+9waTg6e7lWDl/ArsT5PGkTDRDGUEKBApsGDf5g4FyByNWFH9zdE1BntkE4YOr2V WZX1qHU0p9PzLs/KCMVC0BsN9U/S0FaCx5q6/aD++OYUew02HxurEbFso8J43mjIVS13 EhcNUgFPakys1hyba4+kgS8xULwf6ExMeTdGhjDAh4Smf2uzDXKNDhvoul4w3tSbsYxc 2RgQ== 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 69-v6si5981006pla.156.2018.02.04.17.35.21; Sun, 04 Feb 2018 17:35:35 -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 S1752643AbeBEBdZ (ORCPT + 99 others); Sun, 4 Feb 2018 20:33:25 -0500 Received: from mx2.suse.de ([195.135.220.15]:44092 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752791AbeBEB3X (ORCPT ); Sun, 4 Feb 2018 20:29:23 -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 9DC9EAE1C; 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 53/64] arch/nios2: use mm locking wrappers Date: Mon, 5 Feb 2018 02:27:43 +0100 Message-Id: <20180205012754.23615-54-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/nios2/mm/fault.c | 12 ++++++------ arch/nios2/mm/init.c | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/arch/nios2/mm/fault.c b/arch/nios2/mm/fault.c index 768678b685af..a59ebadd8e13 100644 --- a/arch/nios2/mm/fault.c +++ b/arch/nios2/mm/fault.c @@ -85,11 +85,11 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause, if (user_mode(regs)) flags |= FAULT_FLAG_USER; - if (!down_read_trylock(&mm->mmap_sem)) { + if (!mm_read_trylock(mm, &mmrange)) { if (!user_mode(regs) && !search_exception_tables(regs->ea)) goto bad_area_nosemaphore; retry: - down_read(&mm->mmap_sem); + mm_read_lock(mm, &mmrange); } vma = find_vma(mm, address); @@ -174,7 +174,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause, } } - up_read(&mm->mmap_sem); + mm_read_unlock(mm, &mmrange); return; /* @@ -182,7 +182,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause, * 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 */ @@ -220,14 +220,14 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause, * us unable to handle the page fault gracefully. */ out_of_memory: - 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)) diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c index c92fe4234009..58bb1c1441ce 100644 --- a/arch/nios2/mm/init.c +++ b/arch/nios2/mm/init.c @@ -123,15 +123,16 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) { struct mm_struct *mm = current->mm; int ret; + DEFINE_RANGE_LOCK_FULL(mmrange); - down_write(&mm->mmap_sem); + mm_write_lock(mm, &mmrange); /* Map kuser helpers to user space address */ ret = install_special_mapping(mm, KUSER_BASE, KUSER_SIZE, VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC, kuser_page); - up_write(&mm->mmap_sem); + mm_write_unlock(mm, &mmrange); return ret; } -- 2.13.6