From: David Hildenbrand <david@redhat.com>
To: Naoya Horiguchi <naoya.horiguchi@linux.dev>,
Dan Williams <dan.j.williams@intel.com>
Cc: "HORIGUCHI NAOYA(堀口 直也)" <naoya.horiguchi@nec.com>,
"Wang Wensheng" <wangwensheng4@huawei.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"osalvador@suse.de" <osalvador@suse.de>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"rui.xiang@huawei.com" <rui.xiang@huawei.com>,
"HAGIO KAZUHITO(萩尾 一仁)" <k-hagio-ab@nec.com>
Subject: Re: [PATCH] mm/sparse: set SECTION_NID_SHIFT to 6
Date: Tue, 6 Jul 2021 10:36:36 +0200 [thread overview]
Message-ID: <10142860-06b2-df68-c283-64560f31fb44@redhat.com> (raw)
In-Reply-To: <20210628070601.GB418318@u2004>
> Sounds nice to me, so here's a patch. Could you review this?
>
Hi,
sorry for the late reply, I was on vacation. Please send it as a proper
stand-alone patch next time, such that it
1. won't get silently ignored by reviewers/maintainers within a thread
2. Can easily get picked up/tested
Some minor comments below.
> Thanks,
> Naoya Horiguchi
> ---
> From a146c9f12ae8985c8985a5861330f7528cd14fe8 Mon Sep 17 00:00:00 2001
> From: Naoya Horiguchi <naoya.horiguchi@nec.com>
> Date: Mon, 28 Jun 2021 15:50:37 +0900
> Subject: [PATCH] mm/sparse: set SECTION_NID_SHIFT to 6
>
> Hagio-san reported that crash utility can see bit 4 in section_mem_map
> (SECTION_TAINT_ZONE_DEVICE) to be set, even if we do not use any
> ZONE_DEVICE ilke pmem or HMM. This problem could break crash-related
s/ilke/like/
> toolsets and/or other memory analysis tools.
>
I'd rephrase this to "Having SECTION_TAINT_ZONE_DEVICE set for wrong
sections forces pfn_to_online_page() through the slow path, but doesn't
actually break the kernel. However, it can break crash-related toolsets."
However, I am not sure why it actually breaks crash? crash would have to
implement the same slow-path check and would have to double-check the
sub-section present map. Then, it should just work like
pfn_to_online_page() and not have a real issue. What am I missing?
> The root cause is that SECTION_NID_SHIFT is incorrectly set to 3,
> while we use lower 5 bits for SECTION_* flags. So bit 3 and 4 can be
> overlapped by sub-field for early NID, and bit 4 is unexpectedly set
> on (for example) NUMA node id is 2 or 3.
>
> To fix it, set SECTION_NID_SHIFT to 6 which is the minimum number of
> available bits of section flag field.
>
> [1]: https://github.com/crash-utility/crash/commit/0b5435e10161345cf713ed447a155a611a1b408b
[1] is never referenced
>
> Fixes: 1f90a3477df3 ("mm: teach pfn_to_online_page() about ZONE_DEVICE section collisions")
> Cc: stable@vger.kernel.org # v5.12+
^ I am not really convinced that this is a stable fix. It forces
something through the slow path, but the kernel itself is not broken, no?
> Reported-by: Kazuhito Hagio <k-hagio-ab@nec.com>
> Suggested-by: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
> ---
> include/linux/mmzone.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index fcb535560028..d6aa2a196aeb 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -1357,6 +1357,7 @@ extern size_t mem_section_usage_size(void);
> * worst combination is powerpc with 256k pages,
> * which results in PFN_SECTION_SHIFT equal 6.
> * To sum it up, at least 6 bits are available.
> + * SECTION_NID_SHIFT is set to 6 based on this fact.
I'd drop that comment or rephrase to ("once this changes, don't forget
to adjust SECTION_NID_SHIFT")
> */
> #define SECTION_MARKED_PRESENT (1UL<<0)
> #define SECTION_HAS_MEM_MAP (1UL<<1)
> @@ -1365,7 +1366,7 @@ extern size_t mem_section_usage_size(void);
> #define SECTION_TAINT_ZONE_DEVICE (1UL<<4)
> #define SECTION_MAP_LAST_BIT (1UL<<5)
> #define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1))
> -#define SECTION_NID_SHIFT 3
> +#define SECTION_NID_SHIFT 6
>
> static inline struct page *__section_mem_map_addr(struct mem_section *section)
> {
>
Change itself looks correct to me.
Acked-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2021-07-06 8:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-27 8:30 [PATCH] mm/sparse: Fix flags overlap in section_mem_map Wang Wensheng
2021-04-27 9:05 ` David Hildenbrand
2021-06-23 23:09 ` HORIGUCHI NAOYA(堀口 直也)
2021-06-25 21:23 ` Dan Williams
2021-06-28 7:06 ` [PATCH] mm/sparse: set SECTION_NID_SHIFT to 6 Naoya Horiguchi
2021-07-06 8:36 ` David Hildenbrand [this message]
2021-07-07 4:54 ` Naoya Horiguchi
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=10142860-06b2-df68-c283-64560f31fb44@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=k-hagio-ab@nec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@linux.dev \
--cc=naoya.horiguchi@nec.com \
--cc=osalvador@suse.de \
--cc=rui.xiang@huawei.com \
--cc=wangwensheng4@huawei.com \
/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