On Mon, Oct 26, 2026 at 4:03 PM Arnd Bergmann <[email protected]> wrote: > > On Mon, Oct 26, 2026, at 22:52, James Houghton wrote: > > uaccess_without_mm() is inlined into every user copy, including every > > copy_{to,from}_user() call site on architectures that define > > INLINE_COPY_USER, such as arm64. Each inlined WARN_ON_ONCE() adds its > > own __bug_table entry. > > > > Keep the NULL current->mm check inline, but move the warning into a > > single out-of-line, __cold function, uaccess_warn_without_mm(). > > > > The trade-off is that only the first offending access in the system > > warns, rather than the first one from each call site. The stack trace > > still identifies the caller, and the access is refused either way. > > > > Compared to the base of this series, with defconfig + KVM: > > > > inline WARN_ON_ONCE() out-of-line warning > > x86_64 total +5,884 B (+0.014%) +9,714 B (+0.023%) > > arm64 total +40,948 B (+0.10%) +24,609 B (+0.06%) > > > > On arm64, this removes the ~16 KB of __bug_table growth, while text > > size is unchanged, as a call is the same size as the inline brk. On > > x86_64, the call is larger than the inline ud2 and causes more .cold > > splitting, so this is a slight regression. > > > > Signed-off-by: James Houghton <[email protected]> > > --- > > NOTE: This patch is included for reference only, to show the cost of the > > inline warning. > > I would suspect that the growth is larger on architectures that > don't implement __WARN_FLAGS() but rely on the generic WARN_ON(). > > This would mainly affect 32-bit arm and mips machines, some of which > are very memory limited, most of the 64-bit architectures have it.
Thanks, Arnd! I ran some build tests on 32-bit arm and mips: arm (multi_v7_defconfig): - base: 31,913,726 B - patches 1-9: +64,816 B (+0.20%) - patches 1-10: +23,193 B (+0.07%) mips (malta_defconfig): - base: 11,830,177 B - patches 1-9: +61,168 B (+0.52%) - patches 1-10: +25,881 B (+0.22%) I think it makes sense to include patch 10 with these results; cutting >50% of the size increase for arm and mips seems worth the trade-off of only WARNing on the violating callstack. Let me know what you think. Is the increase even with patch 10 too much for mips or arm? I can add a Kconfig in that case.
