All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Walle <mwalle@kernel.org>
To: Huang Jianan <jnhuang95@gmail.com>, Tom Rini <trini@konsulko.com>
Cc: linux-erofs@lists.ozlabs.org, u-boot@lists.denx.de,
	Michael Walle <mwalle@kernel.org>
Subject: [PATCH 0/4] fs/erofs: major alignment fixes
Date: Mon, 23 Mar 2026 14:42:16 +0100	[thread overview]
Message-ID: <20260323134305.2675822-1-mwalle@kernel.org> (raw)

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(-)

-- 
2.47.3



             reply	other threads:[~2026-03-23 13:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23 13:42 Michael Walle [this message]
2026-03-23 13:42 ` [PATCH 1/4] fs/erofs: align the malloc'ed data Michael Walle
2026-03-23 14:41   ` Gao Xiang
2026-03-23 15:08     ` Michael Walle
2026-03-23 15:13       ` Gao Xiang
2026-03-23 13:42 ` [PATCH 2/4] fs/erofs: allocate data buffers on heap with alignment (1/3) Michael Walle
2026-03-23 13:42 ` [PATCH 3/4] fs/erofs: allocate data buffers on heap with alignment (2/3) Michael Walle
2026-03-23 13:42 ` [PATCH 4/4] fs/erofs: allocate data buffers on heap with alignment (3/3) Michael Walle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260323134305.2675822-1-mwalle@kernel.org \
    --to=mwalle@kernel.org \
    --cc=jnhuang95@gmail.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.