Re: [PATCH v2 4/7] mm/sparse.c: only use subsection map in VMEMMAP case

From: Michal Hocko
Date: Wed Feb 26 2020 - 04:10:23 EST


On Wed 26-02-20 11:53:36, Baoquan He wrote:
> On 02/25/20 at 10:57am, Michal Hocko wrote:
> > On Thu 20-02-20 12:33:13, Baoquan He wrote:
> > > Currently, subsection map is used when SPARSEMEM is enabled, including
> > > VMEMMAP case and !VMEMMAP case. However, subsection hotplug is not
> > > supported at all in SPARSEMEM|!VMEMMAP case, subsection map is unnecessary
> > > and misleading. Let's adjust code to only allow subsection map being
> > > used in VMEMMAP case.
> >
> > This really needs more explanation I believe. What exactly happens if
> > somebody tries to hotremove a part of the section with !VMEMMAP? I can
> > see that clear_subsection_map returns 0 but that is not an error code.
> > Besides that section_deactivate doesn't propagate the error upwards.
> > /me stares into the code
> >
> > OK, I can see it now. It is relying on check_pfn_span to use the proper
> > subsection granularity. This really begs for a comment in the code
> > somewhere.
>
> Yes, check_pfn_span() guards it. People have no way to hot add/remove
> on non-section aligned block with !VMEMMAP.
>
> I have added extra comment to above section_activate() to note this,
> please check patch 5/7. Let me see how to add words to reflect the
> check_pfn_span() guard thing.

An explicit note about check_pfn_span gating the proper alignement and
sizing sounds sufficient to me.
--
Michal Hocko
SUSE Labs