Re: [PATCH v1 13/36] mm/hugetlb: cleanup hugetlb_folio_init_tail_vmemmap()
David Hildenbrand <[email protected]>
| Newsgroups | com.zx2c4.lists.wireguard,dev.linux.lists.iommu,dev.linux.lists.virtualization,org.freedesktop.lists.dri-devel,org.freedesktop.lists.intel-gfx,org.infradead.lists.linux-arm-kernel,org.infradead.lists.linux-riscv,org.kernel.vger.io-uring,org.kernel.vger.kvm,org.kernel.vger.linux-crypto,org.kernel.vger.linux-ide,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest,org.kernel.vger.linux-mips,org.kernel.vger.linux-mmc,org.kernel.vger.linux-s390,org.kernel.vger.linux-scsi,org.kernel.vger.netdev,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
On 28.08.25 09:21, Mike Rapoport wrote: > On Thu, Aug 28, 2025 at 12:01:17AM +0200, David Hildenbrand wrote: >> We can now safely iterate over all pages in a folio, so no need for the >> pfn_to_page(). >> >> Also, as we already force the refcount in __init_single_page() to 1, >> we can just set the refcount to 0 and avoid page_ref_freeze() + >> VM_BUG_ON. Likely, in the future, we would just want to tell >> __init_single_page() to which value to initialize the refcount. >> >> Further, adjust the comments to highlight that we are dealing with an >> open-coded prep_compound_page() variant, and add another comment explaining >> why we really need the __init_single_page() only on the tail pages. >> >> Note that the current code was likely problematic, but we never ran into >> it: prep_compound_tail() would have been called with an offset that might >> exceed a memory section, and prep_compound_tail() would have simply >> added that offset to the page pointer -- which would not have done the >> right thing on sparsemem without vmemmap. >> >> Signed-off-by: David Hildenbrand <[email protected]> >> --- >> mm/hugetlb.c | 20 ++++++++++++-------- >> 1 file changed, 12 insertions(+), 8 deletions(-) >> >> diff --git a/mm/hugetlb.c b/mm/hugetlb.c >> index 4a97e4f14c0dc..1f42186a85ea4 100644 >> --- a/mm/hugetlb.c >> +++ b/mm/hugetlb.c >> @@ -3237,17 +3237,18 @@ static void __init hugetlb_folio_init_tail_vmemmap(struct folio *folio, >> { >> enum zone_type zone = zone_idx(folio_zone(folio)); >> int nid = folio_nid(folio); >> + struct page *page = folio_page(folio, start_page_number); >> unsigned long head_pfn = folio_pfn(folio); >> unsigned long pfn, end_pfn = head_pfn + end_page_number; >> - int ret; >> - >> - for (pfn = head_pfn + start_page_number; pfn < end_pfn; pfn++) { >> - struct page *page = pfn_to_page(pfn); >> >> + /* >> + * We mark all tail pages with memblock_reserved_mark_noinit(), >> + * so these pages are completely uninitialized. > > ^ not? ;-) Can you elaborate? -- Cheers David / dhildenb