Skip to content

Commit ec39934

Browse files
htejunaxboe
authored andcommitted
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>
1 parent bc0d650 commit ec39934

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

block/blk-cgroup.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,25 +226,25 @@ static void blkg_destroy(struct blkio_group *blkg)
226226
* aren't shot down. This broken and racy implementation is temporary.
227227
* Eventually, blkg shoot down will be replaced by proper in-place update.
228228
*/
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)
230231
{
231-
struct blkio_policy_type *pol = blkio_policy[plid];
232232
struct blkio_group *blkg = blkg_lookup(&blkio_root_cgroup, q);
233233
struct blkg_policy_data *pd;
234234

235235
if (!blkg)
236236
return;
237237

238-
kfree(blkg->pd[plid]);
239-
blkg->pd[plid] = NULL;
238+
kfree(blkg->pd[pol->plid]);
239+
blkg->pd[pol->plid] = NULL;
240240

241241
if (!pol)
242242
return;
243243

244244
pd = kzalloc(sizeof(*pd) + pol->pdata_size, GFP_KERNEL);
245245
WARN_ON_ONCE(!pd);
246246

247-
blkg->pd[plid] = pd;
247+
blkg->pd[pol->plid] = pd;
248248
pd->blkg = blkg;
249249
pol->ops.blkio_init_group_fn(blkg);
250250
}
@@ -360,16 +360,17 @@ static const char *blkg_dev_name(struct blkio_group *blkg)
360360
*/
361361
void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg,
362362
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)
364365
{
365366
struct blkio_group *blkg;
366367
struct hlist_node *n;
367368
u64 total = 0;
368369

369370
spin_lock_irq(&blkcg->lock);
370371
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);
373374
spin_unlock_irq(&blkcg->lock);
374375

375376
if (show_total)
@@ -739,7 +740,7 @@ void blkio_policy_register(struct blkio_policy_type *blkiop)
739740
BUG_ON(blkio_policy[blkiop->plid]);
740741
blkio_policy[blkiop->plid] = blkiop;
741742
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);
743744

744745
blkcg_bypass_end();
745746

@@ -765,7 +766,7 @@ void blkio_policy_unregister(struct blkio_policy_type *blkiop)
765766
blkio_policy[blkiop->plid] = NULL;
766767

767768
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);
769770
blkcg_bypass_end();
770771

771772
mutex_unlock(&blkcg_pol_mutex);

block/blk-cgroup.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,12 @@ extern void blkio_policy_register(struct blkio_policy_type *);
117117
extern void blkio_policy_unregister(struct blkio_policy_type *);
118118
extern void blkg_destroy_all(struct request_queue *q, bool destroy_root);
119119
extern void update_root_blkg_pd(struct request_queue *q,
120-
enum blkio_policy_id plid);
120+
const struct blkio_policy_type *pol);
121121

122122
void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg,
123123
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);
125126
u64 __blkg_prfill_u64(struct seq_file *sf, void *pdata, u64 v);
126127
u64 __blkg_prfill_rwstat(struct seq_file *sf, void *pdata,
127128
const struct blkg_rwstat *rwstat);
@@ -333,7 +334,7 @@ static inline void blkio_policy_unregister(struct blkio_policy_type *blkiop) { }
333334
static inline void blkg_destroy_all(struct request_queue *q,
334335
bool destory_root) { }
335336
static inline void update_root_blkg_pd(struct request_queue *q,
336-
enum blkio_policy_id plid) { }
337+
const struct blkio_policy_type *pol) { }
337338

338339
static inline void *blkg_to_pdata(struct blkio_group *blkg,
339340
struct blkio_policy_type *pol) { return NULL; }

block/blk-throttle.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ static int tg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft,
946946
{
947947
struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
948948

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,
950950
cft->private, true);
951951
return 0;
952952
}
@@ -973,15 +973,15 @@ static int tg_print_conf_u64(struct cgroup *cgrp, struct cftype *cft,
973973
struct seq_file *sf)
974974
{
975975
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);
977977
return 0;
978978
}
979979

980980
static int tg_print_conf_uint(struct cgroup *cgrp, struct cftype *cft,
981981
struct seq_file *sf)
982982
{
983983
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);
985985
return 0;
986986
}
987987

block/cfq-iosched.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ static int cfqg_print_weight_device(struct cgroup *cgrp, struct cftype *cft,
13801380
struct seq_file *sf)
13811381
{
13821382
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,
13841384
false);
13851385
return 0;
13861386
}
@@ -1445,7 +1445,7 @@ static int cfqg_print_stat(struct cgroup *cgrp, struct cftype *cft,
14451445
{
14461446
struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
14471447

1448-
blkcg_print_blkgs(sf, blkcg, blkg_prfill_stat, BLKIO_POLICY_PROP,
1448+
blkcg_print_blkgs(sf, blkcg, blkg_prfill_stat, &blkio_policy_cfq,
14491449
cft->private, false);
14501450
return 0;
14511451
}
@@ -1455,7 +1455,7 @@ static int cfqg_print_rwstat(struct cgroup *cgrp, struct cftype *cft,
14551455
{
14561456
struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
14571457

1458-
blkcg_print_blkgs(sf, blkcg, blkg_prfill_rwstat, BLKIO_POLICY_PROP,
1458+
blkcg_print_blkgs(sf, blkcg, blkg_prfill_rwstat, &blkio_policy_cfq,
14591459
cft->private, true);
14601460
return 0;
14611461
}
@@ -1482,7 +1482,7 @@ static int cfqg_print_avg_queue_size(struct cgroup *cgrp, struct cftype *cft,
14821482
struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
14831483

14841484
blkcg_print_blkgs(sf, blkcg, cfqg_prfill_avg_queue_size,
1485-
BLKIO_POLICY_PROP, 0, false);
1485+
&blkio_policy_cfq, 0, false);
14861486
return 0;
14871487
}
14881488
#endif /* CONFIG_DEBUG_BLK_CGROUP */
@@ -3938,7 +3938,7 @@ static void cfq_exit_queue(struct elevator_queue *e)
39383938
#ifndef CONFIG_CFQ_GROUP_IOSCHED
39393939
kfree(cfqd->root_group);
39403940
#endif
3941-
update_root_blkg_pd(q, BLKIO_POLICY_PROP);
3941+
update_root_blkg_pd(q, &blkio_policy_cfq);
39423942
kfree(cfqd);
39433943
}
39443944

0 commit comments

Comments
 (0)