Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753711Ab0HRTbR (ORCPT ); Wed, 18 Aug 2010 15:31:17 -0400 Received: from mx2.netapp.com ([216.240.18.37]:25752 "EHLO mx2.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753478Ab0HRTbO convert rfc822-to-8bit (ORCPT ); Wed, 18 Aug 2010 15:31:14 -0400 X-IronPort-AV: E=Sophos;i="4.56,229,1280732400"; d="scan'208";a="431432429" Subject: Re: [PATCH] VM: kswapd should not do blocking memory allocations From: Trond Myklebust To: Ram Pai Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org In-Reply-To: References: <1282158241.8540.85.camel@heimdal.trondhjem.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Organization: NetApp Date: Wed, 18 Aug 2010 15:31:12 -0400 Message-ID: <1282159872.8540.96.camel@heimdal.trondhjem.org> Mime-Version: 1.0 X-Mailer: Evolution 2.30.2 (2.30.2-4.fc13) X-OriginalArrivalTime: 18 Aug 2010 19:31:14.0077 (UTC) FILETIME=[EBA3ECD0:01CB3F0B] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2544 Lines: 75 On Wed, 2010-08-18 at 12:24 -0700, Ram Pai wrote: > > > On Wed, Aug 18, 2010 at 12:04 PM, Trond Myklebust > wrote: > From: Trond Myklebust > > Allowing kswapd to do GFP_KERNEL memory allocations (or any > blocking memory > allocations) is wrong and can cause deadlocks in > try_to_release_page(), as > the filesystem believes it is safe to allocate new memory and > block, > whereas kswapd is there specifically to clear a low-memory > situation... > > Set the gfp_mask to GFP_IOFS instead. > > Signed-off-by: Trond Myklebust > --- > > mm/vmscan.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index ec5ddcc..716dd16 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -2095,7 +2095,7 @@ static unsigned long > balance_pgdat(pg_data_t *pgdat, int order) > unsigned long total_scanned; > struct reclaim_state *reclaim_state = > current->reclaim_state; > struct scan_control sc = { > - .gfp_mask = GFP_KERNEL, > + .gfp_mask = GFP_IOFS, > .may_unmap = 1, > .may_swap = 1, > /* > > Trond, > > Has anyone hit this issue? Or is this based on code > inspection? > > The reason I ask is we are seeing a problem, similar to > the symptom described, on RH based kernel but have not been able to > reproduce on 2.6.35. Hi Ram, I was seeing it on NFS until I put in the following kswapd-specific hack into nfs_release_page(): /* Only do I/O if gfp is a superset of GFP_KERNEL */ if (mapping && (gfp & GFP_KERNEL) == GFP_KERNEL) { int how = FLUSH_SYNC; /* Don't let kswapd deadlock waiting for OOM RPC calls */ if (current_is_kswapd()) how = 0; nfs_commit_inode(mapping->host, how); } Remove the 'if (current_is_kswapd())' line, and run an mmap() write intensive workload, and it should hang pretty much every time. Cheers Trond -- 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/