Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bfq: update internal depth state when queue depth changes

A previous commit moved the shallow depth and BFQ depth map calculations
to be done at init time, moving it outside of the hotter IO path. This
potentially causes hangs if the users changes the depth of the scheduler
map, by writing to the 'nr_requests' sysfs file for that device.

Add a blk-mq-sched hook that allows blk-mq to inform the scheduler if
the depth changes, so that the scheduler can update its internal state.

Tested-by: Kai Krakow <kai@kaishome.de>
Reported-by: Paolo Valente <paolo.valente@linaro.org>
Fixes: f0635b8a416e ("bfq: calculate shallow depths at init time")
Signed-off-by: Jens Axboe <axboe@kernel.dk>

+10 -1
+7 -1
block/bfq-iosched.c
··· 5396 5396 return min_shallow; 5397 5397 } 5398 5398 5399 - static int bfq_init_hctx(struct blk_mq_hw_ctx *hctx, unsigned int index) 5399 + static void bfq_depth_updated(struct blk_mq_hw_ctx *hctx) 5400 5400 { 5401 5401 struct bfq_data *bfqd = hctx->queue->elevator->elevator_data; 5402 5402 struct blk_mq_tags *tags = hctx->sched_tags; ··· 5404 5404 5405 5405 min_shallow = bfq_update_depths(bfqd, &tags->bitmap_tags); 5406 5406 sbitmap_queue_min_shallow_depth(&tags->bitmap_tags, min_shallow); 5407 + } 5408 + 5409 + static int bfq_init_hctx(struct blk_mq_hw_ctx *hctx, unsigned int index) 5410 + { 5411 + bfq_depth_updated(hctx); 5407 5412 return 0; 5408 5413 } 5409 5414 ··· 5831 5826 .requests_merged = bfq_requests_merged, 5832 5827 .request_merged = bfq_request_merged, 5833 5828 .has_work = bfq_has_work, 5829 + .depth_updated = bfq_depth_updated, 5834 5830 .init_hctx = bfq_init_hctx, 5835 5831 .init_sched = bfq_init_queue, 5836 5832 .exit_sched = bfq_exit_queue,
+2
block/blk-mq.c
··· 3135 3135 } 3136 3136 if (ret) 3137 3137 break; 3138 + if (q->elevator && q->elevator->type->ops.depth_updated) 3139 + q->elevator->type->ops.depth_updated(hctx); 3138 3140 } 3139 3141 3140 3142 if (!ret)
+1
include/linux/elevator.h
··· 31 31 void (*exit_sched)(struct elevator_queue *); 32 32 int (*init_hctx)(struct blk_mq_hw_ctx *, unsigned int); 33 33 void (*exit_hctx)(struct blk_mq_hw_ctx *, unsigned int); 34 + void (*depth_updated)(struct blk_mq_hw_ctx *); 34 35 35 36 bool (*allow_merge)(struct request_queue *, struct request *, struct bio *); 36 37 bool (*bio_merge)(struct blk_mq_hw_ctx *, struct bio *);