Message ID | ZdjTMZRwZ_9GjCmc@redhat.com (mailing list archive) |
---|---|
State | Accepted, archived |
Delegated to: | Mike Snitzer |
Headers | show |
Series | [git,pull] device mapper fixes for 6.8-rc6 | expand |
On Fri, 23 Feb 2024 at 09:17, Mike Snitzer <snitzer@kernel.org> wrote: > > - Fix DM crypt and verity targets to align their respective bvec_iter > struct members to avoid the need for byte level access (due to > __packed attribute) that is costly on some arches (like RISC). Ugh. This is due to commit 19416123ab3e ("block: define 'struct bvec_iter' as packed"), and the point of *that* commit was that it doesn't hurt to mark it packed. That was clearly not true. And honestly, "__packed" really is wrong here. Nobody ever wanted it to be completely unaligned. I think we might be better off marking it as being 4-byte aligned. That would mean that instead of __packed, it is done as __packed __aligned(4) because "__aligned" on its own only increases alignment (so without the __packed it would stay 8-byte aligned). Then the only part of that structure that might be unaligned is "sector_t", and that would only matter on 64-bit architectures. And very few architectures are both 64-bit _and_ so broken as to not do unaligned loads well. And even if such broken architectures exist, at least they can do the 8-byte load as two 4-byte ones rather than doing it as byte loads.. Anyway, I've pulled this, but I really think this should have been fixed in bvec.h instead. Jens/Christoph/whoever feels they own bvec.h? Linus
On Fri, Feb 23, 2024 at 09:42:21AM -0800, Linus Torvalds wrote: > And honestly, "__packed" really is wrong here. Nobody ever wanted it > to be completely unaligned. I'll let Ming speak, but I think the idea was to remove the padding at the end of the structure when embedded into the bio. > > I think we might be better off marking it as being 4-byte aligned. > That would mean that instead of __packed, it is done as > > __packed __aligned(4) > > > because "__aligned" on its own only increases alignment (so without > the __packed it would stay 8-byte aligned). > > Then the only part of that structure that might be unaligned is > "sector_t", and that would only matter on 64-bit architectures. Does __aligned also work on struct members? If so we could add a __aligned(8) to bi_sector an get exactly what we want..
On Fri, 23 Feb 2024 at 09:46, Christoph Hellwig <hch@lst.de> wrote: > > I'll let Ming speak, but I think the idea was to remove the padding > at the end of the structure when embedded into the bio. It's not horribly obvious if the beginning is aligned there either. > Does __aligned also work on struct members? If so we could add a > __aligned(8) to bi_sector an get exactly what we want.. Hmm. I'm not sure that works. I think sizeof may always end up being aligned to alignof (because otherwise arrays cannot work) And looking at struct bio_integrity_payload { there's odd padding both before _and_ after the struct bvec_iter due to having three 16-bit fields in between. So right now I think that packing ends up actually horrid. I don't see any *reason* for that odd setup, but right now it might have actually end up being 2-byte aligned with a two-byte padding hole at the end. Linus
The pull request you sent on Fri, 23 Feb 2024 12:17:37 -0500:
> git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git tags/for-6.8/dm-fixes-2
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/e7768e65cd777182553b98f5b4eaffb624974976
Thank you!