blk-wbt: cleanups
PATCH 1/1 blk-wbt: cleanups
Just two smaller cleanups, since we don't support generic users of this code anymore. The first is a prep patch, the second one gets rid of the wrappers around the stats code.
blk-sysfs.c | 23 +---------------------- blk-wbt.c | 35 +++++++++++++++++------------------ blk-wbt.h | 17 +++-------------- 3 files changed, 21 insertions(+), 54 deletions(-)
PATCH 1/2 blk-wbt: store queue instead of bdi
The bdi was a leftover from when the code was block layer agnostic. Now that we just support a block layer user, store the queue directly.
--- block/blk-wbt.c | 20 ++++++++++++-------- block/blk-wbt.h | 4 +--- 2 files changed, 13 insertions(+), 11 deletions(-)
block/blk-wbt.c +12 -8
@@ -96,7 +96,7 @@ static void wb_timestamp(struct rq_wb *rwb, unsigned long *var)*/ static bool wb_recent_wait (struct rq_wb *rwb) { -struct bdi_writeback *wb = &rwb->bdi->wb; +struct bdi_writeback *wb = &rwb->queue->backing_dev_info.wb;return time_before (jiffies, wb->dirty_sleep +HZ ); }
@@ -279,6 +279,7 @@ enum {static int __latency_exceeded (struct rq_wb *rwb,struct blk_rq_stat *stat) { +struct backing_dev_info *bdi = &rwb->queue->backing_dev_info;u64 thislat;/*
@@ -293,7 +294,7 @@ static int __latency_exceeded(struct rq_wb *rwb, struct blk_rq_stat *stat) thislat =rwb_sync_issue_lat (rwb);if (thislat > rwb->cur_win_nsec || (thislat > rwb->min_lat_nsec && !stat[0 ].nr_samples)) { -trace_wbt_lat (rwb->bdi, thislat); +trace_wbt_lat (bdi, thislat);return LAT_EXCEEDED ; }
@@ -317,13 +318,13 @@ static int __latency_exceeded(struct rq_wb *rwb, struct blk_rq_stat *stat)* If the 'min' latency exceeds our target, step down. */ if (stat[0 ].min > rwb->min_lat_nsec) { -trace_wbt_lat (rwb->bdi, stat[0 ].min); -trace_wbt_stat (rwb->bdi, stat); +trace_wbt_lat (bdi, stat[0 ].min); +trace_wbt_stat (bdi, stat);return LAT_EXCEEDED ; }if (rwb->scale_step) -trace_wbt_stat (rwb->bdi, stat); +trace_wbt_stat (bdi, stat);return LAT_OK ; }
@@ -338,7 +339,9 @@ static int latency_exceeded(struct rq_wb *rwb)static void rwb_trace_step (struct rq_wb *rwb,const char *msg) { -trace_wbt_step (rwb->bdi, msg, rwb->scale_step, rwb->cur_win_nsec, +struct backing_dev_info *bdi = &rwb->queue->backing_dev_info; + +trace_wbt_step (bdi, msg, rwb->scale_step, rwb->cur_win_nsec, rwb->wb_background, rwb->wb_normal, rwb->wb_max); }
@@ -420,7 +423,8 @@ static void wb_timer_fn(unsigned long data) status =latency_exceeded (rwb); -trace_wbt_timer (rwb->bdi, status, rwb->scale_step, inflight); +trace_wbt_timer (&rwb->queue->backing_dev_info, status, rwb->scale_step, + inflight);/* * If we exceeded the latency target, step down. If we did not,
@@ -700,7 +704,7 @@ int wbt_init(struct request_queue *q, struct wb_stat_ops *ops) rwb->wc =1 ; rwb->queue_depth =RWB_DEF_DEPTH ; rwb->last_comp = rwb->last_issue = jiffies; - rwb->bdi = &q->backing_dev_info; + rwb->queue = q; rwb->win_nsec =RWB_WINDOW_NSEC ; rwb->stat_ops = ops; rwb->ops_data = q;
block/blk-wbt.h +1 -3
@@ -87,7 +87,7 @@ struct rq_wb {unsigned long last_issue;/* last non-throttled issue */ unsigned long last_comp;/* last non-throttled comp */ unsigned long min_lat_nsec; -struct backing_dev_info *bdi; +struct request_queue *queue;struct rq_wait rq_wait[WBT_NUM_RWQ ];struct wb_stat_ops *stat_ops;
@@ -104,8 +104,6 @@ static inline unsigned int wbt_inflight(struct rq_wb *rwb)return ret; } -struct backing_dev_info ; -#ifdef CONFIG_BLK_WBT void __wbt_done (struct rq_wb *,enum wbt_flags );
Signature · 1 line
2.7.4
Re: [PATCH 1/2] blk-wbt: store queue instead of bdi
Quoted 4 lines · Jens Axboe
The bdi was a leftover from when the code was block layer agnostic. Now that we just support a block layer user, store the queue directly.
Signed-off-by Jens Axboe <[email protected]>
Looks good to me. You can add:
Honza
Quoted 107 lines
--- block/blk-wbt.c | 20 ++++++++++++-------- block/blk-wbt.h | 4 +--- 2 files changed, 13 insertions(+), 11 deletions(-)block/blk-wbt.c +12
-8@@ -96,7 +96,7 @@ static void wb_timestamp(struct rq_wb *rwb, unsigned long *var)*/ static bool wb_recent_wait (struct rq_wb *rwb) { -struct bdi_writeback *wb = &rwb->bdi->wb; +struct bdi_writeback *wb = &rwb->queue->backing_dev_info.wb;return time_before (jiffies, wb->dirty_sleep +HZ ); }@@ -279,6 +279,7 @@ enum {static int __latency_exceeded (struct rq_wb *rwb,struct blk_rq_stat *stat) { +struct backing_dev_info *bdi = &rwb->queue->backing_dev_info;u64 thislat;/* @@ -293,7 +294,7 @@ static int __latency_exceeded(struct rq_wb *rwb, struct blk_rq_stat *stat) thislat =rwb_sync_issue_lat (rwb);if (thislat > rwb->cur_win_nsec || (thislat > rwb->min_lat_nsec && !stat[0 ].nr_samples)) { -trace_wbt_lat (rwb->bdi, thislat); +trace_wbt_lat (bdi, thislat);return LAT_EXCEEDED ; }@@ -317,13 +318,13 @@ static int __latency_exceeded(struct rq_wb *rwb, struct blk_rq_stat *stat)* If the 'min' latency exceeds our target, step down. */ if (stat[0 ].min > rwb->min_lat_nsec) { -trace_wbt_lat (rwb->bdi, stat[0 ].min); -trace_wbt_stat (rwb->bdi, stat); +trace_wbt_lat (bdi, stat[0 ].min); +trace_wbt_stat (bdi, stat);return LAT_EXCEEDED ; }if (rwb->scale_step) -trace_wbt_stat (rwb->bdi, stat); +trace_wbt_stat (bdi, stat);return LAT_OK ; }@@ -338,7 +339,9 @@ static int latency_exceeded(struct rq_wb *rwb)static void rwb_trace_step (struct rq_wb *rwb,const char *msg) { -trace_wbt_step (rwb->bdi, msg, rwb->scale_step, rwb->cur_win_nsec, +struct backing_dev_info *bdi = &rwb->queue->backing_dev_info; + +trace_wbt_step (bdi, msg, rwb->scale_step, rwb->cur_win_nsec, rwb->wb_background, rwb->wb_normal, rwb->wb_max); }@@ -420,7 +423,8 @@ static void wb_timer_fn(unsigned long data) status =latency_exceeded (rwb); -trace_wbt_timer (rwb->bdi, status, rwb->scale_step, inflight); +trace_wbt_timer (&rwb->queue->backing_dev_info, status, rwb->scale_step, + inflight);/* * If we exceeded the latency target, step down. If we did not, @@ -700,7 +704,7 @@ int wbt_init(struct request_queue *q, struct wb_stat_ops *ops) rwb->wc =1 ; rwb->queue_depth =RWB_DEF_DEPTH ; rwb->last_comp = rwb->last_issue = jiffies; - rwb->bdi = &q->backing_dev_info; + rwb->queue = q; rwb->win_nsec =RWB_WINDOW_NSEC ; rwb->stat_ops = ops; rwb->ops_data = q;block/blk-wbt.h +1
-3@@ -87,7 +87,7 @@ struct rq_wb {unsigned long last_issue;/* last non-throttled issue */ unsigned long last_comp;/* last non-throttled comp */ unsigned long min_lat_nsec; -struct backing_dev_info *bdi; +struct request_queue *queue;struct rq_wait rq_wait[WBT_NUM_RWQ ];struct wb_stat_ops *stat_ops;@@ -104,8 +104,6 @@ static inline unsigned int wbt_inflight(struct rq_wb *rwb)return ret; } -struct backing_dev_info ; -#ifdef CONFIG_BLK_WBT void __wbt_done (struct rq_wb *,enum wbt_flags );Signature · 1 line
2.7.4
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH 2/2 blk-wbt: remove stat ops
In reply to Jens AxboeAgain a leftover from when the throttling code was generic. Now that we just have the block user, get rid of the stat ops and indirections.
--- block/blk-sysfs.c | 23 +---------------------- block/blk-wbt.c | 15 +++++---------- block/blk-wbt.h | 13 ++----------- 3 files changed, 8 insertions(+), 43 deletions(-)
block/blk-sysfs.c +1 -22
@@ -770,27 +770,6 @@ struct kobj_type blk_queue_ktype = { .release = blk_release_queue, }; -static void blk_wb_stat_get (void *data,struct blk_rq_stat *stat) -{ -blk_queue_stat_get (data, stat); -} - -static void blk_wb_stat_clear (void *data) -{ -blk_stat_clear (data); -} - -static bool blk_wb_stat_is_current (struct blk_rq_stat *stat) -{ -return blk_stat_is_current (stat); -} - -static struct wb_stat_ops wb_stat_ops = { - .get = blk_wb_stat_get, - .is_current = blk_wb_stat_is_current, - .clear = blk_wb_stat_clear, -}; -static void blk_wb_init (struct request_queue *q) {#ifndef CONFIG_BLK_WBT_MQ
@@ -805,7 +784,7 @@ static void blk_wb_init(struct request_queue *q)/* * If this fails, we don't get throttling */ -wbt_init (q, &wb_stat_ops); +wbt_init (q); }int blk_register_queue (struct gendisk *disk)
block/blk-wbt.c +5 -10
@@ -308,7 +308,7 @@ static int __latency_exceeded(struct rq_wb *rwb, struct blk_rq_stat *stat)* waited or still has writes in flights, consider us doing * just writes as well. */ -if ((stat[1 ].nr_samples && rwb->stat_ops->is_current (stat)) || +if ((stat[1 ].nr_samples &&blk_stat_is_current (stat)) ||wb_recent_wait (rwb) ||wbt_inflight (rwb))return LAT_UNKNOWN_WRITES ;return LAT_UNKNOWN ;
@@ -333,7 +333,7 @@ static int latency_exceeded(struct rq_wb *rwb) {struct blk_rq_stat stat[2 ]; - rwb->stat_ops->get (rwb->ops_data, stat); +blk_queue_stat_get (rwb->queue, stat);return __latency_exceeded (rwb, stat); }
@@ -355,7 +355,7 @@ static void scale_up(struct rq_wb *rwb) rwb->scale_step--; rwb->unknown_cnt =0 ; - rwb->stat_ops->clear (rwb->ops_data); +blk_stat_clear (rwb->queue); rwb->scaled_max =calc_wb_limits (rwb);
@@ -385,7 +385,7 @@ static void scale_down(struct rq_wb *rwb, bool hard_throttle) rwb->scaled_max = false; rwb->unknown_cnt =0 ; - rwb->stat_ops->clear (rwb->ops_data); +blk_stat_clear (rwb->queue);calc_wb_limits (rwb);rwb_trace_step (rwb,"step down" ); }
@@ -675,7 +675,7 @@ void wbt_disable(struct rq_wb *rwb) }EXPORT_SYMBOL_GPL (wbt_disable); -int wbt_init (struct request_queue *q,struct wb_stat_ops *ops) +int wbt_init (struct request_queue *q) {struct rq_wb *rwb;int i;
@@ -688,9 +688,6 @@ int wbt_init(struct request_queue *q, struct wb_stat_ops *ops)BUILD_BUG_ON (RWB_WINDOW_NSEC >BLK_STAT_NSEC );BUILD_BUG_ON (WBT_NR_BITS >BLK_STAT_RES_BITS ); -if (!ops->get || !ops->is_current || !ops->clear) -return -EINVAL ; - rwb =kzalloc (sizeof (*rwb),GFP_KERNEL );if (!rwb)return -ENOMEM ;
@@ -706,8 +703,6 @@ int wbt_init(struct request_queue *q, struct wb_stat_ops *ops) rwb->last_comp = rwb->last_issue = jiffies; rwb->queue = q; rwb->win_nsec =RWB_WINDOW_NSEC ; - rwb->stat_ops = ops; - rwb->ops_data = q;wbt_update_limits (rwb);/*
block/blk-wbt.h +2 -11
@@ -46,12 +46,6 @@ static inline bool wbt_is_read(struct blk_issue_stat *stat)return (stat->time >>BLK_STAT_SHIFT ) &WBT_READ ; } -struct wb_stat_ops { -void (*get)(void *,struct blk_rq_stat *); -bool (*is_current)(struct blk_rq_stat *); -void (*clear)(void *); -}; -struct rq_wait {wait_queue_head_t wait;atomic_t inflight;
@@ -89,9 +83,6 @@ struct rq_wb {unsigned long min_lat_nsec;struct request_queue *queue;struct rq_wait rq_wait[WBT_NUM_RWQ ]; - -struct wb_stat_ops *stat_ops; -void *ops_data; };static inline unsigned int wbt_inflight (struct rq_wb *rwb)
@@ -109,7 +100,7 @@ static inline unsigned int wbt_inflight(struct rq_wb *rwb)void __wbt_done (struct rq_wb *,enum wbt_flags );void wbt_done (struct rq_wb *,struct blk_issue_stat *);enum wbt_flags wbt_wait (struct rq_wb *,struct bio *,spinlock_t *); -int wbt_init (struct request_queue *,struct wb_stat_ops *); +int wbt_init (struct request_queue *);void wbt_exit (struct request_queue *);void wbt_update_limits (struct rq_wb *);void wbt_requeue (struct rq_wb *,struct blk_issue_stat *);
@@ -132,7 +123,7 @@ static inline enum wbt_flags wbt_wait(struct rq_wb *rwb, struct bio *bio, {return 0 ; } -static inline int wbt_init (struct request_queue *q,struct wb_stat_ops *ops) +static inline int wbt_init (struct request_queue *q) {return -EINVAL ; }
Signature · 1 line
2.7.4
Re: [PATCH 2/2] blk-wbt: remove stat ops
Quoted 4 lines · Jens Axboe
Again a leftover from when the throttling code was generic. Now that we just have the block user, get rid of the stat ops and indirections.
Signed-off-by Jens Axboe <[email protected]>
Looks good to me. You can add:
Honza
Quoted 163 lines
--- block/blk-sysfs.c | 23 +---------------------- block/blk-wbt.c | 15 +++++---------- block/blk-wbt.h | 13 ++----------- 3 files changed, 8 insertions(+), 43 deletions(-)block/blk-sysfs.c +1
-22@@ -770,27 +770,6 @@ struct kobj_type blk_queue_ktype = { .release = blk_release_queue, }; -static void blk_wb_stat_get (void *data,struct blk_rq_stat *stat) -{ -blk_queue_stat_get (data, stat); -} - -static void blk_wb_stat_clear (void *data) -{ -blk_stat_clear (data); -} - -static bool blk_wb_stat_is_current (struct blk_rq_stat *stat) -{ -return blk_stat_is_current (stat); -} - -static struct wb_stat_ops wb_stat_ops = { - .get = blk_wb_stat_get, - .is_current = blk_wb_stat_is_current, - .clear = blk_wb_stat_clear, -}; -static void blk_wb_init (struct request_queue *q) {#ifndef CONFIG_BLK_WBT_MQ @@ -805,7 +784,7 @@ static void blk_wb_init(struct request_queue *q)/* * If this fails, we don't get throttling */ -wbt_init (q, &wb_stat_ops); +wbt_init (q); }int blk_register_queue (struct gendisk *disk)block/blk-wbt.c +5
-10@@ -308,7 +308,7 @@ static int __latency_exceeded(struct rq_wb *rwb, struct blk_rq_stat *stat)* waited or still has writes in flights, consider us doing * just writes as well. */ -if ((stat[1 ].nr_samples && rwb->stat_ops->is_current (stat)) || +if ((stat[1 ].nr_samples &&blk_stat_is_current (stat)) ||wb_recent_wait (rwb) ||wbt_inflight (rwb))return LAT_UNKNOWN_WRITES ;return LAT_UNKNOWN ;@@ -333,7 +333,7 @@ static int latency_exceeded(struct rq_wb *rwb) {struct blk_rq_stat stat[2 ]; - rwb->stat_ops->get (rwb->ops_data, stat); +blk_queue_stat_get (rwb->queue, stat);return __latency_exceeded (rwb, stat); }@@ -355,7 +355,7 @@ static void scale_up(struct rq_wb *rwb) rwb->scale_step--; rwb->unknown_cnt =0 ; - rwb->stat_ops->clear (rwb->ops_data); +blk_stat_clear (rwb->queue); rwb->scaled_max =calc_wb_limits (rwb);@@ -385,7 +385,7 @@ static void scale_down(struct rq_wb *rwb, bool hard_throttle) rwb->scaled_max = false; rwb->unknown_cnt =0 ; - rwb->stat_ops->clear (rwb->ops_data); +blk_stat_clear (rwb->queue);calc_wb_limits (rwb);rwb_trace_step (rwb,"step down" ); }@@ -675,7 +675,7 @@ void wbt_disable(struct rq_wb *rwb) }EXPORT_SYMBOL_GPL (wbt_disable); -int wbt_init (struct request_queue *q,struct wb_stat_ops *ops) +int wbt_init (struct request_queue *q) {struct rq_wb *rwb;int i;@@ -688,9 +688,6 @@ int wbt_init(struct request_queue *q, struct wb_stat_ops *ops)BUILD_BUG_ON (RWB_WINDOW_NSEC >BLK_STAT_NSEC );BUILD_BUG_ON (WBT_NR_BITS >BLK_STAT_RES_BITS ); -if (!ops->get || !ops->is_current || !ops->clear) -return -EINVAL ; - rwb =kzalloc (sizeof (*rwb),GFP_KERNEL );if (!rwb)return -ENOMEM ;@@ -706,8 +703,6 @@ int wbt_init(struct request_queue *q, struct wb_stat_ops *ops) rwb->last_comp = rwb->last_issue = jiffies; rwb->queue = q; rwb->win_nsec =RWB_WINDOW_NSEC ; - rwb->stat_ops = ops; - rwb->ops_data = q;wbt_update_limits (rwb);/* block/blk-wbt.h +2
-11@@ -46,12 +46,6 @@ static inline bool wbt_is_read(struct blk_issue_stat *stat)return (stat->time >>BLK_STAT_SHIFT ) &WBT_READ ; } -struct wb_stat_ops { -void (*get)(void *,struct blk_rq_stat *); -bool (*is_current)(struct blk_rq_stat *); -void (*clear)(void *); -}; -struct rq_wait {wait_queue_head_t wait;atomic_t inflight;@@ -89,9 +83,6 @@ struct rq_wb {unsigned long min_lat_nsec;struct request_queue *queue;struct rq_wait rq_wait[WBT_NUM_RWQ ]; - -struct wb_stat_ops *stat_ops; -void *ops_data; };static inline unsigned int wbt_inflight (struct rq_wb *rwb)@@ -109,7 +100,7 @@ static inline unsigned int wbt_inflight(struct rq_wb *rwb)void __wbt_done (struct rq_wb *,enum wbt_flags );void wbt_done (struct rq_wb *,struct blk_issue_stat *);enum wbt_flags wbt_wait (struct rq_wb *,struct bio *,spinlock_t *); -int wbt_init (struct request_queue *,struct wb_stat_ops *); +int wbt_init (struct request_queue *);void wbt_exit (struct request_queue *);void wbt_update_limits (struct rq_wb *);void wbt_requeue (struct rq_wb *,struct blk_issue_stat *);@@ -132,7 +123,7 @@ static inline enum wbt_flags wbt_wait(struct rq_wb *rwb, struct bio *bio, {return 0 ; } -static inline int wbt_init (struct request_queue *q,struct wb_stat_ops *ops) +static inline int wbt_init (struct request_queue *q) {return -EINVAL ; }Signature · 1 line
2.7.4
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR