From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx137.postini.com [74.125.245.137]) by kanga.kvack.org (Postfix) with SMTP id D153E6B0033 for ; Thu, 30 May 2013 16:00:14 -0400 (EDT) Received: by mail-ob0-f172.google.com with SMTP id wo10so1476626obc.31 for ; Thu, 30 May 2013 13:00:13 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <2434dea05a7fda7e7ccf48f70124bd65f2556b2d.1369935749.git.aquini@redhat.com> References: <2434dea05a7fda7e7ccf48f70124bd65f2556b2d.1369935749.git.aquini@redhat.com> From: KOSAKI Motohiro Date: Thu, 30 May 2013 15:59:53 -0400 Message-ID: Subject: Re: [PATCH] swap: avoid read_swap_cache_async() race to deadlock while waiting on discard I/O compeletion Content-Type: text/plain; charset=ISO-8859-1 Sender: owner-linux-mm@kvack.org List-ID: To: Rafael Aquini Cc: LKML , "linux-mm@kvack.org" , Andrew Morton , Hugh Dickins , shli@kernel.org, "riel@redhat.com" , Larry Woodman , KAMEZAWA Hiroyuki , stable@vger.kernel.org On Thu, May 30, 2013 at 2:05 PM, 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 Acked-by: KOSAKI Motohiro -- 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: email@kvack.org