lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1454569683-17918-1-git-send-email-n-horiguchi@ah.jp.nec.com>
Date:	Thu,  4 Feb 2016 16:08:01 +0900
From:	Naoya Horiguchi <n-horiguchi@...jp.nec.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Vladimir Davydov <vdavydov@...allels.com>,
	Konstantin Khlebnikov <koct9i@...il.com>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org,
	Naoya Horiguchi <n-horiguchi@...jp.nec.com>,
	Naoya Horiguchi <nao.horiguchi@...il.com>
Subject: [PATCH v1 1/3] /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.

Signed-off-by: Naoya Horiguchi <n-horiguchi@...jp.nec.com>
---
 fs/proc/page.c             | 2 ++
 include/linux/page-flags.h | 2 ++
 mm/internal.h              | 3 ---
 mm/page_alloc.c            | 2 --
 4 files changed, 4 insertions(+), 5 deletions(-)

diff --git v4.5-rc2-mmotm-2016-02-02-17-08/fs/proc/page.c v4.5-rc2-mmotm-2016-02-02-17-08_patched/fs/proc/page.c
index b2855ee..42998bb 100644
--- v4.5-rc2-mmotm-2016-02-02-17-08/fs/proc/page.c
+++ v4.5-rc2-mmotm-2016-02-02-17-08_patched/fs/proc/page.c
@@ -148,6 +148,8 @@ u64 stable_page_flags(struct page *page)
 	 */
 	if (PageBuddy(page))
 		u |= 1 << KPF_BUDDY;
+	else if (page_count(page) == 0 && is_free_buddy_page(page))
+		u |= 1 << KPF_BUDDY;
 
 	if (PageBalloon(page))
 		u |= 1 << KPF_BALLOON;
diff --git v4.5-rc2-mmotm-2016-02-02-17-08/include/linux/page-flags.h v4.5-rc2-mmotm-2016-02-02-17-08_patched/include/linux/page-flags.h
index 19724e6..5976955 100644
--- v4.5-rc2-mmotm-2016-02-02-17-08/include/linux/page-flags.h
+++ v4.5-rc2-mmotm-2016-02-02-17-08_patched/include/linux/page-flags.h
@@ -593,6 +593,8 @@ static inline void __ClearPageBuddy(struct page *page)
 	atomic_set(&page->_mapcount, -1);
 }
 
+extern bool is_free_buddy_page(struct page *page);
+
 #define PAGE_BALLOON_MAPCOUNT_VALUE (-256)
 
 static inline int PageBalloon(struct page *page)
diff --git v4.5-rc2-mmotm-2016-02-02-17-08/mm/internal.h v4.5-rc2-mmotm-2016-02-02-17-08_patched/mm/internal.h
index 271ad95..06071af 100644
--- v4.5-rc2-mmotm-2016-02-02-17-08/mm/internal.h
+++ v4.5-rc2-mmotm-2016-02-02-17-08_patched/mm/internal.h
@@ -145,9 +145,6 @@ extern int __isolate_free_page(struct page *page, unsigned int order);
 extern void __free_pages_bootmem(struct page *page, unsigned long pfn,
 					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;
 
 #if defined CONFIG_COMPACTION || defined CONFIG_CMA
diff --git v4.5-rc2-mmotm-2016-02-02-17-08/mm/page_alloc.c v4.5-rc2-mmotm-2016-02-02-17-08_patched/mm/page_alloc.c
index 555b9d2..d9c8b70 100644
--- v4.5-rc2-mmotm-2016-02-02-17-08/mm/page_alloc.c
+++ v4.5-rc2-mmotm-2016-02-02-17-08_patched/mm/page_alloc.c
@@ -7182,7 +7182,6 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn)
 }
 #endif
 
-#ifdef CONFIG_MEMORY_FAILURE
 bool is_free_buddy_page(struct page *page)
 {
 	struct zone *zone = page_zone(page);
@@ -7201,4 +7200,3 @@ bool is_free_buddy_page(struct page *page)
 
 	return order < MAX_ORDER;
 }
-#endif
-- 
2.7.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