The patch titled Subject: /proc/kpagecount: return 0 for special pages that are never mapped has been added to the -mm tree. Its filename is proc-kpagecount-return-0-for-special-pages-that-are-never-mapped.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/proc-kpagecount-return-0-for-special-pages-that-are-never-mapped.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/proc-kpagecount-return-0-for-special-pages-that-are-never-mapped.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Anthony Yznaga <anthony.yznaga@xxxxxxxxxx> Subject: /proc/kpagecount: return 0 for special pages that are never mapped Certain pages that are never mapped to userspace have a type indicated in the page_type field of their struct pages (e.g. PG_buddy). page_type overlaps with _mapcount so set the count to 0 and avoid calling page_mapcount() for these pages. Link: http://lkml.kernel.org/r/1543963526-27917-1-git-send-email-anthony.yznaga@xxxxxxxxxx Signed-off-by: Anthony Yznaga <anthony.yznaga@xxxxxxxxxx> Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Alexey Dobriyan <adobriyan@xxxxxxxxx> Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Alexander Duyck <alexander.h.duyck@xxxxxxxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Miles Chen <miles.chen@xxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/proc/page.c | 2 +- include/linux/page-flags.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) --- a/fs/proc/page.c~proc-kpagecount-return-0-for-special-pages-that-are-never-mapped +++ a/fs/proc/page.c @@ -46,7 +46,7 @@ static ssize_t kpagecount_read(struct fi ppage = pfn_to_page(pfn); else ppage = NULL; - if (!ppage || PageSlab(ppage)) + if (!ppage || PageSlab(ppage) || page_has_type(ppage)) pcount = 0; else pcount = page_mapcount(ppage); --- a/include/linux/page-flags.h~proc-kpagecount-return-0-for-special-pages-that-are-never-mapped +++ a/include/linux/page-flags.h @@ -673,10 +673,17 @@ PAGEFLAG_FALSE(DoubleMap) #define PG_balloon 0x00000100 #define PG_kmemcg 0x00000200 #define PG_table 0x00000400 +#define PAGE_TYPE_ALL (PG_buddy | PG_balloon | PG_kmemcg | PG_table) #define PageType(page, flag) \ ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) +static inline int page_has_type(struct page *page) +{ + return (PageType(page, 0) && + ((page->page_type & PAGE_TYPE_ALL) != PAGE_TYPE_ALL)); +} + #define PAGE_TYPE_OPS(uname, lname) \ static __always_inline int Page##uname(struct page *page) \ { \ _ Patches currently in -mm which might be from anthony.yznaga@xxxxxxxxxx are tools-vm-page-typesc-fix-kpagecount-returned-fewer-pages-than-expected-failures.patch proc-kpagecount-return-0-for-special-pages-that-are-never-mapped.patch