aboutsummaryrefslogtreecommitdiffstats
path: root/block/cfq-iosched.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-03-05 16:15:18 -0500
committerJens Axboe <axboe@kernel.dk>2012-03-06 15:27:23 -0500
commit4eef3049986e8397d5003916aed8cad6567a5e02 (patch)
tree5e36431986907b9fa728a6fbeb819a2738a64c82 /block/cfq-iosched.c
parentc1768268f9424410761da57ea71107acae7b03cc (diff)
blkcg: move per-queue blkg list heads and counters to queue and blkg
Currently, specific policy implementations are responsible for maintaining list and number of blkgs. This duplicates code unnecessarily, and hinders factoring common code and providing blkcg API with better defined semantics. After this patch, request_queue hosts list heads and counters and blkg has list nodes for both policies. This patch only relocates the necessary fields and the next patch will actually move management code into blkcg core. Note that request_queue->blkg_list[] and ->nr_blkgs[] are hardcoded to have 2 elements. This is to avoid include dependency and will be removed by the next patch. This patch doesn't introduce any behavior change. -v2: Now unnecessary conditional on CONFIG_BLK_CGROUP_MODULE removed as pointed out by Vivek. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/cfq-iosched.c')
-rw-r--r--block/cfq-iosched.c47
1 files changed, 19 insertions, 28 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 11dd9d7f2edb..e846803280a6 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -208,9 +208,7 @@ struct cfq_group {
208 unsigned long saved_workload_slice; 208 unsigned long saved_workload_slice;
209 enum wl_type_t saved_workload; 209 enum wl_type_t saved_workload;
210 enum wl_prio_t saved_serving_prio; 210 enum wl_prio_t saved_serving_prio;
211#ifdef CONFIG_CFQ_GROUP_IOSCHED 211
212 struct hlist_node cfqd_node;
213#endif
214 /* number of requests that are on the dispatch list or inside driver */ 212 /* number of requests that are on the dispatch list or inside driver */
215 int dispatched; 213 int dispatched;
216 struct cfq_ttime ttime; 214 struct cfq_ttime ttime;
@@ -302,12 +300,6 @@ struct cfq_data {
302 struct cfq_queue oom_cfqq; 300 struct cfq_queue oom_cfqq;
303 301
304 unsigned long last_delayed_sync; 302 unsigned long last_delayed_sync;
305
306 /* List of cfq groups being managed on this device*/
307 struct hlist_head cfqg_list;
308
309 /* Number of groups which are on blkcg->blkg_list */
310 unsigned int nr_blkcg_linked_grps;
311}; 303};
312 304
313static inline struct cfq_group *blkg_to_cfqg(struct blkio_group *blkg) 305static inline struct cfq_group *blkg_to_cfqg(struct blkio_group *blkg)
@@ -1056,13 +1048,9 @@ static void cfq_update_blkio_group_weight(struct request_queue *q,
1056static void cfq_link_blkio_group(struct request_queue *q, 1048static void cfq_link_blkio_group(struct request_queue *q,
1057 struct blkio_group *blkg) 1049 struct blkio_group *blkg)
1058{ 1050{
1059 struct cfq_data *cfqd = q->elevator->elevator_data; 1051 list_add(&blkg->q_node[BLKIO_POLICY_PROP],
1060 struct cfq_group *cfqg = blkg_to_cfqg(blkg); 1052 &q->blkg_list[BLKIO_POLICY_PROP]);
1061 1053 q->nr_blkgs[BLKIO_POLICY_PROP]++;
1062 cfqd->nr_blkcg_linked_grps++;
1063
1064 /* Add group on cfqd list */
1065 hlist_add_head(&cfqg->cfqd_node, &cfqd->cfqg_list);
1066} 1054}
1067 1055
1068static void cfq_init_blkio_group(struct blkio_group *blkg) 1056static void cfq_init_blkio_group(struct blkio_group *blkg)
@@ -1110,13 +1098,15 @@ static void cfq_link_cfqq_cfqg(struct cfq_queue *cfqq, struct cfq_group *cfqg)
1110 1098
1111static void cfq_destroy_cfqg(struct cfq_data *cfqd, struct cfq_group *cfqg) 1099static void cfq_destroy_cfqg(struct cfq_data *cfqd, struct cfq_group *cfqg)
1112{ 1100{
1101 struct blkio_group *blkg = cfqg_to_blkg(cfqg);
1102
1113 /* Something wrong if we are trying to remove same group twice */ 1103 /* Something wrong if we are trying to remove same group twice */
1114 BUG_ON(hlist_unhashed(&cfqg->cfqd_node)); 1104 BUG_ON(list_empty(&blkg->q_node[BLKIO_POLICY_PROP]));
1115 1105
1116 hlist_del_init(&cfqg->cfqd_node); 1106 list_del_init(&blkg->q_node[BLKIO_POLICY_PROP]);
1117 1107
1118 BUG_ON(cfqd->nr_blkcg_linked_grps <= 0); 1108 BUG_ON(cfqd->queue->nr_blkgs[BLKIO_POLICY_PROP] <= 0);
1119 cfqd->nr_blkcg_linked_grps--; 1109 cfqd->queue->nr_blkgs[BLKIO_POLICY_PROP]--;
1120 1110
1121 /* 1111 /*
1122 * Put the reference taken at the time of creation so that when all 1112 * Put the reference taken at the time of creation so that when all
@@ -1127,18 +1117,19 @@ static void cfq_destroy_cfqg(struct cfq_data *cfqd, struct cfq_group *cfqg)
1127 1117
1128static bool cfq_release_cfq_groups(struct cfq_data *cfqd) 1118static bool cfq_release_cfq_groups(struct cfq_data *cfqd)
1129{ 1119{
1130 struct hlist_node *pos, *n; 1120 struct request_queue *q = cfqd->queue;
1131 struct cfq_group *cfqg; 1121 struct blkio_group *blkg, *n;
1132 bool empty = true; 1122 bool empty = true;
1133 1123
1134 hlist_for_each_entry_safe(cfqg, pos, n, &cfqd->cfqg_list, cfqd_node) { 1124 list_for_each_entry_safe(blkg, n, &q->blkg_list[BLKIO_POLICY_PROP],
1125 q_node[BLKIO_POLICY_PROP]) {
1135 /* 1126 /*
1136 * If cgroup removal path got to blk_group first and removed 1127 * If cgroup removal path got to blk_group first and removed
1137 * it from cgroup list, then it will take care of destroying 1128 * it from cgroup list, then it will take care of destroying
1138 * cfqg also. 1129 * cfqg also.
1139 */ 1130 */
1140 if (!cfq_blkiocg_del_blkio_group(cfqg_to_blkg(cfqg))) 1131 if (!cfq_blkiocg_del_blkio_group(blkg))
1141 cfq_destroy_cfqg(cfqd, cfqg); 1132 cfq_destroy_cfqg(cfqd, blkg_to_cfqg(blkg));
1142 else 1133 else
1143 empty = false; 1134 empty = false;
1144 } 1135 }
@@ -3558,13 +3549,13 @@ static void cfq_exit_queue(struct elevator_queue *e)
3558 cfq_put_async_queues(cfqd); 3549 cfq_put_async_queues(cfqd);
3559 cfq_release_cfq_groups(cfqd); 3550 cfq_release_cfq_groups(cfqd);
3560 3551
3552#ifdef CONFIG_BLK_CGROUP
3561 /* 3553 /*
3562 * If there are groups which we could not unlink from blkcg list, 3554 * If there are groups which we could not unlink from blkcg list,
3563 * wait for a rcu period for them to be freed. 3555 * wait for a rcu period for them to be freed.
3564 */ 3556 */
3565 if (cfqd->nr_blkcg_linked_grps) 3557 wait = q->nr_blkgs[BLKIO_POLICY_PROP];
3566 wait = true; 3558#endif
3567
3568 spin_unlock_irq(q->queue_lock); 3559 spin_unlock_irq(q->queue_lock);
3569 3560
3570 cfq_shutdown_timer_wq(cfqd); 3561 cfq_shutdown_timer_wq(cfqd);