lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4BF6480D.4080902@cn.fujitsu.com>
Date:	Fri, 21 May 2010 16:45:01 +0800
From:	Gui Jianfeng <guijianfeng@...fujitsu.com>
To:	Vivek Goyal <vgoyal@...hat.com>, Jens Axboe <jens.axboe@...cle.com>
CC:	linux kernel mailing list <linux-kernel@...r.kernel.org>
Subject: [PATCH 3/4] io-controller: a new interface to keep track of io rate
 when group is backlogged

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@...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 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