Commit ec399347d39fb2337ebace928cf4a2855bd0ec37

Authored by Tejun Heo
Committed by Jens Axboe
1 parent bc0d6501a8

blkcg: use @pol instead of @plid in update_root_blkg_pd() and blkcg_print_blkgs()

The two functions were taking "enum blkio_policy_id plid".  Make them
take "const struct blkio_policy_type *pol" instead.

This is to prepare for per-queue policy activation and doesn't cause
any functional difference.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

Showing 4 changed files with 23 additions and 21 deletions Side-by-side Diff

... ... @@ -226,17 +226,17 @@
226 226 * aren't shot down. This broken and racy implementation is temporary.
227 227 * Eventually, blkg shoot down will be replaced by proper in-place update.
228 228 */
229   -void update_root_blkg_pd(struct request_queue *q, enum blkio_policy_id plid)
  229 +void update_root_blkg_pd(struct request_queue *q,
  230 + const struct blkio_policy_type *pol)
230 231 {
231   - struct blkio_policy_type *pol = blkio_policy[plid];
232 232 struct blkio_group *blkg = blkg_lookup(&blkio_root_cgroup, q);
233 233 struct blkg_policy_data *pd;
234 234  
235 235 if (!blkg)
236 236 return;
237 237  
238   - kfree(blkg->pd[plid]);
239   - blkg->pd[plid] = NULL;
  238 + kfree(blkg->pd[pol->plid]);
  239 + blkg->pd[pol->plid] = NULL;
240 240  
241 241 if (!pol)
242 242 return;
... ... @@ -244,7 +244,7 @@
244 244 pd = kzalloc(sizeof(*pd) + pol->pdata_size, GFP_KERNEL);
245 245 WARN_ON_ONCE(!pd);
246 246  
247   - blkg->pd[plid] = pd;
  247 + blkg->pd[pol->plid] = pd;
248 248 pd->blkg = blkg;
249 249 pol->ops.blkio_init_group_fn(blkg);
250 250 }
... ... @@ -360,7 +360,8 @@
360 360 */
361 361 void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg,
362 362 u64 (*prfill)(struct seq_file *, void *, int),
363   - int pol, int data, bool show_total)
  363 + const struct blkio_policy_type *pol, int data,
  364 + bool show_total)
364 365 {
365 366 struct blkio_group *blkg;
366 367 struct hlist_node *n;
... ... @@ -368,8 +369,8 @@
368 369  
369 370 spin_lock_irq(&blkcg->lock);
370 371 hlist_for_each_entry(blkg, n, &blkcg->blkg_list, blkcg_node)
371   - if (blkg->pd[pol])
372   - total += prfill(sf, blkg->pd[pol]->pdata, data);
  372 + if (blkg->pd[pol->plid])
  373 + total += prfill(sf, blkg->pd[pol->plid]->pdata, data);
373 374 spin_unlock_irq(&blkcg->lock);
374 375  
375 376 if (show_total)
... ... @@ -739,7 +740,7 @@
739 740 BUG_ON(blkio_policy[blkiop->plid]);
740 741 blkio_policy[blkiop->plid] = blkiop;
741 742 list_for_each_entry(q, &all_q_list, all_q_node)
742   - update_root_blkg_pd(q, blkiop->plid);
  743 + update_root_blkg_pd(q, blkiop);
743 744  
744 745 blkcg_bypass_end();
745 746  
... ... @@ -765,7 +766,7 @@
765 766 blkio_policy[blkiop->plid] = NULL;
766 767  
767 768 list_for_each_entry(q, &all_q_list, all_q_node)
768   - update_root_blkg_pd(q, blkiop->plid);
  769 + update_root_blkg_pd(q, blkiop);
769 770 blkcg_bypass_end();
770 771  
771 772 mutex_unlock(&blkcg_pol_mutex);
... ... @@ -117,11 +117,12 @@
117 117 extern void blkio_policy_unregister(struct blkio_policy_type *);
118 118 extern void blkg_destroy_all(struct request_queue *q, bool destroy_root);
119 119 extern void update_root_blkg_pd(struct request_queue *q,
120   - enum blkio_policy_id plid);
  120 + const struct blkio_policy_type *pol);
121 121  
122 122 void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg,
123 123 u64 (*prfill)(struct seq_file *, void *, int),
124   - int pol, int data, bool show_total);
  124 + const struct blkio_policy_type *pol, int data,
  125 + bool show_total);
