Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754026Ab0HRUKW (ORCPT ); Wed, 18 Aug 2010 16:10:22 -0400 Received: from mx2.netapp.com ([216.240.18.37]:15701 "EHLO mx2.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753748Ab0HRUKO convert rfc822-to-8bit (ORCPT ); Wed, 18 Aug 2010 16:10:14 -0400 X-IronPort-AV: E=Sophos;i="4.56,229,1280732400"; d="scan'208";a="431462830" Subject: Re: [PATCH] VM: kswapd should not do blocking memory allocations From: Trond Myklebust To: Chris Mason Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org In-Reply-To: <20100818193440.GZ5854@think> References: <1282158241.8540.85.camel@heimdal.trondhjem.org> <20100818193440.GZ5854@think> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Organization: NetApp Date: Wed, 18 Aug 2010 16:10:10 -0400 Message-ID: <1282162210.8540.100.camel@heimdal.trondhjem.org> Mime-Version: 1.0 X-Mailer: Evolution 2.30.2 (2.30.2-4.fc13) X-OriginalArrivalTime: 18 Aug 2010 20:10:12.0464 (UTC) FILETIME=[5D6D7700:01CB3F11] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1595 Lines: 34 On Wed, 2010-08-18 at 15:34 -0400, Chris Mason wrote: > On Wed, Aug 18, 2010 at 03:04:01PM -0400, 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. > > I always thought releasepage was supposed to do almost zero work. It > could release an instantly freeable page but it wasn't supposed to dive > in and solve world hunger or anything. > > I thought the VM would be using writepage for that. writepage isn't sufficient for the NFS case: the page may be in the 'clean but unstable' state, in which case the NFS client needs to send a COMMIT rpc call before the page can finally be released. That is why we need the gfp_flag to tell us when it is safe to do this, and when it is not. The main case where it is safe and necessary for try_to_release_page() to initiate a COMMIT call is in the invalidate_inode_pages2(). We might want to do it in the kswapd case too, but in that case, we definitely should tell the filesystem that it is unsafe to block. 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/