From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755761AbZD1S2t (ORCPT ); Tue, 28 Apr 2009 14:28:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753179AbZD1S2k (ORCPT ); Tue, 28 Apr 2009 14:28:40 -0400 Received: from extu-mxob-1.symantec.com ([216.10.194.28]:51127 "EHLO extu-mxob-1.symantec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752027AbZD1S2j (ORCPT ); Tue, 28 Apr 2009 14:28:39 -0400 Date: Tue, 28 Apr 2009 19:25:59 +0100 (BST) From: Hugh Dickins X-X-Sender: hugh@blonde.anvils To: Mel Gorman cc: Andrew Morton , Christoph Lameter , Linux Memory Management List , KOSAKI Motohiro , Nick Piggin , Linux Kernel Mailing List , Lin Ming , Peter Zijlstra , Pekka Enberg , "Zhang, Yanmin" Subject: Re: [PATCH] Properly account for freed pages in free_pages_bulk() and when allocating high-order pages in buffered_rmqueue() V2 In-Reply-To: <20090428180759.GB18893@csn.ul.ie> Message-ID: References: <1240408407-21848-1-git-send-email-mel@csn.ul.ie> <1240819119.2567.884.camel@ymzhang> <20090427143845.GC912@csn.ul.ie> <1240883957.2567.886.camel@ymzhang> <20090428103159.GB23540@csn.ul.ie> <20090428165129.GA18893@csn.ul.ie> <20090428180759.GB18893@csn.ul.ie> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Apr 2009, Mel Gorman wrote: > free_pages_bulk() updates the number of free pages in the zone but it is > assuming that the pages being freed are order-0. While this is currently > always true, it's wrong to assume the order is 0. This patch fixes the problem. > > buffered_rmqueue() is not updating NR_FREE_PAGES when allocating pages with > __rmqueue(). As a result, high-order allocation will appear to increase > the number of free pages leading to the situation where the free page count > exceeds available RAM. This patch accounts for those allocated pages properly. > > This is a fix for page-allocator-update-nr_free_pages-only-as-necessary.patch. > > Changelog since V1 > o Change 1UL to 1 as it's unnecessary in this case to be unsigned long > > Reported-by: Zhang, Yanmin > Signed-off-by: Mel Gorman Thanks, Mel! (And I don't need to test it, since it's now remarkably similar to a patch I was preparing yesterday.) Acked-by: Hugh Dickins > --- > mm/page_alloc.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 5dd2d59..59eb2e1 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -545,7 +545,7 @@ static void free_pages_bulk(struct zone *zone, int count, > zone_clear_flag(zone, ZONE_ALL_UNRECLAIMABLE); > zone->pages_scanned = 0; > > - __mod_zone_page_state(zone, NR_FREE_PAGES, count); > + __mod_zone_page_state(zone, NR_FREE_PAGES, count << order); > while (count--) { > struct page *page; > > @@ -1151,6 +1151,7 @@ again: > } else { > spin_lock_irqsave(&zone->lock, flags); > page = __rmqueue(zone, order, migratetype); > + __mod_zone_page_state(zone, NR_FREE_PAGES, -(1 << order)); > spin_unlock(&zone->lock); > if (!page) > goto failed; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail172.messagelabs.com (mail172.messagelabs.com [216.82.254.3]) by kanga.kvack.org (Postfix) with ESMTP id 0956B6B0055 for ; Tue, 28 Apr 2009 14:26:21 -0400 (EDT) Date: Tue, 28 Apr 2009 19:25:59 +0100 (BST) From: Hugh Dickins Subject: Re: [PATCH] Properly account for freed pages in free_pages_bulk() and when allocating high-order pages in buffered_rmqueue() V2 In-Reply-To: <20090428180759.GB18893@csn.ul.ie> Message-ID: References: <1240408407-21848-1-git-send-email-mel@csn.ul.ie> <1240819119.2567.884.camel@ymzhang> <20090427143845.GC912@csn.ul.ie> <1240883957.2567.886.camel@ymzhang> <20090428103159.GB23540@csn.ul.ie> <20090428165129.GA18893@csn.ul.ie> <20090428180759.GB18893@csn.ul.ie> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org To: Mel Gorman Cc: Andrew Morton , Christoph Lameter , Linux Memory Management List , KOSAKI Motohiro , Nick Piggin , Linux Kernel Mailing List , Lin Ming , Peter Zijlstra , Pekka Enberg , "Zhang, Yanmin" List-ID: On Tue, 28 Apr 2009, Mel Gorman wrote: > free_pages_bulk() updates the number of free pages in the zone but it is > assuming that the pages being freed are order-0. While this is currently > always true, it's wrong to assume the order is 0. This patch fixes the problem. > > buffered_rmqueue() is not updating NR_FREE_PAGES when allocating pages with > __rmqueue(). As a result, high-order allocation will appear to increase > the number of free pages leading to the situation where the free page count > exceeds available RAM. This patch accounts for those allocated pages properly. > > This is a fix for page-allocator-update-nr_free_pages-only-as-necessary.patch. > > Changelog since V1 > o Change 1UL to 1 as it's unnecessary in this case to be unsigned long > > Reported-by: Zhang, Yanmin > Signed-off-by: Mel Gorman Thanks, Mel! (And I don't need to test it, since it's now remarkably similar to a patch I was preparing yesterday.) Acked-by: Hugh Dickins > --- > mm/page_alloc.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 5dd2d59..59eb2e1 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -545,7 +545,7 @@ static void free_pages_bulk(struct zone *zone, int count, > zone_clear_flag(zone, ZONE_ALL_UNRECLAIMABLE); > zone->pages_scanned = 0; > > - __mod_zone_page_state(zone, NR_FREE_PAGES, count); > + __mod_zone_page_state(zone, NR_FREE_PAGES, count << order); > while (count--) { > struct page *page; > > @@ -1151,6 +1151,7 @@ again: > } else { > spin_lock_irqsave(&zone->lock, flags); > page = __rmqueue(zone, order, migratetype); > + __mod_zone_page_state(zone, NR_FREE_PAGES, -(1 << order)); > spin_unlock(&zone->lock); > if (!page) > goto failed; -- 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