aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Ma <boyu.mt@taobao.com>2012-04-01 17:33:39 -0400
committerJens Axboe <axboe@kernel.dk>2012-04-01 17:33:39 -0400
commit5bf14c0727a07ded1bd9fa6d77923d7e6dc32833 (patch)
treedb1c4db0ece7ec7f416c9581eef3bdf172a73864
parent8bcb6c7d48eb341b1f49f814cdcbe05eb6f15680 (diff)
block: Make cfq_target_latency tunable through sysfs.
In cfq, when we calculate a time slice for a process(or a cfqq to be precise), we have to consider the cfq_target_latency so that all the sync request have an estimated latency(300ms) and it is controlled by cfq_target_latency. But in some hadoop test, we have found that if there are many processes doing sequential read(24 for example), the throughput is bad because every process can only work for about 25ms and the cfqq is switched. That leads to a higher disk seek. We can achive the good throughput by setting low_latency=0, but then some read's latency is too much for the application. So this patch makes cfq_target_latency tunable through sysfs so that we can tune it and find some magic number which is not bad for both the throughput and the read latency. Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Tao Ma <boyu.mt@taobao.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/cfq-iosched.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 457295253566..3c38536bd52c 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -295,6 +295,7 @@ struct cfq_data {
295 unsigned int cfq_slice_idle; 295 unsigned int cfq_slice_idle;
296 unsigned int cfq_group_idle; 296 unsigned int cfq_group_idle;
297 unsigned int cfq_latency; 297 unsigned int cfq_latency;
298 unsigned int cfq_target_latency;
298 299
299 /* 300 /*
300 * Fallback dummy cfqq for extreme OOM conditions 301 * Fallback dummy cfqq for extreme OOM conditions
@@ -604,7 +605,7 @@ cfq_group_slice(struct cfq_data *cfqd, struct cfq_group *cfqg)
604{ 605{
605 struct cfq_rb_root *st = &cfqd->grp_service_tree; 606 struct cfq_rb_root *st = &cfqd->grp_service_tree;
606 607
607 return cfq_target_latency * cfqg->weight / st->total_weight; 608 return cfqd->cfq_target_latency * cfqg->weight / st->total_weight;
608} 609}
609 610
610static inline unsigned 611static inline unsigned
@@ -2271,7 +2272,8 @@ new_workload:
2271 * to have higher weight. A more accurate thing would be to 2272 * to have higher weight. A more accurate thing would be to
2272 * calculate system wide asnc/sync ratio. 2273 * calculate system wide asnc/sync ratio.
2273 */ 2274 */
2274 tmp = cfq_target_latency * cfqg_busy_async_queues(cfqd, cfqg); 2275 tmp = cfqd->cfq_target_latency *
2276 cfqg_busy_async_queues(cfqd, cfqg);
2275 tmp = tmp/cfqd->busy_queues; 2277 tmp = tmp/cfqd->busy_queues;
2276 slice = min_t(unsigned, slice, tmp); 2278 slice = min_t(unsigned, slice, tmp);
2277 2279
@@ -3737,6 +3739,7 @@ static void *cfq_init_queue(struct request_queue *q)
3737 cfqd->cfq_back_penalty = cfq_back_penalty; 3739 cfqd->cfq_back_penalty = cfq_back_penalty;
3738 cfqd->cfq_slice[0] = cfq_slice_async; 3740 cfqd->cfq_slice[0] = cfq_slice_async;
3739 cfqd->cfq_slice[1] = cfq_slice_sync; 3741 cfqd->cfq_slice[1] = cfq_slice_sync;
3742 cfqd->cfq_target_latency = cfq_target_latency;
3740 cfqd->cfq_slice_async_rq = cfq_slice_async_rq; 3743 cfqd->cfq_slice_async_rq = cfq_slice_async_rq;
3741 cfqd->cfq_slice_idle = cfq_slice_idle; 3744 cfqd->cfq_slice_idle = cfq_slice_idle;
3742 cfqd->cfq_group_idle = cfq_group_idle; 3745 cfqd->cfq_group_idle = cfq_group_idle;
@@ -3788,6 +3791,7 @@ SHOW_FUNCTION(cfq_slice_sync_show, cfqd->cfq_slice[1], 1);
3788SHOW_FUNCTION(cfq_slice_async_show, cfqd->cfq_slice[0], 1); 3791SHOW_FUNCTION(cfq_slice_async_show, cfqd->cfq_slice[0], 1);
3789SHOW_FUNCTION(cfq_slice_async_rq_show, cfqd->cfq_slice_async_rq, 0); 3792SHOW_FUNCTION(cfq_slice_async_rq_show, cfqd->cfq_slice_async_rq, 0);
3790SHOW_FUNCTION(cfq_low_latency_show, cfqd->cfq_latency, 0); 3793SHOW_FUNCTION(cfq_low_latency_show, cfqd->cfq_latency, 0);
3794SHOW_FUNCTION(cfq_target_latency_show, cfqd->cfq_target_latency, 1);
3791#undef SHOW_FUNCTION 3795#undef SHOW_FUNCTION
3792 3796
3793#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \ 3797#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \
@@ -3821,6 +3825,7 @@ STORE_FUNCTION(cfq_slice_async_store, &cfqd->cfq_slice[0], 1, UINT_MAX, 1);
3821STORE_FUNCTION(cfq_slice_async_rq_store, &cfqd->cfq_slice_async_rq, 1, 3825STORE_FUNCTION(cfq_slice_async_rq_store, &cfqd->cfq_slice_async_rq, 1,
3822 UINT_MAX, 0); 3826 UINT_MAX, 0);
3823STORE_FUNCTION(cfq_low_latency_store, &cfqd->cfq_latency, 0, 1, 0); 3827STORE_FUNCTION(cfq_low_latency_store, &cfqd->cfq_latency, 0, 1, 0);
3828STORE_FUNCTION(cfq_target_latency_store, &cfqd->cfq_target_latency, 1, UINT_MAX, 1);
3824#undef STORE_FUNCTION 3829#undef STORE_FUNCTION
3825 3830
3826#define CFQ_ATTR(name) \ 3831#define CFQ_ATTR(name) \
@@ -3838,6 +3843,7 @@ static struct elv_fs_entry cfq_attrs[] = {
3838 CFQ_ATTR(slice_idle), 3843 CFQ_ATTR(slice_idle),
3839 CFQ_ATTR(group_idle), 3844 CFQ_ATTR(group_idle),
3840 CFQ_ATTR(low_latency), 3845 CFQ_ATTR(low_latency),
3846 CFQ_ATTR(target_latency),
3841 __ATTR_NULL 3847 __ATTR_NULL
3842}; 3848};
3843 3849