aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>2012-10-08 19:29:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-09 03:22:26 -0400
commit2017c0bff8ba79ea527361adbe19471e174775d6 (patch)
treea5d6e611ac06180e19bc6a5a3189668259a99742 /mm
parente060f0e0139b83f05bb90fa05563d14179b9a7ff (diff)
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>
Diffstat (limited to 'mm')
-rw-r--r--mm/huge_memory.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 46e3f150a6ca..a94c07a1b3c5 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -154,8 +154,6 @@ static int start_khugepaged(void)
154 154
155 set_recommended_min_free_kbytes(); 155 set_recommended_min_free_kbytes();
156 } else if (khugepaged_thread) { 156 } else if (khugepaged_thread) {
157 /* wakeup to exit */
158 wake_up_interruptible(&khugepaged_wait);
159 kthread_stop(khugepaged_thread); 157 kthread_stop(khugepaged_thread);
160 khugepaged_thread = NULL; 158 khugepaged_thread = NULL;
161 } 159 }
@@ -2221,7 +2219,7 @@ static int khugepaged_has_work(void)
2221static int khugepaged_wait_event(void) 2219static int khugepaged_wait_event(void)
2222{ 2220{
2223 return !list_empty(&khugepaged_scan.mm_head) || 2221 return !list_empty(&khugepaged_scan.mm_head) ||
2224 !khugepaged_enabled(); 2222 kthread_should_stop();
2225} 2223}
2226 2224
2227static void khugepaged_do_scan(struct page **hpage) 2225static void khugepaged_do_scan(struct page **hpage)
@@ -2288,6 +2286,24 @@ static struct page *khugepaged_alloc_hugepage(void)
2288} 2286}
2289#endif 2287#endif
2290 2288
2289static 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
2291static void khugepaged_loop(void) 2307static void khugepaged_loop(void)
2292{ 2308{
2293 struct page *hpage; 2309 struct page *hpage;
@@ -2312,17 +2328,8 @@ static void khugepaged_loop(void)
2312 if (hpage) 2328 if (hpage)
2313 put_page(hpage); 2329 put_page(hpage);
2314#endif 2330#endif
2315 try_to_freeze(); 2331
2316 if (unlikely(kthread_should_stop())) 2332 khugepaged_wait_work();
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());
2326 } 2333 }
2327} 2334}
2328 2335