Skip to content

Commit b462732

Browse files
rhvgoyalJens Axboe
authored andcommitted
cfq-iosched: Fix a gcc 4.5 warning and put some comments
- Andi encountedred following warning with gcc 4.5 linux/block/cfq-iosched.c: In function ‘cfq_dispatch_requests’: linux/block/cfq-iosched.c:2156:3: warning: array subscript is above array bounds - Warning happens due to following code. slice = group_slice * count / max_t(unsigned, cfqg->busy_queues_avg[cfqd->serving_prio], cfq_group_busy_queues_wl(cfqd->serving_prio, cfqd, cfqg)); gcc is complaining about cfqg->busy_queues_avg[] being indexed by CFQ prio classes (RT, BE and IDLE) while the array size is only 2. - At run time, we never access cfqg->busy_queues_avg[IDLE] and return from function before this code hits. - To fix warning increase the array size though it will remain unused. This patch also puts some comments to clarify some of the confusions. - I have taken Jens's patch and modified it a bit. - Compile tested with gcc 4.4 and boot tested. I don't have gcc 4.5 running, Andi can you please test it with gcc 4.5 to make sure it worked. Reported-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Acked-by: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
1 parent 11a691b commit b462732

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎block/cfq-iosched.c‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ enum wl_prio_t {
157157
BE_WORKLOAD = 0,
158158
RT_WORKLOAD = 1,
159159
IDLE_WORKLOAD = 2,
160+
CFQ_PRIO_NR,
160161
};
161162

162163
/*
@@ -181,10 +182,19 @@ struct cfq_group {
181182
/* number of cfqq currently on this group */
182183
int nr_cfqq;
183184

184-
/* Per group busy queus average. Useful for workload slice calc. */
185-
unsigned int busy_queues_avg[2];
186185
/*
187-
* rr lists of queues with requests, onle rr for each priority class.
186+
* Per group busy queus average. Useful for workload slice calc. We
187+
* create the array for each prio class but at run time it is used
188+
* only for RT and BE class and slot for IDLE class remains unused.
189+
* This is primarily done to avoid confusion and a gcc warning.
190+
*/
191+
unsigned int busy_queues_avg[CFQ_PRIO_NR];
192+
/*
193+
* rr lists of queues with requests. We maintain service trees for
194+
* RT and BE classes. These trees are subdivided in subclasses
195+
* of SYNC, SYNC_NOIDLE and ASYNC based on workload type. For IDLE
196+
* class there is no subclassification and all the cfq queues go on
197+
* a single tree service_tree_idle.
188198
* Counts are embedded in the cfq_rb_root
189199
*/
190200
struct cfq_rb_root service_trees[2][3];

0 commit comments

Comments
 (0)