diff mbox series

[1/2] block: re-arrange the struct block_device fields for better layout

Message ID 20230414134848.91563-2-axboe@kernel.dk (mailing list archive)
State New, archived
Headers show
Series Optimize block_device utilization | expand

Commit Message

Jens Axboe April 14, 2023, 1:48 p.m. UTC
This moves struct device out-of-line as it's just used at open/close
time, so we can keep some of the commonly used fields closer together.
On a standard setup, it also reduces the size from 864 bytes to 848
bytes. Yes, struct device is a pig...

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 include/linux/blk_types.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Christoph Hellwig April 16, 2023, 5:51 a.m. UTC | #1
On Fri, Apr 14, 2023 at 07:48:47AM -0600, Jens Axboe wrote:
> This moves struct device out-of-line as it's just used at open/close
> time, so we can keep some of the commonly used fields closer together.
> On a standard setup, it also reduces the size from 864 bytes to 848
> bytes. Yes, struct device is a pig...

Maybe add a comment about keeping struct device last and why?

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Jens Axboe April 16, 2023, 7:01 p.m. UTC | #2
On 4/15/23 11:51 PM, Christoph Hellwig wrote:
> On Fri, Apr 14, 2023 at 07:48:47AM -0600, Jens Axboe wrote:
>> This moves struct device out-of-line as it's just used at open/close
>> time, so we can keep some of the commonly used fields closer together.
>> On a standard setup, it also reduces the size from 864 bytes to 848
>> bytes. Yes, struct device is a pig...
> 
> Maybe add a comment about keeping struct device last and why?

Sure, done.
diff mbox series

Patch

diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 99be590f952f..d68d6e951fad 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -40,26 +40,25 @@  struct bio_crypt_ctx;
 struct block_device {
 	sector_t		bd_start_sect;
 	sector_t		bd_nr_sectors;
+	struct gendisk *	bd_disk;
+	struct request_queue *	bd_queue;
 	struct disk_stats __percpu *bd_stats;
 	unsigned long		bd_stamp;
 	bool			bd_read_only;	/* read-only policy */
+	u8			bd_partno;
+	bool			bd_write_holder;
 	dev_t			bd_dev;
 	atomic_t		bd_openers;
+	spinlock_t		bd_size_lock; /* for bd_inode->i_size updates */
 	struct inode *		bd_inode;	/* will die */
 	struct super_block *	bd_super;
 	void *			bd_claiming;
-	struct device		bd_device;
 	void *			bd_holder;
+	/* The counter of freeze processes */
+	int			bd_fsfreeze_count;
 	int			bd_holders;
-	bool			bd_write_holder;
 	struct kobject		*bd_holder_dir;
-	u8			bd_partno;
-	spinlock_t		bd_size_lock; /* for bd_inode->i_size updates */
-	struct gendisk *	bd_disk;
-	struct request_queue *	bd_queue;
 
-	/* The counter of freeze processes */
-	int			bd_fsfreeze_count;
 	/* Mutex for freeze */
 	struct mutex		bd_fsfreeze_mutex;
 	struct super_block	*bd_fsfreeze_sb;
@@ -68,6 +67,7 @@  struct block_device {
 #ifdef CONFIG_FAIL_MAKE_REQUEST
 	bool			bd_make_it_fail;
 #endif
+	struct device		bd_device;
 } __randomize_layout;
 
 #define bdev_whole(_bdev) \