diff options
| author | Tejun Heo <tj@kernel.org> | 2012-04-01 17:38:45 -0400 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2012-04-01 17:38:45 -0400 |
| commit | 5bc4afb1ec6aa562fac4d9aba34d957ee42f5813 (patch) | |
| tree | dfef1de2dcb71beab3150ffecf6ae564d326ffba /block | |
| parent | d366e7ec41882791c970dfb7c67b737be8c3a174 (diff) | |
blkcg: drop BLKCG_STAT_{PRIV|POL|OFF} macros
Now that all stat handling code lives in policy implementations,
there's no need to encode policy ID in cft->private.
* Export blkcg_prfill_[rw]stat() from blkcg, remove
blkcg_print_[rw]stat(), and implement cfqg_print_[rw]stat() which
use hard-code BLKIO_POLICY_PROP.
* Use cft->private for offset of the target field directly and drop
BLKCG_STAT_{PRIV|POL|OFF}().
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'block')
| -rw-r--r-- | block/blk-cgroup.c | 48 | ||||
| -rw-r--r-- | block/blk-cgroup.h | 11 | ||||
| -rw-r--r-- | block/blk-throttle.c | 12 | ||||
| -rw-r--r-- | block/cfq-iosched.c | 85 |
4 files changed, 72 insertions, 84 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 7de19d7954c7..9449c383b7ba 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
| @@ -430,43 +430,35 @@ u64 __blkg_prfill_rwstat(struct seq_file *sf, void *pdata, | |||
| 430 | return v; | 430 | return v; |
| 431 | } | 431 | } |
| 432 | 432 | ||
| 433 | static u64 blkg_prfill_stat(struct seq_file *sf, void *pdata, int off) | 433 | /** |
| 434 | * blkg_prfill_stat - prfill callback for blkg_stat | ||
| 435 | * @sf: seq_file to print to | ||
| 436 | * @pdata: policy private data of interest | ||
| 437 | * @off: offset to the blkg_stat in @pdata | ||
| 438 | * | ||
| 439 | * prfill callback for printing a blkg_stat. | ||
| 440 | */ | ||
| 441 | u64 blkg_prfill_stat(struct seq_file *sf, void *pdata, int off) | ||
| 434 | { | 442 | { |
| 435 | return __blkg_prfill_u64(sf, pdata, blkg_stat_read(pdata + off)); | 443 | return __blkg_prfill_u64(sf, pdata, blkg_stat_read(pdata + off)); |
| 436 | } | 444 | } |
| 445 | EXPORT_SYMBOL_GPL(blkg_prfill_stat); | ||
| 437 | 446 | ||
| 438 | static u64 blkg_prfill_rwstat(struct seq_file *sf, void *pdata, int off) | 447 | /** |
| 448 | * blkg_prfill_rwstat - prfill callback for blkg_rwstat | ||
| 449 | * @sf: seq_file to print to | ||
| 450 | * @pdata: policy private data of interest | ||
| 451 | * @off: offset to the blkg_rwstat in @pdata | ||
| 452 | * | ||
| 453 | * prfill callback for printing a blkg_rwstat. | ||
| 454 | */ | ||
| 455 | u64 blkg_prfill_rwstat(struct seq_file *sf, void *pdata, int off) | ||
| 439 | { | 456 | { |
| 440 | struct blkg_rwstat rwstat = blkg_rwstat_read(pdata + off); | 457 | struct blkg_rwstat rwstat = blkg_rwstat_read(pdata + off); |
| 441 | 458 | ||
| 442 | return __blkg_prfill_rwstat(sf, pdata, &rwstat); | 459 | return __blkg_prfill_rwstat(sf, pdata, &rwstat); |
| 443 | } | 460 | } |
| 444 | 461 | EXPORT_SYMBOL_GPL(blkg_prfill_rwstat); | |
| 445 | /* print blkg_stat specified by BLKCG_STAT_PRIV() */ | ||
| 446 | int blkcg_print_stat(struct cgroup *cgrp, struct cftype *cft, | ||
| 447 | struct seq_file *sf) | ||
| 448 | { | ||
| 449 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); | ||
| 450 | |||
| 451 | blkcg_print_blkgs(sf, blkcg, blkg_prfill_stat, | ||
| 452 | BLKCG_STAT_POL(cft->private), | ||
| 453 | BLKCG_STAT_OFF(cft->private), false); | ||
| 454 | return 0; | ||
| 455 | } | ||
| 456 | EXPORT_SYMBOL_GPL(blkcg_print_stat); | ||
| 457 | |||
| 458 | /* print blkg_rwstat specified by BLKCG_STAT_PRIV() */ | ||
| 459 | int blkcg_print_rwstat(struct cgroup *cgrp, struct cftype *cft, | ||
| 460 | struct seq_file *sf) | ||
| 461 | { | ||
| 462 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); | ||
| 463 | |||
| 464 | blkcg_print_blkgs(sf, blkcg, blkg_prfill_rwstat, | ||
| 465 | BLKCG_STAT_POL(cft->private), | ||
| 466 | BLKCG_STAT_OFF(cft->private), true); | ||
| 467 | return 0; | ||
| 468 | } | ||
| 469 | EXPORT_SYMBOL_GPL(blkcg_print_rwstat); | ||
| 470 | 462 | ||
| 471 | /** | 463 | /** |
| 472 | * blkg_conf_prep - parse and prepare for per-blkg config update | 464 | * blkg_conf_prep - parse and prepare for per-blkg config update |
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h index c930895bfac9..ca0ff7c0ffb6 100644 --- a/block/blk-cgroup.h +++ b/block/blk-cgroup.h | |||
| @@ -34,11 +34,6 @@ enum blkio_policy_id { | |||
| 34 | #define CFQ_WEIGHT_MAX 1000 | 34 | #define CFQ_WEIGHT_MAX 1000 |
| 35 | #define CFQ_WEIGHT_DEFAULT 500 | 35 | #define CFQ_WEIGHT_DEFAULT 500 |
| 36 | 36 | ||
| 37 | /* cft->private [un]packing for stat printing */ | ||
| 38 | #define BLKCG_STAT_PRIV(pol, off) (((unsigned)(pol) << 16) | (off)) | ||
| 39 | #define BLKCG_STAT_POL(prv) ((unsigned)(prv) >> 16) | ||
| 40 | #define BLKCG_STAT_OFF(prv) ((unsigned)(prv) & 0xffff) | ||
| 41 | |||
| 42 | enum blkg_rwstat_type { | 37 | enum blkg_rwstat_type { |
| 43 | BLKG_RWSTAT_READ, | 38 | BLKG_RWSTAT_READ, |
| 44 | BLKG_RWSTAT_WRITE, | 39 | BLKG_RWSTAT_WRITE, |
| @@ -131,10 +126,8 @@ void blkcg_print_blkgs(struct seq_file *sf, struct blkio_cgroup *blkcg, | |||
| 131 | u64 __blkg_prfill_u64(struct seq_file *sf, void *pdata, u64 v); | 126 | u64 __blkg_prfill_u64(struct seq_file *sf, void *pdata, u64 v); |
| 132 | u64 __blkg_prfill_rwstat(struct seq_file *sf, void *pdata, | 127 | u64 __blkg_prfill_rwstat(struct seq_file *sf, void *pdata, |
| 133 | const struct blkg_rwstat *rwstat); | 128 | const struct blkg_rwstat *rwstat); |
| 134 | int blkcg_print_stat(struct cgroup *cgrp, struct cftype *cft, | 129 | u64 blkg_prfill_stat(struct seq_file *sf, void *pdata, int off); |
| 135 | struct seq_file *sf); | 130 | u64 blkg_prfill_rwstat(struct seq_file *sf, void *pdata, int off); |
| 136 | int blkcg_print_rwstat(struct cgroup *cgrp, struct cftype *cft, | ||
| 137 | struct seq_file *sf); | ||
| 138 | 131 | ||
| 139 | struct blkg_conf_ctx { | 132 | struct blkg_conf_ctx { |
| 140 | struct gendisk *disk; | 133 | struct gendisk *disk; |
diff --git a/block/blk-throttle.c b/block/blk-throttle.c index bd6dbfe1e4e9..60240142f5ae 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c | |||
| @@ -941,15 +941,13 @@ static u64 tg_prfill_cpu_rwstat(struct seq_file *sf, void *pdata, int off) | |||
| 941 | return __blkg_prfill_rwstat(sf, pdata, &rwstat); | 941 | return __blkg_prfill_rwstat(sf, pdata, &rwstat); |
| 942 | } | 942 | } |
| 943 | 943 | ||
| 944 | /* print per-cpu blkg_rwstat specified by BLKCG_STAT_PRIV() */ | ||
| 945 | static int tg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft, | 944 | static int tg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft, |
| 946 | struct seq_file *sf) | 945 | struct seq_file *sf) |
| 947 | { | 946 | { |
| 948 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); | 947 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); |
| 949 | 948 | ||
| 950 | blkcg_print_blkgs(sf, blkcg, tg_prfill_cpu_rwstat, | 949 | blkcg_print_blkgs(sf, blkcg, tg_prfill_cpu_rwstat, BLKIO_POLICY_THROTL, |
| 951 | BLKCG_STAT_POL(cft->private), | 950 | cft->private, true); |
| 952 | BLKCG_STAT_OFF(cft->private), true); | ||
| 953 | return 0; | 951 | return 0; |
| 954 | } | 952 | } |
| 955 | 953 | ||
| @@ -1067,14 +1065,12 @@ static struct cftype throtl_files[] = { | |||
| 1067 | }, | 1065 | }, |
| 1068 | { | 1066 | { |
| 1069 | .name = "throttle.io_service_bytes", | 1067 | .name = "throttle.io_service_bytes", |
| 1070 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_THROTL, | 1068 | .private = offsetof(struct tg_stats_cpu, service_bytes), |
| 1071 | offsetof(struct tg_stats_cpu, service_bytes)), | ||
| 1072 | .read_seq_string = tg_print_cpu_rwstat, | 1069 | .read_seq_string = tg_print_cpu_rwstat, |
| 1073 | }, | 1070 | }, |
| 1074 | { | 1071 | { |
| 1075 | .name = "throttle.io_serviced", | 1072 | .name = "throttle.io_serviced", |
| 1076 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_THROTL, | 1073 | .private = offsetof(struct tg_stats_cpu, serviced), |
| 1077 | offsetof(struct tg_stats_cpu, serviced)), | ||
| 1078 | .read_seq_string = tg_print_cpu_rwstat, | 1074 | .read_seq_string = tg_print_cpu_rwstat, |
| 1079 | }, | 1075 | }, |
| 1080 | { } /* terminate */ | 1076 | { } /* terminate */ |
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index fd505f721f61..cff8b5ba6208 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c | |||
| @@ -1441,6 +1441,26 @@ static int cfq_set_weight(struct cgroup *cgrp, struct cftype *cft, u64 val) | |||
| 1441 | return 0; | 1441 | return 0; |
| 1442 | } | 1442 | } |
| 1443 | 1443 | ||
| 1444 | static int cfqg_print_stat(struct cgroup *cgrp, struct cftype *cft, | ||
| 1445 | struct seq_file *sf) | ||
| 1446 | { | ||
| 1447 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); | ||
| 1448 | |||
| 1449 | blkcg_print_blkgs(sf, blkcg, blkg_prfill_stat, BLKIO_POLICY_PROP, | ||
| 1450 | cft->private, false); | ||
| 1451 | return 0; | ||
| 1452 | } | ||
| 1453 | |||
| 1454 | static int cfqg_print_rwstat(struct cgroup *cgrp, struct cftype *cft, | ||
| 1455 | struct seq_file *sf) | ||
| 1456 | { | ||
| 1457 | struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp); | ||
| 1458 | |||
| 1459 | blkcg_print_blkgs(sf, blkcg, blkg_prfill_rwstat, BLKIO_POLICY_PROP, | ||
| 1460 | cft->private, true); | ||
| 1461 | return 0; | ||
| 1462 | } | ||
| 1463 | |||
| 1444 | #ifdef CONFIG_DEBUG_BLK_CGROUP | 1464 | #ifdef CONFIG_DEBUG_BLK_CGROUP |
| 1445 | static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf, void *pdata, int off) | 1465 | static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf, void *pdata, int off) |
| 1446 | { | 1466 | { |
| @@ -1482,51 +1502,43 @@ static struct cftype cfq_blkcg_files[] = { | |||
| 1482 | }, | 1502 | }, |
| 1483 | { | 1503 | { |
| 1484 | .name = "time", | 1504 | .name = "time", |
| 1485 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_PROP, | 1505 | .private = offsetof(struct cfq_group, stats.time), |
| 1486 | offsetof(struct cfq_group, stats.time)), | 1506 | .read_seq_string = cfqg_print_stat, |
| 1487 | .read_seq_string = blkcg_print_stat, | ||
| 1488 | }, | 1507 | }, |
| 1489 | { | 1508 | { |
| 1490 | .name = "sectors", | 1509 | .name = "sectors", |
| 1491 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_PROP, | 1510 | .private = offsetof(struct cfq_group, stats.sectors), |
| 1492 | offsetof(struct cfq_group, stats.sectors)), | 1511 | .read_seq_string = cfqg_print_stat, |
| 1493 | .read_seq_string = blkcg_print_stat, | ||
| 1494 | }, | 1512 | }, |
| 1495 | { | 1513 | { |
| 1496 | .name = "io_service_bytes", | 1514 | .name = "io_service_bytes", |
| 1497 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_PROP, | 1515 | .private = offsetof(struct cfq_group, stats.service_bytes), |
| 1498 | offsetof(struct cfq_group, stats.service_bytes)), | 1516 | .read_seq_string = cfqg_print_rwstat, |
| 1499 | .read_seq_string = blkcg_print_rwstat, | ||
| 1500 | }, | 1517 | }, |
| 1501 | { | 1518 | { |
| 1502 | .name = "io_serviced", | 1519 | .name = "io_serviced", |
| 1503 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_PROP, | 1520 | .private = offsetof(struct cfq_group, stats.serviced), |
| 1504 | offsetof(struct cfq_group, stats.serviced)), | 1521 | .read_seq_string = cfqg_print_rwstat, |
| 1505 | .read_seq_string = blkcg_print_rwstat, | ||
| 1506 | }, | 1522 | }, |
| 1507 | { | 1523 | { |
| 1508 | .name = "io_service_time", | 1524 | .name = "io_service_time", |
| 1509 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_PROP, | 1525 | .private = offsetof(struct cfq_group, stats.service_time), |
| 1510 | offsetof(struct cfq_group, stats.service_time)), | 1526 | .read_seq_string = cfqg_print_rwstat, |
| 1511 | .read_seq_string = blkcg_print_rwstat, | ||
| 1512 | }, | 1527 | }, |
| 1513 | { | 1528 | { |
| 1514 | .name = "io_wait_time", | 1529 | .name = "io_wait_time", |
| 1515 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_PROP, | 1530 | .private = offsetof(struct cfq_group, stats.wait_time), |
| 1516 | offsetof(struct cfq_group, stats.wait_time)), | 1531 | .read_seq_string = cfqg_print_rwstat, |
| 1517 | .read_seq_string = blkcg_print_rwstat, | ||
| 1518 | }, | 1532 | }, |
| 1519 | { | 1533 | { |
| 1520 | .name = "io_merged", | 1534 | .name = "io_merged", |
| 1521 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_PROP, | 1535 | .private = offsetof(struct cfq_group, stats.merged), |
| 1522 | offsetof(struct cfq_group, stats.merged)), | 1536 | .read_seq_string = cfqg_print_rwstat, |
| 1523 | .read_seq_string = blkcg_print_rwstat, | ||
| 1524 | }, | 1537 | }, |
| 1525 | { | 1538 | { |
| 1526 | .name = "io_queued", | 1539 | .name = "io_queued", |
| 1527 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_PROP, | 1540 | .private = offsetof(struct cfq_group, stats.queued), |
| 1528 | offsetof(struct cfq_group, stats.queued)), | 1541 | .read_seq_string = cfqg_print_rwstat, |
| 1529 | .read_seq_string = blkcg_print_rwstat, | ||
| 1530 | }, | 1542 | }, |
| 1531 | #ifdef CONFIG_DEBUG_BLK_CGROUP | 1543 | #ifdef CONFIG_DEBUG_BLK_CGROUP |
| 1532 | { | 1544 | { |
| @@ -1535,33 +1547,28 @@ static struct cftype cfq_blkcg_files[] = { | |||
| 1535 | }, | 1547 | }, |
| 1536 | { | 1548 | { |
| 1537 | .name = "group_wait_time", | 1549 | .name = "group_wait_time", |
| 1538 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_PROP, | 1550 | .private = offsetof(struct cfq_group, stats.group_wait_time), |
| 1539 | offsetof(struct cfq_group, stats.group_wait_time)), | 1551 | .read_seq_string = cfqg_print_stat, |
| 1540 | .read_seq_string = blkcg_print_stat, | ||
| 1541 | }, | 1552 | }, |
| 1542 | { | 1553 | { |
| 1543 | .name = "idle_time", | 1554 | .name = "idle_time", |
| 1544 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_PROP, | 1555 | .private = offsetof(struct cfq_group, stats.idle_time), |
| 1545 | offsetof(struct cfq_group, stats.idle_time)), | 1556 | .read_seq_string = cfqg_print_stat, |
| 1546 | .read_seq_string = blkcg_print_stat, | ||
| 1547 | }, | 1557 | }, |
| 1548 | { | 1558 | { |
| 1549 | .name = "empty_time", | 1559 | .name = "empty_time", |
| 1550 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_PROP, | 1560 | .private = offsetof(struct cfq_group, stats.empty_time), |
| 1551 | offsetof(struct cfq_group, stats.empty_time)), | 1561 | .read_seq_string = cfqg_print_stat, |
| 1552 | .read_seq_string = blkcg_print_stat, | ||
| 1553 | }, | 1562 | }, |
| 1554 | { | 1563 | { |
| 1555 | .name = "dequeue", | 1564 | .name = "dequeue", |
| 1556 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_PROP, | 1565 | .private = offsetof(struct cfq_group, stats.dequeue), |
| 1557 | offsetof(struct cfq_group, stats.dequeue)), | 1566 | .read_seq_string = cfqg_print_stat, |
| 1558 | .read_seq_string = blkcg_print_stat, | ||
| 1559 | }, | 1567 | }, |
| 1560 | { | 1568 | { |
| 1561 | .name = "unaccounted_time", | 1569 | .name = "unaccounted_time", |
| 1562 | .private = BLKCG_STAT_PRIV(BLKIO_POLICY_PROP, | 1570 | .private = offsetof(struct cfq_group, stats.unaccounted_time), |
| 1563 | offsetof(struct cfq_group, stats.unaccounted_time)), | 1571 | .read_seq_string = cfqg_print_stat, |
| 1564 | .read_seq_string = blkcg_print_stat, | ||
| 1565 | }, | 1572 | }, |
| 1566 | #endif /* CONFIG_DEBUG_BLK_CGROUP */ | 1573 | #endif /* CONFIG_DEBUG_BLK_CGROUP */ |
| 1567 | { } /* terminate */ | 1574 | { } /* terminate */ |
