block: define bvec_iter as __packed __aligned(4)
authorMing Lei <ming.lei@redhat.com>
Sun, 25 Feb 2024 03:01:41 +0000 (11:01 +0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 2 Mar 2024 17:15:01 +0000 (09:15 -0800)
In commit 19416123ab3e ("block: define 'struct bvec_iter' as packed"),
what we need is to save the 4byte padding, and avoid `bio` to spread on
one extra cache line.

It is enough to define it as '__packed __aligned(4)', as '__packed'
alone means byte aligned, and can cause compiler to generate horrible
code on architectures that don't support unaligned access in case that
bvec_iter is embedded in other structures.

Cc: Mikulas Patocka <mpatocka@redhat.com>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Fixes: 19416123ab3e ("block: define 'struct bvec_iter' as packed")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/bvec.h

index 555aae5448ae4ec00065e00553955b31bb44884b..bd1e361b351c5afa88ff02e7023cd79acd5454fd 100644 (file)
@@ -83,7 +83,7 @@ struct bvec_iter {
 
        unsigned int            bi_bvec_done;   /* number of bytes completed in
                                                   current bvec */
-} __packed;
+} __packed __aligned(4);
 
 struct bvec_iter_all {
        struct bio_vec  bv;