[PATCH 1/1] arm64/sparsemem: reduce SECTION_SIZE_BITS
Mike Rapoport
rppt at linux.ibm.com
Thu Jan 21 09:16:07 EST 2021
On Wed, Jan 20, 2021 at 09:29:13PM -0800, Sudarshan Rajagopalan wrote:
> memory_block_size_bytes() determines the memory hotplug granularity i.e the
> amount of memory which can be hot added or hot removed from the kernel. The
> generic value here being MIN_MEMORY_BLOCK_SIZE (1UL << SECTION_SIZE_BITS)
> for memory_block_size_bytes() on platforms like arm64 that does not override.
>
> Current SECTION_SIZE_BITS is 30 i.e 1GB which is large and a reduction here
> increases memory hotplug granularity, thus improving its agility. A reduced
> section size also reduces memory wastage in vmemmmap mapping for sections
> with large memory holes. So we try to set the least section size as possible.
>
> A section size bits selection must follow:
> (MAX_ORDER - 1 + PAGE_SHIFT) <= SECTION_SIZE_BITS
>
> CONFIG_FORCE_MAX_ZONEORDER is always defined on arm64 and so just following it
> would help achieve the smallest section size.
>
> SECTION_SIZE_BITS = (CONFIG_FORCE_MAX_ZONEORDER - 1 + PAGE_SHIFT)
>
> SECTION_SIZE_BITS = 22 (11 - 1 + 12) i.e 4MB for 4K pages
> SECTION_SIZE_BITS = 24 (11 - 1 + 14) i.e 16MB for 16K pages without THP
> SECTION_SIZE_BITS = 25 (12 - 1 + 14) i.e 32MB for 16K pages with THP
> SECTION_SIZE_BITS = 26 (11 - 1 + 16) i.e 64MB for 64K pages without THP
> SECTION_SIZE_BITS = 29 (14 - 1 + 16) i.e 512MB for 64K pages with THP
>
> But there are other problems in reducing SECTION_SIZE_BIT. Reducing it by too
> much would over populate /sys/devices/system/memory/ and also consume too many
> page->flags bits in the !vmemmap case. Also section size needs to be multiple
> of 128MB to have PMD based vmemmap mapping with CONFIG_ARM64_4K_PAGES.
>
> Given these constraints, lets just reduce the section size to 128MB for 4K
> and 16K base page size configs, and to 512MB for 64K base page size config.
>
> Signed-off-by: Sudarshan Rajagopalan <sudaraja at codeaurora.org>
> Suggested-by: Anshuman Khandual <anshuman.khandual at arm.com>
> Suggested-by: David Hildenbrand <david at redhat.com>
> Cc: Catalin Marinas <catalin.marinas at arm.com>
> Cc: Will Deacon <will at kernel.org>
> Cc: Anshuman Khandual <anshuman.khandual at arm.com>
> Cc: David Hildenbrand <david at redhat.com>
> Cc: Mike Rapoport <rppt at linux.ibm.com>
> Cc: Mark Rutland <mark.rutland at arm.com>
> Cc: Logan Gunthorpe <logang at deltatee.com>
> Cc: Andrew Morton <akpm at linux-foundation.org>
> Cc: Steven Price <steven.price at arm.com>
> Cc: Suren Baghdasaryan <surenb at google.com>
Acked-by: Mike Rapoport <rppt at linux.ibm.com>
BTW, after reduction of the section size maybe arm64 should consider opting
out of freeing unused memory map.
This will make David even more happy as this will allow dropping custom
pfn_valid() ;-)
> ---
> arch/arm64/include/asm/sparsemem.h | 23 +++++++++++++++++++++--
> 1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/include/asm/sparsemem.h b/arch/arm64/include/asm/sparsemem.h
> index 1f43fcc79738..eb4a75d720ed 100644
> --- a/arch/arm64/include/asm/sparsemem.h
> +++ b/arch/arm64/include/asm/sparsemem.h
> @@ -7,7 +7,26 @@
>
> #ifdef CONFIG_SPARSEMEM
> #define MAX_PHYSMEM_BITS CONFIG_ARM64_PA_BITS
> -#define SECTION_SIZE_BITS 30
> -#endif
> +
> +/*
> + * Section size must be at least 512MB for 64K base
> + * page size config. Otherwise it will be less than
> + * (MAX_ORDER - 1) and the build process will fail.
> + */
> +#ifdef CONFIG_ARM64_64K_PAGES
> +#define SECTION_SIZE_BITS 29
> +
> +#else
> +
> +/*
> + * Section size must be at least 128MB for 4K base
> + * page size config. Otherwise PMD based huge page
> + * entries could not be created for vmemmap mappings.
> + * 16K follows 4K for simplicity.
> + */
> +#define SECTION_SIZE_BITS 27
> +#endif /* CONFIG_ARM64_64K_PAGES */
> +
> +#endif /* CONFIG_SPARSEMEM*/
>
> #endif
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project
>
--
Sincerely yours,
Mike.
More information about the linux-arm-kernel
mailing list