lkml.org 
[lkml]   [2012]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm: offlining memory may block forever
On 06/21/2012 01:23 AM, Aaditya Kumar wrote:

> 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@ap.sony.com>

Reviewed-by: Minchan Kim <minchan@kernel.org>

Nitpick: We can remove kthread_should_stop check earlier in kswapd_try_to_sleep.
But it's no biggie. And I hope you change patch title

Title : Fix loss of kswapd wakeup in kswapd_stop
Description: Offlining memory may block forever because blah, blah, blah.

--
Kind regards,
Minchan Kim


\
 
 \ /
  Last update: 2012-06-21 04:21    [W:0.074 / U:0.608 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site