Subject: CFQ: add think time check for group
PATCH 3/3 Subject: CFQ: add think time check for group
Subject: CFQ: add think time check for group
Currently when the last queue of a group has no request, we don't expire the queue to hope request from the group comes soon, so the group 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=30
direct=1
[test1]
cgroup=test1
cgroup_weight=1000
rw=randread
ioengine=libaio
size=500m
runtime=30
directory=/mnt
filename=file1
thinktime=9000
[test2]
cgroup=test2
cgroup_weight=1000
rw=randread
ioengine=libaio
size=500m
runtime=30
directory=/mnt
filename=file2
patched base
test1 64k 39k
test2 540k 540k
total 604k 578k
group1 gets much better throughput because it waits less time.
--- block/cfq-iosched.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
block/cfq-iosched.c +16 -3
@@ -215,6 +215,7 @@ struct cfq_group {#endif /* number of requests that are on the dispatch list or inside driver */ int dispatched; +struct cfq_ttime ttime; };/*
@@ -1062,6 +1063,8 @@ static struct cfq_group * cfq_alloc_cfqg *st =CFQ_RB_ROOT ;RB_CLEAR_NODE (&cfqg->rb_node); + cfqg->ttime.last_end_request = jiffies; +/* * Take the initial reference that will be released on destroy * This can be thought of a joint reference by cgroup and
@@ -2385,8 +2388,9 @@ static struct cfq_queue *cfq_select_queu* this group, wait for requests to complete. */ check_group_idle: -if (cfqd->cfq_group_idle && cfqq->cfqg->nr_cfqq ==1 - && cfqq->cfqg->dispatched) { +if (cfqd->cfq_group_idle && cfqq->cfqg->nr_cfqq ==1 && + cfqq->cfqg->dispatched && !cfq_io_thinktime_big (cfqq->cfqg->ttime, + cfqd->cfq_group_idle)) { cfqq =NULL ; goto keep_queue; }
@@ -3245,6 +3249,9 @@ cfq_update_io_thinktime(struct cfq_data__cfq_update_io_thinktime (&service_tree->ttime, cfqd->cfq_slice_idle); } +#ifdef CONFIG_CFQ_GROUP_IOSCHED +__cfq_update_io_thinktime (&cfqg->ttime, cfqd->cfq_group_idle); +#endif } static void
@@ -3536,7 +3543,9 @@ static bool cfq_should_wait_busy(structif (cfqq->cfqg->nr_cfqq >1 )return false; -if (cfq_slice_used (cfqq)) +/* we are the only queue in the group */ +if (cfq_slice_used (cfqq) && + !cfq_io_thinktime_big (cfqq->cfqg->ttime, cfqd->cfq_group_idle))return true;/* if slice left is less than think time, wait busy */
@@ -3593,6 +3602,10 @@ static void cfq_completed_request(struct cfqd->last_delayed_sync = now; } +#ifdef CONFIG_CFQ_GROUP_IOSCHED + cfqq->cfqg->ttime.last_end_request = now; +#endif +/* * If this is the active queue, check if it needs to be expired, * or if we want to idle in case it has no pending requests.
Quoted 66 lines · Shaohua Li
Subject: CFQ: add think time check for group
Currently when the last queue of a group has no request, we don't expire the queue to hope request from the group comes soon, so the group 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=30
direct=1[test1]
cgroup=test1
cgroup_weight=1000
rw=randread
ioengine=libaio
size=500m
runtime=30
directory=/mnt
filename=file1
thinktime=9000[test2]
cgroup=test2
cgroup_weight=1000
rw=randread
ioengine=libaio
size=500m
runtime=30
directory=/mnt
filename=file2patched base
test1 64k 39k
test2 540k 540k
total 604k 578kgroup1 gets much better throughput because it waits less time.
Signed-off-by Shaohua Li <[email protected]>--- block/cfq-iosched.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)Index:
linux/block/cfq-iosched.c
===================================================================block/cfq-iosched.c +3
-0@@ -215,6 +215,7 @@ struct cfq_group {#endif /* number of requests that are on the dispatch list or inside driver */ int dispatched; +struct cfq_ttime ttime; };/* @@ -1062,6 +1063,8 @@ static struct cfq_group * cfq_alloc_cfqg *st =CFQ_RB_ROOT ;RB_CLEAR_NODE (&cfqg->rb_node); + cfqg->ttime.last_end_request = jiffies; +/* * Take the initial reference that will be released on destroy * This can be thought of a joint reference by cgroup and
block/cfq-iosched.c static struct cfq_queue *cfq_select_queu · line 2393
Quoted 8 lines
block/cfq-iosched.c +3
-2@@ -2385,8 +2388,9 @@ static struct cfq_queue *cfq_select_queu* this group, wait for requests to complete. */ check_group_idle: -if (cfqd->cfq_group_idle && cfqq->cfqg->nr_cfqq ==1 - && cfqq->cfqg->dispatched) { +if (cfqd->cfq_group_idle && cfqq->cfqg->nr_cfqq ==1 && + cfqq->cfqg->dispatched && !cfq_io_thinktime_big (cfqq->cfqg->ttime, + cfqd->cfq_group_idle)) {
Lets put the group think time check on new line to avoid splittling function argument on two lines.
Quoted 14 lines
block/cfq-iosched.c +3
-0cfqq =NULL ; goto keep_queue; }@@ -3245,6 +3249,9 @@ cfq_update_io_thinktime(struct cfq_data__cfq_update_io_thinktime (&service_tree->ttime, cfqd->cfq_slice_idle); } +#ifdef CONFIG_CFQ_GROUP_IOSCHED +__cfq_update_io_thinktime (&cfqg->ttime, cfqd->cfq_group_idle); +#endif } static void
block/cfq-iosched.c static bool cfq_should_wait_busy(struct · line 3549
Quoted 8 lines
block/cfq-iosched.c +3
-1@@ -3536,7 +3543,9 @@ static bool cfq_should_wait_busy(structif (cfqq->cfqg->nr_cfqq >1 )return false; -if (cfq_slice_used (cfqq)) +/* we are the only queue in the group */ +if (cfq_slice_used (cfqq) && + !cfq_io_thinktime_big (cfqq->cfqg->ttime, cfqd->cfq_group_idle))return true;
I think thinktime check should not be anded with slice_used() check. Slice used check is about that we have been idling all along on queue and now slice is used so we would like to wait a bit more for queue to get busy so that group does not lose its share. Given the fact slice is used that means we have been idling on the queue and have been getting requests regularly in the queue.
But group think time check should be applicable irrespective of the fact whether we have used the slice or not. If thinktime of a group is big, then we should just not wait for it to get busy because anyway group idle timer will fire and expire the queue/group before that.
Thanks
Vivek
Quoted 70 lines · Vivek Goyal
Quoted 69 lines · Shaohua Li
Subject: CFQ: add think time check for group
Currently when the last queue of a group has no request, we don't expire the queue to hope request from the group comes soon, so the group 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=30
direct=1[test1]
cgroup=test1
cgroup_weight=1000
rw=randread
ioengine=libaio
size=500m
runtime=30
directory=/mnt
filename=file1
thinktime=9000[test2]
cgroup=test2
cgroup_weight=1000
rw=randread
ioengine=libaio
size=500m
runtime=30
directory=/mnt
filename=file2patched base
test1 64k 39k
test2 540k 540k
total 604k 578kgroup1 gets much better throughput because it waits less time.
Signed-off-by Shaohua Li <[email protected]>--- block/cfq-iosched.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)Index:
linux/block/cfq-iosched.c
===================================================================block/cfq-iosched.c +3
-0@@ -215,6 +215,7 @@ struct cfq_group {#endif /* number of requests that are on the dispatch list or inside driver */ int dispatched; +struct cfq_ttime ttime; };/* @@ -1062,6 +1063,8 @@ static struct cfq_group * cfq_alloc_cfqg *st =CFQ_RB_ROOT ;RB_CLEAR_NODE (&cfqg->rb_node); + cfqg->ttime.last_end_request = jiffies; +/* * Take the initial reference that will be released on destroy * This can be thought of a joint reference by cgroup and @@ -2385,8 +2388,9 @@ static struct cfq_queue *cfq_select_queu* this group, wait for requests to complete. */ check_group_idle:
Quoted 8 lines
block/cfq-iosched.c static struct cfq_queue *cfq_select_queu · line 2393
Quoted 5 lines
block/cfq-iosched.c +3
-2-if (cfqd->cfq_group_idle && cfqq->cfqg->nr_cfqq ==1 - && cfqq->cfqg->dispatched) { +if (cfqd->cfq_group_idle && cfqq->cfqg->nr_cfqq ==1 && + cfqq->cfqg->dispatched && !cfq_io_thinktime_big (cfqq->cfqg->ttime, + cfqd->cfq_group_idle)) {Lets put the group think time check on new line to avoid splittling function argument on two lines.
ok
Quoted 30 lines
Quoted 14 lines
block/cfq-iosched.c +3
-0cfqq =NULL ; goto keep_queue; }@@ -3245,6 +3249,9 @@ cfq_update_io_thinktime(struct cfq_data__cfq_update_io_thinktime (&service_tree->ttime, cfqd->cfq_slice_idle); } +#ifdef CONFIG_CFQ_GROUP_IOSCHED +__cfq_update_io_thinktime (&cfqg->ttime, cfqd->cfq_group_idle); +#endif } static voidblock/cfq-iosched.c static bool cfq_should_wait_busy(struct · line 3549
Quoted 8 lines
block/cfq-iosched.c +3
-1@@ -3536,7 +3543,9 @@ static bool cfq_should_wait_busy(structif (cfqq->cfqg->nr_cfqq >1 )return false; -if (cfq_slice_used (cfqq)) +/* we are the only queue in the group */ +if (cfq_slice_used (cfqq) && + !cfq_io_thinktime_big (cfqq->cfqg->ttime, cfqd->cfq_group_idle))return true;I think thinktime check should not be anded with
slice_used()check. Slice used check is about that we have been idling all along on queue and now slice is used so we would like to wait a bit more for queue to get busy so that group does not lose its share. Given the fact slice is used that means we have been idling on the queue and have been getting requests regularly in the queue.
Quoted 4 lines
But group think time check should be applicable irrespective of the fact whether we have used the slice or not. If thinktime of a group is big, then we should just not wait for it to get busy because anyway group idle timer will fire and expire the queue/group before that.
Makes sense. Updated patch below.
Subject: CFQ: add think time check for group
Currently when the last queue of a group has no request, we don't expire the queue to hope request from the group comes soon, so the group 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=30
direct=1
[test1]
cgroup=test1
cgroup_weight=1000
rw=randread
ioengine=libaio
size=500m
runtime=30
directory=/mnt
filename=file1
thinktime=9000
[test2]
cgroup=test2
cgroup_weight=1000
rw=randread
ioengine=libaio
size=500m
runtime=30
directory=/mnt
filename=file2
patched base
test1 64k 39k
test2 540k 540k
total 604k 578k
group1 gets much better throughput because it waits less time.
--- block/cfq-iosched.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
block/cfq-iosched.c +17 -2
@@ -213,6 +213,7 @@ struct cfq_group {#endif /* number of requests that are on the dispatch list or inside driver */ int dispatched; +struct cfq_ttime ttime; };/*
@@ -1072,6 +1073,8 @@ static struct cfq_group * cfq_alloc_cfqg *st =CFQ_RB_ROOT ;RB_CLEAR_NODE (&cfqg->rb_node); + cfqg->ttime.last_end_request = jiffies; +/* * Take the initial reference that will be released on destroy * This can be thought of a joint reference by cgroup and
@@ -2395,8 +2398,9 @@ static struct cfq_queue *cfq_select_queu* this group, wait for requests to complete. */ check_group_idle: -if (cfqd->cfq_group_idle && cfqq->cfqg->nr_cfqq ==1 - && cfqq->cfqg->dispatched) { +if (cfqd->cfq_group_idle && cfqq->cfqg->nr_cfqq ==1 && + cfqq->cfqg->dispatched && + !cfq_io_thinktime_big (cfqd, &cfqq->cfqg->ttime, true)) { cfqq =NULL ; goto keep_queue; }
@@ -3250,6 +3254,9 @@ cfq_update_io_thinktime(struct cfq_data__cfq_update_io_thinktime (&cfqq->service_tree->ttime, cfqd->cfq_slice_idle); } +#ifdef CONFIG_CFQ_GROUP_IOSCHED +__cfq_update_io_thinktime (&cfqq->cfqg->ttime, cfqd->cfq_group_idle); +#endif } static void
@@ -3541,6 +3548,10 @@ static bool cfq_should_wait_busy(structif (cfqq->cfqg->nr_cfqq >1 )return false; +/* the only queue in the group, but think time is big */ +if (cfq_io_thinktime_big (cfqd, &cfqq->cfqg->ttime, true)) +return false; +if (cfq_slice_used (cfqq))return true;
@@ -3598,6 +3609,10 @@ static void cfq_completed_request(struct cfqd->last_delayed_sync = now; } +#ifdef CONFIG_CFQ_GROUP_IOSCHED + cfqq->cfqg->ttime.last_end_request = now; +#endif +/* * If this is the active queue, check if it needs to be expired, * or if we want to idle in case it has no pending requests.
On Wed, Jul 06, 2011 at 09:58:40AM +0800, Shaohua Li wrote:
[..]
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
[global]
runtime=30
direct=1[test1]
cgroup=test1
cgroup_weight=1000
rw=randread
ioengine=libaio
size=500m
runtime=30
directory=/mnt
filename=file1
thinktime=9000[test2]
cgroup=test2
cgroup_weight=1000
rw=randread
ioengine=libaio
size=500m
runtime=30
directory=/mnt
filename=file2
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
patched base
test1 64k 39k
test2 540k 540k
total 604k 578kgroup1 gets much better throughput because it waits less time.
I don't understand it. Thinktime of group test1 is more than 8ms. So now we should not be idling on test1. Hence test1 should lose some share and test2 should gain disk share and overall throughput should go up.
I am wondering why throughput of test2 did not go up?
Also can you run some tests to make sure that disk shares of regular workloads (thinktime less than 8ms) are not impacted.
Thanks
Vivek
Quoted 32 lines · Vivek Goyal
On Wed, Jul 06, 2011 at 09:58:40AM +0800, Shaohua Li wrote:
[..]Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
[global]
runtime=30
direct=1[test1]
cgroup=test1
cgroup_weight=1000
rw=randread
ioengine=libaio
size=500m
runtime=30
directory=/mnt
filename=file1
thinktime=9000[test2]
cgroup=test2
cgroup_weight=1000
rw=randread
ioengine=libaio
size=500m
runtime=30
directory=/mnt
filename=file2patched base
test1 64k 39k
test2 540k 540k
total 604k 578k
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
group1 gets much better throughput because it waits less time.
I don't understand it. Thinktime of group test1 is more than 8ms. So now we should not be idling on test1. Hence test1 should lose some share and test2 should gain disk share and overall throughput should go up.
I am wondering why throughput of test2 did not go up?
hmm, actually the throughput of test2 is better. Maybe I wrote it down wrong. test2 throughput is about 548k/s. Sorry.
Quoted 2 lines
Also can you run some tests to make sure that disk shares of regular workloads (thinktime less than 8ms) are not impacted.
I tried think time 2ms or no think time. there is no difference. the result is quite stable.
Thanks,
Shaohua