Skip to contentSkip to conversation

block: define bvec_iter as __packed __aligned(4)

PATCH New Ming Lei 1 participant 1 message Feb 25, 2024 Block layer

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 block: define bvec_iter as __packed __aligned(4)

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), especially __packed means byte aligned, and can cause compiler to generate too horrible code on ARCHs which don't support unaligned access in case that bvec_iter is embedded in other structures.

Cc Mikulas Patocka <[email protected]>
Fixes 19416123ab3e ("block: define 'struct bvec_iter' as packed")
---
 include/linux/bvec.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/bvec.h +1 -1
index 555aae5448ae..bd1e361b351c 100644
@@ -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;
Signature · 1 line
2.41.0