mm: handling Non-LRU pages returned by vm_normal_pages
[linux-2.6-microblaze.git] / mm / madvise.c
index d7b4f26..5f0f094 100644 (file)
@@ -195,7 +195,6 @@ success:
 static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned long start,
        unsigned long end, struct mm_walk *walk)
 {
-       pte_t *orig_pte;
        struct vm_area_struct *vma = walk->private;
        unsigned long index;
        struct swap_iocb *splug = NULL;
@@ -208,12 +207,13 @@ static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned long start,
                swp_entry_t entry;
                struct page *page;
                spinlock_t *ptl;
+               pte_t *ptep;
 
-               orig_pte = pte_offset_map_lock(vma->vm_mm, pmd, start, &ptl);
-               pte = *(orig_pte + ((index - start) / PAGE_SIZE));
-               pte_unmap_unlock(orig_pte, ptl);
+               ptep = pte_offset_map_lock(vma->vm_mm, pmd, index, &ptl);
+               pte = *ptep;
+               pte_unmap_unlock(ptep, ptl);
 
-               if (pte_present(pte) || pte_none(pte))
+               if (!is_swap_pte(pte))
                        continue;
                entry = pte_to_swp_entry(pte);
                if (unlikely(non_swap_entry(entry)))
@@ -421,7 +421,7 @@ regular_page:
                        continue;
 
                page = vm_normal_page(vma, addr, ptent);
-               if (!page)
+               if (!page || is_zone_device_page(page))
                        continue;
 
                /*
@@ -639,7 +639,7 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,
                }
 
                page = vm_normal_page(vma, addr, ptent);
-               if (!page)
+               if (!page || is_zone_device_page(page))
                        continue;
 
                /*
@@ -1112,7 +1112,7 @@ static int madvise_inject_error(int behavior,
                } else {
                        pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
                                 pfn, start);
-                       ret = memory_failure(pfn, MF_COUNT_INCREASED);
+                       ret = memory_failure(pfn, MF_COUNT_INCREASED | MF_SW_SIMULATED);
                        if (ret == -EOPNOTSUPP)
                                ret = 0;
                }