Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756902Ab2FTRNo (ORCPT ); Wed, 20 Jun 2012 13:13:44 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:56643 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754407Ab2FTRNm (ORCPT ); Wed, 20 Jun 2012 13:13:42 -0400 Date: Wed, 20 Jun 2012 10:13:37 -0700 From: Greg KH To: Aaditya Kumar Cc: KOSAKI Motohiro , linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@kernel.org, kosaki.motohiro@jp.fujitsu.com, Mel Gorman , KAMEZAWA Hiroyuki , Minchan Kim , Michal Hocko , 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 Message-ID: <20120620171337.GA10287@kroah.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1791 Lines: 61 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 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. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/