Skip to content

Commit e06f47a

Browse files
hcahcaakpm00
authored andcommitted
s390/mm: try VMA lock-based page fault handling first
Attempt VMA lock-based page fault handling first, and fall back to the existing mmap_lock-based handling if that fails. This is the s390 variant of "x86/mm: try VMA lock-based page fault handling first". Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Heiko Carstens <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Gerald Schaefer <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Vasily Gorbik <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent c7f8f31 commit e06f47a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

arch/s390/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ config S390
120120
select ARCH_SUPPORTS_DEBUG_PAGEALLOC
121121
select ARCH_SUPPORTS_HUGETLBFS
122122
select ARCH_SUPPORTS_NUMA_BALANCING
123+
select ARCH_SUPPORTS_PER_VMA_LOCK
123124
select ARCH_USE_BUILTIN_BSWAP
124125
select ARCH_USE_CMPXCHG_LOCKREF
125126
select ARCH_WANTS_DYNAMIC_TASK_STRUCT

arch/s390/mm/fault.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,30 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access)
407407
access = VM_WRITE;
408408
if (access == VM_WRITE)
409409
flags |= FAULT_FLAG_WRITE;
410+
#ifdef CONFIG_PER_VMA_LOCK
411+
if (!(flags & FAULT_FLAG_USER))
412+
goto lock_mmap;
413+
vma = lock_vma_under_rcu(mm, address);
414+
if (!vma)
415+
goto lock_mmap;
416+
if (!(vma->vm_flags & access)) {
417+
vma_end_read(vma);
418+
goto lock_mmap;
419+
}
420+
fault = handle_mm_fault(vma, address, flags | FAULT_FLAG_VMA_LOCK, regs);
421+
vma_end_read(vma);
422+
if (!(fault & VM_FAULT_RETRY)) {
423+
count_vm_vma_lock_event(VMA_LOCK_SUCCESS);
424+
goto out;
425+
}
426+
count_vm_vma_lock_event(VMA_LOCK_RETRY);
427+
/* Quick path to respond to signals */
428+
if (fault_signal_pending(fault, regs)) {
429+
fault = VM_FAULT_SIGNAL;
430+
goto out;
431+
}
432+
lock_mmap:
433+
#endif /* CONFIG_PER_VMA_LOCK */
410434
mmap_read_lock(mm);
411435

412436
gmap = NULL;

0 commit comments

Comments
 (0)