Re: [PATCH v1] mm/memory_hotplug: Easier calculation to get pages to next section boundary
From: Wei Yang
Date: Wed Feb 05 2020 - 18:19:34 EST
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.
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.
Seems currently we support subsection hotplug? Then how a subsection range got
hotplug? Or this patch is a pre-requisite?
>---
> mm/memory_hotplug.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
>index 0a54ffac8c68..c30191183c04 100644
>--- a/mm/memory_hotplug.c
>+++ b/mm/memory_hotplug.c
>@@ -528,7 +528,8 @@ void __remove_pages(unsigned long pfn, unsigned long nr_pages,
> for (; pfn < end_pfn; pfn += cur_nr_pages) {
> cond_resched();
> /* Select all remaining pages up to the next section boundary */
>- cur_nr_pages = min(end_pfn - pfn, -(pfn | PAGE_SECTION_MASK));
>+ cur_nr_pages = min(end_pfn - pfn,
>+ SECTION_ALIGN_UP(pfn + 1) - pfn);
> __remove_section(pfn, cur_nr_pages, map_offset, altmap);
> map_offset = 0;
> }
>--
>2.24.1
--
Wei Yang
Help you, Help me