Commit 1dfb059b authored by Andrea Arcangeli's avatar Andrea Arcangeli Committed by Linus Torvalds

thp: reduce khugepaged freezing latency

khugepaged can sometimes cause suspend to fail, requiring that the user
retry the suspend operation.

Use wait_event_freezable_timeout() instead of
schedule_timeout_interruptible() to avoid missing freezer wakeups.  A
try_to_freeze() would have been needed in the khugepaged_alloc_hugepage
tight loop too in case of the allocation failing repeatedly, and
wait_event_freezable_timeout will provide it too.

khugepaged would still freeze just fine by trying again the next minute
but it's better if it freezes immediately.
Reported-by: default avatarJiri Slaby <jslaby@suse.cz>
Signed-off-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
Tested-by: default avatarJiri Slaby <jslaby@suse.cz>
Cc: Tejun Heo <tj@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
Cc: "Rafael J. Wysocki" <rjw@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b53fc7c2
...@@ -2259,12 +2259,8 @@ static void khugepaged_do_scan(struct page **hpage) ...@@ -2259,12 +2259,8 @@ static void khugepaged_do_scan(struct page **hpage)
static void khugepaged_alloc_sleep(void) static void khugepaged_alloc_sleep(void)
{ {
DEFINE_WAIT(wait); wait_event_freezable_timeout(khugepaged_wait, false,
add_wait_queue(&khugepaged_wait, &wait); msecs_to_jiffies(khugepaged_alloc_sleep_millisecs));
schedule_timeout_interruptible(
msecs_to_jiffies(
khugepaged_alloc_sleep_millisecs));
remove_wait_queue(&khugepaged_wait, &wait);
} }
#ifndef CONFIG_NUMA #ifndef CONFIG_NUMA
...@@ -2313,14 +2309,10 @@ static void khugepaged_loop(void) ...@@ -2313,14 +2309,10 @@ static void khugepaged_loop(void)
if (unlikely(kthread_should_stop())) if (unlikely(kthread_should_stop()))
break; break;
if (khugepaged_has_work()) { if (khugepaged_has_work()) {
DEFINE_WAIT(wait);
if (!khugepaged_scan_sleep_millisecs) if (!khugepaged_scan_sleep_millisecs)
continue; continue;
add_wait_queue(&khugepaged_wait, &wait); wait_event_freezable_timeout(khugepaged_wait, false,
schedule_timeout_interruptible( msecs_to_jiffies(khugepaged_scan_sleep_millisecs));
msecs_to_jiffies(
khugepaged_scan_sleep_millisecs));
remove_wait_queue(&khugepaged_wait, &wait);
} else if (khugepaged_enabled()) } else if (khugepaged_enabled())
wait_event_freezable(khugepaged_wait, wait_event_freezable(khugepaged_wait,
khugepaged_wait_event()); khugepaged_wait_event());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment