FROMLIST: mm: cache some VMA fields in the vm_fault structure

When handling speculative page fault, the vma->vm_flags and
vma->vm_page_prot fields are read once the page table lock is released. So
there is no more guarantee that these fields would not change in our back.
They will be saved in the vm_fault structure before the VMA is checked for
changes.

This patch also set the fields in hugetlb_no_page() and
__collapse_huge_page_swapin even if it is not need for the callee.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Change-Id: I9821f02ea32ef220b57b8bfd817992bbf71bbb1d
Link: https://lore.kernel.org/lkml/1523975611-15978-13-git-send-email-ldufour@linux.vnet.ibm.com/
Bug: 161210518
Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
This commit is contained in:
Laurent Dufour
2018-04-17 16:33:18 +02:00
committed by Suren Baghdasaryan
parent 73ab9e34ff
commit 32507b6ff2
6 changed files with 42 additions and 29 deletions

View File

@@ -549,6 +549,12 @@ struct vm_fault {
* page table to avoid allocation from
* atomic context.
*/
/*
* These entries are required when handling speculative page fault.
* This way the page handling is done using consistent field values.
*/
unsigned long vma_flags;
pgprot_t vma_page_prot;
};
/* page entry size for vm->huge_fault() */
@@ -982,9 +988,9 @@ void free_compound_page(struct page *page);
* pte_mkwrite. But get_user_pages can cause write faults for mappings
* that do not have writing enabled, when used by access_process_vm.
*/
static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)
static inline pte_t maybe_mkwrite(pte_t pte, unsigned long vma_flags)
{
if (likely(vma->vm_flags & VM_WRITE))
if (likely(vma_flags & VM_WRITE))
pte = pte_mkwrite(pte);
return pte;
}