On Tue, 5 Aug 2025 at 16:20, David Hildenbrand <david@xxxxxxxxxx> wrote: > > I think that would work, and we could limit the section check to the > problematic case only (sparsemem without VMEMMAP). We really don't need to, because unlike the nth_page() thing, the compiler can see the logic and see "it's always zero". And in the complex case (ie actual sparsemem without VMEMMAP), the page_section() test is at least trivial, unlike the whole "turn it into a pfn and back". Because that "turn it into a pfn and back" is actually a really quite complicated operation (and the compiler won't be able to optimize that one much, so I'm pretty sure it generates horrific code). I wish we didn't have nth_page() at all. I really don't think it's a valid operation. It's been around forever, but I think it was broken as introduced, exactly because I don't think you can validly even have allocations that cross section boundaries. So the only possible reason for nth_page() is that you tried to combine two such allocations into one, and you simply shouldn't do that in the first place. The VM layer can't free them as one allocation anyway, so the only possible use-case is for some broken "let's optimize this IO into one bigger chunk". So people should actively get rid of that, not add to the brokenness. Linus