From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail203.messagelabs.com (mail203.messagelabs.com [216.82.254.243]) by kanga.kvack.org (Postfix) with ESMTP id 00CCE6B0035 for ; Wed, 26 Oct 2011 02:26:45 -0400 (EDT) Received: from wpaz1.hot.corp.google.com (wpaz1.hot.corp.google.com [172.24.198.65]) by smtp-out.google.com with ESMTP id p9Q6QgCj012476 for ; Tue, 25 Oct 2011 23:26:42 -0700 Received: from vcbfl15 (vcbfl15.prod.google.com [10.220.204.79]) by wpaz1.hot.corp.google.com with ESMTP id p9Q6P4SI031481 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Tue, 25 Oct 2011 23:26:41 -0700 Received: by vcbfl15 with SMTP id fl15so1932869vcb.9 for ; Tue, 25 Oct 2011 23:26:41 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1319524789-22818-1-git-send-email-ccross@android.com> <20111025090956.GA10797@suse.de> Date: Tue, 25 Oct 2011 23:26:40 -0700 Message-ID: Subject: Re: [PATCH] mm: avoid livelock on !__GFP_FS allocations From: Colin Cross Content-Type: text/plain; charset=ISO-8859-1 Sender: owner-linux-mm@kvack.org List-ID: To: David Rientjes Cc: Mel Gorman , linux-kernel@vger.kernel.org, Andrew Morton , KAMEZAWA Hiroyuki , Andrea Arcangeli , linux-mm@kvack.org On Tue, Oct 25, 2011 at 11:24 PM, David Rientjes wrote: > On Tue, 25 Oct 2011, Colin Cross wrote: > >> > Or, rather, when pm_restrict_gfp_mask() clears __GFP_IO and __GFP_FS that >> > it also has the same behavior as __GFP_NORETRY in should_alloc_retry() by >> > setting a variable in file scope. >> > >> >> Why do you prefer that over adding a gfp_required_mask? >> > > Because it avoids an unnecessary OR in the page and slab allocator > fastpaths which are red hot :) > Makes sense. What about this? Official patch to follow. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index fef8dc3..59cd4ff 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1786,6 +1786,13 @@ should_alloc_retry(gfp_t gfp_mask, unsigned int order, return 0; /* + * If PM has disabled I/O, OOM is disabled and reclaim is unlikely + * to make any progress. To prevent a livelock, don't retry. + */ + if (!(gfp_allowed_mask & __GFP_FS)) + return 0; + + /* * In this implementation, order <= PAGE_ALLOC_COSTLY_ORDER * means __GFP_NOFAIL, but that may not be true in other * implementations. -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org