mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 20:51:44 +00:00
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: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Tested-by: Jiri 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
b53fc7c297
commit
1dfb059b94
@ -2259,12 +2259,8 @@ 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 +2309,10 @@ 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(
|
||||
msecs_to_jiffies(
|
||||
khugepaged_scan_sleep_millisecs));
|
||||
remove_wait_queue(&khugepaged_wait, &wait);
|
||||
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());
|
||||
|
Loading…
Reference in New Issue
Block a user