Skip to content

Commit 3838c40

Browse files
committed
block: re-arrange the struct block_device fields for better layout
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... Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 310e9c8 commit 3838c40

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

include/linux/blk_types.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,25 @@ struct bio_crypt_ctx;
4040
struct block_device {
4141
sector_t bd_start_sect;
4242
sector_t bd_nr_sectors;
43+
struct gendisk * bd_disk;
44+
struct request_queue * bd_queue;
4345
struct disk_stats __percpu *bd_stats;
4446
unsigned long bd_stamp;
4547
bool bd_read_only; /* read-only policy */
48+
u8 bd_partno;
49+
bool bd_write_holder;
4650
dev_t bd_dev;
4751
atomic_t bd_openers;
52+
spinlock_t bd_size_lock; /* for bd_inode->i_size updates */
4853
struct inode * bd_inode; /* will die */
4954
struct super_block * bd_super;
5055
void * bd_claiming;
51-
struct device bd_device;
5256
void * bd_holder;
57+
/* The counter of freeze processes */
58+
int bd_fsfreeze_count;
5359
int bd_holders;
54-
bool bd_write_holder;
5560
struct kobject *bd_holder_dir;
56-
u8 bd_partno;
57-
spinlock_t bd_size_lock; /* for bd_inode->i_size updates */
58-
struct gendisk * bd_disk;
59-
struct request_queue * bd_queue;
6061

61-
/* The counter of freeze processes */
62-
int bd_fsfreeze_count;
6362
/* Mutex for freeze */
6463
struct mutex bd_fsfreeze_mutex;
6564
struct super_block *bd_fsfreeze_sb;
@@ -68,6 +67,11 @@ struct block_device {
6867
#ifdef CONFIG_FAIL_MAKE_REQUEST
6968
bool bd_make_it_fail;
7069
#endif
70+
/*
71+
* keep this out-of-line as it's both big and not needed in the fast
72+
* path
73+
*/
74+
struct device bd_device;
7175
} __randomize_layout;
7276

7377
#define bdev_whole(_bdev) \

0 commit comments

Comments
 (0)