Re: [PATCH v1] mm/memory_hotplug: Easier calculation to get pages to next section boundary

From: Baoquan He
Date: Wed Feb 05 2020 - 19:13:41 EST


On 02/06/20 at 07:50am, Wei Yang wrote:
> On Thu, Feb 06, 2020 at 07:19:45AM +0800, Wei Yang wrote:
> >On Wed, Feb 05, 2020 at 02:52:51PM +0100, David Hildenbrand wrote:
> >>Let's use a calculation that's easier to understand and calculates the
> >>same result. Reusing existing macros makes this look nicer.
> >>
> >>We always want to have the number of pages (> 0) to the next section
> >>boundary, starting from the current pfn.
> >>
> >>Suggested-by: Segher Boessenkool <segher@xxxxxxxxxxxxxxxxxxx>
> >>Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> >>Cc: Michal Hocko <mhocko@xxxxxxxxxx>
> >>Cc: Oscar Salvador <osalvador@xxxxxxx>
> >>Cc: Baoquan He <bhe@xxxxxxxxxx>
> >>Cc: Wei Yang <richardw.yang@xxxxxxxxxxxxxxx>
> >>Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
> >
> >Reviewed-by: Wei Yang <richardw.yang@xxxxxxxxxxxxxxx>
> >
> >BTW, I got one question about hotplug size requirement.
> >
> >I thought the hotplug range should be section size aligned, while taking a
> >look into current code function check_hotplug_memory_range() guard the range.

A good question. The current code should be block size aligned. I
remember in some places we assume each block comprise all the sections.
Can't imagine one or some of them are half section filled.

It truly has a risk that system ram is very huge to make the block
size is 2G, someone try to insert a 1G memory board. However, it should
only exist in experiment environment, e.g build a guest with enough ram,
then hot add 1G DIMM. In reality, we don't need to worry about it, at
least what I saw is 512G order of magnitude.

> >
> >This function says the range should be block_size aligned. And if I am
> >correct, block size on x86 should be in the range
> >
> > [MIN_MEMORY_BLOCK_SIZE, MEM_SIZE_FOR_LARGE_BLOCK]
> >
> >And MIN_MEMORY_BLOCK_SIZE is section size.

No, if I got it right, the range on x86 is
[MIN_MEMORY_BLOCK_SIZE, MAX_BLOCK_SIZE].

MEM_SIZE_FOR_LARGE_BLOCK is the starting point from which block size can
be adjusted. Otherwise it's MIN_MEMORY_BLOCK_SIZE.

/* Amount of ram needed to start using large blocks */
#define MEM_SIZE_FOR_LARGE_BLOCK (64UL << 30)

> >
> >Seems currently we support subsection hotplug? Then how a subsection range got
> >hotplug? Or this patch is a pre-requisite?

The sub-section hotplug feature was added by your colleague Dan
Williams. It intends to fix a nvdimms issue that nvdimms device could be
mapped into a non section size aligned starting address. And nvdimms
makes use of the existing memory hotplug mechanism to manage pages.
Not sure if we are saying the same thing.

> >
>
> One more question is we support hot-add subsection memory but not support
> hot-online subsection memory.
>
> Is my understanding correct?
>
> --
> Wei Yang
> Help you, Help me
>