From patchwork Thu May 14 01:51:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Jianfeng X-Patchwork-Id: 26248 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4R0GRc4009587 for ; Wed, 27 May 2009 00:16:29 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id D446F61A024; Tue, 26 May 2009 20:16:26 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n4E1qOLj027716 for ; Wed, 13 May 2009 21:52:24 -0400 Received: from mx3.redhat.com (mx3.redhat.com [172.16.48.32]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n4E1qNrM015865; Wed, 13 May 2009 21:52:23 -0400 Received: from song.cn.fujitsu.com (cn.fujitsu.com [222.73.24.84] (may be forged)) by mx3.redhat.com (8.13.8/8.13.8) with ESMTP id n4E1q9OA004276; Wed, 13 May 2009 21:52:09 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 0915A170133; Thu, 14 May 2009 09:53:59 +0800 (CST) Received: from fnst.cn.fujitsu.com (localhost.localdomain [127.0.0.1]) by tang.cn.fujitsu.com (8.13.1/8.13.1) with ESMTP id n4E1q6eg029215; Thu, 14 May 2009 09:52:06 +0800 Received: from [127.0.0.1] (unknown [10.167.141.226]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id D7545D4033; Thu, 14 May 2009 10:01:27 +0800 (CST) Message-ID: <4A0B7911.6080005@cn.fujitsu.com> Date: Thu, 14 May 2009 09:51:13 +0800 From: Gui Jianfeng User-Agent: Thunderbird 2.0.0.5 (Windows/20070716) MIME-Version: 1.0 To: Vivek Goyal References: <1241553525-28095-1-git-send-email-vgoyal@redhat.com> <4A0A29B5.7030109@cn.fujitsu.com> <20090513155900.GA15623@redhat.com> In-Reply-To: <20090513155900.GA15623@redhat.com> X-RedHat-Spam-Score: -0.7 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.32 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Tue, 26 May 2009 20:16:14 -0400 Cc: dhaval@linux.vnet.ibm.com, snitzer@redhat.com, dm-devel@redhat.com, dpshah@google.com, jens.axboe@oracle.com, agk@redhat.com, balbir@linux.vnet.ibm.com, paolo.valente@unimore.it, fernando@oss.ntt.co.jp, mikew@google.com, jmoyer@redhat.com, nauman@google.com, m-ikeda@ds.jp.nec.com, lizf@cn.fujitsu.com, fchecconi@gmail.com, s-uchida@ap.jp.nec.com, containers@lists.linux-foundation.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, righi.andrea@gmail.com Subject: [dm-devel] Re: [PATCH] IO Controller: Add per-device weight and ioprio_class handling X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Vivek Goyal wrote: ... > > Hi Gui, > > It might make sense to also store the device name or device major and > minor number in io_group while creating the io group. This will help us > to display io.disk_time and io.disk_sector statistics per device instead > of aggregate. > > I am attaching a patch I was playing around with to display per device > statistics instead of aggregate one. So if user has specified the per > device rule. > > Thanks > Vivek > > > o Currently the statistics exported through cgroup are aggregate of statistics > on all devices for that cgroup. Instead of aggregate, make these per device. Hi Vivek, Actually, I did it also. FYI Examples: # cat io.disk_time dev:/dev/hdb time:4421 dev:others time:3741 # cat io.disk_sectors dev:/dev/hdb sectors:585696 dev:others sectors:2664 Signed-off-by: Gui Jianfeng --- block/elevator-fq.c | 104 +++++++++++++++++++++++--------------------------- 1 files changed, 48 insertions(+), 56 deletions(-) diff --git a/block/elevator-fq.c b/block/elevator-fq.c index 7c95d55..1620074 100644 --- a/block/elevator-fq.c +++ b/block/elevator-fq.c @@ -1162,90 +1162,82 @@ STORE_FUNCTION(weight, 0, WEIGHT_MAX); STORE_FUNCTION(ioprio_class, IOPRIO_CLASS_RT, IOPRIO_CLASS_IDLE); #undef STORE_FUNCTION -/* - * traverse through all the io_groups associated with this cgroup and calculate - * the aggr disk time received by all the groups on respective disks. - */ -static u64 calculate_aggr_disk_time(struct io_cgroup *iocg) +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; - u64 disk_time = 0; - - rcu_read_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 (rcu_dereference(iog->key)) - disk_time += iog->entity.total_service; - } - rcu_read_unlock(); - - return disk_time; -} + struct policy_node *pn; + unsigned int other, time; -static u64 io_cgroup_disk_time_read(struct cgroup *cgroup, - struct cftype *cftype) -{ - struct io_cgroup *iocg; - u64 ret; + other = 0; if (!cgroup_lock_live_group(cgroup)) return -ENODEV; iocg = cgroup_to_io_cgroup(cgroup); spin_lock_irq(&iocg->lock); - ret = jiffies_to_msecs(calculate_aggr_disk_time(iocg)); + hlist_for_each_entry_rcu(iog, n, &iocg->group_data, group_node) { + if (iog->key != NULL) { + pn = policy_search_node(iocg, iog->key); + if (pn) { + time = jiffies_to_msecs(iog->entity. + total_service); + seq_printf(m, "dev:%s time:%u\n", + pn->dev_name, time); + } else { + other += jiffies_to_msecs(iog->entity. + total_service); + } + } + } + seq_printf(m, "dev:others time:%u\n", other); + spin_unlock_irq(&iocg->lock); cgroup_unlock(); - return ret; + return 0; } -/* - * traverse through all the io_groups associated with this cgroup and calculate - * the aggr number of sectors transferred by all the groups on respective disks. - */ -static u64 calculate_aggr_disk_sectors(struct io_cgroup *iocg) +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; - u64 disk_sectors = 0; - - rcu_read_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 (rcu_dereference(iog->key)) - disk_sectors += iog->entity.total_sector_service; - } - rcu_read_unlock(); + struct policy_node *pn; + u64 other = 0; - return disk_sectors; -} - -static u64 io_cgroup_disk_sectors_read(struct cgroup *cgroup, - struct cftype *cftype) -{ - struct io_cgroup *iocg; - u64 ret; if (!cgroup_lock_live_group(cgroup)) return -ENODEV; iocg = cgroup_to_io_cgroup(cgroup); spin_lock_irq(&iocg->lock); - ret = calculate_aggr_disk_sectors(iocg); + hlist_for_each_entry_rcu(iog, n, &iocg->group_data, group_node) { + if (iog->key) { + pn = policy_search_node(iocg, iog->key); + if (pn) { + seq_printf(m, "dev:%s sectors:%lu\n", + pn->dev_name, + iog->entity.total_sector_service); + } else { + other += iog->entity.total_sector_service; + } + } + } + + seq_printf(m, "dev:others sectors:%llu\n", other); + spin_unlock_irq(&iocg->lock); cgroup_unlock(); - return ret; + return 0; } /** @@ -1783,11 +1775,11 @@ struct cftype bfqio_files[] = { }, { .name = "disk_time", - .read_u64 = io_cgroup_disk_time_read, + .read_seq_string = io_cgroup_disk_time_read, }, { .name = "disk_sectors", - .read_u64 = io_cgroup_disk_sectors_read, + .read_seq_string = io_cgroup_disk_sectors_read, }, };