Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754920Ab3E3Sef (ORCPT ); Thu, 30 May 2013 14:34:35 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59030 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756113Ab3E3SeT (ORCPT ); Thu, 30 May 2013 14:34:19 -0400 Date: Fri, 31 May 2013 03:32:58 +0900 From: Greg KH To: Rafael Aquini Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, hughd@google.com, shli@kernel.org, riel@redhat.com, lwoodman@redhat.com, kosaki.motohiro@jp.fujitsu.com, kamezawa.hiroyu@jp.fujitsu.com, stable@vger.kernel.org Subject: Re: [PATCH] swap: avoid read_swap_cache_async() race to deadlock while waiting on discard I/O compeletion Message-ID: <20130530183258.GA3453@kroah.com> References: <2434dea05a7fda7e7ccf48f70124bd65f2556b2d.1369935749.git.aquini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2434dea05a7fda7e7ccf48f70124bd65f2556b2d.1369935749.git.aquini@redhat.com> 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: 1508 Lines: 33 On Thu, May 30, 2013 at 03:05:00PM -0300, Rafael Aquini wrote: > read_swap_cache_async() can race against get_swap_page(), and stumble across > a SWAP_HAS_CACHE entry in the swap map whose page wasn't brought into the > swapcache yet. This transient swap_map state is expected to be transitory, > but the actual placement of discard at scan_swap_map() inserts a wait for > I/O completion thus making the thread at read_swap_cache_async() to loop > around its -EEXIST case, while the other end at get_swap_page() > is scheduled away at scan_swap_map(). This can leave the system deadlocked > if the I/O completion happens to be waiting on the CPU workqueue where > read_swap_cache_async() is busy looping and !CONFIG_PREEMPT. > > This patch introduces a cond_resched() call to make the aforementioned > read_swap_cache_async() busy loop condition to bail out when necessary, > thus avoiding the subtle race window. > > Signed-off-by: Rafael Aquini > --- > mm/swap_state.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) 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/