From: Catalin Marinas <catalin.marinas@arm.com>
To: Zhenhua Huang <quic_zhenhuah@quicinc.com>
Cc: will@kernel.org, ardb@kernel.org, ryan.roberts@arm.com,
mark.rutland@arm.com, joey.gouly@arm.com,
dave.hansen@linux.intel.com, akpm@linux-foundation.org,
chenfeiyang@loongson.cn, chenhuacai@kernel.org,
linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Anshuman Khandual <anshuman.khandual@arm.com>
Subject: Re: [PATCH v2 1/2] arm64: mm: vmemmap populate to page level if not section aligned
Date: Tue, 24 Dec 2024 14:09:51 +0000 [thread overview]
Message-ID: <Z2rAr9APkgpkwOl8@arm.com> (raw)
In-Reply-To: <a720aaa5-a75e-481e-b396-a5f2b50ed362@quicinc.com>
On Tue, Dec 24, 2024 at 05:32:06PM +0800, Zhenhua Huang wrote:
> Thanks Catalin for review!
> Merry Christmas.
Merry Christmas to you too!
> On 2024/12/21 2:30, Catalin Marinas wrote:
> > On Mon, Dec 09, 2024 at 05:42:26PM +0800, Zhenhua Huang wrote:
> > > Fixes: c1cc1552616d ("arm64: MMU initialisation")
> >
> > I wouldn't add a fix for the first commit adding arm64 support, we did
> > not even have memory hotplug at the time (added later in 5.7 by commit
> > bbd6ec605c0f ("arm64/mm: Enable memory hot remove")). IIUC, this hasn't
> > been a problem until commit ba72b4c8cf60 ("mm/sparsemem: support
> > sub-section hotplug"). That commit broke some arm64 assumptions.
>
> Shall we add ba72b4c8cf60 ("mm/sparsemem: support sub-section hotplug")
> because it broke arm64 assumptions ?
Yes, I think that would be better. And a cc stable to 5.4 (the above
commit appeared in 5.3).
> > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> > > index e2739b69e11b..fd59ee44960e 100644
> > > --- a/arch/arm64/mm/mmu.c
> > > +++ b/arch/arm64/mm/mmu.c
> > > @@ -1177,7 +1177,9 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
> > > {
> > > WARN_ON((start < VMEMMAP_START) || (end > VMEMMAP_END));
> > > - if (!IS_ENABLED(CONFIG_ARM64_4K_PAGES))
> > > + if (!IS_ENABLED(CONFIG_ARM64_4K_PAGES) ||
> > > + !IS_ALIGNED(page_to_pfn((struct page *)start), PAGES_PER_SECTION) ||
> > > + !IS_ALIGNED(page_to_pfn((struct page *)end), PAGES_PER_SECTION))
> > > return vmemmap_populate_basepages(start, end, node, altmap);
> > > else
> > > return vmemmap_populate_hugepages(start, end, node, altmap);
> >
> > An alternative would be to fix unmap_hotplug_pmd_range() etc. to avoid
> > nuking the whole vmemmap pmd section if it's not empty. Not sure how
> > easy that is, whether we have the necessary information (I haven't
> > looked in detail).
> >
> > A potential issue - can we hotplug 128MB of RAM and only unplug 2MB? If
> > that's possible, the problem isn't solved by this patch.
>
> Indeed, seems there is no guarantee that plug size must be equal to unplug
> size...
>
> I have two ideas:
> 1. Completely disable this PMD mapping optimization since there is no
> guarantee we must align 128M memory for hotplug ..
I'd be in favour of this, at least if CONFIG_MEMORY_HOTPLUG is enabled.
I think the only advantage here is that we don't allocate a full 2MB
block for vmemmap when only plugging in a sub-section.
> 2. If we want to take this optimization.
> I propose adding one argument to vmemmap_free to indicate if the entire
> section is freed(based on subsection map). Vmemmap_free is a common function
> and might affect other architectures... The process would be:
> vmemmap_free
> unmap_hotplug_range //In unmap_hotplug_pmd_range() as you mentioned:if
> whole section is freed, proceed as usual. Otherwise, *just clear out struct
> page content but do not free*.
> free_empty_tables // will be called only if entire section is freed
>
> On the populate side,
> else if (vmemmap_check_pmd(pmd, node, addr, next)) //implement this function
> continue; //Buffer still exists, just abort..
>
> Could you please comment further whether #2 is feasible ?
vmemmap_free() already gets start/end, so it could at least check the
alignment and avoid freeing if it's not unplugging a full section. It
does leave a 2MB vmemmap block in place when freeing the last subsection
but it's safer than freeing valid struct page entries. In addition, it
could query the memory hotplug state with something like
find_memory_block() and figure out whether the section is empty.
Anyway, I'll be off until the new year, maybe I get other ideas by then.
--
Catalin
next prev parent reply other threads:[~2024-12-24 14:11 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-09 9:42 [PATCH v2 0/2] Fix subsection vmemmap_populate logic Zhenhua Huang
2024-12-09 9:42 ` [PATCH v2 1/2] arm64: mm: vmemmap populate to page level if not section aligned Zhenhua Huang
2024-12-20 18:30 ` Catalin Marinas
2024-12-24 9:32 ` Zhenhua Huang
2024-12-24 14:09 ` Catalin Marinas [this message]
2024-12-25 9:59 ` Zhenhua Huang
2024-12-27 7:49 ` Anshuman Khandual
2024-12-30 7:48 ` Zhenhua Huang
2024-12-31 5:52 ` Zhenhua Huang
2025-01-02 3:16 ` Anshuman Khandual
2025-01-02 9:07 ` Zhenhua Huang
2025-01-02 3:51 ` Anshuman Khandual
2025-01-02 9:13 ` Zhenhua Huang
2025-01-02 18:58 ` Catalin Marinas
2025-01-03 2:01 ` Zhenhua Huang
2024-12-09 9:42 ` [PATCH v2 2/2] arm64: mm: implement vmemmap_check_pmd for arm64 Zhenhua Huang
2024-12-20 18:35 ` Catalin Marinas
2024-12-27 2:57 ` Anshuman Khandual
2024-12-30 7:48 ` Zhenhua Huang
2024-12-31 6:59 ` Anshuman Khandual
2024-12-31 7:18 ` Zhenhua Huang
2025-01-02 18:12 ` Catalin Marinas
2025-01-03 2:43 ` Zhenhua Huang
2025-01-03 17:58 ` Catalin Marinas
2024-12-17 1:47 ` [PATCH v2 0/2] Fix subsection vmemmap_populate logic Zhenhua Huang
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=Z2rAr9APkgpkwOl8@arm.com \
--to=catalin.marinas@arm.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=ardb@kernel.org \
--cc=chenfeiyang@loongson.cn \
--cc=chenhuacai@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=joey.gouly@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=quic_zhenhuah@quicinc.com \
--cc=ryan.roberts@arm.com \
--cc=will@kernel.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).