mm: hugetlb: Copy general hugetlb code from x86 to mm.
[firefly-linux-kernel-4.4.55.git] / mm / rmap.c
index 807c96bf0dc6d08cdc167ce432a68999b1e21692..3f6077461aeacaac7d80049fd5043b49547c9d80 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -600,7 +600,11 @@ pte_t *__page_check_address(struct page *page, struct mm_struct *mm,
        spinlock_t *ptl;
 
        if (unlikely(PageHuge(page))) {
+               /* when pud is not present, pte will be NULL */
                pte = huge_pte_offset(mm, address);
+               if (!pte)
+                       return NULL;
+
                ptl = &mm->page_table_lock;
                goto check;
        }
@@ -1513,6 +1517,9 @@ static int try_to_unmap_file(struct page *page, enum ttu_flags flags)
        unsigned long max_nl_size = 0;
        unsigned int mapcount;
 
+       if (PageHuge(page))
+               pgoff = page->index << compound_order(page);
+
        mutex_lock(&mapping->i_mmap_mutex);
        vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) {
                unsigned long address = vma_address(page, vma);