On 1/8/25 15:37, Zhenhua Huang wrote:
/* @@ -1175,9 +1178,21 @@ int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node, int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, struct vmem_altmap *altmap) { + unsigned long start_pfn; + struct mem_section *ms;
WARN_ON((start < VMEMMAP_START) || (end > VMEMMAP_END)); - if (!IS_ENABLED(CONFIG_ARM64_4K_PAGES)) + start_pfn = page_to_pfn((struct page *)start); + ms = __pfn_to_section(start_pfn);
Hmm, it would have been better if the core code provided the start pfn as it does for vmemmap_populate_compound_pages() but I'm fine with deducting it from 'start'.
I found another bug, that even for early section, when vmemmap_populate is called, SECTION_IS_EARLY is not set. Therefore, early_section() always return false.
Hmm, well that's unexpected.
Since vmemmap_populate() occurs during section initialization, it may be hard to say it is a bug.. However, should we instead using SECTION_MARKED_PRESENT to check? I tested well in my setup.
Hot plug flow:
- section_activate -> vmemmap_populate
- mark PRESENT
In contrast, the early flow:
- memblocks_present -> mark PRESENT
- __populate_section_memmap -> vmemmap_populate
But from a semantics perspective, should SECTION_MARKED_PRESENT be marked on a section before SECTION_IS_EARLY ? Is it really the expected behaviour here or that needs to be fixed first ?
Although SYSTEM_BOOTING state check might help but section flag seems to be the right thing to do here.