[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120620171337.GA10287@kroah.com>
Date: Wed, 20 Jun 2012 10:13:37 -0700
From: Greg KH <gregkh@...uxfoundation.org>
To: Aaditya Kumar <aaditya.kumar.30@...il.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@...il.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
stable@...nel.org, kosaki.motohiro@...fujitsu.com,
Mel Gorman <mel@....ul.ie>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
Minchan Kim <minchan@...nel.org>,
Michal Hocko <mhocko@...e.cz>, tim.bird@...sony.com,
frank.rowand@...sony.com, takuzo.ohara@...sony.com,
kan.iibuchi@...sony.com, aaditya.kumar@...sony.com
Subject: Re: [PATCH] mm: offlining memory may block forever
On Wed, Jun 20, 2012 at 09:53:31PM +0530, 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@...sony.com>
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read Documentation/stable_kernel_rules.txt
for how to do this properly.
</formletter>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists