From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Alexander Gordeev <agordeev@linux.ibm.com>,
Kevin Brodsky <kevin.brodsky@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Ryan Roberts <Ryan.Roberts@arm.com>
Cc: linux-s390@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/6] mm/pgtable: Fix bogus comment to clear_not_present_full_ptes()
Date: Thu, 16 Apr 2026 09:58:47 +0200 [thread overview]
Message-ID: <844d4076-a250-486e-aa16-fe5149c9d508@kernel.org> (raw)
In-Reply-To: <fecfcf70436e267968c1c3b6908e51fe49fd9009.1776264097.git.agordeev@linux.ibm.com>
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@arm.com>
> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
> ---
> 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?
From 0899495ba8ecc73273450e58737bc458976dfa12 Mon Sep 17 00:00:00 2001
From: "David Hildenbrand (Arm)" <david@kernel.org>
Date: Thu, 16 Apr 2026 09:51:07 +0200
Subject: [PATCH] tmp
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
arch/sparc/include/asm/pgtable_64.h | 4 ----
include/linux/pgtable.h | 28 +++++-----------------------
mm/madvise.c | 6 +++---
mm/memory.c | 2 +-
4 files changed, 9 insertions(+), 31 deletions(-)
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
index 74ede706fb32..0837ebbc5dce 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -945,10 +945,6 @@ static inline void set_ptes(struct mm_struct *mm, unsigned long addr,
#define pte_clear(mm,addr,ptep) \
set_pte_at((mm), (addr), (ptep), __pte(0UL))
-#define __HAVE_ARCH_PTE_CLEAR_NOT_PRESENT_FULL
-#define pte_clear_not_present_full(mm,addr,ptep,fullmm) \
- __set_pte_at((mm), (addr), (ptep), __pte(0UL), (fullmm))
-
#ifdef DCACHE_ALIASING_POSSIBLE
#define __HAVE_ARCH_MOVE_PTE
#define move_pte(pte, old_addr, new_addr) \
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
index 17d961c612fc..b3d6c8ddd687 100644
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -955,24 +955,8 @@ static inline void update_mmu_tlb(struct vm_area_struct *vma,
update_mmu_tlb_range(vma, address, ptep, 1);
}
-/*
- * Some architectures may be able to avoid expensive synchronization
- * primitives when modifications are made to PTE's which are already
- * not present, or in the process of an address space destruction.
- */
-#ifndef __HAVE_ARCH_PTE_CLEAR_NOT_PRESENT_FULL
-static inline void pte_clear_not_present_full(struct mm_struct *mm,
- unsigned long address,
- pte_t *ptep,
- int full)
-{
- pte_clear(mm, address, ptep);
-}
-#endif
-
-#ifndef clear_not_present_full_ptes
/**
- * clear_not_present_full_ptes - Clear multiple not present PTEs which are
+ * clear_not_present_full_ptes - Clear multiple non-present PTEs which are
* consecutive in the pgtable.
* @mm: Address space the ptes represent.
* @addr: Address of the first pte.
@@ -980,24 +964,22 @@ static inline void pte_clear_not_present_full(struct mm_struct *mm,
* @nr: Number of entries to clear.
* @full: Whether we are clearing a full mm.
*
- * May be overridden by the architecture; otherwise, implemented as a simple
- * loop over pte_clear_not_present_full().
+ * Implemented as a simple loop over pte_clear().
*
* Context: The caller holds the page table lock. The PTEs are all not present.
* The PTEs are all in the same PMD.
*/
-static inline void clear_not_present_full_ptes(struct mm_struct *mm,
- unsigned long addr, pte_t *ptep, unsigned int nr, int full)
+static inline void clear_non_present_ptes(struct mm_struct *mm,
+ unsigned long addr, pte_t *ptep, unsigned int nr)
{
for (;;) {
- pte_clear_not_present_full(mm, addr, ptep, full);
+ pte_clear(mm, addr, ptep);
if (--nr == 0)
break;
ptep++;
addr += PAGE_SIZE;
}
}
-#endif
#ifndef __HAVE_ARCH_PTEP_CLEAR_FLUSH
extern pte_t ptep_clear_flush(struct vm_area_struct *vma,
diff --git a/mm/madvise.c b/mm/madvise.c
index 69708e953cf5..0e430e03e69c 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -695,10 +695,10 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,
nr = swap_pte_batch(pte, max_nr, ptent);
nr_swap -= nr;
swap_put_entries_direct(entry, nr);
- clear_not_present_full_ptes(mm, addr, pte, nr, tlb->fullmm);
+ clear_non_present_(mm, addr, pte, nr);
} else if (softleaf_is_hwpoison(entry) ||
softleaf_is_poison_marker(entry)) {
- pte_clear_not_present_full(mm, addr, pte, tlb->fullmm);
+ pte_clear(mm, addr, pte);
}
continue;
}
@@ -1234,7 +1234,7 @@ static int guard_remove_pte_entry(pte_t *pte, unsigned long addr,
if (is_guard_pte_marker(ptent)) {
/* Simply clear the PTE marker. */
- pte_clear_not_present_full(walk->mm, addr, pte, false);
+ pte_clear(walk->mm, addr, pte);
update_mmu_cache(walk->vma, addr, pte);
}
diff --git a/mm/memory.c b/mm/memory.c
index 631205a384e1..d61d4ba906cd 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1781,7 +1781,7 @@ static inline int zap_nonpresent_ptes(struct mmu_gather *tlb,
pr_alert("unrecognized swap entry 0x%lx\n", entry.val);
WARN_ON_ONCE(1);
}
- clear_not_present_full_ptes(vma->vm_mm, addr, pte, nr, tlb->fullmm);
+ clear_non_present_ptes(vma->vm_mm, addr, pte, nr);
*any_skipped = zap_install_uffd_wp_if_needed(vma, addr, pte, nr, details, ptent);
return nr;
--
2.43.0
--
Cheers,
David
next prev parent reply other threads:[~2026-04-16 7:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 15:01 [PATCH v2 0/6] s390/mm: Batch PTE updates in lazy MMU mode Alexander Gordeev
2026-04-15 15:01 ` [PATCH v2 1/6] mm: Make lazy MMU mode context-aware Alexander Gordeev
2026-04-15 15:01 ` [PATCH v2 2/6] mm/pgtable: Fix bogus comment to clear_not_present_full_ptes() Alexander Gordeev
2026-04-16 7:58 ` David Hildenbrand (Arm) [this message]
2026-04-16 8:53 ` Alexander Gordeev
2026-04-15 15:01 ` [PATCH v2 3/6] s390/mm: Complete ptep_get() conversion Alexander Gordeev
2026-04-15 15:01 ` [PATCH v2 4/6] s390/mm: Make PTC and UV call order consistent Alexander Gordeev
2026-04-15 15:01 ` [PATCH v2 5/6] s390/mm: Batch PTE updates in lazy MMU mode Alexander Gordeev
2026-04-16 5:40 ` Heiko Carstens
2026-04-16 5:51 ` Alexander Gordeev
2026-04-15 15:01 ` [PATCH v2 6/6] s390/mm: Allow lazy MMU mode disabling Alexander Gordeev
2026-04-16 5:44 ` Heiko Carstens
2026-04-16 7:00 ` Alexander Gordeev
2026-04-16 8:22 ` Christian Borntraeger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=844d4076-a250-486e-aa16-fe5149c9d508@kernel.org \
--to=david@kernel.org \
--cc=Ryan.Roberts@arm.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=borntraeger@linux.ibm.com \
--cc=gerald.schaefer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kevin.brodsky@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-s390@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox