Skip to content

Commit 72d711c

Browse files
committed
dm: adjust structure members to improve alignment
Eliminate most holes in DM data structures that were modified by commit 6f1c819 ("dm: convert to bioset_init()/mempool_init()"). Also prevent structure members from unnecessarily spanning cache lines. Signed-off-by: Mike Snitzer <[email protected]>
1 parent b2b04e7 commit 72d711c

File tree

9 files changed

+79
-73
lines changed

9 files changed

+79
-73
lines changed

drivers/md/dm-bio-prison-v1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
struct dm_bio_prison {
2121
spinlock_t lock;
22-
mempool_t cell_pool;
2322
struct rb_root cells;
23+
mempool_t cell_pool;
2424
};
2525

2626
static struct kmem_cache *_cell_cache;

drivers/md/dm-bio-prison-v2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ struct dm_bio_prison_v2 {
2121
struct workqueue_struct *wq;
2222

2323
spinlock_t lock;
24-
mempool_t cell_pool;
2524
struct rb_root cells;
25+
mempool_t cell_pool;
2626
};
2727

2828
static struct kmem_cache *_cell_cache;

drivers/md/dm-cache-target.c

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,13 @@ struct cache_stats {
371371

372372
struct cache {
373373
struct dm_target *ti;
374-
struct dm_target_callbacks callbacks;
374+
spinlock_t lock;
375+
376+
/*
377+
* Fields for converting from sectors to blocks.
378+
*/
379+
int sectors_per_block_shift;
380+
sector_t sectors_per_block;
375381

376382
struct dm_cache_metadata *cmd;
377383

@@ -402,13 +408,11 @@ struct cache {
402408
dm_cblock_t cache_size;
403409

404410
/*
405-
* Fields for converting from sectors to blocks.
411+
* Invalidation fields.
406412
*/
407-
sector_t sectors_per_block;
408-
int sectors_per_block_shift;
413+
spinlock_t invalidation_lock;
414+
struct list_head invalidation_requests;
409415

410-
spinlock_t lock;
411-
struct bio_list deferred_bios;
412416
sector_t migration_threshold;
413417
wait_queue_head_t migration_wait;
414418
atomic_t nr_allocated_migrations;
@@ -419,13 +423,11 @@ struct cache {
419423
*/
420424
atomic_t nr_io_migrations;
421425

426+
struct bio_list deferred_bios;
427+
422428
struct rw_semaphore quiesce_lock;
423429

424-
/*
425-
* cache_size entries, dirty if set
426-
*/
427-
atomic_t nr_dirty;
428-
unsigned long *dirty_bitset;
430+
struct dm_target_callbacks callbacks;
429431

430432
/*
431433
* origin_blocks entries, discarded if set.
@@ -442,17 +444,27 @@ struct cache {
442444
const char **ctr_args;
443445

444446
struct dm_kcopyd_client *copier;
445-
struct workqueue_struct *wq;
446447
struct work_struct deferred_bio_worker;
447448
struct work_struct migration_worker;
449+
struct workqueue_struct *wq;
448450
struct delayed_work waker;
449451
struct dm_bio_prison_v2 *prison;
450-
struct bio_set bs;
451452

452-
mempool_t migration_pool;
453+
/*
454+
* cache_size entries, dirty if set
455+
*/
456+
unsigned long *dirty_bitset;
457+
atomic_t nr_dirty;
453458

454-
struct dm_cache_policy *policy;
455459
unsigned policy_nr_args;
460+
struct dm_cache_policy *policy;
461+
462+
/*
463+
* Cache features such as write-through.
464+
*/
465+
struct cache_features features;
466+
467+
struct cache_stats stats;
456468

457469
bool need_tick_bio:1;
458470
bool sized:1;
@@ -461,25 +473,16 @@ struct cache {
461473
bool loaded_mappings:1;
462474
bool loaded_discards:1;
463475

464-
/*
465-
* Cache features such as write-through.
466-
*/
467-
struct cache_features features;
468-
469-
struct cache_stats stats;
476+
struct rw_semaphore background_work_lock;
470477

471-
/*
472-
* Invalidation fields.
473-
*/
474-
spinlock_t invalidation_lock;
475-
struct list_head invalidation_requests;
478+
struct batcher committer;
479+
struct work_struct commit_ws;
476480

477481
struct io_tracker tracker;
478482

479-
struct work_struct commit_ws;
480-
struct batcher committer;
483+
mempool_t migration_pool;
481484

482-
struct rw_semaphore background_work_lock;
485+
struct bio_set bs;
483486
};
484487

485488
struct per_bio_data {

drivers/md/dm-core.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,46 +31,46 @@ struct dm_kobject_holder {
3131
struct mapped_device {
3232
struct mutex suspend_lock;
3333

34+
struct mutex table_devices_lock;
35+
struct list_head table_devices;
36+
3437
/*
3538
* The current mapping (struct dm_table *).
3639
* Use dm_get_live_table{_fast} or take suspend_lock for
3740
* dereference.
3841
*/
3942
void __rcu *map;
4043

41-
struct list_head table_devices;
42-
struct mutex table_devices_lock;
43-
4444
unsigned long flags;
4545

46-
struct request_queue *queue;
47-
int numa_node_id;
48-
49-
enum dm_queue_mode type;
5046
/* Protect queue and type against concurrent access. */
5147
struct mutex type_lock;
48+
enum dm_queue_mode type;
49+
50+
int numa_node_id;
51+
struct request_queue *queue;
5252

5353
atomic_t holders;
5454
atomic_t open_count;
5555

5656
struct dm_target *immutable_target;
5757
struct target_type *immutable_target_type;
5858

59+
char name[16];
5960
struct gendisk *disk;
6061
struct dax_device *dax_dev;
61-
char name[16];
62-
63-
void *interface_ptr;
6462

6563
/*
6664
* A list of ios that arrived while we were suspended.
6765
*/
68-
atomic_t pending[2];
69-
wait_queue_head_t wait;
7066
struct work_struct work;
67+
wait_queue_head_t wait;
68+
atomic_t pending[2];
7169
spinlock_t deferred_lock;
7270
struct bio_list deferred;
7371

72+
void *interface_ptr;
73+
7474
/*
7575
* Event handling.
7676
*/
@@ -83,17 +83,17 @@ struct mapped_device {
8383
/* the number of internal suspends */
8484
unsigned internal_suspend_count;
8585

86-
/*
87-
* Processing queue (flush)
88-
*/
89-
struct workqueue_struct *wq;
90-
9186
/*
9287
* io objects are allocated from here.
9388
*/
9489
struct bio_set io_bs;
9590
struct bio_set bs;
9691

92+
/*
93+
* Processing queue (flush)
94+
*/
95+
struct workqueue_struct *wq;
96+
9797
/*
9898
* freeze/thaw support require holding onto a super block
9999
*/
@@ -102,11 +102,11 @@ struct mapped_device {
102102
/* forced geometry settings */
103103
struct hd_geometry geometry;
104104

105-
struct block_device *bdev;
106-
107105
/* kobject and completion */
108106
struct dm_kobject_holder kobj_holder;
109107

108+
struct block_device *bdev;
109+
110110
/* zero-length flush that will be cloned and submitted to targets */
111111
struct bio flush_bio;
112112

drivers/md/dm-crypt.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,25 +139,13 @@ struct crypt_config {
139139
struct dm_dev *dev;
140140
sector_t start;
141141

142-
/*
143-
* pool for per bio private data, crypto requests,
144-
* encryption requeusts/buffer pages and integrity tags
145-
*/
146-
mempool_t req_pool;
147-
mempool_t page_pool;
148-
mempool_t tag_pool;
149-
unsigned tag_pool_max_sectors;
150-
151142
struct percpu_counter n_allocated_pages;
152143

153-
struct bio_set bs;
154-
struct mutex bio_alloc_lock;
155-
156144
struct workqueue_struct *io_queue;
157145
struct workqueue_struct *crypt_queue;
158146

159-
struct task_struct *write_thread;
160147
wait_queue_head_t write_thread_wait;
148+
struct task_struct *write_thread;
161149
struct rb_root write_tree;
162150

163151
char *cipher;
@@ -213,6 +201,18 @@ struct crypt_config {
213201
unsigned int integrity_iv_size;
214202
unsigned int on_disk_tag_size;
215203

204+
/*
205+
* pool for per bio private data, crypto requests,
206+
* encryption requeusts/buffer pages and integrity tags
207+
*/
208+
unsigned tag_pool_max_sectors;
209+
mempool_t tag_pool;
210+
mempool_t req_pool;
211+
mempool_t page_pool;
212+
213+
struct bio_set bs;
214+
struct mutex bio_alloc_lock;
215+
216216
u8 *authenc_key; /* space for keys in authenc() format (if used) */
217217
u8 key[0];
218218
};

drivers/md/dm-kcopyd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ struct dm_kcopyd_client {
4545
struct dm_io_client *io_client;
4646

4747
wait_queue_head_t destroyq;
48-
atomic_t nr_jobs;
4948

5049
mempool_t job_pool;
5150

@@ -54,6 +53,8 @@ struct dm_kcopyd_client {
5453

5554
struct dm_kcopyd_throttle *throttle;
5655

56+
atomic_t nr_jobs;
57+
5758
/*
5859
* We maintain three lists of jobs:
5960
*

drivers/md/dm-region-hash.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,28 @@ struct dm_region_hash {
6363

6464
/* hash table */
6565
rwlock_t hash_lock;
66-
mempool_t region_pool;
6766
unsigned mask;
6867
unsigned nr_buckets;
6968
unsigned prime;
7069
unsigned shift;
7170
struct list_head *buckets;
7271

72+
/*
73+
* If there was a flush failure no regions can be marked clean.
74+
*/
75+
int flush_failure;
76+
7377
unsigned max_recovery; /* Max # of regions to recover in parallel */
7478

7579
spinlock_t region_lock;
7680
atomic_t recovery_in_flight;
77-
struct semaphore recovery_count;
7881
struct list_head clean_regions;
7982
struct list_head quiesced_regions;
8083
struct list_head recovered_regions;
8184
struct list_head failed_recovered_regions;
85+
struct semaphore recovery_count;
8286

83-
/*
84-
* If there was a flush failure no regions can be marked clean.
85-
*/
86-
int flush_failure;
87+
mempool_t region_pool;
8788

8889
void *context;
8990
sector_t target_begin;

drivers/md/dm-thin.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ struct pool {
240240
struct dm_bio_prison *prison;
241241
struct dm_kcopyd_client *copier;
242242

243+
struct work_struct worker;
243244
struct workqueue_struct *wq;
244245
struct throttle throttle;
245-
struct work_struct worker;
246246
struct delayed_work waker;
247247
struct delayed_work no_space_timeout;
248248

@@ -260,7 +260,6 @@ struct pool {
260260
struct dm_deferred_set *all_io_ds;
261261

262262
struct dm_thin_new_mapping *next_mapping;
263-
mempool_t mapping_pool;
264263

265264
process_bio_fn process_bio;
266265
process_bio_fn process_discard;
@@ -273,6 +272,8 @@ struct pool {
273272
process_mapping_fn process_prepared_discard_pt2;
274273

275274
struct dm_bio_prison_cell **cell_sort_array;
275+
276+
mempool_t mapping_pool;
276277
};
277278

278279
static enum pool_mode get_pool_mode(struct pool *pool);

drivers/md/dm-zoned-target.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ struct dmz_target {
5252
struct dmz_reclaim *reclaim;
5353

5454
/* For chunk work */
55-
struct mutex chunk_lock;
5655
struct radix_tree_root chunk_rxtree;
5756
struct workqueue_struct *chunk_wq;
57+
struct mutex chunk_lock;
5858

5959
/* For cloned BIOs to zones */
6060
struct bio_set bio_set;

0 commit comments

Comments
 (0)