aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-04-01 17:38:44 -0400
committerTejun Heo <tj@kernel.org>2012-04-01 17:38:44 -0400
commit3381cb8d2ef1523dbaeec99161d766c25f1e52d6 (patch)
treeb5592ee2a0f84e694282c947611971eb7735622d /block
parent8a3d26151f24e2a2ffa550890144c3d54d2edb15 (diff)
blkcg: move blkio_group_conf->weight to cfq
blkio_group_conf->weight is owned by cfq and has no reason to be defined in blkcg core. Replace it with cfq_group->dev_weight and let conf setting functions directly set it. If dev_weight is zero, the cfqg doesn't have device specific weight configured. Also, rename BLKIO_WEIGHT_* constants to CFQ_WEIGHT_* and rename blkio_cgroup->weight to blkio_cgroup->cfq_weight. We eventually want per-policy storage in blkio_cgroup but just mark the ownership of the field for now. Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'block')
-rw-r--r--block/blk-cgroup.c4
-rw-r--r--block/blk-cgroup.h14
-rw-r--r--block/cfq-iosched.c77
3 files changed, 45 insertions, 50 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 16f6ee65a593..c0e239b8455e 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -30,7 +30,7 @@ static LIST_HEAD(blkio_list);
30static DEFINE_MUTEX(all_q_mutex); 30static DEFINE_MUTEX(all_q_mutex);
31static LIST_HEAD(all_q_list); 31static LIST_HEAD(all_q_list);
32 32
33struct blkio_cgroup blkio_root_cgroup = { .weight = 2*BLKIO_WEIGHT_DEFAULT }; 33struct blkio_cgroup blkio_root_cgroup = { .cfq_weight = 2 * CFQ_WEIGHT_DEFAULT };
34EXPORT_SYMBOL_GPL(blkio_root_cgroup); 34EXPORT_SYMBOL_GPL(blkio_root_cgroup);
35 35
36static struct blkio_policy_type *blkio_policy[BLKIO_NR_POLICIES]; 36static struct blkio_policy_type *blkio_policy[BLKIO_NR_POLICIES];
@@ -611,7 +611,7 @@ static struct cgroup_subsys_state *blkiocg_create(struct cgroup *cgroup)
611 if (!blkcg) 611 if (!blkcg)
612 return ERR_PTR(-ENOMEM); 612 return ERR_PTR(-ENOMEM);
613 613
614 blkcg->weight = BLKIO_WEIGHT_DEFAULT; 614 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
615 blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */ 615 blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
616done: 616done:
617 spin_lock_init(&blkcg->lock); 617 spin_lock_init(&blkcg->lock);
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index e368dd00b8cf..386db2974a08 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -29,6 +29,11 @@ enum blkio_policy_id {
29 29
30#ifdef CONFIG_BLK_CGROUP 30#ifdef CONFIG_BLK_CGROUP
31 31
32/* CFQ specific, out here for blkcg->cfq_weight */
33#define CFQ_WEIGHT_MIN 10
34#define CFQ_WEIGHT_MAX 1000
35#define CFQ_WEIGHT_DEFAULT 500
36
32/* cft->private [un]packing for stat printing */ 37/* cft->private [un]packing for stat printing */
33#define BLKCG_STAT_PRIV(pol, off) (((unsigned)(pol) << 16) | (off)) 38#define BLKCG_STAT_PRIV(pol, off) (((unsigned)(pol) << 16) | (off))
34#define BLKCG_STAT_POL(prv) ((unsigned)(prv) >> 16) 39#define BLKCG_STAT_POL(prv) ((unsigned)(prv) >> 16)
@@ -46,12 +51,14 @@ enum blkg_rwstat_type {
46 51
47struct blkio_cgroup { 52struct blkio_cgroup {
48 struct cgroup_subsys_state css; 53 struct cgroup_subsys_state css;
49 unsigned int weight;
50 spinlock_t lock; 54 spinlock_t lock;
51 struct hlist_head blkg_list; 55 struct hlist_head blkg_list;
52 56
53 /* for policies to test whether associated blkcg has changed */ 57 /* for policies to test whether associated blkcg has changed */
54 uint64_t id; 58 uint64_t id;
59
60 /* TODO: per-policy storage in blkio_cgroup */
61 unsigned int cfq_weight; /* belongs to cfq */
55}; 62};
56 63
57struct blkg_stat { 64struct blkg_stat {
@@ -65,7 +72,6 @@ struct blkg_rwstat {
65}; 72};
66 73
67struct blkio_group_conf { 74struct blkio_group_conf {
68 unsigned int weight;
69 u64 iops[2]; 75 u64 iops[2];
70 u64 bps[2]; 76 u64 bps[2];
71}; 77};
@@ -355,10 +361,6 @@ static inline void blkg_put(struct blkio_group *blkg) { }
355 361
356#endif 362#endif
357 363
358#define BLKIO_WEIGHT_MIN 10
359#define BLKIO_WEIGHT_MAX 1000
360#define BLKIO_WEIGHT_DEFAULT 500
361
362#ifdef CONFIG_BLK_CGROUP 364#ifdef CONFIG_BLK_CGROUP
363extern struct blkio_cgroup blkio_root_cgroup; 365extern struct blkio_cgroup blkio_root_cgroup;
364extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup); 366extern struct blkio_cgroup *cgroup_to_blkio_cgroup(struct cgroup *cgroup);
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index a1f37dfd1b8b..adab10de6eea 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -224,7 +224,7 @@ struct cfq_group {
224 u64 vdisktime; 224 u64 vdisktime;
225 unsigned int weight; 225 unsigned int weight;
226 unsigned int new_weight; 226 unsigned int new_weight;
227 bool needs_update; 227 unsigned int dev_weight;
228 228
229 /* number of cfqq currently on this group */ 229 /* number of cfqq currently on this group */
230 int nr_cfqq; 230 int nr_cfqq;
@@ -838,7 +838,7 @@ static inline u64 cfq_scale_slice(unsigned long delta, struct cfq_group *cfqg)
838{ 838{
839 u64 d = delta << CFQ_SERVICE_SHIFT; 839 u64 d = delta << CFQ_SERVICE_SHIFT;
840 840
841 d = d * BLKIO_WEIGHT_DEFAULT; 841 d = d * CFQ_WEIGHT_DEFAULT;
842 do_div(d, cfqg->weight); 842 do_div(d, cfqg->weight);
843 return d; 843 return d;
844} 844}
@@ -1165,9 +1165,9 @@ static void
1165cfq_update_group_weight(struct cfq_group *cfqg) 1165cfq_update_group_weight(struct cfq_group *cfqg)
1166{ 1166{
1167 BUG_ON(!RB_EMPTY_NODE(&cfqg->rb_node)); 1167 BUG_ON(!RB_EMPTY_NODE(&cfqg->rb_node));
1168 if (cfqg->needs_update) { 1168 if (cfqg->new_weight) {
1169 cfqg->weight = cfqg->new_weight; 1169 cfqg->weight = cfqg->new_weight;
1170 cfqg->needs_update = false; 1170 cfqg->new_weight = 0;
1171 } 1171 }
1172} 1172}
1173 1173
@@ -1325,21 +1325,12 @@ static void cfq_init_cfqg_base(struct cfq_group *cfqg)
1325} 1325}
1326 1326
1327#ifdef CONFIG_CFQ_GROUP_IOSCHED 1327#ifdef CONFIG_CFQ_GROUP_IOSCHED
1328static void cfq_update_blkio_group_weight(struct blkio_group *blkg,
1329 unsigned int weight)
1330{
1331 struct cfq_group *cfqg = blkg_to_cfqg(blkg);
1332
1333 cfqg->new_weight = weight;
1334 cfqg->needs_update = true;
1335}
1336
1337static void cfq_init_blkio_group(struct blkio_group *blkg) 1328static void cfq_init_blkio_group(struct blkio_group *blkg)
1338{ 1329{
1339 struct cfq_group *cfqg = blkg_to_cfqg(blkg); 1330 struct cfq_group *cfqg = blkg_to_cfqg(blkg);
1340 1331
1341 cfq_init_cfqg_base(cfqg); 1332 cfq_init_cfqg_base(cfqg);
1342 cfqg->weight = blkg->blkcg->weight; 1333 cfqg->weight = blkg->blkcg->cfq_weight;
1343} 1334}
1344 1335
1345/* 1336/*
@@ -1377,36 +1368,38 @@ static void cfq_link_cfqq_cfqg(struct cfq_queue *cfqq, struct cfq_group *cfqg)
1377 cfqg_get(cfqg); 1368 cfqg_get(cfqg);
1378} 1369}
1379 1370
1380static u64 blkg_prfill_weight_device(struct seq_file *sf, 1371static u64 cfqg_prfill_weight_device(struct seq_file *sf,
1381 struct blkg_policy_data *pd, int off) 1372 struct blkg_policy_data *pd, int off)
1382{ 1373{
1383 if (!pd->conf.weight) 1374 struct cfq_group *cfqg = (void *)pd->pdata;
1375
1376 if (!cfqg->dev_weight)
1384 return 0; 1377 return 0;
1385 return __blkg_prfill_u64(sf, pd, pd->conf.weight); 1378 return __blkg_prfill_u64(sf, pd, cfqg->dev_weight);
1386} 1379}
1387 1380
1388static int blkcg_print_weight_device(struct cgroup *cgrp, struct cftype *cft, 1381static int cfqg_print_weight_device(struct cgroup *cgrp, struct cftype *cft,
1389 struct seq_file *sf) 1382 struct seq_file *sf)
1390{ 1383{
1391 blkcg_print_blkgs(sf, cgroup_to_blkio_cgroup(cgrp), 1384 blkcg_print_blkgs(sf, cgroup_to_blkio_cgroup(cgrp),
1392 blkg_prfill_weight_device, BLKIO_POLICY_PROP, 0, 1385 cfqg_prfill_weight_device, BLKIO_POLICY_PROP, 0,
1393 false); 1386 false);
1394 return 0; 1387 return 0;
1395} 1388}
1396 1389
1397static int blkcg_print_weight(struct cgroup *cgrp, struct cftype *cft, 1390static int cfq_print_weight(struct cgroup *cgrp, struct cftype *cft,
1398 struct seq_file *sf) 1391 struct seq_file *sf)
1399{ 1392{
1400 seq_printf(sf, "%u\n", cgroup_to_blkio_cgroup(cgrp)->weight); 1393 seq_printf(sf, "%u\n", cgroup_to_blkio_cgroup(cgrp)->cfq_weight);
1401 return 0; 1394 return 0;
1402} 1395}
1403 1396
1404static int blkcg_set_weight_device(struct cgroup *cgrp, struct cftype *cft, 1397static int cfqg_set_weight_device(struct cgroup *cgrp, struct cftype *cft,
1405 const char *buf) 1398 const char *buf)
1406{ 1399{
1407 struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); 1400 struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
1408 struct blkg_policy_data *pd;
1409 struct blkg_conf_ctx ctx; 1401 struct blkg_conf_ctx ctx;
1402 struct cfq_group *cfqg;
1410 int ret; 1403 int ret;
1411 1404
1412 ret = blkg_conf_prep(blkcg, buf, &ctx); 1405 ret = blkg_conf_prep(blkcg, buf, &ctx);
@@ -1414,11 +1407,11 @@ static int blkcg_set_weight_device(struct cgroup *cgrp, struct cftype *cft,
1414 return ret; 1407 return ret;
1415 1408
1416 ret = -EINVAL; 1409 ret = -EINVAL;
1417 pd = ctx.blkg->pd[BLKIO_POLICY_PROP]; 1410 cfqg = blkg_to_cfqg(ctx.blkg);
1418 if (pd && (!ctx.v || (ctx.v >= BLKIO_WEIGHT_MIN && 1411 if (cfqg && (!ctx.v || (ctx.v >= CFQ_WEIGHT_MIN &&
1419 ctx.v <= BLKIO_WEIGHT_MAX))) { 1412 ctx.v <= CFQ_WEIGHT_MAX))) {
1420 pd->conf.weight = ctx.v; 1413 cfqg->dev_weight = ctx.v;
1421 cfq_update_blkio_group_weight(ctx.blkg, ctx.v ?: blkcg->weight); 1414 cfqg->new_weight = cfqg->dev_weight ?: blkcg->cfq_weight;
1422 ret = 0; 1415 ret = 0;
1423 } 1416 }
1424 1417
@@ -1426,23 +1419,23 @@ static int blkcg_set_weight_device(struct cgroup *cgrp, struct cftype *cft,
1426 return ret; 1419 return ret;
1427} 1420}
1428 1421
1429static int blkcg_set_weight(struct cgroup *cgrp, struct cftype *cft, u64 val) 1422static int cfq_set_weight(struct cgroup *cgrp, struct cftype *cft, u64 val)
1430{ 1423{
1431 struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); 1424 struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
1432 struct blkio_group *blkg; 1425 struct blkio_group *blkg;
1433 struct hlist_node *n; 1426 struct hlist_node *n;
1434 1427
1435 if (val < BLKIO_WEIGHT_MIN || val > BLKIO_WEIGHT_MAX) 1428 if (val < CFQ_WEIGHT_MIN || val > CFQ_WEIGHT_MAX)
1436 return -EINVAL; 1429 return -EINVAL;
1437 1430
1438 spin_lock_irq(&blkcg->lock); 1431 spin_lock_irq(&blkcg->lock);
1439 blkcg->weight = (unsigned int)val; 1432 blkcg->cfq_weight = (unsigned int)val;
1440 1433
1441 hlist_for_each_entry(blkg, n, &blkcg->blkg_list, blkcg_node) { 1434 hlist_for_each_entry(blkg, n, &blkcg->blkg_list, blkcg_node) {
1442 struct blkg_policy_data *pd = blkg->pd[BLKIO_POLICY_PROP]; 1435 struct cfq_group *cfqg = blkg_to_cfqg(blkg);
1443 1436
1444 if (pd && !pd->conf.weight) 1437 if (cfqg && !cfqg->dev_weight)
1445 cfq_update_blkio_group_weight(blkg, blkcg->weight); 1438 cfqg->new_weight = blkcg->cfq_weight;
1446 } 1439 }
1447 1440
1448 spin_unlock_irq(&blkcg->lock); 1441 spin_unlock_irq(&blkcg->lock);
@@ -1480,14 +1473,14 @@ static int cfqg_print_avg_queue_size(struct cgroup *cgrp, struct cftype *cft,
1480static struct cftype cfq_blkcg_files[] = { 1473static struct cftype cfq_blkcg_files[] = {
1481 { 1474 {
1482 .name = "weight_device", 1475 .name = "weight_device",
1483 .read_seq_string = blkcg_print_weight_device, 1476 .read_seq_string = cfqg_print_weight_device,
1484 .write_string = blkcg_set_weight_device, 1477 .write_string = cfqg_set_weight_device,
1485 .max_write_len = 256, 1478 .max_write_len = 256,
1486 }, 1479 },
1487 { 1480 {
1488 .name = "weight", 1481 .name = "weight",
1489 .read_seq_string = blkcg_print_weight, 1482 .read_seq_string = cfq_print_weight,
1490 .write_u64 = blkcg_set_weight, 1483 .write_u64 = cfq_set_weight,
1491 }, 1484 },
1492 { 1485 {
1493 .name = "time", 1486 .name = "time",
@@ -3983,7 +3976,7 @@ static int cfq_init_queue(struct request_queue *q)
3983 return -ENOMEM; 3976 return -ENOMEM;
3984 } 3977 }
3985 3978
3986 cfqd->root_group->weight = 2*BLKIO_WEIGHT_DEFAULT; 3979 cfqd->root_group->weight = 2 * CFQ_WEIGHT_DEFAULT;
3987 3980
3988 /* 3981 /*
3989 * Not strictly needed (since RB_ROOT just clears the node and we 3982 * Not strictly needed (since RB_ROOT just clears the node and we