From: Davidlohr Bueso <dbueso@suse.de>
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 <dbueso@suse.de>
Subject: [PATCH 30/64] arch/tile: use mm locking wrappers
Date: Mon, 5 Feb 2018 02:27:20 +0100 [thread overview]
Message-ID: <20180205012754.23615-31-dbueso@wotan.suse.de> (raw)
In-Reply-To: <20180205012754.23615-1-dbueso@wotan.suse.de>
From: Davidlohr Bueso <dave@stgolabs.net>
This becomes quite straightforward with the mmrange in place.
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
arch/tile/kernel/stack.c | 5 +++--
arch/tile/mm/elf.c | 12 +++++++-----
arch/tile/mm/fault.c | 12 ++++++------
arch/tile/mm/pgtable.c | 6 ++++--
4 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/arch/tile/kernel/stack.c b/arch/tile/kernel/stack.c
index 94ecbc6676e5..acd4a1ee8df1 100644
--- a/arch/tile/kernel/stack.c
+++ b/arch/tile/kernel/stack.c
@@ -378,6 +378,7 @@ void tile_show_stack(struct KBacktraceIterator *kbt)
{
int i;
int have_mmap_sem = 0;
+ DEFINE_RANGE_LOCK_FULL(mmrange);
if (!start_backtrace())
return;
@@ -398,7 +399,7 @@ void tile_show_stack(struct KBacktraceIterator *kbt)
if (kbt->task == current && address < PAGE_OFFSET &&
!have_mmap_sem && kbt->task->mm && !in_interrupt()) {
have_mmap_sem =
- down_read_trylock(&kbt->task->mm->mmap_sem);
+ mm_read_trylock(kbt->task->mm, &mmrange);
}
describe_addr(kbt, address, have_mmap_sem,
@@ -415,7 +416,7 @@ void tile_show_stack(struct KBacktraceIterator *kbt)
if (kbt->end == KBT_LOOP)
pr_err("Stack dump stopped; next frame identical to this one\n");
if (have_mmap_sem)
- up_read(&kbt->task->mm->mmap_sem);
+ mm_read_unlock(kbt->task->mm, &mmrange);
end_backtrace();
}
EXPORT_SYMBOL(tile_show_stack);
diff --git a/arch/tile/mm/elf.c b/arch/tile/mm/elf.c
index 889901824400..9aba9813cdb8 100644
--- a/arch/tile/mm/elf.c
+++ b/arch/tile/mm/elf.c
@@ -44,6 +44,7 @@ static int notify_exec(struct mm_struct *mm)
char *buf, *path;
struct vm_area_struct *vma;
struct file *exe_file;
+ DEFINE_RANGE_LOCK_FULL(mmrange);
if (!sim_is_simulator())
return 1;
@@ -60,10 +61,10 @@ static int notify_exec(struct mm_struct *mm)
if (IS_ERR(path))
goto done_put;
- down_read(&mm->mmap_sem);
+ mm_read_lock(mm, &mmrange);
for (vma = current->mm->mmap; ; vma = vma->vm_next) {
if (vma == NULL) {
- up_read(&mm->mmap_sem);
+ mm_read_unlock(mm, &mmrange);
goto done_put;
}
if (vma->vm_file == exe_file)
@@ -91,7 +92,7 @@ static int notify_exec(struct mm_struct *mm)
}
}
}
- up_read(&mm->mmap_sem);
+ mm_read_unlock(mm, &mmrange);
sim_notify_exec(path);
done_put:
@@ -119,6 +120,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
{
struct mm_struct *mm = current->mm;
int retval = 0;
+ DEFINE_RANGE_LOCK_FULL(mmrange);
/*
* Notify the simulator that an exec just occurred.
@@ -128,7 +130,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
if (!notify_exec(mm))
sim_notify_exec(bprm->filename);
- down_write(&mm->mmap_sem);
+ mm_write_lock(mm, &mmrange);
retval = setup_vdso_pages();
@@ -149,7 +151,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
}
#endif
- up_write(&mm->mmap_sem);
+ mm_write_unlock(mm, &mmrange);
return retval;
}
diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c
index 09f053eb146f..f4ce0806653a 100644
--- a/arch/tile/mm/fault.c
+++ b/arch/tile/mm/fault.c
@@ -383,7 +383,7 @@ static int handle_page_fault(struct pt_regs *regs,
* source. If this is invalid we can skip the address space check,
* thus avoiding the deadlock.
*/
- if (!down_read_trylock(&mm->mmap_sem)) {
+ if (!mm_read_trylock(mm, &mmrange)) {
if (is_kernel_mode &&
!search_exception_tables(regs->pc)) {
vma = NULL; /* happy compiler */
@@ -391,7 +391,7 @@ static int handle_page_fault(struct pt_regs *regs,
}
retry:
- down_read(&mm->mmap_sem);
+ mm_read_lock(mm, &mmrange);
}
vma = find_vma(mm, address);
@@ -482,7 +482,7 @@ static int handle_page_fault(struct pt_regs *regs,
}
#endif
- up_read(&mm->mmap_sem);
+ mm_read_unlock(mm, &mmrange);
return 1;
/*
@@ -490,7 +490,7 @@ static int handle_page_fault(struct pt_regs *regs,
* 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 */
@@ -557,14 +557,14 @@ static int handle_page_fault(struct pt_regs *regs,
* us unable to handle the page fault gracefully.
*/
out_of_memory:
- up_read(&mm->mmap_sem);
+ mm_read_unlock(mm, &mmrange);
if (is_kernel_mode)
goto no_context;
pagefault_out_of_memory();
return 0;
do_sigbus:
- up_read(&mm->mmap_sem);
+ mm_read_unlock(mm, &mmrange);
/* Kernel mode? Handle exceptions or die */
if (is_kernel_mode)
diff --git a/arch/tile/mm/pgtable.c b/arch/tile/mm/pgtable.c
index ec5576fd3a86..2aab41fe69cf 100644
--- a/arch/tile/mm/pgtable.c
+++ b/arch/tile/mm/pgtable.c
@@ -430,7 +430,9 @@ void start_mm_caching(struct mm_struct *mm)
*/
static unsigned long update_priority_cached(struct mm_struct *mm)
{
- if (mm->context.priority_cached && down_write_trylock(&mm->mmap_sem)) {
+ DEFINE_RANGE_LOCK_FULL(mmrange);
+
+ if (mm->context.priority_cached && mm_write_trylock(mm, &mmrange)) {
struct vm_area_struct *vm;
for (vm = mm->mmap; vm; vm = vm->vm_next) {
if (hv_pte_get_cached_priority(vm->vm_page_prot))
@@ -438,7 +440,7 @@ static unsigned long update_priority_cached(struct mm_struct *mm)
}
if (vm == NULL)
mm->context.priority_cached = 0;
- up_write(&mm->mmap_sem);
+ mm_write_unlock(mm, &mmrange);
}
return mm->context.priority_cached;
}
--
2.13.6
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2018-02-05 1:29 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-05 1:26 [RFC PATCH 00/64] mm: towards parallel address space operations Davidlohr Bueso
2018-02-05 1:26 ` [PATCH 01/64] interval-tree: build unconditionally Davidlohr Bueso
2018-02-05 1:26 ` [PATCH 02/64] Introduce range reader/writer lock Davidlohr Bueso
2018-02-05 1:26 ` [PATCH 03/64] mm: introduce mm locking wrappers Davidlohr Bueso
2018-02-05 1:26 ` [PATCH 04/64] mm: add a range parameter to the vm_fault structure Davidlohr Bueso
2018-02-05 1:26 ` [PATCH 05/64] mm,khugepaged: prepare passing of rangelock field to vm_fault Davidlohr Bueso
2018-02-05 1:26 ` [PATCH 06/64] mm: teach pagefault paths about range locking Davidlohr Bueso
2018-02-05 16:09 ` Laurent Dufour
2018-02-06 18:32 ` Davidlohr Bueso
2018-02-05 1:26 ` [PATCH 07/64] mm/hugetlb: teach hugetlb_fault() " Davidlohr Bueso
2018-02-05 1:26 ` [PATCH 08/64] mm: teach lock_page_or_retry() " Davidlohr Bueso
2018-02-05 1:26 ` [PATCH 09/64] mm/mmu_notifier: teach oom reaper " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 10/64] kernel/exit: teach exit_mm() " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 11/64] prctl: teach " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 12/64] fs/userfaultfd: teach userfaultfd_must_wait() " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 13/64] fs/proc: teach " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 14/64] fs/coredump: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 15/64] ipc: use mm locking wrappers Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 16/64] virt: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 17/64] kernel: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 18/64] mm/ksm: teach about range locking Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 19/64] mm/mlock: use mm locking wrappers Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 20/64] mm/madvise: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 21/64] mm: teach drop/take_all_locks() about range locking Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 22/64] mm: avoid mmap_sem trylock in vm_insert_page() Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 23/64] mm: huge pagecache: do not check mmap_sem state Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 24/64] mm/thp: disable mmap_sem is_locked checks Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 25/64] mm: use mm locking wrappers Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 26/64] fs: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 27/64] arch/{x86,sh,ppc}: teach bad_area() about range locking Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 28/64] arch/x86: use mm locking wrappers Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 29/64] arch/alpha: " Davidlohr Bueso
2018-02-05 1:27 ` Davidlohr Bueso [this message]
2018-02-05 1:27 ` [PATCH 31/64] arch/sparc: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 32/64] arch/s390: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 33/64] arch/powerpc: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 34/64] arch/parisc: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 35/64] arch/ia64: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 36/64] arch/mips: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 37/64] arch/arc: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 38/64] arch/blackfin: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 39/64] arch/m68k: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 40/64] arch/sh: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 41/64] arch/cris: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 42/64] arch/frv: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 43/64] arch/hexagon: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 44/64] arch/score: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 45/64] arch/m32r: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 46/64] arch/metag: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 47/64] arch/microblaze: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 48/64] arch/tile: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 49/64] arch/xtensa: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 50/64] arch/unicore32: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 51/64] arch/mn10300: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 52/64] arch/openrisc: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 53/64] arch/nios2: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 54/64] arch/arm: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 55/64] arch/riscv: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 56/64] drivers/android: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 57/64] drivers/gpu: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 58/64] drivers/infiniband: " Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 59/64] drivers/iommu: use mm locking helpers Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 60/64] drivers/xen: use mm locking wrappers Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 61/64] staging/lustre: use generic range lock Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 62/64] drivers: use mm locking wrappers (the rest) Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 63/64] mm/mmap: hack drop down_write_nest_lock() Davidlohr Bueso
2018-02-05 1:27 ` [PATCH 64/64] mm: convert mmap_sem to range mmap_lock Davidlohr Bueso
2018-02-05 16:53 ` [RFC PATCH 00/64] mm: towards parallel address space operations Laurent Dufour
2018-02-06 18:48 ` Davidlohr Bueso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180205012754.23615-31-dbueso@wotan.suse.de \
--to=dbueso@suse.de \
--cc=akpm@linux-foundation.org \
--cc=dave@stgolabs.net \
--cc=jack@suse.cz \
--cc=kirill.shutemov@linux.intel.com \
--cc=ldufour@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mawilcox@microsoft.com \
--cc=mgorman@techsingularity.net \
--cc=mhocko@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).