2023-11-28 12:31:35

by Yu Kuai

[permalink] [raw]
Subject: [PATCH v4 0/2] block: warn once for each partition in bio_check_ro()

From: Yu Kuai <[email protected]>

Changes in v4:
- remove the patch to add 'bd_flags', and add a new field 'bool
bd_ro_warned' in patch 2. 'bd_flags' will be added once 'bd_inode' is
removed from other thread.

Changes in v3:
- add patch 1 from Ming, swap bd_inode layout with bd_openers and
bd_size_lock;
- change bd_flags from u32 to u16 in patch 2, prevent to affect layout of
other fields;

Changes in v2:
- don't use test/set_bit() for new field, because unsigned long will
cause that some field can't be placed in the first cacheline(64 bytes),
use unsigned int for new field and test/set/clear it like 'bio->bi_flags'.

Ming Lei (1):
block: move .bd_inode into 1st cacheline of block_device

Yu Kuai (1):
block: warn once for each partition in bio_check_ro()

block/blk-core.c | 14 +++++++++++---
include/linux/blk_types.h | 4 +++-
2 files changed, 14 insertions(+), 4 deletions(-)

--
2.39.2


2023-11-28 12:31:42

by Yu Kuai

[permalink] [raw]
Subject: [PATCH v4 1/2] block: move .bd_inode into 1st cacheline of block_device

From: Ming Lei <[email protected]>

The .bd_inode field of block_device is used in IO fast path of
blkdev_write_iter() and blkdev_llseek(), so it is more efficient to keep
it into the 1st cacheline.

.bd_openers is only touched in open()/close(), and .bd_size_lock is only
for updating bdev capacity, which is in slow path too.

So swap .bd_inode layout with .bd_openers & .bd_size_lock to move
.bd_inode into the 1st cache line.

Cc: Yu Kuai <[email protected]>
Signed-off-by: Ming Lei <[email protected]>
Signed-off-by: Yu Kuai <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
---
include/linux/blk_types.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index d5c5e59ddbd2..f7d40692dd94 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -49,9 +49,10 @@ struct block_device {
bool bd_write_holder;
bool bd_has_submit_bio;
dev_t bd_dev;
+ struct inode *bd_inode; /* will die */
+
atomic_t bd_openers;
spinlock_t bd_size_lock; /* for bd_inode->i_size updates */
- struct inode * bd_inode; /* will die */
void * bd_claiming;
void * bd_holder;
const struct blk_holder_ops *bd_holder_ops;
--
2.39.2

2023-11-28 19:11:41

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH v4 0/2] block: warn once for each partition in bio_check_ro()


On Tue, 28 Nov 2023 20:30:25 +0800, Yu Kuai wrote:
> Changes in v4:
> - remove the patch to add 'bd_flags', and add a new field 'bool
> bd_ro_warned' in patch 2. 'bd_flags' will be added once 'bd_inode' is
> removed from other thread.
>
> Changes in v3:
> - add patch 1 from Ming, swap bd_inode layout with bd_openers and
> bd_size_lock;
> - change bd_flags from u32 to u16 in patch 2, prevent to affect layout of
> other fields;
>
> [...]

Applied, thanks!

[1/2] block: move .bd_inode into 1st cacheline of block_device
commit: fad907cffd4bde7384812cf32fcf69becab805cc
[2/2] block: warn once for each partition in bio_check_ro()
commit: 67d995e069535c32829f5d368d919063492cec6e

Best regards,
--
Jens Axboe