55 lines
1.8 KiB
Diff
55 lines
1.8 KiB
Diff
From: Andrea Arcangeli <aarcange@redhat.com>
|
|
Subject: thp: reduce khugepaged freezing latency
|
|
|
|
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: Jiri Slaby <jslaby@suse.cz>
|
|
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
|
|
|
|
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
|
|
index 4298aba..fd925d0 100644
|
|
--- a/mm/huge_memory.c
|
|
+++ b/mm/huge_memory.c
|
|
@@ -2259,12 +2259,9 @@ static void khugepaged_do_scan(struct page **hpage)
|
|
|
|
static void khugepaged_alloc_sleep(void)
|
|
{
|
|
- DEFINE_WAIT(wait);
|
|
- add_wait_queue(&khugepaged_wait, &wait);
|
|
- schedule_timeout_interruptible(
|
|
- msecs_to_jiffies(
|
|
- khugepaged_alloc_sleep_millisecs));
|
|
- remove_wait_queue(&khugepaged_wait, &wait);
|
|
+ wait_event_freezable_timeout(khugepaged_wait, false,
|
|
+ msecs_to_jiffies(
|
|
+ khugepaged_alloc_sleep_millisecs));
|
|
}
|
|
|
|
#ifndef CONFIG_NUMA
|
|
@@ -2313,14 +2310,11 @@ static void khugepaged_loop(void)
|
|
if (unlikely(kthread_should_stop()))
|
|
break;
|
|
if (khugepaged_has_work()) {
|
|
- DEFINE_WAIT(wait);
|
|
if (!khugepaged_scan_sleep_millisecs)
|
|
continue;
|
|
- add_wait_queue(&khugepaged_wait, &wait);
|
|
- schedule_timeout_interruptible(
|
|
+ wait_event_freezable_timeout(khugepaged_wait, false,
|
|
msecs_to_jiffies(
|
|
khugepaged_scan_sleep_millisecs));
|
|
- remove_wait_queue(&khugepaged_wait, &wait);
|
|
} else if (khugepaged_enabled())
|
|
wait_event_freezable(khugepaged_wait,
|
|
khugepaged_wait_event());
|
|
|
|
|