Commit 9817626e authored by Xiao Guangrong's avatar Xiao Guangrong Committed by Linus Torvalds

thp: remove some code depend on CONFIG_NUMA

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: default avatarXiao 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2017c0bf
...@@ -2306,11 +2306,8 @@ static void khugepaged_wait_work(void) ...@@ -2306,11 +2306,8 @@ static void khugepaged_wait_work(void)
static void khugepaged_loop(void) static void khugepaged_loop(void)
{ {
struct page *hpage; struct page *hpage = NULL;
#ifdef CONFIG_NUMA
hpage = NULL;
#endif
while (likely(khugepaged_enabled())) { while (likely(khugepaged_enabled())) {
#ifndef CONFIG_NUMA #ifndef CONFIG_NUMA
hpage = khugepaged_alloc_hugepage(); hpage = khugepaged_alloc_hugepage();
...@@ -2324,10 +2321,9 @@ static void khugepaged_loop(void) ...@@ -2324,10 +2321,9 @@ static void khugepaged_loop(void)
#endif #endif
khugepaged_do_scan(&hpage); khugepaged_do_scan(&hpage);
#ifndef CONFIG_NUMA
if (hpage) if (!IS_ERR_OR_NULL(hpage))
put_page(hpage); put_page(hpage);
#endif
khugepaged_wait_work(); khugepaged_wait_work();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment