linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] page owners: correct page->order when to free page
@ 2014-03-12  6:58 Jungsoo Son
  2014-03-12  7:06 ` Minchan Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Jungsoo Son @ 2014-03-12  6:58 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, linux-mm, Jungsoo Son, Minchan Kim, Joonsoo Kim

When I use PAGE_OWNER in mmotm tree, I found a problem that mismatches
the number of allocated pages. When I investigate, the problem is that
set_page_order is called for only a head page if freed page is merged to
a higher order page in the buddy allocator so tail pages of the higher
order page couldn't be reset to page->order = -1.

It means when we do 'cat /proc/page-owner', it could show wrong
information.

So page->order should be set to -1 for all the tail pages as well as the
first page before buddy allocator merges them.

This patch is for clearing page->order of all the tail pages in
free_pages_prepare() when to free page.

Signed-off-by: Jungsoo Son <jungsoo.son@lge.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
 mm/page_alloc.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index dfbc967..9b946f0 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -741,6 +741,13 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
 	if (bad)
 		return false;
 
+#ifdef CONFIG_PAGE_OWNER
+	for (i = 0; i < (1 << order); i++) {
+		struct page *p = (page + i);
+		p->order = -1;
+	}
+#endif
+
 	if (!PageHighMem(page)) {
 		debug_check_no_locks_freed(page_address(page),
 					   PAGE_SIZE << order);
-- 
1.7.9.5

--
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>

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] page owners: correct page->order when to free page
  2014-03-12  6:58 [PATCH] page owners: correct page->order when to free page Jungsoo Son
@ 2014-03-12  7:06 ` Minchan Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Minchan Kim @ 2014-03-12  7:06 UTC (permalink / raw)
  To: Jungsoo Son; +Cc: akpm, linux-kernel, linux-mm, Joonsoo Kim

On Wed, Mar 12, 2014 at 03:58:06PM +0900, Jungsoo Son wrote:
> When I use PAGE_OWNER in mmotm tree, I found a problem that mismatches
> the number of allocated pages. When I investigate, the problem is that
> set_page_order is called for only a head page if freed page is merged to
> a higher order page in the buddy allocator so tail pages of the higher
> order page couldn't be reset to page->order = -1.
> 
> It means when we do 'cat /proc/page-owner', it could show wrong
> information.

We could make read_page_owner more smart so that it could check
PageBuddy at head page of high order page and skip tail pages but
it needs zone->lock which is already heavy contention lock.
Additionally, it could make wrong information on pcp pages, too.
So, I like this simple approach.

> 
> So page->order should be set to -1 for all the tail pages as well as the
> first page before buddy allocator merges them.
> 
> This patch is for clearing page->order of all the tail pages in
> free_pages_prepare() when to free page.
> 
> Signed-off-by: Jungsoo Son <jungsoo.son@lge.com>
> Cc: Minchan Kim <minchan@kernel.org>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>

Acked-by: Minchan Kim <minchan@kernel.org>

Thanks.

-- 
Kind regards,
Minchan Kim

--
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>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-12  7:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-12  6:58 [PATCH] page owners: correct page->order when to free page Jungsoo Son
2014-03-12  7:06 ` Minchan Kim

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).