Thread (22 messages) 22 messages, 5 authors, 2023-02-13

Re: [PATCH v2 4/4] mm, arch: add generic implementation of pfn_valid() for FLATMEM

From: Conor Dooley <conor@kernel.org>
Date: 2023-01-31 18:55:43
Also in: linux-alpha, linux-arch, linux-m68k, linux-mips, linux-mm, linux-riscv, linux-sh, linux-um, linuxppc-dev, lkml, loongarch, sparclinux

Hi Mike,

On Tue, Jan 31, 2023 at 08:41:49PM +0200, Mike Rapoport wrote:
quoted hunk ↗ jump to hunk
On Tue, Jan 31, 2023 at 05:47:24PM +0000, Conor Dooley wrote:
quoted
On Sun, Jan 29, 2023 at 02:42:35PM +0200, Mike Rapoport wrote:
quoted
From: "Mike Rapoport (IBM)" <rppt@kernel.org>

Every architecture that supports FLATMEM memory model defines its own
version of pfn_valid() that essentially compares a pfn to max_mapnr.

Use mips/powerpc version implemented as static inline as a generic
implementation of pfn_valid() and drop its per-architecture definitions.

Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Guo Ren <guoren@kernel.org>		# csky
Acked-by: Huacai Chen <redacted>	# LoongArch
Acked-by: Stafford Horne <shorne@gmail.com>	# OpenRISC
Hmm, so this landed in linux-next today and I bisected a boot failure in
my CI to it. However, I am not really sure if it is a real issue worth
worrying about as the platform it triggered on is supposed to be using
SPARSEMEM, but isn't.
I had thought that my CI was using a config with SPARSEMEM since that
became required for riscv defconfig builds to boot in v6.1-rc1, but I
must have just forgotten to add it to my $platform_defconfig builds too.
However, those $platform_defconfig builds continued booting without
SPARSEMEM enabled until today.
The issue seems to be that the generic pfn_valid() does not take into
account pfn_offset when it compares it with max_mapnr.
Can you please test with the patch below?
diff --git a/include/asm-generic/memory_model.h b/include/asm-generic/memory_model.h
index 13d2a844d928..6796abe1900e 100644
--- a/include/asm-generic/memory_model.h
+++ b/include/asm-generic/memory_model.h
@@ -26,7 +26,7 @@ static inline int pfn_valid(unsigned long pfn)
 	extern unsigned long max_mapnr;
 	unsigned long pfn_offset = ARCH_PFN_OFFSET;
 
-	return pfn >= pfn_offset && pfn < max_mapnr;
+	return pfn >= pfn_offset && (pfn - pfn_offset) < max_mapnr;
 }
 #define pfn_valid pfn_valid
 #endif
Gave that a go, board is booting properly again! Feel free to add a:
Tested-by: Conor Dooley <conor.dooley@microchip.com>

Thanks for the prompt fix!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help