[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250602041118.GA2675383@ZenIV>
Date: Mon, 2 Jun 2025 05:11:18 +0100
From: Al Viro <viro@...iv.linux.org.uk>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: linmag7@...il.com, Al Viro <viro@....linux.org.uk>, arnd@...db.de,
chris@...kel.net, dinguyen@...nel.org, glaubitz@...sik.fu-berlin.de,
ink@...een.parts, jcmvbkbc@...il.com, kees@...nel.org,
linux-alpha@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-csky@...r.kernel.org, linux-hexagon@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-m68k@...ts.linux-m68k.org,
linux-mips@...r.kernel.org, linux-openrisc@...r.kernel.org,
linux-parisc@...r.kernel.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,
linuxppc-dev@...ts.ozlabs.org, loongarch@...ts.linux.dev,
mattst88@...il.com, monstr@...str.eu, richard.henderson@...aro.org,
sparclinux@...r.kernel.org, x86@...nel.org,
Sam James <sam@...too.org>
Subject: Re: [PATCH v2 1/1] mm: pgtable: fix pte_swp_exclusive
On Sat, Apr 05, 2025 at 06:09:11PM +0100, Sam James wrote:
> Sam James <sam@...too.org> writes:
>
> > Lovely cleanup and a great suggestion from Al.
> >
> > Reviewed-by: Sam James <sam@...too.org>
> >
> > I'd suggest adding a:
> > Suggested-by: Al Viro <viro@...iv.linux.org.uk>
>
> Al, were you planning on taking this through your tree?
FWIW, I expected it to get sent to Linus as "please, run this
sed script before -rc1" kind of thing, script being something
like
sed -i -e 's/int pte_swp_exclusive/bool pte_swp_exclusive/' \
`git grep -l 'int pte_swp_exclusive'`
with suggested commit message... It's absolutely regular and
that kind of tree-wide change is easier handled that way.
Oh, well... To restore the context: Magnus had spotted a fun
bug on Alpha back in February - pte_swp_exclusive() there returned
pte_val(pte) & _PAGE_SWP_EXCLUSIVE as int. The problem is that
_PAGE_SWP_EXCLUSIVE is 1UL<<39 there, with obvious results...
I looked at the originally posted patch and suggested to
make pte_swp_exclusive() return bool instead of int. All users
are in explicitly boolean contexts:
include/linux/swapops.h: if (pte_swp_exclusive(pte))
mm/debug_vm_pgtable.c: WARN_ON(pte_swp_exclusive(pte));
mm/debug_vm_pgtable.c: WARN_ON(!pte_swp_exclusive(pte));
mm/debug_vm_pgtable.c: WARN_ON(pte_swp_exclusive(pte));
mm/internal.h: if (pte_swp_exclusive(pte))
mm/memory.c: if (pte_swp_exclusive(orig_pte)) {
mm/memory.c: exclusive = pte_swp_exclusive(vmf->orig_pte);
mm/swapfile.c: if (pte_swp_exclusive(old_pte))
mm/userfaultfd.c: if (!pte_swp_exclusive(orig_src_pte)) {
Magnus posted patch of that form (see
https://lore.kernel.org/all/20250218175735.19882-2-linmag7@gmail.com/),
got no serious objections and then it went nowhere.
Bug is real and fairly obvious, fix is entirely mechanical and
affects one line in each asm/pgtable.h out there. Linus, could you
run that sed script just before -rc1? Commit message from the patch refered
above looks sane:
mm: pgtable: fix pte_swp_exclusive
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).
Signed-off-by: Magnus Lindholm <linmag7@...il.com>
Powered by blists - more mailing lists