Commit 832fc1de authored by Naoya Horiguchi's avatar Naoya Horiguchi Committed by Linus Torvalds

/proc/kpageflags: return KPF_BUDDY for "tail" buddy pages

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.

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

783657 pages is 3134628 kB (roughly consistent with the global counter,)
so it's OK.

[akpm@linux-foundation.org: update comment, per Naoya]
Signed-off-by: default avatarNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Reviewed-by: default avatarVladimir Davydov <vdavydov@virtuozzo.com&gt;>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 12580e4b
...@@ -103,9 +103,9 @@ u64 stable_page_flags(struct page *page) ...@@ -103,9 +103,9 @@ u64 stable_page_flags(struct page *page)
* pseudo flags for the well known (anonymous) memory mapped pages * pseudo flags for the well known (anonymous) memory mapped pages
* *
* Note that page->_mapcount is overloaded in SLOB/SLUB/SLQB, so the * Note that page->_mapcount is overloaded in SLOB/SLUB/SLQB, so the
* simple test in page_mapcount() is not enough. * simple test in page_mapped() is not enough.
*/ */
if (!PageSlab(page) && page_mapcount(page)) if (!PageSlab(page) && page_mapped(page))
u |= 1 << KPF_MMAP; u |= 1 << KPF_MMAP;
if (PageAnon(page)) if (PageAnon(page))
u |= 1 << KPF_ANON; u |= 1 << KPF_ANON;
...@@ -148,6 +148,8 @@ u64 stable_page_flags(struct page *page) ...@@ -148,6 +148,8 @@ u64 stable_page_flags(struct page *page)
*/ */
if (PageBuddy(page)) if (PageBuddy(page))
u |= 1 << KPF_BUDDY; u |= 1 << KPF_BUDDY;
else if (page_count(page) == 0 && is_free_buddy_page(page))
u |= 1 << KPF_BUDDY;
if (PageBalloon(page)) if (PageBalloon(page))
u |= 1 << KPF_BALLOON; u |= 1 << KPF_BALLOON;
......
...@@ -593,6 +593,8 @@ static inline void __ClearPageBuddy(struct page *page) ...@@ -593,6 +593,8 @@ static inline void __ClearPageBuddy(struct page *page)
atomic_set(&page->_mapcount, -1); atomic_set(&page->_mapcount, -1);
} }
extern bool is_free_buddy_page(struct page *page);
#define PAGE_BALLOON_MAPCOUNT_VALUE (-256) #define PAGE_BALLOON_MAPCOUNT_VALUE (-256)
static inline int PageBalloon(struct page *page) static inline int PageBalloon(struct page *page)
......
...@@ -148,9 +148,6 @@ extern int __isolate_free_page(struct page *page, unsigned int order); ...@@ -148,9 +148,6 @@ extern int __isolate_free_page(struct page *page, unsigned int order);
extern void __free_pages_bootmem(struct page *page, unsigned long pfn, extern void __free_pages_bootmem(struct page *page, unsigned long pfn,
unsigned int order); unsigned int order);
extern void prep_compound_page(struct page *page, unsigned int order); extern void prep_compound_page(struct page *page, unsigned int order);
#ifdef CONFIG_MEMORY_FAILURE
extern bool is_free_buddy_page(struct page *page);
#endif
extern int user_min_free_kbytes; extern int user_min_free_kbytes;
#if defined CONFIG_COMPACTION || defined CONFIG_CMA #if defined CONFIG_COMPACTION || defined CONFIG_CMA
......
...@@ -7152,7 +7152,6 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn) ...@@ -7152,7 +7152,6 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn)
} }
#endif #endif
#ifdef CONFIG_MEMORY_FAILURE
bool is_free_buddy_page(struct page *page) bool is_free_buddy_page(struct page *page)
{ {
struct zone *zone = page_zone(page); struct zone *zone = page_zone(page);
...@@ -7171,4 +7170,3 @@ bool is_free_buddy_page(struct page *page) ...@@ -7171,4 +7170,3 @@ bool is_free_buddy_page(struct page *page)
return order < MAX_ORDER; return order < MAX_ORDER;
} }
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment