Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332366
b: refs/heads/master
c: 2017c0b
h: refs/heads/master
v: v3
  • Loading branch information
Xiao Guangrong authored and Linus Torvalds committed Oct 9, 2012
1 parent 2bae67a commit 403edab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e060f0e0139b83f05bb90fa05563d14179b9a7ff
refs/heads/master: 2017c0bff8ba79ea527361adbe19471e174775d6
35 changes: 21 additions & 14 deletions trunk/mm/huge_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,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;
}
Expand Down Expand Up @@ -2221,7 +2219,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)
Expand Down Expand Up @@ -2288,6 +2286,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;
Expand All @@ -2312,17 +2328,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();
}
}

Expand Down

0 comments on commit 403edab

Please sign in to comment.