From: David Hildenbrand <david@redhat.com>
To: kbuild test robot <lkp@intel.com>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, Alexey Dobriyan <adobriyan@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Oscar Salvador <osalvador@suse.de>,
Michal Hocko <mhocko@kernel.org>,
Stephen Rothwell <sfr@canb.auug.org.au>,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v1 2/3] fs/proc/page.c: allow inspection of last section and fix end detection
Date: Tue, 10 Dec 2019 11:53:44 +0100 [thread overview]
Message-ID: <bc3eedd4-77bc-4168-2a59-6ea5a67ba53e@redhat.com> (raw)
In-Reply-To: <201912100809.P9SHh5Nz%lkp@intel.com>
On 10.12.19 02:04, kbuild test robot wrote:
> Hi David,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on linus/master]
> [also build test ERROR on linux/master v5.5-rc1 next-20191209]
> [cannot apply to mmotm/master]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system. BTW, we also suggest to use '--base' option to specify the
> base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
>
> url: https://github.com/0day-ci/linux/commits/David-Hildenbrand/mm-fix-max_pfn-not-falling-on-section-boundary/20191210-071011
> base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 6794862a16ef41f753abd75c03a152836e4c8028
> config: i386-defconfig (attached as .config)
> compiler: gcc-7 (Debian 7.5.0-1) 7.5.0
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386
>
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
>
> In file included from include/asm-generic/bug.h:19:0,
> from arch/x86/include/asm/bug.h:83,
> from include/linux/bug.h:5,
> from include/linux/mmdebug.h:5,
> from include/linux/mm.h:9,
> from include/linux/memblock.h:13,
> from fs/proc/page.c:2:
> fs/proc/page.c: In function 'kpagecount_read':
>>> fs/proc/page.c:32:55: error: 'PAGES_PER_SECTION' undeclared (first use in this function); did you mean 'PAGE_KERNEL_IO'?
> const unsigned long max_dump_pfn = round_up(max_pfn, PAGES_PER_SECTION);
> ^
> include/linux/kernel.h:62:46: note: in definition of macro '__round_mask'
> #define __round_mask(x, y) ((__typeof__(x))((y)-1))
> ^
> fs/proc/page.c:32:37: note: in expansion of macro 'round_up'
> const unsigned long max_dump_pfn = round_up(max_pfn, PAGES_PER_SECTION);
> ^~~~~~~~
> fs/proc/page.c:32:55: note: each undeclared identifier is reported only once for each function it appears in
> const unsigned long max_dump_pfn = round_up(max_pfn, PAGES_PER_SECTION);
> ^
> include/linux/kernel.h:62:46: note: in definition of macro '__round_mask'
> #define __round_mask(x, y) ((__typeof__(x))((y)-1))
> ^
> fs/proc/page.c:32:37: note: in expansion of macro 'round_up'
> const unsigned long max_dump_pfn = round_up(max_pfn, PAGES_PER_SECTION);
> ^~~~~~~~
> fs/proc/page.c: In function 'kpageflags_read':
> fs/proc/page.c:212:55: error: 'PAGES_PER_SECTION' undeclared (first use in this function); did you mean 'PAGE_KERNEL_IO'?
> const unsigned long max_dump_pfn = round_up(max_pfn, PAGES_PER_SECTION);
> ^
> include/linux/kernel.h:62:46: note: in definition of macro '__round_mask'
> #define __round_mask(x, y) ((__typeof__(x))((y)-1))
> ^
> fs/proc/page.c:212:37: note: in expansion of macro 'round_up'
> const unsigned long max_dump_pfn = round_up(max_pfn, PAGES_PER_SECTION);
> ^~~~~~~~
>
So PAGES_PER_SECTION only applies to CONFIG_SPARSEMEM. Some local function
that messes with that should do the trick. Allows us to add a comment as
well :)
diff --git a/fs/proc/page.c b/fs/proc/page.c
index e40dbfe1168e..2984df28ccea 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -21,6 +21,21 @@
#define KPMMASK (KPMSIZE - 1)
#define KPMBITS (KPMSIZE * BITS_PER_BYTE)
+static inline unsigned long get_max_dump_pfn(void)
+{
+#ifdef CONFIG_SPARSEMEM
+ /*
+ * The memmap of early sections is completely populated and marked
+ * online even if max_pfn does not fall on a section boundary -
+ * pfn_to_online_page() will succeed on all pages. Allow inspecting
+ * these memmaps.
+ */
+ return round_up(max_pfn, PAGES_PER_SECTION);
+#else
+ return max_pfn;
+#endif
+}
+
/* /proc/kpagecount - an array exposing page counts
*
* Each entry is a u64 representing the corresponding
@@ -29,6 +44,7 @@
static ssize_t kpagecount_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
+ const unsigned long max_dump_pfn = get_max_dump_pfn();
u64 __user *out = (u64 __user *)buf;
struct page *ppage;
unsigned long src = *ppos;
@@ -37,9 +53,11 @@ static ssize_t kpagecount_read(struct file *file, char __user *buf,
u64 pcount;
pfn = src / KPMSIZE;
- count = min_t(size_t, count, (max_pfn * KPMSIZE) - src);
if (src & KPMMASK || count & KPMMASK)
return -EINVAL;
+ if (src >= max_dump_pfn * KPMSIZE)
+ return 0;
+ count = min_t(unsigned long, count, (max_dump_pfn * KPMSIZE) - src);
while (count > 0) {
/*
@@ -208,6 +226,7 @@ u64 stable_page_flags(struct page *page)
static ssize_t kpageflags_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
+ const unsigned long max_dump_pfn = get_max_dump_pfn();
u64 __user *out = (u64 __user *)buf;
struct page *ppage;
unsigned long src = *ppos;
@@ -215,9 +234,11 @@ static ssize_t kpageflags_read(struct file *file, char __user *buf,
ssize_t ret = 0;
pfn = src / KPMSIZE;
- count = min_t(unsigned long, count, (max_pfn * KPMSIZE) - src);
if (src & KPMMASK || count & KPMMASK)
return -EINVAL;
+ if (src >= max_dump_pfn * KPMSIZE)
+ return 0;
+ count = min_t(unsigned long, count, (max_dump_pfn * KPMSIZE) - src);
while (count > 0) {
/*
@@ -253,6 +274,7 @@ static const struct file_operations proc_kpageflags_operations = {
static ssize_t kpagecgroup_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
+ const unsigned long max_dump_pfn = get_max_dump_pfn();
u64 __user *out = (u64 __user *)buf;
struct page *ppage;
unsigned long src = *ppos;
@@ -261,9 +283,11 @@ static ssize_t kpagecgroup_read(struct file *file, char __user *buf,
u64 ino;
pfn = src / KPMSIZE;
- count = min_t(unsigned long, count, (max_pfn * KPMSIZE) - src);
if (src & KPMMASK || count & KPMMASK)
return -EINVAL;
+ if (src >= max_dump_pfn * KPMSIZE)
+ return 0;
+ count = min_t(unsigned long, count, (max_dump_pfn * KPMSIZE) - src);
while (count > 0) {
/*
--
2.21.0
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2019-12-10 10:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-09 17:48 [PATCH v1 0/3] mm: fix max_pfn not falling on section boundary David Hildenbrand
2019-12-09 17:48 ` [PATCH v1 1/3] mm: fix uninitialized memmaps on a partially populated last section David Hildenbrand
2019-12-09 21:15 ` Daniel Jordan
2019-12-10 10:11 ` David Hildenbrand
2019-12-10 22:18 ` Daniel Jordan
2019-12-09 17:48 ` [PATCH v1 2/3] fs/proc/page.c: allow inspection of last section and fix end detection David Hildenbrand
2019-12-10 0:46 ` kbuild test robot
2019-12-10 1:04 ` kbuild test robot
2019-12-10 10:53 ` David Hildenbrand [this message]
2019-12-09 17:48 ` [PATCH v1 3/3] mm: initialize memmap of unavailable memory directly 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=bc3eedd4-77bc-4168-2a59-6ea5a67ba53e@redhat.com \
--to=david@redhat.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=kbuild-all@lists.01.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=mhocko@kernel.org \
--cc=osalvador@suse.de \
--cc=sfr@canb.auug.org.au \
/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).