Commit f5f2b6ce authored by Shaohua Li's avatar Shaohua Li Committed by Jens Axboe

CFQ: add think time check for service tree

Currently when the last queue of a service tree has no request, we don't
expire the queue to hope request from the service tree comes soon, so the
service tree doesn't miss its share. But if the think time is big, the
assumption isn't correct and we just waste bandwidth. In such case, we
don't do idle.

[global]
runtime=10
direct=1

[test1]
rw=randread
ioengine=libaio
size=500m
directory=/mnt
filename=file1
thinktime=9000

[test2]
rw=read
ioengine=libaio
size=1G
directory=/mnt
filename=file2

	patched		base
test1	41k/s		33k/s
test2	15868k/s	15789k/s
total	15902k/s	15817k/s

A slightly better

To check if the patch changes behavior of queue without think time. I also
tried to give test1 2ms think time or no think time. The test has variation
even without the patch, but the average throughput doesn't change with/without
the patch.
Signed-off-by: default avatarShaohua Li <shaohua.li@intel.com>
Acked-by: default avatarVivek Goyal <vgoyal@redhat.com>
Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
parent 383cd721
...@@ -87,9 +87,10 @@ struct cfq_rb_root { ...@@ -87,9 +87,10 @@ struct cfq_rb_root {
unsigned count; unsigned count;
unsigned total_weight; unsigned total_weight;
u64 min_vdisktime; u64 min_vdisktime;
struct cfq_ttime ttime;
}; };
#define CFQ_RB_ROOT (struct cfq_rb_root) { .rb = RB_ROOT, .left = NULL, \ #define CFQ_RB_ROOT (struct cfq_rb_root) { .rb = RB_ROOT, \
.count = 0, .min_vdisktime = 0, } .ttime = {.last_end_request = jiffies,},}
/* /*
* Per process-grouping structure * Per process-grouping structure
...@@ -391,6 +392,18 @@ CFQ_CFQQ_FNS(wait_busy); ...@@ -391,6 +392,18 @@ CFQ_CFQQ_FNS(wait_busy);
j++, st = i < IDLE_WORKLOAD ? \ j++, st = i < IDLE_WORKLOAD ? \
&cfqg->service_trees[i][j]: NULL) \ &cfqg->service_trees[i][j]: NULL) \
static inline bool cfq_io_thinktime_big(struct cfq_data *cfqd,
struct cfq_ttime *ttime, bool group_idle)
{
unsigned long slice;
if (!sample_valid(ttime->ttime_samples))
return false;
if (group_idle)
slice = cfqd->cfq_group_idle;
else
slice = cfqd->cfq_slice_idle;
return ttime->ttime_mean > slice;
}
static inline bool iops_mode(struct cfq_data *cfqd) static inline bool iops_mode(struct cfq_data *cfqd)
{ {
...@@ -1955,7 +1968,8 @@ static bool cfq_should_idle(struct cfq_data *cfqd, struct cfq_queue *cfqq) ...@@ -1955,7 +1968,8 @@ static bool cfq_should_idle(struct cfq_data *cfqd, struct cfq_queue *cfqq)
* Otherwise, we do only if they are the last ones * Otherwise, we do only if they are the last ones
* in their service tree. * in their service tree.
*/ */
if (service_tree->count == 1 && cfq_cfqq_sync(cfqq)) if (service_tree->count == 1 && cfq_cfqq_sync(cfqq) &&
!cfq_io_thinktime_big(cfqd, &service_tree->ttime, false))
return true; return true;
cfq_log_cfqq(cfqd, cfqq, "Not idling. st->count:%d", cfq_log_cfqq(cfqd, cfqq, "Not idling. st->count:%d",
service_tree->count); service_tree->count);
...@@ -3220,8 +3234,11 @@ static void ...@@ -3220,8 +3234,11 @@ static void
cfq_update_io_thinktime(struct cfq_data *cfqd, struct cfq_queue *cfqq, cfq_update_io_thinktime(struct cfq_data *cfqd, struct cfq_queue *cfqq,
struct cfq_io_context *cic) struct cfq_io_context *cic)
{ {
if (cfq_cfqq_sync(cfqq)) if (cfq_cfqq_sync(cfqq)) {
__cfq_update_io_thinktime(&cic->ttime, cfqd->cfq_slice_idle); __cfq_update_io_thinktime(&cic->ttime, cfqd->cfq_slice_idle);
__cfq_update_io_thinktime(&cfqq->service_tree->ttime,
cfqd->cfq_slice_idle);
}
} }
static void static void
...@@ -3550,7 +3567,16 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq) ...@@ -3550,7 +3567,16 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
cfqd->rq_in_flight[cfq_cfqq_sync(cfqq)]--; cfqd->rq_in_flight[cfq_cfqq_sync(cfqq)]--;
if (sync) { if (sync) {
struct cfq_rb_root *service_tree;
RQ_CIC(rq)->ttime.last_end_request = now; RQ_CIC(rq)->ttime.last_end_request = now;
if (cfq_cfqq_on_rr(cfqq))
service_tree = cfqq->service_tree;
else
service_tree = service_tree_for(cfqq->cfqg,
cfqq_prio(cfqq), cfqq_type(cfqq));
service_tree->ttime.last_end_request = now;
if (!time_after(rq->start_time + cfqd->cfq_fifo_expire[1], now)) if (!time_after(rq->start_time + cfqd->cfq_fifo_expire[1], now))
cfqd->last_delayed_sync = now; cfqd->last_delayed_sync = now;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment