Re: [PATCH v20 8/9] mm: memory_hotplug: disable memmap_on_memory when hugetlb_free_vmemmap enabled

From: Oscar Salvador
Date: Tue Apr 20 2021 - 06:35:43 EST


On Thu, Apr 15, 2021 at 04:40:04PM +0800, Muchun Song wrote:
> bool mhp_supports_memmap_on_memory(unsigned long size)
> {
> + bool supported;
> unsigned long nr_vmemmap_pages = size / PAGE_SIZE;
> unsigned long vmemmap_size = nr_vmemmap_pages * sizeof(struct page);
> unsigned long remaining_size = size - vmemmap_size;
> @@ -1011,11 +1012,18 @@ bool mhp_supports_memmap_on_memory(unsigned long size)
> * altmap as an alternative source of memory, and we do not exactly
> * populate a single PMD.
> */
> - return memmap_on_memory &&
> - IS_ENABLED(CONFIG_MHP_MEMMAP_ON_MEMORY) &&
> - size == memory_block_size_bytes() &&
> - IS_ALIGNED(vmemmap_size, PMD_SIZE) &&
> - IS_ALIGNED(remaining_size, pageblock_nr_pages << PAGE_SHIFT);
> + supported = memmap_on_memory &&
> + IS_ENABLED(CONFIG_MHP_MEMMAP_ON_MEMORY) &&
> + size == memory_block_size_bytes() &&
> + IS_ALIGNED(vmemmap_size, PMD_SIZE) &&
> + IS_ALIGNED(remaining_size, pageblock_nr_pages << PAGE_SHIFT);
> +
> + if (supported && is_hugetlb_free_vmemmap_enabled()) {
> + pr_info("Cannot enable memory_hotplug.memmap_on_memory, it is not compatible with hugetlb_free_vmemmap\n");
> + supported = false;
> + }

I would not print anything and rather have

return memmap_on_memory &&
!is_hugetlb_free_vmemmap_enabled &&
IS_ENABLED(CONFIG_MHP_MEMMAP_ON_MEMORY) &&
size == memory_block_size_bytes() &&
IS_ALIGNED(vmemmap_size, PMD_SIZE) &&
IS_ALIGNED(remaining_size, pageblock_nr_pages << PAGE_SHIFT);

Documentation/admin-guide/kernel-parameters.txt already provides an
explanation on memory_hotplug.memmap_on_memory parameter that states
that the feature cannot be enabled when using hugetlb-vmemmap
optimization.

Users can always check whether the feature is enabled via
/sys/modules/memory_hotplug/parameters/memmap_on_memory.

Also, I did not check if it is, but if not, the fact about hugetlb-vmemmmap vs
hotplug-vmemmap should also be called out in the hugetlb-vmemmap kernel
parameter.

Thanks

--
Oscar Salvador
SUSE L3