From: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
To: Vivek Goyal <vgoyal@redhat.com>, Jens Axboe <jens.axboe@oracle.com>
Cc: linux kernel mailing list <linux-kernel@vger.kernel.org>
Subject: [PATCH 3/4] io-controller: a new interface to keep track of io rate when group is backlogged
Date: Fri, 21 May 2010 16:45:01 +0800 [thread overview]
Message-ID: <4BF6480D.4080902@cn.fujitsu.com> (raw)
In-Reply-To: <4BF64712.1070500@cn.fujitsu.com>
Add a new interface to keep track of io rate of a group when it's backlogged.
If the group is dequeued, io rate isn't calculated.
Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
---
block/blk-cgroup.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
block/blk-cgroup.h | 5 +++++
2 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 5b47655..01a8c4e 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -611,6 +611,49 @@ static uint64_t blkio_get_stat(struct blkio_group *blkg,
delta, cb, dev);
}
+ if (type == BLKIO_STAT_ACTIVE_RATE) {
+ uint64_t bytes;
+ uint64_t delta;
+
+ delta = get_jiffies_64() -
+ blkg->stats.active_start_time;
+
+ list_for_each_entry(blkiop, &blkio_list, list) {
+ ret = blkiop->ops.blkio_is_blkg_active_fn(blkg);
+ if (!ret) {
+ delta = 0;
+ break;
+ }
+ }
+
+ if (delta == 0)
+ return 0;
+
+ delta = jiffies_to_msecs(delta);
+
+ for (sub_type = BLKIO_STAT_READ; sub_type < BLKIO_STAT_TOTAL;
+ sub_type++) {
+ blkio_get_key_name(sub_type, dev, key_str,
+ MAX_KEY_LEN, false);
+
+ bytes = blkg->stats.stat_arr
+ [BLKIO_STAT_ACTIVE_BYTES][sub_type];
+ do_div(bytes, delta);
+ cb->fill(cb, key_str, bytes);
+ }
+
+ disk_total = blkg->stats.stat_arr[BLKIO_STAT_ACTIVE_BYTES]
+ [BLKIO_STAT_READ] +
+ blkg->stats.stat_arr[BLKIO_STAT_ACTIVE_BYTES]
+ [BLKIO_STAT_WRITE];
+
+ do_div(disk_total, delta);
+ blkio_get_key_name(BLKIO_STAT_TOTAL, dev,
+ key_str, MAX_KEY_LEN, false);
+ cb->fill(cb, key_str, disk_total);
+ return 0;
+ }
+
#ifdef CONFIG_DEBUG_BLK_CGROUP
if (type == BLKIO_STAT_AVG_QUEUE_SIZE) {
uint64_t sum = blkg->stats.avg_queue_size_sum;
@@ -681,6 +724,7 @@ SHOW_FUNCTION_PER_GROUP(sectors, BLKIO_STAT_SECTORS, 0);
SHOW_FUNCTION_PER_GROUP(io_service_bytes, BLKIO_STAT_SERVICE_BYTES, 1);
SHOW_FUNCTION_PER_GROUP(io_active_bytes, BLKIO_STAT_ACTIVE_BYTES, 1);
SHOW_FUNCTION_PER_GROUP(io_active_time, BLKIO_STAT_ACTIVE_TIME, 0);
+SHOW_FUNCTION_PER_GROUP(io_active_rate, BLKIO_STAT_ACTIVE_RATE, 0);
SHOW_FUNCTION_PER_GROUP(io_serviced, BLKIO_STAT_SERVICED, 1);
SHOW_FUNCTION_PER_GROUP(io_service_time, BLKIO_STAT_SERVICE_TIME, 1);
SHOW_FUNCTION_PER_GROUP(io_wait_time, BLKIO_STAT_WAIT_TIME, 1);
@@ -915,6 +959,10 @@ struct cftype blkio_files[] = {
.read_map = blkiocg_io_active_time_read,
},
{
+ .name = "io_active_rate",
+ .read_map = blkiocg_io_active_rate_read,
+ },
+ {
.name = "io_serviced",
.read_map = blkiocg_io_serviced_read,
},
diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h
index 2ae7976..cd72e7f 100644
--- a/block/blk-cgroup.h
+++ b/block/blk-cgroup.h
@@ -40,6 +40,11 @@ enum stat_type {
* reset when group enqueued.
*/
BLKIO_STAT_ACTIVE_TIME,
+ /*
+ * io rate (in bytes/ms) of the group since group became backlogged,
+ * if group is dequeued, show zero.
+ */
+ BLKIO_STAT_ACTIVE_RATE,
/* Total IOs serviced, post merge */
BLKIO_STAT_SERVICED,
/* Total time spent waiting in scheduler queue in ns */
-- 1.5.4.rc3
next prev parent reply other threads:[~2010-05-21 8:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-21 8:40 [PATCH 0/4] io-controller: Add new interfaces to trace backlogged group status Gui Jianfeng
2010-05-21 8:43 ` [PATCH 1/4] io-controller: a new interface to keep track of bytes during group is backlogged Gui Jianfeng
2010-05-21 8:44 ` [PATCH 2/4] io-controller: a new interface to keep track of the time since group bacame backlogged Gui Jianfeng
2010-05-21 8:45 ` Gui Jianfeng [this message]
2010-05-21 8:46 ` [PATCH 4/4] io-controller: Document for active bytes, time and rate Gui Jianfeng
2010-05-26 18:57 ` Randy Dunlap
2010-05-21 13:17 ` [PATCH 0/4] io-controller: Add new interfaces to trace backlogged group status Vivek Goyal
2010-05-24 1:12 ` Gui Jianfeng
2010-05-24 21:22 ` Vivek Goyal
2010-05-25 1:37 ` Gui Jianfeng
2010-05-25 2:03 ` Vivek Goyal
2010-05-25 3:00 ` Gui Jianfeng
2010-05-25 13:25 ` Vivek Goyal
2010-06-11 5:10 ` Divyesh Shah
2010-06-11 6:31 ` Gui Jianfeng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BF6480D.4080902@cn.fujitsu.com \
--to=guijianfeng@cn.fujitsu.com \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vgoyal@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox