The patch titled Subject: mm: fix lost kswapd wakeup in kswapd_stop() has been added to the -mm tree. Its filename is mm-fix-lost-kswapd-wakeup-in-kswapd_stop.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Aaditya Kumar <aaditya.kumar.30@xxxxxxxxx> Subject: mm: fix lost kswapd wakeup in kswapd_stop() Offlining memory may block forever, waiting for kswapd() to wake up because kswapd() does not check the event kthread->should_stop before sleeping. The proper pattern, from Documentation/memory-barriers.txt, is: --- waker --- event_indicated = 1; wake_up_process(event_daemon); --- sleeper --- for (;;) { set_current_state(TASK_UNINTERRUPTIBLE); if (event_indicated) break; schedule(); } set_current_state() may be wrapped by: prepare_to_wait(); In the kswapd() case, event_indicated is kthread->should_stop. === offlining memory (waker) === kswapd_stop() kthread_stop() kthread->should_stop = 1 wake_up_process() wait_for_completion() === kswapd_try_to_sleep (sleeper) === kswapd_try_to_sleep() prepare_to_wait() . . schedule() . . finish_wait() The schedule() needs to be protected by a test of kthread->should_stop, which is wrapped by kthread_should_stop(). Reproducer: Do heavy file I/O in background. Do a memory offline/online in a tight loop Signed-off-by: Aaditya Kumar <aaditya.kumar@xxxxxxxxxxx> Acked-by: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> Reviewed-by: Minchan Kim <minchan@xxxxxxxxxx> Acked-by: Mel Gorman <mel@xxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/vmscan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff -puN mm/vmscan.c~mm-fix-lost-kswapd-wakeup-in-kswapd_stop mm/vmscan.c --- a/mm/vmscan.c~mm-fix-lost-kswapd-wakeup-in-kswapd_stop +++ a/mm/vmscan.c @@ -2706,7 +2706,10 @@ static void kswapd_try_to_sleep(pg_data_ * them before going back to sleep. */ set_pgdat_percpu_threshold(pgdat, calculate_normal_threshold); - schedule(); + + if (!kthread_should_stop()) + schedule(); + set_pgdat_percpu_threshold(pgdat, calculate_pressure_threshold); } else { if (remaining) _ Subject: Subject: mm: fix lost kswapd wakeup in kswapd_stop() Patches currently in -mm which might be from aaditya.kumar.30@xxxxxxxxx are mm-fix-lost-kswapd-wakeup-in-kswapd_stop.patch memory-hotplug-fix-kswapd-looping-forever-problem.patch memory-hotplug-fix-kswapd-looping-forever-problem-fix.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html