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

Commit 7366f77d authored by Laurent Dufour's avatar Laurent Dufour Committed by Vinayak Menon
Browse files

mm: introduce __vm_normal_page()



When dealing with the speculative fault path we should use the VMA's field
cached value stored in the vm_fault structure.

Currently vm_normal_page() is using the pointer to the VMA to fetch the
vm_flags value. This patch provides a new __vm_normal_page() which is
receiving the vm_flags flags value as parameter.

Note: The speculative path is turned on for architecture providing support
for special PTE flag. So only the first block of vm_normal_page is used
during the speculative path.

Change-Id: I0f2c4ab1212fbca449bdf6e7993dafa0d41044bc
Signed-off-by: default avatarLaurent Dufour <ldufour@linux.vnet.ibm.com>
Patch-mainline: linux-mm @ Tue, 17 Apr 2018 16:33:21
[vinmenon@codeaurora.org: 4.9 porting fixes + checkpatch fixes]
Signed-off-by: default avatarVinayak Menon <vinmenon@codeaurora.org>
parent 62cd1d97
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1174,8 +1174,13 @@ struct zap_details {
	pgoff_t last_index;			/* Highest page->index to unmap */
};

struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
		pte_t pte);
struct page *__vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
			      pte_t pte, unsigned long vma_flags);
static inline struct page *vm_normal_page(struct vm_area_struct *vma,
		unsigned long addr, pte_t pte)
{
	return __vm_normal_page(vma, addr, pte, vma->vm_flags);
}

static inline void INIT_VMA(struct vm_area_struct *vma)
{
+15 −9
Original line number Diff line number Diff line
@@ -707,7 +707,8 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
}

/*
 * vm_normal_page -- This function gets the "struct page" associated with a pte.
 * __vm_normal_page -- This function gets the "struct page" associated with
 * a pte.
 *
 * "Special" mappings do not wish to be associated with a "struct page" (either
 * it doesn't exist, or it exists but they don't want to touch it). In this
@@ -753,8 +754,8 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
#else
# define HAVE_PTE_SPECIAL 0
#endif
struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
				pte_t pte)
struct page *__vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
			      pte_t pte, unsigned long vma_flags)
{
	unsigned long pfn = pte_pfn(pte);

@@ -763,7 +764,7 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
			goto check_pfn;
		if (vma->vm_ops && vma->vm_ops->find_special_page)
			return vma->vm_ops->find_special_page(vma, addr);
		if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
		if (vma_flags & (VM_PFNMAP | VM_MIXEDMAP))
			return NULL;
		if (!is_zero_pfn(pfn))
			print_bad_pte(vma, addr, pte, NULL);
@@ -771,9 +772,13 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
	}

	/* !HAVE_PTE_SPECIAL case follows: */
	/*
	 * This part should never get called when CONFIG_SPECULATIVE_PAGE_FAULT
	 * is set. This is mainly because we can't rely on vm_start.
	 */

	if (unlikely(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))) {
		if (vma->vm_flags & VM_MIXEDMAP) {
	if (unlikely(vma_flags & (VM_PFNMAP|VM_MIXEDMAP))) {
		if (vma_flags & VM_MIXEDMAP) {
			if (!pfn_valid(pfn))
				return NULL;
			goto out;
@@ -782,7 +787,7 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
			off = (addr - vma->vm_start) >> PAGE_SHIFT;
			if (pfn == vma->vm_pgoff + off)
				return NULL;
			if (!is_cow_mapping(vma->vm_flags))
			if (!is_cow_mapping(vma_flags))
				return NULL;
		}
	}
@@ -2398,7 +2403,8 @@ static int do_wp_page(struct fault_env *fe, pte_t orig_pte)
	struct vm_area_struct *vma = fe->vma;
	struct page *old_page;

	old_page = vm_normal_page(vma, fe->address, orig_pte);
	old_page = __vm_normal_page(vma, fe->address, orig_pte,
				     fe->vma_flags);
	if (!old_page) {
		/*
		 * VM_MIXEDMAP !pfn_valid() case, or VM_SOFTDIRTY clear on a
@@ -3419,7 +3425,7 @@ static int do_numa_page(struct fault_env *fe, pte_t pte)
	set_pte_at(vma->vm_mm, fe->address, fe->pte, pte);
	update_mmu_cache(vma, fe->address, fe->pte);

	page = vm_normal_page(vma, fe->address, pte);
	page = __vm_normal_page(vma, fe->address, pte, fe->vma_flags);
	if (!page) {
		pte_unmap_unlock(fe->pte, fe->ptl);
		return 0;