Skip to content

Commit 5be6b75

Browse files
Hou Taoaxboe
authored andcommitted
cfq-iosched: fix the delay of cfq_group's vdisktime under iops mode
When adding a cfq_group into the cfq service tree, we use CFQ_IDLE_DELAY as the delay of cfq_group's vdisktime if there have been other cfq_groups already. When cfq is under iops mode, commit 9a7f38c ("cfq-iosched: Convert from jiffies to nanoseconds") could result in a large iops delay and lead to an abnormal io schedule delay for the added cfq_group. To fix it, we just need to revert to the old CFQ_IDLE_DELAY value: HZ / 5 when iops mode is enabled. Despite having the same value, the delay of a cfq_queue in idle class and the delay of cfq_group are different things, so I define two new macros for the delay of a cfq_group under time-slice mode and iops mode. Fixes: 9a7f38c ("cfq-iosched: Convert from jiffies to nanoseconds") Cc: <stable@vger.kernel.org> # 4.8+ Signed-off-by: Hou Tao <houtao1@huawei.com> Acked-by: Jan Kara <jack@suse.cz> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent e4dc2b3 commit 5be6b75

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

block/cfq-iosched.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ static const u64 cfq_target_latency = (u64)NSEC_PER_SEC * 3/10; /* 300 ms */
3838
static const int cfq_hist_divisor = 4;
3939

4040
/*
41-
* offset from end of service tree
41+
* offset from end of queue service tree for idle class
4242
*/
4343
#define CFQ_IDLE_DELAY (NSEC_PER_SEC / 5)
44+
/* offset from end of group service tree under time slice mode */
45+
#define CFQ_SLICE_MODE_GROUP_DELAY (NSEC_PER_SEC / 5)
46+
/* offset from end of group service under IOPS mode */
47+
#define CFQ_IOPS_MODE_GROUP_DELAY (HZ / 5)
4448

4549
/*
4650
* below this threshold, we consider thinktime immediate
@@ -1362,6 +1366,14 @@ cfq_group_service_tree_add(struct cfq_rb_root *st, struct cfq_group *cfqg)
13621366
cfqg->vfraction = max_t(unsigned, vfr, 1);
13631367
}
13641368

1369+
static inline u64 cfq_get_cfqg_vdisktime_delay(struct cfq_data *cfqd)
1370+
{
1371+
if (!iops_mode(cfqd))
1372+
return CFQ_SLICE_MODE_GROUP_DELAY;
1373+
else
1374+
return CFQ_IOPS_MODE_GROUP_DELAY;
1375+
}
1376+
13651377
static void
13661378
cfq_group_notify_queue_add(struct cfq_data *cfqd, struct cfq_group *cfqg)
13671379
{
@@ -1381,7 +1393,8 @@ cfq_group_notify_queue_add(struct cfq_data *cfqd, struct cfq_group *cfqg)
13811393
n = rb_last(&st->rb);
13821394
if (n) {
13831395
__cfqg = rb_entry_cfqg(n);
1384-
cfqg->vdisktime = __cfqg->vdisktime + CFQ_IDLE_DELAY;
1396+
cfqg->vdisktime = __cfqg->vdisktime +
1397+
cfq_get_cfqg_vdisktime_delay(cfqd);
13851398
} else
13861399
cfqg->vdisktime = st->min_vdisktime;
13871400
cfq_group_service_tree_add(st, cfqg);

0 commit comments

Comments
 (0)