]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
thp: remove wake_up_interruptible in the exit path
authorXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Wed, 26 Sep 2012 01:33:22 +0000 (11:33 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 27 Sep 2012 07:25:55 +0000 (17:25 +1000)
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>
mm/huge_memory.c

index a0b1dd879f81929345c4581d31afeaf11e640c90..8294f5fb795208fc6f4a494bc88a12ab0bf0775d 100644 (file)
@@ -155,8 +155,6 @@ static int start_khugepaged(void)
 
                set_recommended_min_free_kbytes();
        } else if (khugepaged_thread) {
-               /* wakeup to exit */
-               wake_up_interruptible(&khugepaged_wait);
                kthread_stop(khugepaged_thread);
                khugepaged_thread = NULL;
        }
@@ -2306,7 +2304,7 @@ static int khugepaged_has_work(void)
 static int khugepaged_wait_event(void)
 {
        return !list_empty(&khugepaged_scan.mm_head) ||
-               !khugepaged_enabled();
+               kthread_should_stop();
 }
 
 static void khugepaged_do_scan(struct page **hpage)
@@ -2371,6 +2369,24 @@ static struct page *khugepaged_alloc_hugepage(void)
 }
 #endif
 
+static void khugepaged_wait_work(void)
+{
+       try_to_freeze();
+
+       if (khugepaged_has_work()) {
+               if (!khugepaged_scan_sleep_millisecs)
+                       return;
+
+               wait_event_freezable_timeout(khugepaged_wait,
+                                            kthread_should_stop(),
+                       msecs_to_jiffies(khugepaged_scan_sleep_millisecs));
+               return;
+       }
+
+       if (khugepaged_enabled())
+               wait_event_freezable(khugepaged_wait, khugepaged_wait_event());
+}
+
 static void khugepaged_loop(void)
 {
        struct page *hpage;
@@ -2395,17 +2411,8 @@ static void khugepaged_loop(void)
                if (hpage)
                        put_page(hpage);
 #endif
-               try_to_freeze();
-               if (unlikely(kthread_should_stop()))
-                       break;
-               if (khugepaged_has_work()) {
-                       if (!khugepaged_scan_sleep_millisecs)
-                               continue;
-                       wait_event_freezable_timeout(khugepaged_wait, false,
-                           msecs_to_jiffies(khugepaged_scan_sleep_millisecs));
-               } else if (khugepaged_enabled())
-                       wait_event_freezable(khugepaged_wait,
-                                            khugepaged_wait_event());
+
+               khugepaged_wait_work();
        }
 }