From: Dave Hansen <dave@linux.vnet.ibm.com>
To: mgorman@suse.de
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org,
torvalds@linux-foundation.org, linux-mm@kvack.org,
Dave Hansen <dave@linux.vnet.ibm.com>
Subject: [PATCH] [3.7-rc] fix incorrect NR_FREE_PAGES accounting (appears like memory leak)
Date: Wed, 21 Nov 2012 14:21:51 -0500 [thread overview]
Message-ID: <20121121192151.3FFE0A9A@kernel.stglabs.ibm.com> (raw)
This needs to make it in before 3.7 is released.
--
There have been some 3.7-rc reports of vm issues, including some
kswapd bugs and, more importantly, some memory "leaks":
http://www.spinics.net/lists/linux-mm/msg46187.html
https://bugzilla.kernel.org/show_bug.cgi?id=50181
The post-3.6 commit 1fb3f8ca took split_free_page() and reused
it for the compaction code. It does something curious with
capture_free_page() (previously known as split_free_page()):
int capture_free_page(struct page *page, int alloc_order,
...
__mod_zone_page_state(zone, NR_FREE_PAGES, -(1UL << order));
- /* Split into individual pages */
- set_page_refcounted(page);
- split_page(page, order);
+ if (alloc_order != order)
+ expand(zone, page, alloc_order, order,
+ &zone->free_area[order], migratetype);
Note that expand() puts the pages _back_ in the allocator, but it
does not bump NR_FREE_PAGES. We "return" 'alloc_order' worth of
pages, but we accounted for removing 'order' in the
__mod_zone_page_state() call. For the old split_page()-style use
(order==alloc_order) the bug will not trigger. But, when called
from the compaction code where we occasionally get a larger page
out of the buddy allocator than we need, we will run in to this.
This patch simply changes the NR_FREE_PAGES manipulation to the
correct 'alloc_order' instead of 'order'.
I've been able to repeatedly trigger this in my testing
environment. The amount "leaked" very closely tracks the
imbalance I see in buddy pages vs. NR_FREE_PAGES. I have
confirmed that this patch fixes the imbalance
Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
Acked-by: Mel Gorman <mgorman@suse.de>
---
linux-2.6.git-dave/mm/page_alloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff -puN mm/page_alloc.c~leak-fix-20121120-2 mm/page_alloc.c
--- linux-2.6.git/mm/page_alloc.c~leak-fix-20121120-2 2012-11-21 14:14:52.053714749 -0500
+++ linux-2.6.git-dave/mm/page_alloc.c 2012-11-21 14:14:52.069714883 -0500
@@ -1405,7 +1405,7 @@ int capture_free_page(struct page *page,
mt = get_pageblock_migratetype(page);
if (unlikely(mt != MIGRATE_ISOLATE))
- __mod_zone_freepage_state(zone, -(1UL << order), mt);
+ __mod_zone_freepage_state(zone, -(1UL << alloc_order), mt);
if (alloc_order != order)
expand(zone, page, alloc_order, order,
_
--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2012-11-21 19:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-21 19:21 Dave Hansen [this message]
2012-11-26 11:23 ` [PATCH] mm: compaction: Fix return value of capture_free_page Mel Gorman
2012-11-26 15:06 ` Dave Hansen
2012-11-27 11:07 ` Mel Gorman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121121192151.3FFE0A9A@kernel.stglabs.ibm.com \
--to=dave@linux.vnet.ibm.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).