On Tue, Jun 17, 2025 at 05:43:41PM +0200, David Hildenbrand wrote: > Let's reduce the code duplication and factor out the non-pte/pmd related > magic into vm_normal_page_pfn(). > > To keep it simpler, check the pfn against both zero folios. We could > optimize this, but as it's only for the !CONFIG_ARCH_HAS_PTE_SPECIAL > case, it's not a compelling micro-optimization. > > With CONFIG_ARCH_HAS_PTE_SPECIAL we don't have to check anything else, > really. > > It's a good question if we can even hit the !CONFIG_ARCH_HAS_PTE_SPECIAL > scenario in the PMD case in practice: but doesn't really matter, as > it's now all unified in vm_normal_page_pfn(). > > While at it, add a check that pmd_special() is really only set where we > would expect it. > > No functional change intended. > > Signed-off-by: David Hildenbrand <da...@redhat.com>
Reviewed-by: Oscar Salvador <osalva...@suse.de> Comment below > struct folio *vm_normal_folio(struct vm_area_struct *vma, unsigned long addr, > @@ -650,35 +661,12 @@ struct page *vm_normal_page_pmd(struct vm_area_struct > *vma, unsigned long addr, > { > unsigned long pfn = pmd_pfn(pmd); > > - /* Currently it's only used for huge pfnmaps */ Although the check kind of spells it out, we could leave this one and also add that huge_zero_pfn, to make it more explicit. -- Oscar Salvador SUSE Labs