Skip to content

fs/erofs: major alignment fixes

Michael Walle linux-erofs u-boot 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4fs/erofs: align the malloc'ed datafs/erofs/data.c fs/erofs/internal.h+5 -73 replies
2/4fs/erofs: allocate data buffers on heap with alignment (1/3)fs/erofs/data.c fs/erofs/fs.c fs/erofs/namei.c +2 more+91 -320 replies
3/4fs/erofs: allocate data buffers on heap with alignment (2/3)fs/erofs/namei.c+15 -60 replies
4/4fs/erofs: allocate data buffers on heap with alignment (3/3)fs/erofs/data.c fs/erofs/internal.h fs/erofs/zmap.c+94 -420 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] fs/erofs: major alignment fixes

Throughout the whole fs code, large (4k) data buffers are allocated on the stack. While it is not nice, to allocate that large buffers on the stack, there is a much more fundamental problem: it's not aligned.

This will result in a huge amount of cache misaligned messages on arm32 SoCs, e.g.:

CACHE: Misaligned operation at range [x, y]

While this is more or less a warning, as it will only invalidate surrounding data, DMA is more of a problem. Some DMA controllers have address restrictions and because of that there is ARCH_DMA_MINALIGN. Thus as a first fix, move all the data buffers from the stack to the heap with proper alignment.

There are still some misalignment warnings. I've traced it to fs_devread(). Most of the calls to blk_dread() will pass an aligned buffer. But the main blk_dread() will just pass buf, which might have previously been advanced by readlen. Not sure how that could be fixed in an elegant way. The simplest would probably be just a bounce buffer, which there is already one in blk_read() if BOUNCE_BUFFERS is enabled. But I haven't managed to get that working. And now, I'm running out of time.

Michael Walle (4):
fs/erofs: align the malloc'ed data
fs/erofs: allocate data buffers on heap with alignment (1/3) fs/erofs: allocate data buffers on heap with alignment (2/3) fs/erofs: allocate data buffers on heap with alignment (3/3)

 fs/erofs/data.c     | 125 +++++++++++++++++++++++++++++---------------
 fs/erofs/fs.c       |  14 ++++-
 fs/erofs/internal.h |   5 +-
 fs/erofs/namei.c    |  47 ++++++++++++-----
 fs/erofs/super.c    |  40 ++++++++++----
 fs/erofs/zmap.c     |  61 +++++++++++++++------
 6 files changed, 205 insertions(+), 87 deletions(-)
Signature · 1 line
2.47.3