125 126 u64 __blkg_prfill_u64(struct seq_file *sf, void *pdata, u64 v);
126 127 u64 __blkg_prfill_rwstat(struct seq_file *sf, void *pdata,
127 128 const struct blkg_rwstat *rwstat);
... ... @@ -333,7 +334,7 @@
333 334 static inline void blkg_destroy_all(struct request_queue *q,
334 335 bool destory_root) { }
335 336 static inline void update_root_blkg_pd(struct request_queue *q,
336   - enum blkio_policy_id plid) { }
  337 + const struct blkio_policy_type *pol) { }
337 338  
338 339 static inline void *blkg_to_pdata(struct blkio_group *blkg,
339 340 struct blkio_policy_type *pol) { return NULL; }
block/blk-throttle.c
... ... @@ -946,7 +946,7 @@
946 946 {
947 947 struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
948 948  
949   - blkcg_print_blkgs(sf, blkcg, tg_prfill_cpu_rwstat, BLKIO_POLICY_THROTL,
  949 + blkcg_print_blkgs(sf, blkcg, tg_prfill_cpu_rwstat, &blkio_policy_throtl,
950 950 cft->private, true);
951 951 return 0;
952 952 }
... ... @@ -973,7 +973,7 @@
973 973 struct seq_file *sf)
974 974 {
975 975 blkcg_print_blkgs(sf, cgroup_to_blkio_cgroup(cgrp), tg_prfill_conf_u64,
976   - BLKIO_POLICY_THROTL, cft->private, false);
  976 + &blkio_policy_throtl, cft->private, false);
977 977 return 0;
978 978 }
979 979  
... ... @@ -981,7 +981,7 @@
981 981 struct seq_file *sf)
982 982 {
983 983 blkcg_print_blkgs(sf, cgroup_to_blkio_cgroup(cgrp), tg_prfill_conf_uint,
984   - BLKIO_POLICY_THROTL, cft->private, false);
  984 + &blkio_policy_throtl, cft->private, false);
985 985 return 0;
986 986 }
987 987  
... ... @@ -1380,7 +1380,7 @@
1380 1380 struct seq_file *sf)
1381 1381 {
1382 1382 blkcg_print_blkgs(sf, cgroup_to_blkio_cgroup(cgrp),
1383   - cfqg_prfill_weight_device, BLKIO_POLICY_PROP, 0,
  1383 + cfqg_prfill_weight_device, &blkio_policy_cfq, 0,
1384 1384 false);
1385 1385 return 0;
1386 1386 }
... ... @@ -1445,7 +1445,7 @@
1445 1445 {
1446 1446 struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
1447 1447  
1448   - blkcg_print_blkgs(sf, blkcg, blkg_prfill_stat, BLKIO_POLICY_PROP,
  1448 + blkcg_print_blkgs(sf, blkcg, blkg_prfill_stat, &blkio_policy_cfq,
1449 1449 cft->private, false);
1450 1450 return 0;
1451 1451 }
... ... @@ -1455,7 +1455,7 @@
1455 1455 {
1456 1456 struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
1457 1457  
1458   - blkcg_print_blkgs(sf, blkcg, blkg_prfill_rwstat, BLKIO_POLICY_PROP,
  1458 + blkcg_print_blkgs(sf, blkcg, blkg_prfill_rwstat, &blkio_policy_cfq,
1459 1459 cft->private, true);
1460 1460 return 0;
1461 1461 }
... ... @@ -1482,7 +1482,7 @@
1482 1482 struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
1483 1483  
1484 1484 blkcg_print_blkgs(sf, blkcg, cfqg_prfill_avg_queue_size,
1485   - BLKIO_POLICY_PROP, 0, false);
  1485 + &blkio_policy_cfq, 0, false);
1486 1486 return 0;
1487 1487 }
1488 1488 #endif /* CONFIG_DEBUG_BLK_CGROUP */
... ... @@ -3938,7 +3938,7 @@
3938 3938 #ifndef CONFIG_CFQ_GROUP_IOSCHED
3939 3939 kfree(cfqd->root_group);
3940 3940 #endif
3941   - update_root_blkg_pd(q, BLKIO_POLICY_PROP);
  3941 + update_root_blkg_pd(q, &blkio_policy_cfq);
3942 3942 kfree(cfqd);
3943 3943 }
3944 3944