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

Commit 10f57b92 authored by Mahendran Ganesh's avatar Mahendran Ganesh Committed by Gerrit - the friendly Code Review server
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 cd2595f2
Loading
Loading
Loading
Loading
+23 −4
Original line number Diff line number Diff line
@@ -380,14 +380,12 @@ 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 task_struct *tsk)
{
	struct vm_area_struct *vma;
	vm_fault_t fault;

	vma = find_vma(mm, addr);
	fault = VM_FAULT_BADMAP;
	if (unlikely(!vma))
		goto out;
@@ -431,6 +429,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;
	unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
	struct vm_area_struct *vma = NULL;

	if (notify_page_fault(regs, esr))
		return 0;
@@ -472,6 +471,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,
@@ -494,7 +501,10 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
#endif
	}

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

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

	if (fault & VM_FAULT_RETRY) {
@@ -517,11 +527,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.
	 */