Re: [PATCH v1 1/3] /proc/kpageflags: return KPF_BUDDY for "tail" buddy pages

From: Vladimir Davydov
Date: Thu Feb 04 2016 - 11:42:41 EST


On Thu, Feb 04, 2016 at 04:08:01PM +0900, Naoya Horiguchi wrote:
> Currently /proc/kpageflags returns nothing for "tail" buddy pages, which
> is inconvenient when grasping how free pages are distributed. This patch
> sets KPF_BUDDY for such pages.

Looks reasonable to me,

Reviewed-by: Vladimir Davydov <vdavydov@xxxxxxxxxxxxx>

>
> With this patch:
>
> $ grep MemFree /proc/meminfo ; tools/vm/page-types -b buddy
> MemFree: 3134992 kB
> flags page-count MB symbolic-flags long-symbolic-flags
> 0x0000000000000400 779272 3044 __________B_______________________________ buddy
> 0x0000000000000c00 4385 17 __________BM______________________________ buddy,mmap
> total 783657 3061

Why are buddy pages reported as mmapped? That looks weird. Shouldn't we
fix it? Something like this, may be?
--
From: Vladimir Davydov <vdavydov@xxxxxxxxxxxxx>
Subject: [PATCH] proc: kpageflags: do not report buddy and balloon pages as
mapped

PageBuddy and PageBalloon are not usual page flags - they are identified
by a special negative (so as not to confuse with mapped pages) value of
page->_mapcount. Since /proc/kpageflags uses page_mapcount helper to
check if a page is mapped, it reports pages of these kinds as being
mapped, which is confusing. Fix that by replacing page_mapcount with
page_mapped.

Signed-off-by: Vladimir Davydov <vdavydov@xxxxxxxxxxxxx>

diff --git a/fs/proc/page.c b/fs/proc/page.c
index b2855eea5405..332450d87ea4 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -105,7 +105,7 @@ u64 stable_page_flags(struct page *page)
* Note that page->_mapcount is overloaded in SLOB/SLUB/SLQB, so the
* simple test in page_mapcount() is not enough.
*/
- if (!PageSlab(page) && page_mapcount(page))
+ if (!PageSlab(page) && page_mapped(page))
u |= 1 << KPF_MMAP;
if (PageAnon(page))
u |= 1 << KPF_ANON;