From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933563Ab0JRWmd (ORCPT ); Mon, 18 Oct 2010 18:42:33 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:51505 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933093Ab0JRWm3 (ORCPT ); Mon, 18 Oct 2010 18:42:29 -0400 Date: Mon, 18 Oct 2010 15:41:37 -0700 From: Andrew Morton To: Neil Brown Cc: Wu Fengguang , Rik van Riel , KOSAKI Motohiro , KAMEZAWA Hiroyuki , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "Li, Shaohua" Subject: Re: Deadlock possibly caused by too_many_isolated. Message-Id: <20101018154137.90f5325f.akpm@linux-foundation.org> In-Reply-To: <20101019093142.509d6947@notabene> References: <20100915091118.3dbdc961@notabene> <4C90139A.1080809@redhat.com> <20100915122334.3fa7b35f@notabene> <20100915082843.GA17252@localhost> <20100915184434.18e2d933@notabene> <20101018151459.2b443221@notabene> <20101018161504.GB29500@localhost> <20101018145859.eee1ae33.akpm@linux-foundation.org> <20101019093142.509d6947@notabene> X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.9; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 19 Oct 2010 09:31:42 +1100 Neil Brown wrote: > On Mon, 18 Oct 2010 14:58:59 -0700 > Andrew Morton wrote: > > > On Tue, 19 Oct 2010 00:15:04 +0800 > > Wu Fengguang wrote: > > > > > Neil find that if too_many_isolated() returns true while performing > > > direct reclaim we can end up waiting for other threads to complete their > > > direct reclaim. If those threads are allowed to enter the FS or IO to > > > free memory, but this thread is not, then it is possible that those > > > threads will be waiting on this thread and so we get a circular > > > deadlock. > > > > > > some task enters direct reclaim with GFP_KERNEL > > > => too_many_isolated() false > > > => vmscan and run into dirty pages > > > => pageout() > > > => take some FS lock > > > => fs/block code does GFP_NOIO allocation > > > => enter direct reclaim again > > > => too_many_isolated() true > > > => waiting for others to progress, however the other > > > tasks may be circular waiting for the FS lock.. I'm assuming that the last four "=>"'s here should have been indented another stop. > > > The fix is to let !__GFP_IO and !__GFP_FS direct reclaims enjoy higher > > > priority than normal ones, by honouring them higher throttle threshold. > > > > > > Now !GFP_IOFS reclaims won't be waiting for GFP_IOFS reclaims to > > > progress. They will be blocked only when there are too many concurrent > > > !GFP_IOFS reclaims, however that's very unlikely because the IO-less > > > direct reclaims is able to progress much more faster, and they won't > > > deadlock each other. The threshold is raised high enough for them, so > > > that there can be sufficient parallel progress of !GFP_IOFS reclaims. > > > > I'm not sure that this is really a full fix. Torsten's analysis does > > appear to point at the real bug: raid1 has code paths which allocate > > more than a single element from a mempool without starting IO against > > previous elements. > > ... point at "a" real bug. > > I think there are two bugs here. > The raid1 bug that Torsten mentions is certainly real (and has been around > for an embarrassingly long time). > The bug that I identified in too_many_isolated is also a real bug and can be > triggered without md/raid1 in the mix. > So this is not a 'full fix' for every bug in the kernel :-), but it could > well be a full fix for this particular bug. > Can we just delete the too_many_isolated() logic? (Crappy comment describes what the code does but not why it does it). From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail143.messagelabs.com (mail143.messagelabs.com [216.82.254.35]) by kanga.kvack.org (Postfix) with ESMTP id 8DE586B00DA for ; Mon, 18 Oct 2010 18:42:16 -0400 (EDT) Date: Mon, 18 Oct 2010 15:41:37 -0700 From: Andrew Morton Subject: Re: Deadlock possibly caused by too_many_isolated. Message-Id: <20101018154137.90f5325f.akpm@linux-foundation.org> In-Reply-To: <20101019093142.509d6947@notabene> References: <20100915091118.3dbdc961@notabene> <4C90139A.1080809@redhat.com> <20100915122334.3fa7b35f@notabene> <20100915082843.GA17252@localhost> <20100915184434.18e2d933@notabene> <20101018151459.2b443221@notabene> <20101018161504.GB29500@localhost> <20101018145859.eee1ae33.akpm@linux-foundation.org> <20101019093142.509d6947@notabene> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org To: Neil Brown Cc: Wu Fengguang , Rik van Riel , KOSAKI Motohiro , KAMEZAWA Hiroyuki , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "Li, Shaohua" List-ID: On Tue, 19 Oct 2010 09:31:42 +1100 Neil Brown wrote: > On Mon, 18 Oct 2010 14:58:59 -0700 > Andrew Morton wrote: > > > On Tue, 19 Oct 2010 00:15:04 +0800 > > Wu Fengguang wrote: > > > > > Neil find that if too_many_isolated() returns true while performing > > > direct reclaim we can end up waiting for other threads to complete their > > > direct reclaim. If those threads are allowed to enter the FS or IO to > > > free memory, but this thread is not, then it is possible that those > > > threads will be waiting on this thread and so we get a circular > > > deadlock. > > > > > > some task enters direct reclaim with GFP_KERNEL > > > => too_many_isolated() false > > > => vmscan and run into dirty pages > > > => pageout() > > > => take some FS lock > > > => fs/block code does GFP_NOIO allocation > > > => enter direct reclaim again > > > => too_many_isolated() true > > > => waiting for others to progress, however the other > > > tasks may be circular waiting for the FS lock.. I'm assuming that the last four "=>"'s here should have been indented another stop. > > > The fix is to let !__GFP_IO and !__GFP_FS direct reclaims enjoy higher > > > priority than normal ones, by honouring them higher throttle threshold. > > > > > > Now !GFP_IOFS reclaims won't be waiting for GFP_IOFS reclaims to > > > progress. They will be blocked only when there are too many concurrent > > > !GFP_IOFS reclaims, however that's very unlikely because the IO-less > > > direct reclaims is able to progress much more faster, and they won't > > > deadlock each other. The threshold is raised high enough for them, so > > > that there can be sufficient parallel progress of !GFP_IOFS reclaims. > > > > I'm not sure that this is really a full fix. Torsten's analysis does > > appear to point at the real bug: raid1 has code paths which allocate > > more than a single element from a mempool without starting IO against > > previous elements. > > ... point at "a" real bug. > > I think there are two bugs here. > The raid1 bug that Torsten mentions is certainly real (and has been around > for an embarrassingly long time). > The bug that I identified in too_many_isolated is also a real bug and can be > triggered without md/raid1 in the mix. > So this is not a 'full fix' for every bug in the kernel :-), but it could > well be a full fix for this particular bug. > Can we just delete the too_many_isolated() logic? (Crappy comment describes what the code does but not why it does it). -- 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