block: move .bd_inode into 1st cacheline of block_device
authorMing Lei <ming.lei@redhat.com>
Tue, 28 Nov 2023 12:30:26 +0000 (20:30 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 28 Nov 2023 19:11:08 +0000 (12:11 -0700)
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 <yukuai3@huawei.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20231128123027.971610-2-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/blk_types.h

index d5c5e59ddbd25afd284a1094948850be42437fb2..f7d40692dd9481e7cad3f95892c9053311f1edf0 100644 (file)
@@ -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;