Skip to content

Commit b84477d

Browse files
harshadjsaxboe
authored andcommitted
blk-wbt: fix performance regression in wbt scale_up/scale_down
scale_up wakes up waiters after scaling up. But after scaling max, it should not wake up more waiters as waiters will not have anything to do. This patch fixes this by making scale_up (and also scale_down) return when threshold is reached. This bug causes increased fdatasync latency when fdatasync and dd conv=sync are performed in parallel on 4.19 compared to 4.14. This bug was introduced during refactoring of blk-wbt code. Fixes: a790504 ("blk-rq-qos: refactor out common elements of blk-wbt") Cc: [email protected] Cc: Josef Bacik <[email protected]> Signed-off-by: Harshad Shirwadkar <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 0e48f51 commit b84477d

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

block/blk-rq-qos.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,32 +160,35 @@ bool rq_depth_calc_max_depth(struct rq_depth *rqd)
160160
return ret;
161161
}
162162

163-
void rq_depth_scale_up(struct rq_depth *rqd)
163+
/* Returns true on success and false if scaling up wasn't possible */
164+
bool rq_depth_scale_up(struct rq_depth *rqd)
164165
{
165166
/*
166167
* Hit max in previous round, stop here
167168
*/
168169
if (rqd->scaled_max)
169-
return;
170+
return false;
170171

171172
rqd->scale_step--;
172173

173174
rqd->scaled_max = rq_depth_calc_max_depth(rqd);
175+
return true;
174176
}
175177

176178
/*
177179
* Scale rwb down. If 'hard_throttle' is set, do it quicker, since we
178-
* had a latency violation.
180+
* had a latency violation. Returns true on success and returns false if
181+
* scaling down wasn't possible.
179182
*/
180-
void rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle)
183+
bool rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle)
181184
{
182185
/*
183186
* Stop scaling down when we've hit the limit. This also prevents
184187
* ->scale_step from going to crazy values, if the device can't
185188
* keep up.
186189
*/
187190
if (rqd->max_depth == 1)
188-
return;
191+
return false;
189192

190193
if (rqd->scale_step < 0 && hard_throttle)
191194
rqd->scale_step = 0;
@@ -194,6 +197,7 @@ void rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle)
194197

195198
rqd->scaled_max = false;
196199
rq_depth_calc_max_depth(rqd);
200+
return true;
197201
}
198202

199203
struct rq_qos_wait_data {

block/blk-rq-qos.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data,
130130
acquire_inflight_cb_t *acquire_inflight_cb,
131131
cleanup_cb_t *cleanup_cb);
132132
bool rq_wait_inc_below(struct rq_wait *rq_wait, unsigned int limit);
133-
void rq_depth_scale_up(struct rq_depth *rqd);
134-
void rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle);
133+
bool rq_depth_scale_up(struct rq_depth *rqd);
134+
bool rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle);
135135
bool rq_depth_calc_max_depth(struct rq_depth *rqd);
136136

137137
void __rq_qos_cleanup(struct rq_qos *rqos, struct bio *bio);

block/blk-wbt.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ static void calc_wb_limits(struct rq_wb *rwb)
308308

309309
static void scale_up(struct rq_wb *rwb)
310310
{
311-
rq_depth_scale_up(&rwb->rq_depth);
311+
if (!rq_depth_scale_up(&rwb->rq_depth))
312+
return;
312313
calc_wb_limits(rwb);
313314
rwb->unknown_cnt = 0;
314315
rwb_wake_all(rwb);
@@ -317,7 +318,8 @@ static void scale_up(struct rq_wb *rwb)
317318

318319
static void scale_down(struct rq_wb *rwb, bool hard_throttle)
319320
{
320-
rq_depth_scale_down(&rwb->rq_depth, hard_throttle);
321+
if (!rq_depth_scale_down(&rwb->rq_depth, hard_throttle))
322+
return;
321323
calc_wb_limits(rwb);
322324
rwb->unknown_cnt = 0;
323325
rwb_trace_step(rwb, "scale down");

0 commit comments

Comments
 (0)