Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad3023ac authored by Mahendran Ganesh's avatar Mahendran Ganesh Committed by Vinayak Menon
Browse files

arm64/mm: add speculative page fault



This patch enables the speculative page fault on the arm64
architecture.

I completed spf porting in 4.9. From the test result,
we can see app launching time improved by about 10% in average.
For the apps which have more than 50 threads, 15% or even more
improvement can be got.

Signed-off-by: default avatarGanesh Mahendran <opensource.ganesh@gmail.com>
Change-Id: Ib7c8b2e354800b5023e6c6400448a6d40aaf89c8
Patch-mainline: linux-mm @ Wed, 2 May 2018 15:54:32
[vinmenon@codeaurora.org: remove the speculative fault perf counter]
Signed-off-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
[charante@codeaurora.org: trivial merge conflict fixes]
Signed-off-by: default avatarCharan Teja Reddy <charante@codeaurora.org>
parent bcca0756
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -406,10 +406,9 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
#define VM_FAULT_BADMAP		0x010000
#define VM_FAULT_BADACCESS	0x020000

static vm_fault_t __do_page_fault(struct mm_struct *mm, unsigned long addr,
static int __do_page_fault(struct vm_area_struct *vma, unsigned long addr,
			   unsigned int mm_flags, unsigned long vm_flags)
{
	struct vm_area_struct *vma = find_vma(mm, addr);

	if (unlikely(!vma))
		return VM_FAULT_BADMAP;
@@ -456,6 +455,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
	vm_fault_t fault, major = 0;
	unsigned long vm_flags = VM_READ | VM_WRITE | VM_EXEC;
	unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
	struct vm_area_struct *vma = NULL;

	if (kprobe_page_fault(regs, esr))
		return 0;
@@ -495,6 +495,14 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,

	perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);

	/*
	 * let's try a speculative page fault without grabbing the
	 * mmap_sem.
	 */
	fault = handle_speculative_fault(mm, addr, mm_flags, &vma);
	if (fault != VM_FAULT_RETRY)
		goto done;

	/*
	 * As per x86, we may deadlock here. However, since the kernel only
	 * validly references user space from well defined areas of the code,
@@ -519,7 +527,10 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
#endif
	}

	fault = __do_page_fault(mm, addr, mm_flags, vm_flags);
	if (!vma || !can_reuse_spf_vma(vma, addr))
		vma = find_vma(mm, addr);

	fault = __do_page_fault(vma, addr, mm_flags, vm_flags);
	major |= fault & VM_FAULT_MAJOR;

	if (fault & VM_FAULT_RETRY) {
@@ -542,11 +553,20 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
		if (mm_flags & FAULT_FLAG_ALLOW_RETRY) {
			mm_flags &= ~FAULT_FLAG_ALLOW_RETRY;
			mm_flags |= FAULT_FLAG_TRIED;

			/*
			 * Do not try to reuse this vma and fetch it
			 * again since we will release the mmap_sem.
			 */
			vma = NULL;

			goto retry;
		}
	}
	up_read(&mm->mmap_sem);

done:

	/*
	 * Handle the "normal" (no error) case first.
	 */