Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Andrea Arcangeli and committed by
Linus Torvalds
1dfb059b b53fc7c2

+4 -12
+4 -12
mm/huge_memory.c
··· 2259 2259 2260 2260 static void khugepaged_alloc_sleep(void) 2261 2261 { 2262 - DEFINE_WAIT(wait); 2263 - add_wait_queue(&khugepaged_wait, &wait); 2264 - schedule_timeout_interruptible( 2265 - msecs_to_jiffies( 2266 - khugepaged_alloc_sleep_millisecs)); 2267 - remove_wait_queue(&khugepaged_wait, &wait); 2262 + wait_event_freezable_timeout(khugepaged_wait, false, 2263 + msecs_to_jiffies(khugepaged_alloc_sleep_millisecs)); 2268 2264 } 2269 2265 2270 2266 #ifndef CONFIG_NUMA ··· 2309 2313 if (unlikely(kthread_should_stop())) 2310 2314 break; 2311 2315 if (khugepaged_has_work()) { 2312 - DEFINE_WAIT(wait); 2313 2316 if (!khugepaged_scan_sleep_millisecs) 2314 2317 continue; 2315 - add_wait_queue(&khugepaged_wait, &wait); 2316 - schedule_timeout_interruptible( 2317 - msecs_to_jiffies( 2318 - khugepaged_scan_sleep_millisecs)); 2319 - remove_wait_queue(&khugepaged_wait, &wait); 2318 + wait_event_freezable_timeout(khugepaged_wait, false, 2319 + msecs_to_jiffies(khugepaged_scan_sleep_millisecs)); 2320 2320 } else if (khugepaged_enabled()) 2321 2321 wait_event_freezable(khugepaged_wait, 2322 2322 khugepaged_wait_event());