aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/compile/pr68538.c
blob: 2822cdb6b5815c63fbfd51b32f38958fa72aa4ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
struct percpu_counter {
	signed long long count;
};
struct blkg_rwstat {
	struct percpu_counter cpu_cnt[4];
};
struct cfq_group {
	struct blkg_rwstat service_time;
};
struct cfq_queue {
	struct cfq_group *group;
};
struct request {
	struct cfq_queue *active_queue;
	unsigned long long cmd_flags;
	void *priv;
};
static void blkg_rwstat_add(struct blkg_rwstat *rwstat, int rw, unsigned long long val)
{
	struct percpu_counter *cnt;
	if (rw & 1)
		cnt = &rwstat->cpu_cnt[1];
	else
		cnt = &rwstat->cpu_cnt[0];
	cnt->count += val;
	if (rw & 2)
		cnt = &rwstat->cpu_cnt[2];
	else
		cnt = &rwstat->cpu_cnt[3];
	cnt->count += val;
}
extern unsigned long long rq_start_time_ns(void);
extern unsigned long long rq_io_start_time_ns(void);
extern int rq_is_sync(void);
extern void cfq_arm_slice_timer(void);
void cfq_completed_request(struct request *rq)
{
	struct cfq_queue *queue = rq->priv;
	int sync = rq_is_sync();
	struct cfq_group *group = queue->group;
	long long start_time = rq_start_time_ns();
	long long io_start_time = rq_io_start_time_ns();
	int rw = rq->cmd_flags;

	if (io_start_time < 1)
		blkg_rwstat_add(&group->service_time, rw, 1 - io_start_time);
	blkg_rwstat_add(0, rw, io_start_time - start_time);

	if (rq->active_queue == queue && sync)
		cfq_arm_slice_timer();
}