All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	jens.axboe-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
	nauman-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	dpshah-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org
Cc: akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
	snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Subject: [PATCH 07/19] io-controller: Export disk time used and nr sectors dipatched through cgroups
Date: Mon,  8 Jun 2009 22:08:50 -0400	[thread overview]
Message-ID: <1244513342-11758-8-git-send-email-vgoyal__37546.7845974073$1244515062$gmane$org@redhat.com> (raw)
In-Reply-To: <1244513342-11758-1-git-send-email-vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

o This patch exports some statistics through cgroup interface. Two of the
  statistics currently exported are actual disk time assigned to the cgroup
  and actual number of sectors dispatched to disk on behalf of this cgroup.

Signed-off-by: Vivek Goyal <vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 block/elevator-fq.c |   89 +++++++++++++++++++++++++++++++++++++++++++++++---
 block/elevator-fq.h |   10 ++++++
 2 files changed, 93 insertions(+), 6 deletions(-)

diff --git a/block/elevator-fq.c b/block/elevator-fq.c
index 1640949..7165902 100644
--- a/block/elevator-fq.c
+++ b/block/elevator-fq.c
@@ -13,6 +13,7 @@
 #include <linux/blkdev.h>
 #include "elevator-fq.h"
 #include <linux/blktrace_api.h>
+#include <linux/seq_file.h>
 
 /* Values taken from cfq */
 const int elv_slice_sync = HZ / 10;
@@ -916,12 +917,15 @@ struct io_entity *bfq_lookup_next_entity(struct io_sched_data *sd,
 	return entity;
 }
 
