On Thu, Jan 14, 2021 at 7:52 PM Oscar Salvador <osalvador@xxxxxxx> wrote: > > On Thu, Jan 14, 2021 at 06:54:30PM +0800, Muchun Song wrote: > > I think this approach may be only suitable for generic huge page only. > > So we can implement it only for huge page. > > > > Hi Oscar, > > > > What's your opinion about this? > > I tried something like: > > static void vmemmap_pte_range(pmd_t *pmd, unsigned long addr, > unsigned long end, > struct vmemmap_remap_walk *walk) > { > pte_t *pte; > > pte = pte_offset_kernel(pmd, addr); > > if (!walk->reuse_page) { > BUG_ON(pte_none(*pte)); > > walk->reuse_page = pte_page(*pte++); > addr = walk->remap_start; > } > > for (; addr != end; addr += PAGE_SIZE, pte++) { > BUG_ON(pte_none(*pte)); > > walk->remap_pte(pte, addr, walk); > } > } > > void vmemmap_remap_free(unsigned long start, unsigned long end, > unsigned long reuse) > { > LIST_HEAD(vmemmap_pages); > struct vmemmap_remap_walk walk = { > .remap_pte = vmemmap_remap_pte, > .reuse_addr = reuse, > .remap_start = start, > .vmemmap_pages = &vmemmap_pages, > }; > > BUG_ON(start != reuse + PAGE_SIZE); > > vmemmap_remap_range(reuse, end, &walk); > free_vmemmap_page_list(&vmemmap_pages); > } > > but it might overcomplicate things and I am not sure it is any better. > So I am fine with keeping it as is. > Should another user come in the future, we can always revisit. > Maybe just add a little comment in vmemmap_pte_range(), explaining while we > are "+= PAGE_SIZE" for address and I would like to see a comment in > vmemmap_remap_free why the BUG_ON and more important what it is checking. OK, I will add some comments to explain why we do this in vmemmap_remap_free and vmemmap_remap_free. Thanks. > > -- > Oscar Salvador > SUSE L3