Re: [PATCH v2 1/1] s390/mm: Fix handling of _PAGE_UNUSED pte bit

From: Claudio Imbrenda

Date: Mon Jun 15 2026 - 06:31:44 EST


On Mon, 15 Jun 2026 11:43:00 +0200
Heiko Carstens <hca@xxxxxxxxxxxxx> wrote:

[...]

> > @@ -175,6 +179,8 @@ pte_t ptep_modify_prot_start(struct
vm_area_struct *vma, unsigned long addr,
> > void ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr,
> > pte_t *ptep, pte_t old_pte, pte_t pte)
> > {
> > + if (pte_present(pte))
> > + pte = clear_pte_bit(pte, __pgprot(_PAGE_UNUSED));
> > set_pte(ptep, pte);
>
> Can't we move the logic from set_ptes() to set_pte() instead? The above

set_pte() is also used for things that are not ptes, and in those cases
we probably don't want to touch that bit, although technically it is
currently unused for present large pmds and puds.

> approach remembers me of the open-coded removal of the no-exec bit at many
> places we had, which became a maintenance mess until it was rewritten.
>
> The compiler _might_ even be clever enough to move the removal of the bit
> outside the loop within set_ptes().