Re: [RFC PATCH 02/34] ARM: mm: make 2-level pgd_t a scalar
"Arnd Bergmann" <[email protected]> Tue, 14 Jul 2026 17:06:00 +0200
| Newsgroups | org.kernel.vger.linux-csky,dev.linux.lists.loongarch,org.infradead.lists.kvm-riscv,org.infradead.lists.linux-riscv,org.kernel.vger.linux-arch,org.kernel.vger.linux-kernel,org.kernel.vger.linux-m68k,org.kernel.vger.linux-mips,org.kernel.vger.linux-openrisc,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Jul 14, 2026, at 15:34, David Laight wrote: > On Tue, 14 Jul 2026 13:55:18 +0200 > "Arnd Bergmann" <[email protected]> wrote: >> > I see the compiler has an awkward time returning a u64 struct (see >> > https://godbolt.org/z/qejbv6j9a), but if this doesn't work maybe we should >> > get rid of the STRICT_MM_TYPECHECKS stuff? I seriously doubt anyone is >> > purposefully toggling it on for testing from time to time. >> >> As far as I can tell, the #ifdef was originally in i386 and >> got copied to all other architectures at the time, but was >> removed in linux-2.3.23 from the original copy when CONFIG_X86_PAE >> was introduced. > > For x86-32 the makefiles request 64bit structures be returned in registers > (at the same place regparm=3 is set - probably added at the same time > between 2.4 and 2.6). > > Note that arm32 can will return a 32bit struct in a register and > arm64 will return a 128bit struct in two registers. > > The only problem is returning a 64bit struct in 32bit mode. > > I'm sure this code is arm64 only. The file we are talking about is arch/arm/include/asm/pgtable-2level-types.h, which is definitely 32-bit only and force a 64-bit struct return on the stack. I checked some trivial tests that show that arm-linux-gnueabihf-gcc-16 also still produces badly optimized object code with structures passed by value, and will spill those to the stack for no apparent reason. clang handles those just fine as a pair of registers. For the 2-level page table, this only concerns pgd_t, which is rarely passed around or returned by value. The 3-level page table has a 64-bit pte_t, which means we probably won't want STRICT_MM_TYPECHECKS there. Arnd