]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
thp: release page in page pre-alloc path
authorXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Fri, 28 Sep 2012 00:19:18 +0000 (10:19 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 5 Oct 2012 04:00:51 +0000 (14:00 +1000)
If NUMA is enabled, we can release the page in the page pre-alloc
operation, then the CONFIG_NUMA dependent code can be reduced

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/huge_memory.c

index e414b1d996a4201e3aff73b6ffa948f544727bf5..6e4645b732f445c9619aaef542c8c12b916ca1f8 100644 (file)
@@ -1939,15 +1939,12 @@ static void collapse_huge_page(struct mm_struct *mm,
                *hpage = ERR_PTR(-ENOMEM);
                return;
        }
+       *hpage = new_page;
        count_vm_event(THP_COLLAPSE_ALLOC);
 #endif
 
-       if (unlikely(mem_cgroup_newpage_charge(new_page, mm, GFP_KERNEL))) {
-#ifdef CONFIG_NUMA
-               put_page(new_page);
-#endif
+       if (unlikely(mem_cgroup_newpage_charge(new_page, mm, GFP_KERNEL)))
                return;
-       }
 
        /*
         * Prevent all access to pagetables with the exception of
@@ -2048,9 +2045,8 @@ static void collapse_huge_page(struct mm_struct *mm,
        prepare_pmd_huge_pte(pgtable, mm);
        spin_unlock(&mm->page_table_lock);
 
-#ifndef CONFIG_NUMA
        *hpage = NULL;
-#endif
+
        khugepaged_pages_collapsed++;
 out_up_write:
        up_write(&mm->mmap_sem);
@@ -2058,9 +2054,6 @@ out_up_write:
 
 out:
        mem_cgroup_uncharge_page(new_page);
-#ifdef CONFIG_NUMA
-       put_page(new_page);
-#endif
        goto out_up_write;
 }
 
@@ -2324,8 +2317,6 @@ static void khugepaged_do_scan(void)
        bool wait = true;
 
        while (progress < pages) {
-               cond_resched();
-
 #ifndef CONFIG_NUMA
                if (!hpage)
                        hpage = khugepaged_alloc_hugepage(&wait);
@@ -2338,8 +2329,12 @@ static void khugepaged_do_scan(void)
                                break;
                        wait = false;
                        khugepaged_alloc_sleep();
+               } else if (hpage) {
+                       put_page(hpage);
+                       hpage = NULL;
                }
 #endif
+               cond_resched();
 
                if (unlikely(kthread_should_stop() || freezing(current)))
                        break;