From: Tejun Heo <tj@kernel.org>
To: lizefan@huawei.com, axboe@kernel.dk, vgoyal@redhat.com
Cc: containers@lists.linux-foundation.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org, ctalbott@google.com,
rni@google.com, Tejun Heo <tj@kernel.org>
Subject: [PATCH 23/24] cfq-iosched: collect stats from dead cfqgs
Date: Fri, 28 Dec 2012 12:35:45 -0800 [thread overview]
Message-ID: <1356726946-26037-24-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1356726946-26037-1-git-send-email-tj@kernel.org>
To support hierarchical stats, it's necessary to remember stats from
dead children. Add cfqg->dead_stats and make a dying cfqg transfer
its stats to the parent's dead-stats.
The transfer happens form ->pd_offline_fn() and it is possible that
there are some residual IOs completing afterwards. Currently, we lose
these stats. Given that cgroup removal isn't a very high frequency
operation and the amount of residual IOs on offline are likely to be
nil or small, this shouldn't be a big deal and the complexity needed
to handle residual IOs - another callback and rather elaborate
synchronization to reach and lock the matching q - doesn't seem
justified.
Signed-off-by: Tejun Heo <tj@kernel.org>
---
block/cfq-iosched.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index f8b34bb..4d75b79 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -289,7 +289,8 @@ struct cfq_group {
/* number of requests that are on the dispatch list or inside driver */
int dispatched;
struct cfq_ttime ttime;
- struct cfqg_stats stats;
+ struct cfqg_stats stats; /* stats for this cfqg */
+ struct cfqg_stats dead_stats; /* stats pushed from dead children */
};
struct cfq_io_cq {
@@ -709,6 +710,47 @@ static void cfqg_stats_reset(struct cfqg_stats *stats)
#endif
}
+/* @to += @from */
+static void cfqg_stats_merge(struct cfqg_stats *to, struct cfqg_stats *from)
+{
+ /* queued stats shouldn't be cleared */
+ blkg_rwstat_merge(&to->service_bytes, &from->service_bytes);
+ blkg_rwstat_merge(&to->serviced, &from->serviced);
+ blkg_rwstat_merge(&to->merged, &from->merged);
+ blkg_rwstat_merge(&to->service_time, &from->service_time);
+ blkg_rwstat_merge(&to->wait_time, &from->wait_time);
+ blkg_stat_merge(&from->time, &from->time);
+#ifdef CONFIG_DEBUG_BLK_CGROUP
+ blkg_stat_merge(&to->unaccounted_time, &from->unaccounted_time);
+ blkg_stat_merge(&to->avg_queue_size_sum, &from->avg_queue_size_sum);
+ blkg_stat_merge(&to->avg_queue_size_samples, &from->avg_queue_size_samples);
+ blkg_stat_merge(&to->dequeue, &from->dequeue);
+ blkg_stat_merge(&to->group_wait_time, &from->group_wait_time);
+ blkg_stat_merge(&to->idle_time, &from->idle_time);
+ blkg_stat_merge(&to->empty_time, &from->empty_time);
+#endif
+}
+
+/*
+ * Transfer @cfqg's stats to its parent's dead_stats so that the ancestors'
+ * recursive stats can still account for the amount used by this cfqg after
+ * it's gone.
+ */
+static void cfqg_stats_xfer_dead(struct cfq_group *cfqg)
+{
+ struct cfq_group *parent = cfqg_parent(cfqg);
+
+ lockdep_assert_held(cfqg_to_blkg(cfqg)->q->queue_lock);
+
+ if (unlikely(!parent))
+ return;
+
+ cfqg_stats_merge(&parent->dead_stats, &cfqg->stats);
+ cfqg_stats_merge(&parent->dead_stats, &cfqg->dead_stats);
+ cfqg_stats_reset(&cfqg->stats);
+ cfqg_stats_reset(&cfqg->dead_stats);
+}
+
#else /* CONFIG_CFQ_GROUP_IOSCHED */
static inline struct cfq_group *cfqg_parent(struct cfq_group *cfqg) { return NULL; }
@@ -1475,11 +1517,23 @@ static void cfq_pd_init(struct blkcg_gq *blkg)
cfqg->leaf_weight = blkg->blkcg->cfq_leaf_weight;
}
+static void cfq_pd_offline(struct blkcg_gq *blkg)
+{
+ /*
+ * @blkg is going offline and will be ignored by
+ * blkg_[rw]stat_recursive_sum(). Transfer stats to the parent so
+ * that they don't get lost. If IOs complete after this point, the
+ * stats for them will be lost. Oh well...
+ */
+ cfqg_stats_xfer_dead(blkg_to_cfqg(blkg));
+}
+
static void cfq_pd_reset_stats(struct blkcg_gq *blkg)
{
struct cfq_group *cfqg = blkg_to_cfqg(blkg);
cfqg_stats_reset(&cfqg->stats);
+ cfqg_stats_reset(&cfqg->dead_stats);
}
/*
@@ -4408,6 +4462,7 @@ static struct blkcg_policy blkcg_policy_cfq = {
.cftypes = cfq_blkcg_files,
.pd_init_fn = cfq_pd_init,
+ .pd_offline_fn = cfq_pd_offline,
.pd_reset_stats_fn = cfq_pd_reset_stats,
};
#endif
--
1.8.0.2
next prev parent reply other threads:[~2012-12-28 20:35 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-28 20:35 [PATCHSET] block: implement blkcg hierarchy support in cfq, take#2 Tejun Heo
[not found] ` <1356726946-26037-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2012-12-28 20:35 ` [PATCH 01/24] cfq-iosched: Properly name all references to IO class Tejun Heo
2012-12-28 20:35 ` [PATCH 02/24] cfq-iosched: More renaming to better represent wl_class and wl_type Tejun Heo
2012-12-28 20:35 ` [PATCH 03/24] cfq-iosched: Rename "service_tree" to "st" at some places Tejun Heo
2012-12-28 20:35 ` [PATCH 04/24] cfq-iosched: Rename few functions related to selecting workload Tejun Heo
2012-12-28 20:35 ` [PATCH 05/24] cfq-iosched: Get rid of unnecessary local variable Tejun Heo
2012-12-28 20:35 ` [PATCH 06/24] cfq-iosched: Print sync-noidle information in blktrace messages Tejun Heo
2012-12-28 20:35 ` [PATCH 07/24] blkcg: fix minor bug in blkg_alloc() Tejun Heo
2012-12-28 20:35 ` [PATCH 08/24] blkcg: reorganize blkg_lookup_create() and friends Tejun Heo
2012-12-28 20:35 ` [PATCH 09/24] blkcg: cosmetic updates to blkg_create() Tejun Heo
2012-12-28 20:35 ` [PATCH 10/24] blkcg: make blkcg_gq's hierarchical Tejun Heo
2012-12-28 20:35 ` [PATCH 13/24] cfq-iosched: implement hierarchy-ready cfq_group charge scaling Tejun Heo
[not found] ` <1356726946-26037-14-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-08 16:16 ` Vivek Goyal
2012-12-28 20:35 ` [PATCH 17/24] blkcg: implement blkcg_policy->on/offline_pd_fn() and blkcg_gq->online Tejun Heo
[not found] ` <1356726946-26037-18-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-02 19:38 ` Vivek Goyal
[not found] ` <20130102193828.GE4306-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-01-02 20:37 ` Tejun Heo
2013-01-08 16:58 ` Vivek Goyal
2012-12-28 20:35 ` [PATCH 18/24] blkcg: s/blkg_rwstat_sum()/blkg_rwstat_total()/ Tejun Heo
[not found] ` <1356726946-26037-19-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-08 16:59 ` Vivek Goyal
2012-12-28 20:35 ` [PATCH 21/24] blkcg: make blkcg_print_blkgs() grab q locks instead of blkcg lock Tejun Heo
[not found] ` <1356726946-26037-22-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-02 19:27 ` Vivek Goyal
[not found] ` <20130102192700.GA9552-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-01-02 20:45 ` Tejun Heo
2013-01-08 18:08 ` Vivek Goyal
2012-12-28 23:18 ` [PATCH 18.5/24] blkcg: export __blkg_prfill_rwstat() take#2 Tejun Heo
2013-01-02 18:20 ` [PATCHSET] block: implement blkcg hierarchy support in cfq, take#2 Vivek Goyal
[not found] ` <20130102182037.GC4306-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-01-07 16:34 ` Tejun Heo
[not found] ` <20130107163437.GF3926-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-01-08 18:28 ` Vivek Goyal
2012-12-28 20:35 ` [PATCH 11/24] cfq-iosched: add leaf_weight Tejun Heo
[not found] ` <1356726946-26037-12-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-08 15:34 ` Vivek Goyal
[not found] ` <20130108153448.GB29635-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-01-08 17:24 ` Tejun Heo
2012-12-28 20:35 ` [PATCH 12/24] cfq-iosched: implement cfq_group->nr_active and ->children_weight Tejun Heo
[not found] ` <1356726946-26037-13-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-08 15:51 ` Vivek Goyal
2012-12-28 20:35 ` [PATCH 14/24] cfq-iosched: convert cfq_group_slice() to use cfqg->vfraction Tejun Heo
[not found] ` <1356726946-26037-15-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-08 16:42 ` Vivek Goyal
2012-12-28 20:35 ` [PATCH 15/24] cfq-iosched: enable full blkcg hierarchy support Tejun Heo
[not found] ` <1356726946-26037-16-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-07 16:34 ` [PATCH UPDATED " Tejun Heo
[not found] ` <20130107163405.GE3926-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-01-08 14:42 ` Vivek Goyal
[not found] ` <20130108144240.GA29635-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-01-08 17:19 ` Tejun Heo
2012-12-28 20:35 ` [PATCH 16/24] blkcg: add blkg_policy_data->plid Tejun Heo
[not found] ` <1356726946-26037-17-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-08 16:51 ` Vivek Goyal
2012-12-28 20:35 ` [PATCH 19/24] blkcg: implement blkg_[rw]stat_recursive_sum() and blkg_[rw]stat_merge() Tejun Heo
[not found] ` <1356726946-26037-20-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-08 18:03 ` Vivek Goyal
2012-12-28 20:35 ` [PATCH 20/24] block: RCU free request_queue Tejun Heo
[not found] ` <1356726946-26037-21-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-02 18:48 ` Vivek Goyal
[not found] ` <20130102184814.GD4306-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-01-02 20:43 ` Tejun Heo
2013-01-08 18:05 ` Vivek Goyal
2012-12-28 20:35 ` [PATCH 22/24] cfq-iosched: separate out cfqg_stats_reset() from cfq_pd_reset_stats() Tejun Heo
[not found] ` <1356726946-26037-23-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-08 18:09 ` Vivek Goyal
2012-12-28 20:35 ` Tejun Heo [this message]
[not found] ` <1356726946-26037-24-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-02 16:24 ` [PATCH 23/24] cfq-iosched: collect stats from dead cfqgs Vivek Goyal
[not found] ` <20130102162415.GA4306-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-01-02 16:30 ` Tejun Heo
[not found] ` <20130102163010.GC11220-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-01-02 16:44 ` Vivek Goyal
[not found] ` <20130102164415.GB4306-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-01-02 16:52 ` Tejun Heo
2013-01-08 18:12 ` Vivek Goyal
2012-12-28 20:35 ` [PATCH 24/24] cfq-iosched: add hierarchical cfq_group statistics Tejun Heo
[not found] ` <1356726946-26037-25-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-01-08 18:27 ` Vivek Goyal
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=1356726946-26037-24-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=axboe@kernel.dk \
--cc=cgroups@vger.kernel.org \
--cc=containers@lists.linux-foundation.org \
--cc=ctalbott@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=rni@google.com \
--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;
as well as URLs for NNTP newsgroup(s).