diff options
author | Jens Axboe <axboe@fb.com> | 2014-05-19 11:17:48 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-05-19 13:02:47 -0400 |
commit | e93ecf602beb8439f0bdcc1fa2cbc1f31fdfb8e2 (patch) | |
tree | 030ba8a90d4ebf1f9cd5d546066d12037402eda1 /block | |
parent | 2667bcbbd5ed71f29b78ba69f059dbc450e07faf (diff) |
blk-mq: move the cache friendly bitmap type of out blk-mq-tag
We will use it for the pending list in blk-mq core as well.
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-mq-tag.c | 10 | ||||
-rw-r--r-- | block/blk-mq-tag.h | 9 | ||||
-rw-r--r-- | block/blk-mq.h | 9 |
3 files changed, 17 insertions, 11 deletions
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index 8d526a3e02f6..03ce6a11ba79 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c | |||
@@ -21,7 +21,7 @@ static bool bt_has_free_tags(struct blk_mq_bitmap_tags *bt) | |||
21 | int i; | 21 | int i; |
22 | 22 | ||
23 | for (i = 0; i < bt->map_nr; i++) { | 23 | for (i = 0; i < bt->map_nr; i++) { |
24 | struct blk_mq_bitmap *bm = &bt->map[i]; | 24 | struct blk_align_bitmap *bm = &bt->map[i]; |
25 | int ret; | 25 | int ret; |
26 | 26 | ||
27 | ret = find_first_zero_bit(&bm->word, bm->depth); | 27 | ret = find_first_zero_bit(&bm->word, bm->depth); |
@@ -40,7 +40,7 @@ bool blk_mq_has_free_tags(struct blk_mq_tags *tags) | |||
40 | return bt_has_free_tags(&tags->bitmap_tags); | 40 | return bt_has_free_tags(&tags->bitmap_tags); |
41 | } | 41 | } |
42 | 42 | ||
43 | static int __bt_get_word(struct blk_mq_bitmap *bm, unsigned int last_tag) | 43 | static int __bt_get_word(struct blk_align_bitmap *bm, unsigned int last_tag) |
44 | { | 44 | { |
45 | int tag, org_last_tag, end; | 45 | int tag, org_last_tag, end; |
46 | 46 | ||
@@ -283,7 +283,7 @@ static void bt_for_each_free(struct blk_mq_bitmap_tags *bt, | |||
283 | int i; | 283 | int i; |
284 | 284 | ||
285 | for (i = 0; i < bt->map_nr; i++) { | 285 | for (i = 0; i < bt->map_nr; i++) { |
286 | struct blk_mq_bitmap *bm = &bt->map[i]; | 286 | struct blk_align_bitmap *bm = &bt->map[i]; |
287 | int bit = 0; | 287 | int bit = 0; |
288 | 288 | ||
289 | do { | 289 | do { |
@@ -323,7 +323,7 @@ static unsigned int bt_unused_tags(struct blk_mq_bitmap_tags *bt) | |||
323 | unsigned int i, used; | 323 | unsigned int i, used; |
324 | 324 | ||
325 | for (i = 0, used = 0; i < bt->map_nr; i++) { | 325 | for (i = 0, used = 0; i < bt->map_nr; i++) { |
326 | struct blk_mq_bitmap *bm = &bt->map[i]; | 326 | struct blk_align_bitmap *bm = &bt->map[i]; |
327 | 327 | ||
328 | used += bitmap_weight(&bm->word, bm->depth); | 328 | used += bitmap_weight(&bm->word, bm->depth); |
329 | } | 329 | } |
@@ -361,7 +361,7 @@ static int bt_alloc(struct blk_mq_bitmap_tags *bt, unsigned int depth, | |||
361 | } | 361 | } |
362 | 362 | ||
363 | nr = ALIGN(depth, tags_per_word) / tags_per_word; | 363 | nr = ALIGN(depth, tags_per_word) / tags_per_word; |
364 | bt->map = kzalloc_node(nr * sizeof(struct blk_mq_bitmap), | 364 | bt->map = kzalloc_node(nr * sizeof(struct blk_align_bitmap), |
365 | GFP_KERNEL, node); | 365 | GFP_KERNEL, node); |
366 | if (!bt->map) | 366 | if (!bt->map) |
367 | return -ENOMEM; | 367 | return -ENOMEM; |
diff --git a/block/blk-mq-tag.h b/block/blk-mq-tag.h index 7aa9f0665489..9014269f3910 100644 --- a/block/blk-mq-tag.h +++ b/block/blk-mq-tag.h | |||
@@ -1,6 +1,8 @@ | |||
1 | #ifndef INT_BLK_MQ_TAG_H | 1 | #ifndef INT_BLK_MQ_TAG_H |
2 | #define INT_BLK_MQ_TAG_H | 2 | #define INT_BLK_MQ_TAG_H |
3 | 3 | ||
4 | #include "blk-mq.h" | ||
5 | |||
4 | enum { | 6 | enum { |
5 | BT_WAIT_QUEUES = 8, | 7 | BT_WAIT_QUEUES = 8, |
6 | BT_WAIT_BATCH = 8, | 8 | BT_WAIT_BATCH = 8, |
@@ -14,18 +16,13 @@ struct bt_wait_state { | |||
14 | #define TAG_TO_INDEX(bt, tag) ((tag) >> (bt)->bits_per_word) | 16 | #define TAG_TO_INDEX(bt, tag) ((tag) >> (bt)->bits_per_word) |
15 | #define TAG_TO_BIT(bt, tag) ((tag) & ((1 << (bt)->bits_per_word) - 1)) | 17 | #define TAG_TO_BIT(bt, tag) ((tag) & ((1 << (bt)->bits_per_word) - 1)) |
16 | 18 | ||
17 | struct blk_mq_bitmap { | ||
18 | unsigned long word; | ||
19 | unsigned long depth; | ||
20 | } ____cacheline_aligned_in_smp; | ||
21 | |||
22 | struct blk_mq_bitmap_tags { | 19 | struct blk_mq_bitmap_tags { |
23 | unsigned int depth; | 20 | unsigned int depth; |
24 | unsigned int wake_cnt; | 21 | unsigned int wake_cnt; |
25 | unsigned int bits_per_word; | 22 | unsigned int bits_per_word; |
26 | 23 | ||
27 | unsigned int map_nr; | 24 | unsigned int map_nr; |
28 | struct blk_mq_bitmap *map; | 25 | struct blk_align_bitmap *map; |
29 | 26 | ||
30 | unsigned int wake_index; | 27 | unsigned int wake_index; |
31 | struct bt_wait_state *bs; | 28 | struct bt_wait_state *bs; |
diff --git a/block/blk-mq.h b/block/blk-mq.h index 97cfab9c092f..5e5a378962b7 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h | |||
@@ -52,4 +52,13 @@ void blk_mq_disable_hotplug(void); | |||
52 | extern unsigned int *blk_mq_make_queue_map(struct blk_mq_tag_set *set); | 52 | extern unsigned int *blk_mq_make_queue_map(struct blk_mq_tag_set *set); |
53 | extern int blk_mq_update_queue_map(unsigned int *map, unsigned int nr_queues); | 53 | extern int blk_mq_update_queue_map(unsigned int *map, unsigned int nr_queues); |
54 | 54 | ||
55 | /* | ||
56 | * Basic implementation of sparser bitmap, allowing the user to spread | ||
57 | * the bits over more cachelines. | ||
58 | */ | ||
59 | struct blk_align_bitmap { | ||
60 | unsigned long word; | ||
61 | unsigned long depth; | ||
62 | } ____cacheline_aligned_in_smp; | ||
63 | |||
55 | #endif | 64 | #endif |