On Fri, Oct 02, 2026 at 02:04:48PM +0400, Alexey Charkov wrote: > ARM passes -mstrict-align (-mno-unaligned-access on ARMv7) to everything, > because when the MMU is off any unaligned access there faults. The > compiler then has to assemble every wide unaligned load out of single > bytes: one ldr becomes eight ldrb and seven orr/lsl. > > This is especially painful for decompressors which refill their buffer > in 64-bit words. On a Rockchip RK3576 SPL, zstd unpacks a 30MiB Falcon > mode Linux kernel in 1947ms built this way and 596ms without the flag, > and the SPL gets 2.3KiB smaller by cutting down on the byte-wise loads and > ORs. gzip, whose inflate walks its input a byte at a time anyway, gains > 6%. > > Add ASSUME_UNALIGNED_ACCESS_OK for a platform to state that the MMU is on > by the time it unpacks an image, and let the decompression libraries drop > the flag when it is set. The arch exports the flag it added rather than > lib/ naming it, so this stays correct for anything else which adds one. > > No functional change anywhere until the symbol is selected. > > Signed-off-by: Alexey Charkov <[email protected]>
I think there is future room here to build on, I don't hate the idea of someone looking at how to invert the logic if and only if there's a clean way to say "here is the pre-MMU-enabled world". I don't know that such a line easily exists. It might also not really be a win for anything other than decompression and a few other operations anyhow. With that note for future work: Reviewed-by: Tom Rini <[email protected]> -- Tom
signature.asc
Description: PGP signature
