Skip to content

Commit e93ecf6

Browse files
committed
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>
1 parent 2667bcb commit e93ecf6

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

‎block/blk-mq-tag.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static bool bt_has_free_tags(struct blk_mq_bitmap_tags *bt)
2121
int i;
2222

2323
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];
2525
int ret;
2626

2727
ret = find_first_zero_bit(&bm->word, bm->depth);
@@ -40,7 +40,7 @@ bool blk_mq_has_free_tags(struct blk_mq_tags *tags)
4040
return bt_has_free_tags(&tags->bitmap_tags);
4141
}
4242

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)
4444
{
4545
int tag, org_last_tag, end;
4646

@@ -283,7 +283,7 @@ static void bt_for_each_free(struct blk_mq_bitmap_tags *bt,
283283
int i;
284284

285285
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];
287287
int bit = 0;
288288

289289
do {
@@ -323,7 +323,7 @@ static unsigned int bt_unused_tags(struct blk_mq_bitmap_tags *bt)
323323
unsigned int i, used;
324324

325325
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];
327327

328328
used += bitmap_weight(&bm->word, bm->depth);
329329
}
@@ -361,7 +361,7 @@ static int bt_alloc(struct blk_mq_bitmap_tags *bt, unsigned int depth,
361361
}
362362

363363
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),
365365
GFP_KERNEL, node);
366366
if (!bt->map)
367367
return -ENOMEM;

‎block/blk-mq-tag.h‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef INT_BLK_MQ_TAG_H
22
#define INT_BLK_MQ_TAG_H
33

4+
#include "blk-mq.h"
5+
46
enum {
57
BT_WAIT_QUEUES = 8,
68
BT_WAIT_BATCH = 8,
@@ -14,18 +16,13 @@ struct bt_wait_state {
1416
#define TAG_TO_INDEX(bt, tag) ((tag) >> (bt)->bits_per_word)
1517
#define TAG_TO_BIT(bt, tag) ((tag) & ((1 << (bt)->bits_per_word) - 1))
1618

17-
struct blk_mq_bitmap {
18-
unsigned long word;
19-
unsigned long depth;
20-
} ____cacheline_aligned_in_smp;
21-
2219
struct blk_mq_bitmap_tags {
2320
unsigned int depth;
2421
unsigned int wake_cnt;
2522
unsigned int bits_per_word;
2623

2724
unsigned int map_nr;
28-
struct blk_mq_bitmap *map;
25+
struct blk_align_bitmap *map;
2926

3027
unsigned int wake_index;
3128
struct bt_wait_state *bs;

‎block/blk-mq.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,13 @@ void blk_mq_disable_hotplug(void);
5252
extern unsigned int *blk_mq_make_queue_map(struct blk_mq_tag_set *set);
5353
extern int blk_mq_update_queue_map(unsigned int *map, unsigned int nr_queues);
5454

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+
5564
#endif

0 commit comments

Comments
 (0)