Re: [PATCH RFC 00/35] mm: remove nth_page()
Jason Gunthorpe <[email protected]> Fri, 22 Aug 2025 11:30:43 -0300
| 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-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 Thu, Aug 21, 2025 at 10:06:26PM +0200, David Hildenbrand wrote: > As discussed recently with Linus, nth_page() is just nasty and we would > like to remove it. > > To recap, the reason we currently need nth_page() within a folio is because > on some kernel configs (SPARSEMEM without SPARSEMEM_VMEMMAP), the > memmap is allocated per memory section. > > While buddy allocations cannot cross memory section boundaries, hugetlb > and dax folios can. > > So crossing a memory section means that "page++" could do the wrong thing. > Instead, nth_page() on these problematic configs always goes from > page->pfn, to the go from (++pfn)->page, which is rather nasty. > > Likely, many people have no idea when nth_page() is required and when > it might be dropped. > > We refer to such problematic PFN ranges and "non-contiguous pages". > If we only deal with "contiguous pages", there is not need for nth_page(). > > Besides that "obvious" folio case, we might end up using nth_page() > within CMA allocations (again, could span memory sections), and in > one corner case (kfence) when processing memblock allocations (again, > could span memory sections). I browsed the patches and it looks great to me, thanks for doing this Jason