From 630cf553367c4ded1a9f4e46720d3a976716f514 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 28 Aug 2019 15:05:55 -0700 Subject: [PATCH 0148/2944] block/rq_qos: implement rq_qos_ops->queue_depth_changed() commit 9677a3e01f838622d2efc9a3ccb97090a2c3156a upstream. wbt already gets queue depth changed notification through wbt_set_queue_depth(). Generalize it into rq_qos_ops->queue_depth_changed() so that other rq_qos policies can easily hook into the events too. Signed-off-by: Tejun Heo Signed-off-by: Jens Axboe Signed-off-by: Joseph Qi Signed-off-by: Jiufei Xue Reviewed-by: Joseph Qi --- block/blk-rq-qos.c | 9 +++++++++ block/blk-rq-qos.h | 8 ++++++++ block/blk-settings.c | 2 +- block/blk-wbt.c | 18 ++++++++---------- block/blk-wbt.h | 4 ---- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c index 45df288..7dfc09e 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -107,6 +107,15 @@ void rq_qos_done_bio(struct request_queue *q, struct bio *bio) } } +void __rq_qos_queue_depth_changed(struct rq_qos *rqos) +{ + do { + if (rqos->ops->queue_depth_changed) + rqos->ops->queue_depth_changed(rqos); + rqos = rqos->next; + } while (rqos); +} + /* * Return true, if we can't increase the depth further by scaling */ diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index 7cceed7..adc4810 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -33,6 +33,7 @@ struct rq_qos_ops { void (*done)(struct rq_qos *, struct request *); void (*done_bio)(struct rq_qos *, struct bio *); void (*cleanup)(struct rq_qos *, struct bio *); + void (*queue_depth_changed)(struct rq_qos *); void (*exit)(struct rq_qos *); }; @@ -104,6 +105,7 @@ static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos) void rq_qos_throttle(struct request_queue *, struct bio *, spinlock_t *); void rq_qos_track(struct request_queue *q, struct request *, struct bio *); void __rq_qos_merge(struct rq_qos *rqos, struct request *rq, struct bio *bio); +void __rq_qos_queue_depth_changed(struct rq_qos *rqos); void rq_qos_exit(struct request_queue *); static inline void rq_qos_merge(struct request_queue *q, struct request *rq, @@ -113,4 +115,10 @@ static inline void rq_qos_merge(struct request_queue *q, struct request *rq, __rq_qos_merge(q->rq_qos, rq, bio); } +static inline void rq_qos_queue_depth_changed(struct request_queue *q) +{ + if (q->rq_qos) + __rq_qos_queue_depth_changed(q->rq_qos); +} + #endif diff --git a/block/blk-settings.c b/block/blk-settings.c index ffd4599..49fac87 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -875,7 +875,7 @@ void blk_queue_flush_queueable(struct request_queue *q, bool queueable) void blk_set_queue_depth(struct request_queue *q, unsigned int depth) { q->queue_depth = depth; - wbt_set_queue_depth(q, depth); + rq_qos_queue_depth_changed(q); } EXPORT_SYMBOL(blk_set_queue_depth); diff --git a/block/blk-wbt.c b/block/blk-wbt.c index f1de8ba..544a043 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -681,15 +681,6 @@ void wbt_requeue(struct rq_qos *rqos, struct request *rq) } } -void wbt_set_queue_depth(struct request_queue *q, unsigned int depth) -{ - struct rq_qos *rqos = wbt_rq_qos(q); - if (rqos) { - RQWB(rqos)->rq_depth.queue_depth = depth; - __wbt_update_limits(RQWB(rqos)); - } -} - void wbt_set_write_cache(struct request_queue *q, bool write_cache_on) { struct rq_qos *rqos = wbt_rq_qos(q); @@ -742,6 +733,12 @@ static int wbt_data_dir(const struct request *rq) return -1; } +static void wbt_queue_depth_changed(struct rq_qos *rqos) +{ + RQWB(rqos)->rq_depth.queue_depth = blk_queue_depth(rqos->q); + __wbt_update_limits(RQWB(rqos)); +} + static void wbt_exit(struct rq_qos *rqos) { struct rq_wb *rwb = RQWB(rqos); @@ -777,6 +774,7 @@ void wbt_disable_default(struct request_queue *q) .requeue = wbt_requeue, .done = wbt_done, .cleanup = wbt_cleanup, + .queue_depth_changed = wbt_queue_depth_changed, .exit = wbt_exit, }; @@ -816,7 +814,7 @@ int wbt_init(struct request_queue *q) rwb->min_lat_nsec = wbt_default_latency_nsec(q); - wbt_set_queue_depth(q, blk_queue_depth(q)); + wbt_queue_depth_changed(&rwb->rqos); wbt_set_write_cache(q, test_bit(QUEUE_FLAG_WC, &q->queue_flags)); return 0; diff --git a/block/blk-wbt.h b/block/blk-wbt.h index f47218d..8e4e376 100644 --- a/block/blk-wbt.h +++ b/block/blk-wbt.h @@ -95,7 +95,6 @@ static inline unsigned int wbt_inflight(struct rq_wb *rwb) u64 wbt_get_min_lat(struct request_queue *q); void wbt_set_min_lat(struct request_queue *q, u64 val); -void wbt_set_queue_depth(struct request_queue *, unsigned int); void wbt_set_write_cache(struct request_queue *, bool); u64 wbt_default_latency_nsec(struct request_queue *); @@ -118,9 +117,6 @@ static inline void wbt_disable_default(struct request_queue *q) static inline void wbt_enable_default(struct request_queue *q) { } -static inline void wbt_set_queue_depth(struct request_queue *q, unsigned int depth) -{ -} static inline void wbt_set_write_cache(struct request_queue *q, bool wc) { } -- 1.8.3.1