[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMuHMdWLVw8aUY8aCowgOz+puxjrDqcbUXUAoVXGi8=FpTHwrA@mail.gmail.com>
Date: Mon, 7 Apr 2025 10:06:03 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: John Paul Adrian Glaubitz <glaubitz@...sik.fu-berlin.de>
Cc: Magnus Lindholm <linmag7@...il.com>, richard.henderson@...aro.org, mattst88@...il.com,
ink@...een.parts, kees@...nel.org, arnd@...db.de,
linux-kernel@...r.kernel.org, linux-alpha@...r.kernel.org, chris@...kel.net,
dinguyen@...nel.org, jcmvbkbc@...il.com, linux-arm-kernel@...ts.infradead.org,
linux-csky@...r.kernel.org, linux-hexagon@...r.kernel.org,
linux-m68k@...ts.linux-m68k.org, linux-mips@...r.kernel.org,
linux-openrisc@...r.kernel.org, linux-parisc@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org, linux-riscv@...ts.infradead.org,
linux-s390@...r.kernel.org, linux-sh@...r.kernel.org,
linux-snps-arc@...ts.infradead.org, linux-um@...ts.infradead.org,
loongarch@...ts.linux.dev, monstr@...str.eu, sparclinux@...r.kernel.org,
x86@...nel.org
Subject: Re: [PATCH v2 1/1] mm: pgtable: fix pte_swp_exclusive
Hi Adrian,
On Sat, 5 Apr 2025 at 19:22, John Paul Adrian Glaubitz
<glaubitz@...sik.fu-berlin.de> wrote:
> On Tue, 2025-02-18 at 18:55 +0100, Magnus Lindholm wrote:
> > Make pte_swp_exclusive return bool instead of int. This will better reflect
> > how pte_swp_exclusive is actually used in the code. This fixes swap/swapoff
> > problems on Alpha due pte_swp_exclusive not returning correct values when
> > _PAGE_SWP_EXCLUSIVE bit resides in upper 32-bits of PTE (like on alpha).
>
> Minor nitpick:
>
> "when _PAGE_SWP_EXCLUSIVE" => "when the _PAGE_SWP_EXCLUSIVE"
>
> >
> > Signed-off-by: Magnus Lindholm <linmag7@...il.com>
> > --- a/arch/alpha/include/asm/pgtable.h
> > +++ b/arch/alpha/include/asm/pgtable.h
> > @@ -334,7 +334,7 @@ extern inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
> > #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
> > #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
> >
> > -static inline int pte_swp_exclusive(pte_t pte)
> > +static inline bool pte_swp_exclusive(pte_t pte)
> > {
> > return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
> > }
> > --- a/arch/xtensa/include/asm/pgtable.h
> > +++ b/arch/xtensa/include/asm/pgtable.h
> > @@ -355,7 +355,7 @@ ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
> > #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
> > #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
> >
> > -static inline int pte_swp_exclusive(pte_t pte)
> > +static inline bool pte_swp_exclusive(pte_t pte)
> > {
> > return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
> > }
>
> I'm not so sure about this implicit cast from unsigned long to bool though.
>
> Is this verified to work correctly on all architectures? I wonder why this
Should work fine: any non-zero value is mapped to one.
> bug was not caught earlier on alpha on the other hand.
On Alpha, "pte_val(pte) & _PAGE_SWP_EXCLUSIVE" is either
_PAGE_SWP_EXCLUSIVE == 0x8000000000UL or zero. Due to the return
type being int, the return value was truncated, and the function always
returned zero.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists