From: Greg KH <gregkh@linuxfoundation.org>
To: Aaditya Kumar <aaditya.kumar.30@gmail.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
stable@kernel.org, kosaki.motohiro@jp.fujitsu.com,
Mel Gorman <mel@csn.ul.ie>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Minchan Kim <minchan@kernel.org>, Michal Hocko <mhocko@suse.cz>,
tim.bird@am.sony.com, frank.rowand@am.sony.com,
takuzo.ohara@ap.sony.com, kan.iibuchi@jp.sony.com,
aaditya.kumar@ap.sony.com
Subject: Re: [PATCH] mm: offlining memory may block forever
Date: Wed, 20 Jun 2012 10:13:37 -0700 [thread overview]
Message-ID: <20120620171337.GA10287@kroah.com> (raw)
In-Reply-To: <CAEtiSau6dRYVOSD4-QUWkYZ8p7z1ATLHZY9v871VS=o0LduU_Q@mail.gmail.com>
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@ap.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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <gregkh@linuxfoundation.org>
To: Aaditya Kumar <aaditya.kumar.30@gmail.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
stable@kernel.org, kosaki.motohiro@jp.fujitsu.com,
Mel Gorman <mel@csn.ul.ie>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Minchan Kim <minchan@kernel.org>, Michal Hocko <mhocko@suse.cz>,
tim.bird@am.sony.com, frank.rowand@am.sony.com,
takuzo.ohara@ap.sony.com, kan.iibuchi@jp.sony.com,
aaditya.kumar@ap.sony.com
Subject: Re: [PATCH] mm: offlining memory may block forever
Date: Wed, 20 Jun 2012 10:13:37 -0700 [thread overview]
Message-ID: <20120620171337.GA10287@kroah.com> (raw)
In-Reply-To: <CAEtiSau6dRYVOSD4-QUWkYZ8p7z1ATLHZY9v871VS=o0LduU_Q@mail.gmail.com>
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@ap.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>
next prev parent reply other threads:[~2012-06-20 17:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-20 16:23 [PATCH] mm: offlining memory may block forever Aaditya Kumar
2012-06-20 16:23 ` Aaditya Kumar
2012-06-20 17:13 ` Greg KH [this message]
2012-06-20 17:13 ` Greg KH
2012-06-20 18:49 ` KOSAKI Motohiro
2012-06-20 18:49 ` KOSAKI Motohiro
2012-06-21 1:37 ` Minchan Kim
2012-06-21 1:37 ` Minchan Kim
2012-06-21 13:04 ` Mel Gorman
2012-06-21 13:04 ` Mel Gorman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120620171337.GA10287@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=aaditya.kumar.30@gmail.com \
--cc=aaditya.kumar@ap.sony.com \
--cc=frank.rowand@am.sony.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kan.iibuchi@jp.sony.com \
--cc=kosaki.motohiro@gmail.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=mhocko@suse.cz \
--cc=minchan@kernel.org \
--cc=stable@kernel.org \
--cc=takuzo.ohara@ap.sony.com \
--cc=tim.bird@am.sony.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.