Commit 2017c0bff8ba79ea527361adbe19471e174775d6
Committed by
Linus Torvalds
1 parent
e060f0e013
Exists in
master
and in
20 other branches
thp: remove wake_up_interruptible in the exit path
Add the check of kthread_should_stop() to the conditions which are used to wakeup on khugepaged_wait, then kthread_stop is enough to let the thread exit 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>
Showing 1 changed file with 21 additions and 14 deletions Side-by-side Diff
mm/huge_memory.c
... | ... | @@ -154,8 +154,6 @@ |
154 | 154 | |
155 | 155 | set_recommended_min_free_kbytes(); |
156 | 156 | } else if (khugepaged_thread) { |
157 | - /* wakeup to exit */ | |
158 | - wake_up_interruptible(&khugepaged_wait); | |
159 | 157 | kthread_stop(khugepaged_thread); |
160 | 158 | khugepaged_thread = NULL; |
161 | 159 | } |
... | ... | @@ -2221,7 +2219,7 @@ |
2221 | 2219 | static int khugepaged_wait_event(void) |
2222 | 2220 | { |
2223 | 2221 | return !list_empty(&khugepaged_scan.mm_head) || |
2224 | - !khugepaged_enabled(); | |
2222 | + kthread_should_stop(); | |
2225 | 2223 | } |
2226 | 2224 | |
2227 | 2225 | static void khugepaged_do_scan(struct page **hpage) |
... | ... | @@ -2288,6 +2286,24 @@ |
2288 | 2286 | } |
2289 | 2287 | #endif |
2290 | 2288 | |
2289 | +static void khugepaged_wait_work(void) | |
2290 | +{ | |
2291 | + try_to_freeze(); | |
2292 | + | |
2293 | + if (khugepaged_has_work()) { | |
2294 | + if (!khugepaged_scan_sleep_millisecs) | |
2295 | + return; | |
2296 | + | |
2297 | + wait_event_freezable_timeout(khugepaged_wait, | |
2298 | + kthread_should_stop(), | |
2299 | + msecs_to_jiffies(khugepaged_scan_sleep_millisecs)); | |
2300 | + return; | |
2301 | + } | |
2302 | + | |
2303 | + if (khugepaged_enabled()) | |
2304 | + wait_event_freezable(khugepaged_wait, khugepaged_wait_event()); | |
2305 | +} | |
2306 | + | |
2291 | 2307 | static void khugepaged_loop(void) |
2292 | 2308 | { |
2293 | 2309 | struct page *hpage; |
... | ... | @@ -2312,17 +2328,8 @@ |
2312 | 2328 | if (hpage) |
2313 | 2329 | put_page(hpage); |
2314 | 2330 | #endif |
2315 | - try_to_freeze(); | |
2316 | - if (unlikely(kthread_should_stop())) | |
2317 | - break; | |
2318 | - if (khugepaged_has_work()) { | |
2319 | - if (!khugepaged_scan_sleep_millisecs) | |
2320 | - continue; | |
2321 | - wait_event_freezable_timeout(khugepaged_wait, false, | |
2322 | - msecs_to_jiffies(khugepaged_scan_sleep_millisecs)); | |
2323 | - } else if (khugepaged_enabled()) | |
2324 | - wait_event_freezable(khugepaged_wait, | |
2325 | - khugepaged_wait_event()); | |
2331 | + | |
2332 | + khugepaged_wait_work(); | |
2326 | 2333 | } |
2327 | 2334 | } |
2328 | 2335 |