From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: aaditya.kumar.30@gmail.com
Cc: kosaki.motohiro@gmail.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, stable@kernel.org,
kosaki.motohiro@jp.fujitsu.com, gregkh@linuxfoundation.org,
mel@csn.ul.ie, kamezawa.hiroyu@jp.fujitsu.com,
minchan@kernel.org, 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 14:49:05 -0400 [thread overview]
Message-ID: <4FE21B21.6070608@jp.fujitsu.com> (raw)
In-Reply-To: <CAEtiSau6dRYVOSD4-QUWkYZ8p7z1ATLHZY9v871VS=o0LduU_Q@mail.gmail.com>
On 6/20/2012 12:23 PM, 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) ---
Please avoid "---". This is used for a separator between a patch
description and code.
Other than that,
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> 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>
>
> ---
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index eeb3bc9..b60691e 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -2688,7 +2688,10 @@ static void kswapd_try_to_sleep(pg_data_t
> *pgdat, int order, int classzone_idx)
> * 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)
>
--
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: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: aaditya.kumar.30@gmail.com
Cc: kosaki.motohiro@gmail.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, stable@kernel.org,
kosaki.motohiro@jp.fujitsu.com, gregkh@linuxfoundation.org,
mel@csn.ul.ie, kamezawa.hiroyu@jp.fujitsu.com,
minchan@kernel.org, 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 14:49:05 -0400 [thread overview]
Message-ID: <4FE21B21.6070608@jp.fujitsu.com> (raw)
In-Reply-To: <CAEtiSau6dRYVOSD4-QUWkYZ8p7z1ATLHZY9v871VS=o0LduU_Q@mail.gmail.com>
On 6/20/2012 12:23 PM, 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) ---
Please avoid "---". This is used for a separator between a patch
description and code.
Other than that,
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> 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>
>
> ---
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index eeb3bc9..b60691e 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -2688,7 +2688,10 @@ static void kswapd_try_to_sleep(pg_data_t
> *pgdat, int order, int classzone_idx)
> * 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)
>
next prev parent reply other threads:[~2012-06-20 18:49 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
2012-06-20 17:13 ` Greg KH
2012-06-20 18:49 ` KOSAKI Motohiro [this message]
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=4FE21B21.6070608@jp.fujitsu.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=aaditya.kumar.30@gmail.com \
--cc=aaditya.kumar@ap.sony.com \
--cc=frank.rowand@am.sony.com \
--cc=gregkh@linuxfoundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kan.iibuchi@jp.sony.com \
--cc=kosaki.motohiro@gmail.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.