Re: [PATCH v9 10/12] mm/devm_memremap_pages: Enable sub-section remap

From: Aneesh Kumar K.V
Date: Sun Jun 16 2019 - 03:55:03 EST


Dan Williams <dan.j.williams@xxxxxxxxx> writes:

> Teach devm_memremap_pages() about the new sub-section capabilities of
> arch_{add,remove}_memory(). Effectively, just replace all usage of
> align_start, align_end, and align_size with res->start, res->end, and
> resource_size(res). The existing sanity check will still make sure that
> the two separate remap attempts do not collide within a sub-section (2MB
> on x86).
>
> Cc: Michal Hocko <mhocko@xxxxxxxx>
> Cc: Toshi Kani <toshi.kani@xxxxxxx>
> Cc: JÃrÃme Glisse <jglisse@xxxxxxxxxx>
> Cc: Logan Gunthorpe <logang@xxxxxxxxxxxx>
> Cc: Oscar Salvador <osalvador@xxxxxxx>
> Cc: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx>
> Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
> ---
> kernel/memremap.c | 61 +++++++++++++++++++++--------------------------------
> 1 file changed, 24 insertions(+), 37 deletions(-)
>
> diff --git a/kernel/memremap.c b/kernel/memremap.c
> index 57980ed4e571..a0e5f6b91b04 100644
> --- a/kernel/memremap.c
> +++ b/kernel/memremap.c
> @@ -58,7 +58,7 @@ static unsigned long pfn_first(struct dev_pagemap *pgmap)
> struct vmem_altmap *altmap = &pgmap->altmap;
> unsigned long pfn;
>
> - pfn = res->start >> PAGE_SHIFT;
> + pfn = PHYS_PFN(res->start);
> if (pgmap->altmap_valid)
> pfn += vmem_altmap_offset(altmap);
> return pfn;
> @@ -86,7 +86,6 @@ static void devm_memremap_pages_release(void *data)
> struct dev_pagemap *pgmap = data;
> struct device *dev = pgmap->dev;
> struct resource *res = &pgmap->res;
> - resource_size_t align_start, align_size;
> unsigned long pfn;
> int nid;
>
> @@ -96,25 +95,21 @@ static void devm_memremap_pages_release(void *data)
> pgmap->cleanup(pgmap->ref);
>
> /* pages are dead and unused, undo the arch mapping */
> - align_start = res->start & ~(PA_SECTION_SIZE - 1);
> - align_size = ALIGN(res->start + resource_size(res), PA_SECTION_SIZE)
> - - align_start;
> -
> - nid = page_to_nid(pfn_to_page(align_start >> PAGE_SHIFT));
> + nid = page_to_nid(pfn_to_page(PHYS_PFN(res->start)));

Why do we not require to align things to subsection size now?

-aneesh