aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2017-04-10 11:54:54 -0400
committerJens Axboe <axboe@fb.com>2017-04-28 10:10:15 -0400
commit9f993737906b30d7b2454a38637d1f70ffd60f2f (patch)
treede9f50b9f8411ad9306796746900195a0b6f45e6
parent60ae36ad0340b1ba88530d6a5e141455dd3afd81 (diff)
blk-mq: unify hctx delayed_run_work and run_work
They serve the exact same purpose. Get rid of the non-delayed work variant, and just run it without delay for the normal case. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Bart Van Assche <Bart.VanAssche@sandisk.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--block/blk-core.c2
-rw-r--r--block/blk-mq.c27
-rw-r--r--include/linux/blk-mq.h3
3 files changed, 8 insertions, 24 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 6bd4d1754d29..37939672d4df 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -269,7 +269,7 @@ void blk_sync_queue(struct request_queue *q)
269 int i; 269 int i;
270 270
271 queue_for_each_hw_ctx(q, hctx, i) { 271 queue_for_each_hw_ctx(q, hctx, i) {
272 cancel_work_sync(&hctx->run_work); 272 cancel_delayed_work_sync(&hctx->run_work);
273 cancel_delayed_work_sync(&hctx->delay_work); 273 cancel_delayed_work_sync(&hctx->delay_work);
274 } 274 }
275 } else { 275 } else {
diff --git a/block/blk-mq.c b/block/blk-mq.c
index e6aad49c1686..5c68fce87ffc 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1166,13 +1166,9 @@ static void __blk_mq_delay_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async,
1166 put_cpu(); 1166 put_cpu();
1167 } 1167 }
1168 1168
1169 if (msecs == 0) 1169 kblockd_schedule_delayed_work_on(blk_mq_hctx_next_cpu(hctx),
1170 kblockd_schedule_work_on(blk_mq_hctx_next_cpu(hctx), 1170 &hctx->run_work,
1171 &hctx->run_work); 1171 msecs_to_jiffies(msecs));
1172 else
1173 kblockd_schedule_delayed_work_on(blk_mq_hctx_next_cpu(hctx),
1174 &hctx->delayed_run_work,
1175 msecs_to_jiffies(msecs));
1176} 1172}
1177 1173
1178void blk_mq_delay_run_hw_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs) 1174void blk_mq_delay_run_hw_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs)
@@ -1224,7 +1220,7 @@ EXPORT_SYMBOL(blk_mq_queue_stopped);
1224 1220
1225void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx) 1221void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx)
1226{ 1222{
1227 cancel_work(&hctx->run_work); 1223 cancel_delayed_work_sync(&hctx->run_work);
1228 cancel_delayed_work(&hctx->delay_work); 1224 cancel_delayed_work(&hctx->delay_work);
1229 set_bit(BLK_MQ_S_STOPPED, &hctx->state); 1225 set_bit(BLK_MQ_S_STOPPED, &hctx->state);
1230} 1226}
@@ -1282,17 +1278,7 @@ static void blk_mq_run_work_fn(struct work_struct *work)
1282{ 1278{
1283 struct blk_mq_hw_ctx *hctx; 1279 struct blk_mq_hw_ctx *hctx;
1284 1280
1285 hctx = container_of(work, struct blk_mq_hw_ctx, run_work); 1281 hctx = container_of(work, struct blk_mq_hw_ctx, run_work.work);
1286
1287 __blk_mq_run_hw_queue(hctx);
1288}
1289
1290static void blk_mq_delayed_run_work_fn(struct work_struct *work)
1291{
1292 struct blk_mq_hw_ctx *hctx;
1293
1294 hctx = container_of(work, struct blk_mq_hw_ctx, delayed_run_work.work);
1295
1296 __blk_mq_run_hw_queue(hctx); 1282 __blk_mq_run_hw_queue(hctx);
1297} 1283}
1298 1284
@@ -1898,8 +1884,7 @@ static int blk_mq_init_hctx(struct request_queue *q,
1898 if (node == NUMA_NO_NODE) 1884 if (node == NUMA_NO_NODE)
1899 node = hctx->numa_node = set->numa_node; 1885 node = hctx->numa_node = set->numa_node;
1900 1886
1901 INIT_WORK(&hctx->run_work, blk_mq_run_work_fn); 1887 INIT_DELAYED_WORK(&hctx->run_work, blk_mq_run_work_fn);
1902 INIT_DELAYED_WORK(&hctx->delayed_run_work, blk_mq_delayed_run_work_fn);
1903 INIT_DELAYED_WORK(&hctx->delay_work, blk_mq_delay_work_fn); 1888 INIT_DELAYED_WORK(&hctx->delay_work, blk_mq_delay_work_fn);
1904 spin_lock_init(&hctx->lock); 1889 spin_lock_init(&hctx->lock);
1905 INIT_LIST_HEAD(&hctx->dispatch); 1890 INIT_LIST_HEAD(&hctx->dispatch);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 32bd8eb5ba67..c7cc90328426 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -15,7 +15,7 @@ struct blk_mq_hw_ctx {
15 unsigned long state; /* BLK_MQ_S_* flags */ 15 unsigned long state; /* BLK_MQ_S_* flags */
16 } ____cacheline_aligned_in_smp; 16 } ____cacheline_aligned_in_smp;
17 17
18 struct work_struct run_work; 18 struct delayed_work run_work;
19 cpumask_var_t cpumask; 19 cpumask_var_t cpumask;
20 int next_cpu; 20 int next_cpu;
21 int next_cpu_batch; 21 int next_cpu_batch;
@@ -51,7 +51,6 @@ struct blk_mq_hw_ctx {
51 51
52 atomic_t nr_active; 52 atomic_t nr_active;
53 53
54 struct delayed_work delayed_run_work;
55 struct delayed_work delay_work; 54 struct delayed_work delay_work;
56 55
57 struct hlist_node cpuhp_dead; 56 struct hlist_node cpuhp_dead;