On 2024/11/14 16:04, David Hildenbrand wrote:
static unsigned long zap_pte_range(struct mmu_gather *tlb,
struct vm_area_struct *vma, pmd_t *pmd,
unsigned long addr, unsigned long end,
@@ -1682,13 +1704,17 @@ static unsigned long zap_pte_range(struct
mmu_gather *tlb,
pte_t ptent = ptep_get(pte);
int max_nr;
- nr = 1;
- if (pte_none(ptent))
- continue;
-
if (need_resched())
break;
+ nr = skip_none_ptes(pte, addr, end);
+ if (nr) {
+ addr += PAGE_SIZE * nr;
+ if (addr == end)
+ break;
+ pte += nr;
+ }
+
max_nr = (end - addr) / PAGE_SIZE;
I dislike calculating max_nr twice, once here and once in skip_non_ptes.
Further, you're missing to update ptent here.
Oh, my bad. However, with [PATCH v3 5/9], there will be no problem, but
there are still two ptep_get() and max_nr calculation.
If you inline it you can
avoid another ptep_get().
Do you mean to inline the skip_none_ptes() into do_zap_pte_range()? This
will cause these none ptes to be checked again in count_pte_none() when
PTE_MARKER_UFFD_WP is enabled. Of course, maybe we can count none ptes
in do_zap_pte_range() and pass it through function parameters like
force_break.
if (pte_present(ptent)) {
nr = zap_present_ptes(tlb, vma, pte, ptent, max_nr,