From: Anthony Yznaga <anthony.yznaga@oracle.com>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: adobriyan@gmail.com, akpm@linux-foundation.org, vbabka@suse.cz,
sfr@canb.auug.org.au, willy@infradead.org,
kirill.shutemov@linux.intel.com, rppt@linux.vnet.ibm.com,
mhocko@suse.com, alexander.h.duyck@linux.intel.com,
hannes@cmpxchg.org, miles.chen@mediatek.com,
n-horiguchi@ah.jp.nec.com
Subject: [PATCH] /proc/kpagecount: return 0 for special pages that are never mapped
Date: Tue, 4 Dec 2018 14:45:26 -0800 [thread overview]
Message-ID: <1543963526-27917-1-git-send-email-anthony.yznaga@oracle.com> (raw)
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.
Signed-off-by: Anthony Yznaga <anthony.yznaga@oracle.com>
---
fs/proc/page.c | 2 +-
include/linux/page-flags.h | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/fs/proc/page.c b/fs/proc/page.c
index 6c517b11acf8..40b05e0d4274 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -46,7 +46,7 @@ static ssize_t kpagecount_read(struct file *file, char __user *buf,
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);
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 50ce1bddaf56..f9a1c50ccefc 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -673,10 +673,17 @@ static inline int TestClearPageDoubleMap(struct page *page)
#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) \
{ \
--
1.8.3.1
next reply other threads:[~2018-12-04 22:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-04 22:45 Anthony Yznaga [this message]
2018-12-05 0:48 ` [PATCH] /proc/kpagecount: return 0 for special pages that are never mapped Matthew Wilcox
2018-12-05 1:18 ` anthony.yznaga
2018-12-05 1:25 ` Matthew Wilcox
2018-12-05 19:40 ` Anthony Yznaga
2018-12-05 19:44 ` Matthew Wilcox
2018-12-06 0:44 ` Anthony Yznaga
2018-12-06 4:26 ` Matthew Wilcox
2018-12-06 6:07 ` Anthony Yznaga
2018-12-08 0:27 ` Andrew Morton
2018-12-05 8:28 ` David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1543963526-27917-1-git-send-email-anthony.yznaga@oracle.com \
--to=anthony.yznaga@oracle.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.h.duyck@linux.intel.com \
--cc=hannes@cmpxchg.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.com \
--cc=miles.chen@mediatek.com \
--cc=n-horiguchi@ah.jp.nec.com \
--cc=rppt@linux.vnet.ibm.com \
--cc=sfr@canb.auug.org.au \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).