BACKPORT: mm/memory.c: Add memory read privilege on page fault handling

Here add pte_sw_mkyoung function to make page readable on MIPS
platform during page fault handling. This patch improves page
fault latency about 10% on my MIPS machine with lmbench
lat_pagefault case.

It is noop function on other arches, there is no negative
influence on those architectures.

Change-Id: Ia5edb3d745d9949cfb0b1316ec5d08dae5761956
Signed-off-by: Bibo Mao <[email protected]>
Acked-by: Andrew Morton <[email protected]>
Signed-off-by: Thomas Bogendoerfer <[email protected]>
This commit is contained in:
Bibo Mao 2020-05-27 10:25:19 +08:00 • committed by basamaryan
commit ce18ca1ed3
No known key found for this signature in database
GPG key ID: 210D5384FB2A5885
3 changed files with 21 additions and 0 deletions

View file

@ -2539,6 +2539,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf)
}
flush_cache_page(vma, vmf->address, pte_pfn(vmf->orig_pte));
entry = mk_pte(new_page, vma->vm_page_prot);
entry = pte_sw_mkyoung(entry);
entry = maybe_mkwrite(pte_mkdirty(entry), vma);
/*
* Clear the pte entry and flush it first, before updating the
@ -3214,6 +3215,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf)
__SetPageUptodate(page);
entry = mk_pte(page, vma->vm_page_prot);
entry = pte_sw_mkyoung(entry);
if (vma->vm_flags & VM_WRITE)
entry = pte_mkwrite(pte_mkdirty(entry));
@ -3502,6 +3504,7 @@ vm_fault_t alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg,
flush_icache_page(vma, page);
entry = mk_pte(page, vma->vm_page_prot);
entry = pte_sw_mkyoung(entry);
if (write)
entry = maybe_mkwrite(pte_mkdirty(entry), vma);