diff options
Diffstat (limited to 'block/blk-mq-cpumap.c')
-rw-r--r-- | block/blk-mq-cpumap.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c index f8721278601c..1065d7c65fa1 100644 --- a/block/blk-mq-cpumap.c +++ b/block/blk-mq-cpumap.c | |||
@@ -1,3 +1,8 @@ | |||
1 | /* | ||
2 | * CPU <-> hardware queue mapping helpers | ||
3 | * | ||
4 | * Copyright (C) 2013-2014 Jens Axboe | ||
5 | */ | ||
1 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
2 | #include <linux/threads.h> | 7 | #include <linux/threads.h> |
3 | #include <linux/module.h> | 8 | #include <linux/module.h> |
@@ -9,15 +14,6 @@ | |||
9 | #include "blk.h" | 14 | #include "blk.h" |
10 | #include "blk-mq.h" | 15 | #include "blk-mq.h" |
11 | 16 | ||
12 | static void show_map(unsigned int *map, unsigned int nr) | ||
13 | { | ||
14 | int i; | ||
15 | |||
16 | pr_info("blk-mq: CPU -> queue map\n"); | ||
17 | for_each_online_cpu(i) | ||
18 | pr_info(" CPU%2u -> Queue %u\n", i, map[i]); | ||
19 | } | ||
20 | |||
21 | static int cpu_to_queue_index(unsigned int nr_cpus, unsigned int nr_queues, | 17 | static int cpu_to_queue_index(unsigned int nr_cpus, unsigned int nr_queues, |
22 | const int cpu) | 18 | const int cpu) |
23 | { | 19 | { |
@@ -85,24 +81,39 @@ int blk_mq_update_queue_map(unsigned int *map, unsigned int nr_queues) | |||
85 | map[i] = map[first_sibling]; | 81 | map[i] = map[first_sibling]; |
86 | } | 82 | } |
87 | 83 | ||
88 | show_map(map, nr_cpus); | ||
89 | free_cpumask_var(cpus); | 84 | free_cpumask_var(cpus); |
90 | return 0; | 85 | return 0; |
91 | } | 86 | } |
92 | 87 | ||
93 | unsigned int *blk_mq_make_queue_map(struct blk_mq_reg *reg) | 88 | unsigned int *blk_mq_make_queue_map(struct blk_mq_tag_set *set) |
94 | { | 89 | { |
95 | unsigned int *map; | 90 | unsigned int *map; |
96 | 91 | ||
97 | /* If cpus are offline, map them to first hctx */ | 92 | /* If cpus are offline, map them to first hctx */ |
98 | map = kzalloc_node(sizeof(*map) * num_possible_cpus(), GFP_KERNEL, | 93 | map = kzalloc_node(sizeof(*map) * num_possible_cpus(), GFP_KERNEL, |
99 | reg->numa_node); | 94 | set->numa_node); |
100 | if (!map) | 95 | if (!map) |
101 | return NULL; | 96 | return NULL; |
102 | 97 | ||
103 | if (!blk_mq_update_queue_map(map, reg->nr_hw_queues)) | 98 | if (!blk_mq_update_queue_map(map, set->nr_hw_queues)) |
104 | return map; | 99 | return map; |
105 | 100 | ||
106 | kfree(map); | 101 | kfree(map); |
107 | return NULL; | 102 | return NULL; |
108 | } | 103 | } |
104 | |||
105 | /* | ||
106 | * We have no quick way of doing reverse lookups. This is only used at | ||
107 | * queue init time, so runtime isn't important. | ||
108 | */ | ||
109 | int blk_mq_hw_queue_to_node(unsigned int *mq_map, unsigned int index) | ||
110 | { | ||
111 | int i; | ||
112 | |||
113 | for_each_possible_cpu(i) { | ||
114 | if (index == mq_map[i]) | ||
115 | return cpu_to_node(i); | ||
116 | } | ||
117 | |||
118 | return NUMA_NO_NODE; | ||
119 | } | ||