diff options
author | Kirill A. Shutemov <kirill.shutemov@linux.intel.com> | 2015-04-15 19:14:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-15 19:35:19 -0400 |
commit | 79553da293d38d63097278de13e28a3b371f43c1 (patch) | |
tree | 2b259efd74662ef3d6aed55f86f6490a3e98207b /mm | |
parent | e39155ea11eac6da056b04669d7c9fc612e2065a (diff) |
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: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/huge_memory.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 0af19fffe1df..078832cf3636 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
@@ -110,10 +110,6 @@ static int set_recommended_min_free_kbytes(void) | |||
110 | int nr_zones = 0; | 110 | int nr_zones = 0; |
111 | unsigned long recommended_min; | 111 | unsigned long recommended_min; |
112 | 112 | ||
113 | /* khugepaged thread has stopped to failed to start */ | ||
114 | if (!khugepaged_thread) | ||
115 | return 0; | ||
116 | |||
117 | for_each_populated_zone(zone) | 113 | for_each_populated_zone(zone) |
118 | nr_zones++; | 114 | nr_zones++; |
119 | 115 | ||
@@ -145,9 +141,8 @@ static int set_recommended_min_free_kbytes(void) | |||
145 | setup_per_zone_wmarks(); | 141 | setup_per_zone_wmarks(); |
146 | return 0; | 142 | return 0; |
147 | } | 143 | } |
148 | late_initcall(set_recommended_min_free_kbytes); | ||
149 | 144 | ||
150 | static int start_khugepaged(void) | 145 | static int start_stop_khugepaged(void) |
151 | { | 146 | { |
152 | int err = 0; | 147 | int err = 0; |
153 | if (khugepaged_enabled()) { | 148 | if (khugepaged_enabled()) { |
@@ -158,6 +153,7 @@ static int start_khugepaged(void) | |||
158 | pr_err("khugepaged: kthread_run(khugepaged) failed\n"); | 153 | pr_err("khugepaged: kthread_run(khugepaged) failed\n"); |
159 | err = PTR_ERR(khugepaged_thread); | 154 | err = PTR_ERR(khugepaged_thread); |
160 | khugepaged_thread = NULL; | 155 | khugepaged_thread = NULL; |
156 | goto fail; | ||
161 | } | 157 | } |
162 | 158 | ||
163 | if (!list_empty(&khugepaged_scan.mm_head)) | 159 | if (!list_empty(&khugepaged_scan.mm_head)) |
@@ -168,7 +164,7 @@ static int start_khugepaged(void) | |||
168 | kthread_stop(khugepaged_thread); | 164 | kthread_stop(khugepaged_thread); |
169 | khugepaged_thread = NULL; | 165 | khugepaged_thread = NULL; |
170 | } | 166 | } |
171 | 167 | fail: | |
172 | return err; | 168 | return err; |
173 | } | 169 | } |
174 | 170 | ||
@@ -302,7 +298,7 @@ static ssize_t enabled_store(struct kobject *kobj, | |||
302 | int err; | 298 | int err; |
303 | 299 | ||
304 | mutex_lock(&khugepaged_mutex); | 300 | mutex_lock(&khugepaged_mutex); |
305 | err = start_khugepaged(); | 301 | err = start_stop_khugepaged(); |
306 | mutex_unlock(&khugepaged_mutex); | 302 | mutex_unlock(&khugepaged_mutex); |
307 | 303 | ||
308 | if (err) | 304 | if (err) |
@@ -651,10 +647,12 @@ static int __init hugepage_init(void) | |||
651 | * where the extra memory used could hurt more than TLB overhead | 647 | * where the extra memory used could hurt more than TLB overhead |
652 | * is likely to save. The admin can still enable it through /sys. | 648 | * is likely to save. The admin can still enable it through /sys. |
653 | */ | 649 | */ |
654 | if (totalram_pages < (512 << (20 - PAGE_SHIFT))) | 650 | if (totalram_pages < (512 << (20 - PAGE_SHIFT))) { |
655 | transparent_hugepage_flags = 0; | 651 | transparent_hugepage_flags = 0; |
652 | return 0; | ||
653 | } | ||
656 | 654 | ||
657 | err = start_khugepaged(); | 655 | err = start_stop_khugepaged(); |
658 | if (err) | 656 | if (err) |
659 | goto err_khugepaged; | 657 | goto err_khugepaged; |
660 | 658 | ||