Commit 79553da2 authored by Kirill A. Shutemov's avatar Kirill A. Shutemov Committed by Linus Torvalds

thp: cleanup khugepaged startup

Few trivial cleanups:

 - no need to call set_recommended_min_free_kbytes() from
   late_initcall() -- start_khugepaged() calls it;

 - no need to call set_recommended_min_free_kbytes() from
   start_khugepaged() if khugepaged is not started;

 - there isn't much point in running start_khugepaged() if we've just
   set transparent_hugepage_flags to zero;

 - start_khugepaged() is misnamed -- it also used to stop the thread;
Signed-off-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e39155ea
...@@ -110,10 +110,6 @@ static int set_recommended_min_free_kbytes(void) ...@@ -110,10 +110,6 @@ static int set_recommended_min_free_kbytes(void)
int nr_zones = 0; int nr_zones = 0;
unsigned long recommended_min; unsigned long recommended_min;
/* khugepaged thread has stopped to failed to start */
if (!khugepaged_thread)
return 0;
for_each_populated_zone(zone) for_each_populated_zone(zone)
nr_zones++; nr_zones++;
...@@ -145,9 +141,8 @@ static int set_recommended_min_free_kbytes(void) ...@@ -145,9 +141,8 @@ static int set_recommended_min_free_kbytes(void)
setup_per_zone_wmarks(); setup_per_zone_wmarks();
return 0; return 0;
} }
late_initcall(set_recommended_min_free_kbytes);
static int start_khugepaged(void) static int start_stop_khugepaged(void)
{ {
int err = 0; int err = 0;
if (khugepaged_enabled()) { if (khugepaged_enabled()) {
...@@ -158,6 +153,7 @@ static int start_khugepaged(void) ...@@ -158,6 +153,7 @@ static int start_khugepaged(void)
pr_err("khugepaged: kthread_run(khugepaged) failed\n"); pr_err("khugepaged: kthread_run(khugepaged) failed\n");
err = PTR_ERR(khugepaged_thread); err = PTR_ERR(khugepaged_thread);
khugepaged_thread = NULL; khugepaged_thread = NULL;
goto fail;
} }
if (!list_empty(&khugepaged_scan.mm_head)) if (!list_empty(&khugepaged_scan.mm_head))
...@@ -168,7 +164,7 @@ static int start_khugepaged(void) ...@@ -168,7 +164,7 @@ static int start_khugepaged(void)
kthread_stop(khugepaged_thread); kthread_stop(khugepaged_thread);
khugepaged_thread = NULL; khugepaged_thread = NULL;
} }
fail:
return err; return err;
} }
...@@ -302,7 +298,7 @@ static ssize_t enabled_store(struct kobject *kobj, ...@@ -302,7 +298,7 @@ static ssize_t enabled_store(struct kobject *kobj,
int err; int err;
mutex_lock(&khugepaged_mutex); mutex_lock(&khugepaged_mutex);
err = start_khugepaged(); err = start_stop_khugepaged();
mutex_unlock(&khugepaged_mutex); mutex_unlock(&khugepaged_mutex);
if (err) if (err)
...@@ -651,10 +647,12 @@ static int __init hugepage_init(void) ...@@ -651,10 +647,12 @@ static int __init hugepage_init(void)
* where the extra memory used could hurt more than TLB overhead * where the extra memory used could hurt more than TLB overhead
* is likely to save. The admin can still enable it through /sys. * is likely to save. The admin can still enable it through /sys.
*/ */
if (totalram_pages < (512 << (20 - PAGE_SHIFT))) if (totalram_pages < (512 << (20 - PAGE_SHIFT))) {
transparent_hugepage_flags = 0; transparent_hugepage_flags = 0;
return 0;
}
err = start_khugepaged(); err = start_stop_khugepaged();
if (err) if (err)
goto err_khugepaged; goto err_khugepaged;
......
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