]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm, thp: allow fallback when pte_alloc_one() fails for huge pmd
authorDavid Rientjes <rientjes@google.com>
Thu, 12 Apr 2012 22:51:58 +0000 (08:51 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 17 Apr 2012 03:47:17 +0000 (13:47 +1000)
The transparent hugepages feature is careful to not invoke the oom killer
when a hugepage cannot be allocated.

pte_alloc_one() failing in __do_huge_pmd_anonymous_page(), however,
currently results in VM_FAULT_OOM which invokes the pagefault oom killer
to kill a memory-hogging task.

This is unnecessary since it's possible to drop the reference to the
hugepage and fallback to allocating a small page.

Signed-off-by: David Rientjes <rientjes@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/huge_memory.c

index 8ab2d24faae5ad4abae79b825b3563f221a9ca78..d7d7165156ca27b3bfe6bc3f149dc9aaad71ea06 100644 (file)
@@ -640,11 +640,8 @@ static int __do_huge_pmd_anonymous_page(struct mm_struct *mm,
 
        VM_BUG_ON(!PageCompound(page));
        pgtable = pte_alloc_one(mm, haddr);
-       if (unlikely(!pgtable)) {
-               mem_cgroup_uncharge_page(page);
-               put_page(page);
+       if (unlikely(!pgtable))
                return VM_FAULT_OOM;
-       }
 
        clear_huge_page(page, haddr, HPAGE_PMD_NR);
        __SetPageUptodate(page);
@@ -723,8 +720,14 @@ int do_huge_pmd_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
                        put_page(page);
                        goto out;
                }
+               if (unlikely(__do_huge_pmd_anonymous_page(mm, vma, haddr, pmd,
+                                                         page))) {
+                       mem_cgroup_uncharge_page(page);
+                       put_page(page);
+                       goto out;
+               }
 
-               return __do_huge_pmd_anonymous_page(mm, vma, haddr, pmd, page);
+               return 0;
        }
 out:
        /*