-void entity_served(struct io_entity *entity, bfq_service_t served)
+void entity_served(struct io_entity *entity, bfq_service_t served,
+					bfq_service_t nr_sectors)
 {
 	struct io_service_tree *st;
 	for_each_entity(entity) {
 		st = io_entity_service_tree(entity);
 		entity->service += served;
+		entity->total_service += served;
+		entity->total_sector_service += nr_sectors;
 		BUG_ON(st->wsum == 0);
 		st->vtime += bfq_delta(served, st->wsum);
 		bfq_forget_idle(st);
@@ -1082,6 +1086,66 @@ STORE_FUNCTION(weight, 1, WEIGHT_MAX);
 STORE_FUNCTION(ioprio_class, IOPRIO_CLASS_RT, IOPRIO_CLASS_IDLE);
 #undef STORE_FUNCTION
 
+static int io_cgroup_disk_time_read(struct cgroup *cgroup,
+				struct cftype *cftype, struct seq_file *m)
+{
+	struct io_cgroup *iocg;
+	struct io_group *iog;
+	struct hlist_node *n;
+
+	if (!cgroup_lock_live_group(cgroup))
+		return -ENODEV;
+
+	iocg = cgroup_to_io_cgroup(cgroup);
+
+	spin_lock_irq(&iocg->lock);
+	hlist_for_each_entry_rcu(iog, n, &iocg->group_data, group_node) {
+		/*
+		 * There might be groups which are not functional and
+		 * waiting to be reclaimed upon cgoup deletion.
+		 */
+		if (iog->key) {
+			seq_printf(m, "%u %u %lu\n", MAJOR(iog->dev),
+					MINOR(iog->dev),
+					iog->entity.total_service);
+		}
+	}
+	spin_unlock_irq(&iocg->lock);
+	cgroup_unlock();
+
+	return 0;
+}
+
+static int io_cgroup_disk_sectors_read(struct cgroup *cgroup,
+				struct cftype *cftype, struct seq_file *m)
+{
+	struct io_cgroup *iocg;
+	struct io_group *iog;
+	struct hlist_node *n;
+
+	if (!cgroup_lock_live_group(cgroup))
+		return -ENODEV;
+
+	iocg = cgroup_to_io_cgroup(cgroup);
+
+	spin_lock_irq(&iocg->lock);
+	hlist_for_each_entry_rcu(iog, n, &iocg->group_data, group_node) {
+		/*
+		 * There might be groups which are not functional and
+		 * waiting to be reclaimed upon cgoup deletion.
+		 */
+		if (iog->key) {
+			seq_printf(m, "%u %u %lu\n", MAJOR(iog->dev),
+					MINOR(iog->dev),
+					iog->entity.total_sector_service);
+		}
+	}
+	spin_unlock_irq(&iocg->lock);
+	cgroup_unlock();
+
+	return 0;
+}
+
 /**
  * bfq_group_chain_alloc - allocate a chain of groups.
  * @bfqd: queue descriptor.
@@ -1092,7 +1156,7 @@ STORE_FUNCTION(ioprio_class, IOPRIO_CLASS_RT, IOPRIO_CLASS_IDLE);
  * to the root has already an allocated group on @bfqd.
  */
 struct io_group *io_group_chain_alloc(struct request_queue *q, void *key,
-					struct cgroup *cgroup)
+					struct cgroup *cgroup, struct bio *bio)
 {
 	struct io_cgroup *iocg;
 	struct io_group *iog, *leaf = NULL, *prev = NULL;
@@ -1131,6 +1195,11 @@ struct io_group *io_group_chain_alloc(struct request_queue *q, void *key,
 
 		iog->iocg_id = css_id(&iocg->css);
 
+		if (bio) {
+			struct gendisk *disk = bio->bi_bdev->bd_disk;
+			iog->dev = MKDEV(disk->major, disk->first_minor);
+		}
+
 		if (leaf == NULL) {
 			leaf = iog;
 			prev = leaf;
@@ -1234,7 +1303,7 @@ void io_group_chain_link(struct request_queue *q, void *key,
  */
 struct io_group *io_find_alloc_group(struct request_queue *q,
 			struct cgroup *cgroup, struct elv_fq_data *efqd,
-			int create)
+			int create, struct bio *bio)
 {
 	struct io_cgroup *iocg = cgroup_to_io_cgroup(cgroup);
 	struct io_group *iog = NULL;
@@ -1253,7 +1322,7 @@ struct io_group *io_find_alloc_group(struct request_queue *q,
 	if (iog != NULL || !create)
 		goto end;
 
-	iog = io_group_chain_alloc(q, key, cgroup);
+	iog = io_group_chain_alloc(q, key, cgroup, bio);
 	if (iog != NULL)
 		io_group_chain_link(q, key, cgroup, iog, efqd);
 
@@ -1283,7 +1352,7 @@ struct io_group *io_get_io_group(struct request_queue *q, int create)
 
 	rcu_read_lock();
 	cgroup = task_cgroup(current, io_subsys_id);
-	iog = io_find_alloc_group(q, cgroup, efqd, create);
+	iog = io_find_alloc_group(q, cgroup, efqd, create, NULL);
 	if (!iog) {
 		if (create)
 			iog = efqd->root_group;
@@ -1358,6 +1427,14 @@ struct cftype bfqio_files[] = {
 		.read_u64 = io_cgroup_ioprio_class_read,
 		.write_u64 = io_cgroup_ioprio_class_write,
 	},
+	{
+		.name = "disk_time",
+		.read_seq_string = io_cgroup_disk_time_read,
+	},
+	{
+		.name = "disk_sectors",
+		.read_seq_string = io_cgroup_disk_sectors_read,
+	},
 };
 
 int iocg_populate(struct cgroup_subsys *subsys, struct cgroup *cgroup)
@@ -1811,7 +1888,7 @@ EXPORT_SYMBOL(elv_get_slice_idle);
 
 void elv_ioq_served(struct io_queue *ioq, bfq_service_t served)
 {
-	entity_served(&ioq->entity, served);
+	entity_served(&ioq->entity, served, ioq->nr_sectors);
 }
 
 /* Tells whether ioq is queued in root group or not */
diff --git a/block/elevator-fq.h b/block/elevator-fq.h
index a37be0f..447cea0 100644
--- a/block/elevator-fq.h
+++ b/block/elevator-fq.h
@@ -147,6 +147,13 @@ struct io_entity {
 	unsigned short ioprio_class, new_ioprio_class;
 
 	int ioprio_changed;
+
+	/*
+	 * Keep track of total service received by this entity. Keep the
+	 * stats both for time slices and number of sectors dispatched
+	 */
+	unsigned long total_service;
+	unsigned long total_sector_service;
 };
 
 /*
@@ -234,6 +241,9 @@ struct io_group {
 
 	int deleting;
 	unsigned short iocg_id;
+
+	/* The device MKDEV(major, minor), this group has been created for */
+	dev_t	dev;
 };
 
 /**
-- 
1.6.0.6

  parent reply	other threads:[~2009-06-09  2:08 UTC|newest]

Thread overview: 130+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-09  2:08 [RFC] IO scheduler based IO controller V4 Vivek Goyal
2009-06-09  2:08 ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 01/19] io-controller: Documentation Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 02/19] io-controller: Common flat fair queuing code in elevaotor layer Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-09  8:45   ` Gui Jianfeng
2009-06-09  8:45     ` Gui Jianfeng
2009-06-16  3:54   ` Gui Jianfeng
2009-06-16  3:54     ` Gui Jianfeng
2009-06-16 13:02     ` Vivek Goyal
2009-06-16 13:02       ` Vivek Goyal
     [not found]     ` <4A37175C.80906-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-06-16 13:02       ` Vivek Goyal
     [not found]   ` <1244513342-11758-3-git-send-email-vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-06-09  8:45     ` Gui Jianfeng
2009-06-16  3:54     ` Gui Jianfeng
2009-06-16 19:44     ` Divyesh Shah
2009-06-16 19:44   ` Divyesh Shah
2009-06-16 19:44     ` Divyesh Shah
2009-06-17 12:59     ` Vivek Goyal
2009-06-17 12:59       ` Vivek Goyal
     [not found]     ` <af41c7c40906161244q61fd47c5u1a10243c8839938-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-06-17 12:59       ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 03/19] io-controller: Charge for time slice based on average disk rate Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 04/19] io-controller: Modify cfq to make use of flat elevator fair queuing Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-11  6:12   ` Gui Jianfeng
2009-06-11 14:21     ` Vivek Goyal
2009-06-11 14:21       ` Vivek Goyal
     [not found]     ` <4A30A05C.4060703-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-06-11 14:21       ` Vivek Goyal
     [not found]   ` <1244513342-11758-5-git-send-email-vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-06-11  6:12     ` Gui Jianfeng
2009-06-15  8:56     ` Gui Jianfeng
2009-06-17  2:22     ` Gui Jianfeng
2009-06-15  8:56   ` Gui Jianfeng
2009-06-15  8:56     ` Gui Jianfeng
2009-06-15 13:02     ` Vivek Goyal
2009-06-15 13:02       ` Vivek Goyal
     [not found]     ` <4A360CD2.8060707-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-06-15 13:02       ` Vivek Goyal
2009-06-17  2:22   ` Gui Jianfeng
     [not found]     ` <4A385374.7060708-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-06-17 13:00       ` Vivek Goyal
2009-06-17 13:00     ` Vivek Goyal
2009-06-17 13:00       ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 05/19] io-controller: Common hierarchical fair queuing code in elevaotor layer Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 06/19] io-controller: cfq changes to use " Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 07/19] io-controller: Export disk time used and nr sectors dipatched through cgroups Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 08/19] io-controller: idle for sometime on sync queue before expiring it Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
     [not found] ` <1244513342-11758-1-git-send-email-vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-06-09  2:08   ` [PATCH 01/19] io-controller: Documentation Vivek Goyal
2009-06-09  2:08   ` [PATCH 02/19] io-controller: Common flat fair queuing code in elevaotor layer Vivek Goyal
2009-06-09  2:08   ` [PATCH 03/19] io-controller: Charge for time slice based on average disk rate Vivek Goyal
2009-06-09  2:08   ` [PATCH 04/19] io-controller: Modify cfq to make use of flat elevator fair queuing Vivek Goyal
2009-06-09  2:08   ` [PATCH 05/19] io-controller: Common hierarchical fair queuing code in elevaotor layer Vivek Goyal
2009-06-09  2:08   ` [PATCH 06/19] io-controller: cfq changes to use " Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal [this message]
2009-06-09  2:08   ` [PATCH 08/19] io-controller: idle for sometime on sync queue before expiring it Vivek Goyal
2009-06-09  2:08   ` [PATCH 09/19] io-controller: Separate out queue and data Vivek Goyal
2009-06-09  2:08   ` [PATCH 10/19] io-conroller: Prepare elevator layer for single queue schedulers Vivek Goyal
2009-06-09  2:08   ` [PATCH 11/19] io-controller: noop changes for hierarchical fair queuing Vivek Goyal
2009-06-09  2:08   ` [PATCH 12/19] io-controller: deadline " Vivek Goyal
2009-06-09  2:08   ` [PATCH 13/19] io-controller: anticipatory " Vivek Goyal
2009-06-09  2:08   ` [PATCH 14/19] blkio_cgroup patches from Ryo to track async bios Vivek Goyal
2009-06-09  2:08   ` [PATCH 15/19] io-controller: map async requests to appropriate cgroup Vivek Goyal
2009-06-09  2:08   ` [PATCH 16/19] io-controller: Per cgroup request descriptor support Vivek Goyal
2009-06-09  2:09   ` [PATCH 17/19] io-controller: Support per cgroup per device weights and io class Vivek Goyal
2009-06-09  2:09   ` [PATCH 18/19] io-controller: Debug hierarchical IO scheduling Vivek Goyal
2009-06-09  2:09   ` [PATCH 19/19] io-controller: experimental debug patch for async queue wait before expiry Vivek Goyal
2009-06-09  4:22   ` [RFC] IO scheduler based IO controller V4 Gui Jianfeng
2009-06-09  2:08 ` [PATCH 09/19] io-controller: Separate out queue and data Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 10/19] io-conroller: Prepare elevator layer for single queue schedulers Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-11  8:10   ` Gui Jianfeng
     [not found]     ` <4A30BC0F.3000401-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-06-11 14:41       ` Vivek Goyal
2009-06-11 14:41     ` Vivek Goyal
2009-06-11 14:41       ` Vivek Goyal
     [not found]       ` <20090611144136.GC27892-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-06-12  0:37         ` Gui Jianfeng
2009-06-12  0:37       ` Gui Jianfeng
2009-06-15 13:00         ` Vivek Goyal
2009-06-15 13:00           ` Vivek Goyal
     [not found]         ` <4A31A345.50705-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-06-15 13:00           ` Vivek Goyal
     [not found]   ` <1244513342-11758-11-git-send-email-vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-06-11  8:10     ` Gui Jianfeng
2009-06-09  2:08 ` [PATCH 11/19] io-controller: noop changes for hierarchical fair queuing Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 12/19] io-controller: deadline " Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 13/19] io-controller: anticipatory " Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 14/19] blkio_cgroup patches from Ryo to track async bios Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 15/19] io-controller: map async requests to appropriate cgroup Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
     [not found]   ` <1244513342-11758-16-git-send-email-vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-06-17  9:17     ` Gui Jianfeng
2009-06-17  9:17   ` Gui Jianfeng
2009-06-17  9:17     ` Gui Jianfeng
2009-06-17 13:00     ` Vivek Goyal
2009-06-17 13:00       ` Vivek Goyal
     [not found]     ` <4A38B4B4.7060101-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-06-17 13:00       ` Vivek Goyal
2009-06-09  2:08 ` [PATCH 16/19] io-controller: Per cgroup request descriptor support Vivek Goyal
2009-06-09  2:08   ` Vivek Goyal
2009-06-09  2:09 ` [PATCH 17/19] io-controller: Support per cgroup per device weights and io class Vivek Goyal
2009-06-09  2:09   ` Vivek Goyal
     [not found]   ` <1244513342-11758-18-git-send-email-vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-06-10  7:44     ` Gui Jianfeng
2009-06-10  7:44   ` Gui Jianfeng
2009-06-10 13:22     ` Vivek Goyal
2009-06-10 13:22       ` Vivek Goyal
     [not found]     ` <4A2F646A.8070403-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-06-10 13:22       ` Vivek Goyal
2009-06-09  2:09 ` [PATCH 18/19] io-controller: Debug hierarchical IO scheduling Vivek Goyal
2009-06-09  2:09   ` Vivek Goyal
2009-06-19  1:40   ` Gui Jianfeng
2009-06-19 14:05     ` Vivek Goyal
2009-06-19 14:05       ` Vivek Goyal
     [not found]     ` <4A3AEC96.7050500-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-06-19 14:05       ` Vivek Goyal
2009-06-19  6:26   ` Gui Jianfeng
2009-06-19  6:26     ` Gui Jianfeng
     [not found]     ` <4A3B2F7E.10405-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-06-19 14:08       ` Vivek Goyal
2009-06-19 14:08     ` Vivek Goyal
2009-06-19 14:08       ` Vivek Goyal
     [not found]   ` <1244513342-11758-19-git-send-email-vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-06-19  1:40     ` Gui Jianfeng
2009-06-19  6:26     ` Gui Jianfeng
2009-06-09  2:09 ` [PATCH 19/19] io-controller: experimental debug patch for async queue wait before expiry Vivek Goyal
2009-06-09  2:09   ` Vivek Goyal
2009-06-09  4:22 ` [RFC] IO scheduler based IO controller V4 Gui Jianfeng
2009-06-09  4:22   ` Gui Jianfeng
     [not found]   ` <4A2DE381.6090205-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-06-09 13:52     ` Vivek Goyal
2009-06-09 13:52   ` Vivek Goyal
2009-06-09 13:52     ` Vivek Goyal
     [not found]     ` <20090609135256.GA13476-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-06-10  1:05       ` Gui Jianfeng
2009-06-10  1:05     ` 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='1244513342-11758-8-git-send-email-vgoyal__37546.7845974073$1244515062$gmane$org@redhat.com' \
    --to=vgoyal-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=agk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=dpshah-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=jens.axboe-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org \
    --cc=nauman-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.