Re: [PATCH v2 2/6] mm/pgtable: Fix bogus comment to clear_not_present_full_ptes()

From: David Hildenbrand (Arm)

Date: Thu Apr 16 2026 - 03:59:00 EST


On 4/15/26 17:01, Alexander Gordeev wrote:
> The address provided to clear_not_present_full_ptes() is the
> address of the underlying memory, not address of the first PTE.
> The exact wording is taken from clear_ptes() comment.
>
> Suggested-by: Kevin Brodsky <kevin.brodsky@xxxxxxx>
> Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxxxxx>
> ---
> include/linux/pgtable.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
> index 9ff7b78d65b1..2b82a71f13d7 100644
> --- a/include/linux/pgtable.h
> +++ b/include/linux/pgtable.h
> @@ -1021,8 +1021,8 @@ static inline void pte_clear_not_present_full(struct mm_struct *mm,
> /**
> * clear_not_present_full_ptes - Clear multiple not present PTEs which are
> * consecutive in the pgtable.
> - * @mm: Address space the ptes represent.
> - * @addr: Address of the first pte.
> + * @mm: Address space the pages are mapped into.
> + * @addr: Address the first page is mapped at.


Talking about pages with non-present entries does not make sense. So both changes
are wrong. Can you find something better and send that out separately?
I don't think this is required for your series, right?


Also, looking at it, it does not make sense to specify "full" when there is nothing
to flush. We are dealing with non-present PTEs after all.

Looking into the sparc variant of pte_clear_not_present_full(), it does

__set_pte_at((mm), (addr), (ptep), __pte(0UL), (fullmm))

and that does

pte_t orig = *ptep;

*ptep = pte;
maybe_tlb_batch_add(mm, addr, ptep, orig, fullmm, PAGE_SHIFT);

but in maybe_tlb_batch_add we have

if (likely(mm != &init_mm) && pte_accessible(mm, orig))
tlb_batch_add(mm, vaddr, ptep, orig, fullmm, hugepage_shift);

And as the pte is non-present, the pte is certainly not accessible. fullmm
is unused on that path.


All the talk about flushing TLBs about something that is non-present for
pte_clear_not_present_full looks weird.


@Ryan, you added clear_not_present_full_ptes() back then, but you were simply
reusing pte_clear_not_present_full(). Does below seem reasonable to you?