Skip to content

Commit

Permalink
thp: remove some code depend on CONFIG_NUMA
Browse files Browse the repository at this point in the history
If NUMA is disabled, hpage is used as page pre-alloc, so there are two
cases for hpage:

- it is !NULL, means the page is not consumed otherwise,
- the page has been consumed

If NUMA is enabled, hpage is just used as alloc-fail indicator which is
not a real page, NULL means not fail triggered.

So, we can release the page only if !IS_ERR_OR_NULL

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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Xiao Guangrong authored and Linus Torvalds committed Oct 9, 2012
1 parent 2017c0b commit 9817626
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions mm/huge_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2306,11 +2306,8 @@ static void khugepaged_wait_work(void)

static void khugepaged_loop(void)
{
struct page *hpage;
struct page *hpage = NULL;

#ifdef CONFIG_NUMA
hpage = NULL;
#endif
while (likely(khugepaged_enabled())) {
#ifndef CONFIG_NUMA
hpage = khugepaged_alloc_hugepage();
Expand All @@ -2324,10 +2321,9 @@ static void khugepaged_loop(void)
#endif

khugepaged_do_scan(&hpage);
#ifndef CONFIG_NUMA
if (hpage)

if (!IS_ERR_OR_NULL(hpage))
put_page(hpage);
#endif

khugepaged_wait_work();
}
Expand Down

0 comments on commit 9817626

Please sign in to comment.