On Wed, Feb 01, 2023 at 05:38:39PM +0000, Matthew Wilcox wrote: > On Wed, Feb 01, 2023 at 04:17:36PM +0800, Yin Fengwei wrote: > > do_set_pte_range() allows to setup page table entries for a > > specific range. It calls page_add_file_rmap_range() to take > > advantage of batched rmap update for large folio. > > How about something more like this? Yes, we need to define > flush_icache_pages() and PTE_STRIDE. Never mind about PTE_STRIDE. I forgot that pte_t isn't an integer type. Instead, we'll want each architecture to define /* This should be right for x86 */ static inline pte_next(pte_t pte) { return __pte(pte_val(pte) + PAGE_SIZE); } > + for (i = 0; i < nr; i++) { > + set_pte_at(vma->vm_mm, addr, vmf->pte + i, entry); > + /* no need to invalidate: a not-present page won't be cached */ > + update_mmu_cache(vma, addr, vmf->pte + i); > + addr += PAGE_SIZE; > + entry += PTE_STRIDE; entry = pte_next(entry);