Commit 383cd7213f95a2784ab5038fe292844178768b82
Committed by
Jens Axboe
1 parent
4aede84b33
Exists in
master
and in
4 other branches
CFQ: move think time check variables to a separate struct
Move the variables to do think time check to a sepatate struct. This is to prepare adding think time check for service tree and group. No functional change. Signed-off-by: Shaohua Li <shaohua.li@intel.com> Acked-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Showing 2 changed files with 33 additions and 21 deletions Side-by-side Diff
block/cfq-iosched.c
... | ... | @@ -2008,10 +2008,10 @@ |
2008 | 2008 | * slice, then don't idle. This avoids overrunning the allotted |
2009 | 2009 | * time slice. |
2010 | 2010 | */ |
2011 | - if (sample_valid(cic->ttime_samples) && | |
2012 | - (cfqq->slice_end - jiffies < cic->ttime_mean)) { | |
2011 | + if (sample_valid(cic->ttime.ttime_samples) && | |
2012 | + (cfqq->slice_end - jiffies < cic->ttime.ttime_mean)) { | |
2013 | 2013 | cfq_log_cfqq(cfqd, cfqq, "Not idling. think_time:%lu", |
2014 | - cic->ttime_mean); | |
2014 | + cic->ttime.ttime_mean); | |
2015 | 2015 | return; |
2016 | 2016 | } |
2017 | 2017 | |
... | ... | @@ -2819,7 +2819,7 @@ |
2819 | 2819 | cic = kmem_cache_alloc_node(cfq_ioc_pool, gfp_mask | __GFP_ZERO, |
2820 | 2820 | cfqd->queue->node); |
2821 | 2821 | if (cic) { |
2822 | - cic->last_end_request = jiffies; | |
2822 | + cic->ttime.last_end_request = jiffies; | |
2823 | 2823 | INIT_LIST_HEAD(&cic->queue_list); |
2824 | 2824 | INIT_HLIST_NODE(&cic->cic_list); |
2825 | 2825 | cic->dtor = cfq_free_io_context; |
2826 | 2826 | |
2827 | 2827 | |
2828 | 2828 | |
... | ... | @@ -3206,17 +3206,25 @@ |
3206 | 3206 | } |
3207 | 3207 | |
3208 | 3208 | static void |
3209 | -cfq_update_io_thinktime(struct cfq_data *cfqd, struct cfq_io_context *cic) | |
3209 | +__cfq_update_io_thinktime(struct cfq_ttime *ttime, unsigned long slice_idle) | |
3210 | 3210 | { |
3211 | - unsigned long elapsed = jiffies - cic->last_end_request; | |
3212 | - unsigned long ttime = min(elapsed, 2UL * cfqd->cfq_slice_idle); | |
3211 | + unsigned long elapsed = jiffies - ttime->last_end_request; | |
3212 | + elapsed = min(elapsed, 2UL * slice_idle); | |
3213 | 3213 | |
3214 | - cic->ttime_samples = (7*cic->ttime_samples + 256) / 8; | |
3215 | - cic->ttime_total = (7*cic->ttime_total + 256*ttime) / 8; | |
3216 | - cic->ttime_mean = (cic->ttime_total + 128) / cic->ttime_samples; | |
3214 | + ttime->ttime_samples = (7*ttime->ttime_samples + 256) / 8; | |
3215 | + ttime->ttime_total = (7*ttime->ttime_total + 256*elapsed) / 8; | |
3216 | + ttime->ttime_mean = (ttime->ttime_total + 128) / ttime->ttime_samples; | |
3217 | 3217 | } |
3218 | 3218 | |
3219 | 3219 | static void |
3220 | +cfq_update_io_thinktime(struct cfq_data *cfqd, struct cfq_queue *cfqq, | |
3221 | + struct cfq_io_context *cic) | |
3222 | +{ | |
3223 | + if (cfq_cfqq_sync(cfqq)) | |
3224 | + __cfq_update_io_thinktime(&cic->ttime, cfqd->cfq_slice_idle); | |
3225 | +} | |
3226 | + | |
3227 | +static void | |
3220 | 3228 | cfq_update_io_seektime(struct cfq_data *cfqd, struct cfq_queue *cfqq, |
3221 | 3229 | struct request *rq) |
3222 | 3230 | { |
... | ... | @@ -3262,8 +3270,8 @@ |
3262 | 3270 | else if (!atomic_read(&cic->ioc->nr_tasks) || !cfqd->cfq_slice_idle || |
3263 | 3271 | (!cfq_cfqq_deep(cfqq) && CFQQ_SEEKY(cfqq))) |
3264 | 3272 | enable_idle = 0; |
3265 | - else if (sample_valid(cic->ttime_samples)) { | |
3266 | - if (cic->ttime_mean > cfqd->cfq_slice_idle) | |
3273 | + else if (sample_valid(cic->ttime.ttime_samples)) { | |
3274 | + if (cic->ttime.ttime_mean > cfqd->cfq_slice_idle) | |
3267 | 3275 | enable_idle = 0; |
3268 | 3276 | else |
3269 | 3277 | enable_idle = 1; |
... | ... | @@ -3389,7 +3397,7 @@ |
3389 | 3397 | |
3390 | 3398 | cfqd->rq_queued++; |
3391 | 3399 | |
3392 | - cfq_update_io_thinktime(cfqd, cic); | |
3400 | + cfq_update_io_thinktime(cfqd, cfqq, cic); | |
3393 | 3401 | cfq_update_io_seektime(cfqd, cfqq, rq); |
3394 | 3402 | cfq_update_idle_window(cfqd, cfqq, cic); |
3395 | 3403 | |
... | ... | @@ -3500,8 +3508,8 @@ |
3500 | 3508 | return true; |
3501 | 3509 | |
3502 | 3510 | /* if slice left is less than think time, wait busy */ |
3503 | - if (cic && sample_valid(cic->ttime_samples) | |
3504 | - && (cfqq->slice_end - jiffies < cic->ttime_mean)) | |
3511 | + if (cic && sample_valid(cic->ttime.ttime_samples) | |
3512 | + && (cfqq->slice_end - jiffies < cic->ttime.ttime_mean)) | |
3505 | 3513 | return true; |
3506 | 3514 | |
3507 | 3515 | /* |
... | ... | @@ -3542,7 +3550,7 @@ |
3542 | 3550 | cfqd->rq_in_flight[cfq_cfqq_sync(cfqq)]--; |
3543 | 3551 | |
3544 | 3552 | if (sync) { |
3545 | - RQ_CIC(rq)->last_end_request = now; | |
3553 | + RQ_CIC(rq)->ttime.last_end_request = now; | |
3546 | 3554 | if (!time_after(rq->start_time + cfqd->cfq_fifo_expire[1], now)) |
3547 | 3555 | cfqd->last_delayed_sync = now; |
3548 | 3556 | } |
include/linux/iocontext.h
... | ... | @@ -5,6 +5,14 @@ |
5 | 5 | #include <linux/rcupdate.h> |
6 | 6 | |
7 | 7 | struct cfq_queue; |
8 | +struct cfq_ttime { | |
9 | + unsigned long last_end_request; | |
10 | + | |
11 | + unsigned long ttime_total; | |
12 | + unsigned long ttime_samples; | |
13 | + unsigned long ttime_mean; | |
14 | +}; | |
15 | + | |
8 | 16 | struct cfq_io_context { |
9 | 17 | void *key; |
10 | 18 | |
... | ... | @@ -12,11 +20,7 @@ |
12 | 20 | |
13 | 21 | struct io_context *ioc; |
14 | 22 | |
15 | - unsigned long last_end_request; | |
16 | - | |
17 | - unsigned long ttime_total; | |
18 | - unsigned long ttime_samples; | |
19 | - unsigned long ttime_mean; | |
23 | + struct cfq_ttime ttime; | |
20 | 24 | |
21 | 25 | struct list_head queue_list; |
22 | 26 | struct hlist_node cic_list; |