1 struct percpu_counter
{
2 signed long long count
;
5 struct percpu_counter cpu_cnt
[4];
8 struct blkg_rwstat service_time
;
11 struct cfq_group
*group
;
14 struct cfq_queue
*active_queue
;
15 unsigned long long cmd_flags
;
18 static void blkg_rwstat_add(struct blkg_rwstat
*rwstat
, int rw
, unsigned long long val
)
20 struct percpu_counter
*cnt
;
22 cnt
= &rwstat
->cpu_cnt
[1];
24 cnt
= &rwstat
->cpu_cnt
[0];
27 cnt
= &rwstat
->cpu_cnt
[2];
29 cnt
= &rwstat
->cpu_cnt
[3];
32 extern unsigned long long rq_start_time_ns(void);
33 extern unsigned long long rq_io_start_time_ns(void);
34 extern int rq_is_sync(void);
35 extern void cfq_arm_slice_timer(void);
36 void cfq_completed_request(struct request
*rq
)
38 struct cfq_queue
*queue
= rq
->priv
;
39 int sync
= rq_is_sync();
40 struct cfq_group
*group
= queue
->group
;
41 long long start_time
= rq_start_time_ns();
42 long long io_start_time
= rq_io_start_time_ns();
43 int rw
= rq
->cmd_flags
;
45 if (io_start_time
< 1)
46 blkg_rwstat_add(&group
->service_time
, rw
, 1 - io_start_time
);
47 blkg_rwstat_add(0, rw
, io_start_time
- start_time
);
49 if (rq
->active_queue
== queue
&& sync
)
50 cfq_arm_slice_timer();