From: Tejun Heo <tj@kernel.org>
To: axboe@kernel.dk, vgoyal@redhat.com
Cc: ctalbott@google.com, rni@google.com,
linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>
Subject: [PATCH 04/11] blkcg: clear all request_queues on blkcg policy [un]registrations
Date: Wed, 1 Feb 2012 13:19:09 -0800 [thread overview]
Message-ID: <1328131156-13290-5-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1328131156-13290-1-git-send-email-tj@kernel.org>
Keep track of all request_queues which have blkcg initialized and turn
on bypass and invoke blkcg_clear_queue() on all before making changes
to blkcg policies.
This is to prepare for moving blkg management into blkcg core. Note
that this uses more brute force than necessary. Finer grained shoot
down will be implemented later and given that policy [un]registration
almost never happens on running systems (blk-throtl can't be built as
a module and cfq usually is the builtin default iosched), this
shouldn't be a problem for the time being.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
---
block/blk-cgroup.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
include/linux/blkdev.h | 3 +++
2 files changed, 50 insertions(+), 1 deletions(-)
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 15264d0..10878a4 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -27,6 +27,9 @@
static DEFINE_SPINLOCK(blkio_list_lock);
static LIST_HEAD(blkio_list);
+static DEFINE_MUTEX(all_q_mutex);
+static LIST_HEAD(all_q_list);
+
struct blkio_cgroup blkio_root_cgroup = { .weight = 2*BLKIO_WEIGHT_DEFAULT };
EXPORT_SYMBOL_GPL(blkio_root_cgroup);
@@ -1461,9 +1464,20 @@ done:
*/
int blkcg_init_queue(struct request_queue *q)
{
+ int ret;
+
might_sleep();
- return blk_throtl_init(q);
+ ret = blk_throtl_init(q);
+ if (ret)
+ return ret;
+
+ mutex_lock(&all_q_mutex);
+ INIT_LIST_HEAD(&q->all_q_node);
+ list_add_tail(&q->all_q_node, &all_q_list);
+ mutex_unlock(&all_q_mutex);
+
+ return 0;
}
/**
@@ -1487,6 +1501,10 @@ void blkcg_drain_queue(struct request_queue *q)
*/
void blkcg_exit_queue(struct request_queue *q)
{
+ mutex_lock(&all_q_mutex);
+ list_del_init(&q->all_q_node);
+ mutex_unlock(&all_q_mutex);
+
blk_throtl_exit(q);
}
@@ -1532,8 +1550,33 @@ static void blkiocg_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
}
}
+static void blkcg_bypass_start(void)
+ __acquires(&all_q_mutex)
+{
+ struct request_queue *q;
+
+ mutex_lock(&all_q_mutex);
+
+ list_for_each_entry(q, &all_q_list, all_q_node) {
+ blk_queue_bypass_start(q);
+ blkg_destroy_all(q);
+ }
+}
+
+static void blkcg_bypass_end(void)
+ __releases(&all_q_mutex)
+{
+ struct request_queue *q;
+
+ list_for_each_entry(q, &all_q_list, all_q_node)
+ blk_queue_bypass_end(q);
+
+ mutex_unlock(&all_q_mutex);
+}
+
void blkio_policy_register(struct blkio_policy_type *blkiop)
{
+ blkcg_bypass_start();
spin_lock(&blkio_list_lock);
BUG_ON(blkio_policy[blkiop->plid]);
@@ -1541,11 +1584,13 @@ void blkio_policy_register(struct blkio_policy_type *blkiop)
list_add_tail(&blkiop->list, &blkio_list);
spin_unlock(&blkio_list_lock);
+ blkcg_bypass_end();
}
EXPORT_SYMBOL_GPL(blkio_policy_register);
void blkio_policy_unregister(struct blkio_policy_type *blkiop)
{
+ blkcg_bypass_start();
spin_lock(&blkio_list_lock);
BUG_ON(blkio_policy[blkiop->plid] != blkiop);
@@ -1553,5 +1598,6 @@ void blkio_policy_unregister(struct blkio_policy_type *blkiop)
list_del_init(&blkiop->list);
spin_unlock(&blkio_list_lock);
+ blkcg_bypass_end();
}
EXPORT_SYMBOL_GPL(blkio_policy_unregister);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f10958b..e38e4d0 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -397,6 +397,9 @@ struct request_queue {
struct bsg_class_device bsg_dev;
#endif
+#ifdef CONFIG_BLK_CGROUP
+ struct list_head all_q_node;
+#endif
#ifdef CONFIG_BLK_DEV_THROTTLING
/* Throttle data */
struct throtl_data *td;
--
1.7.7.3
next prev parent reply other threads:[~2012-02-01 21:26 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-01 21:19 [PATCHSET] blkcg: unify blkgs for different policies Tejun Heo
2012-02-01 21:19 ` [PATCH 01/11] blkcg: let blkio_group point to blkio_cgroup directly Tejun Heo
2012-02-02 20:03 ` Vivek Goyal
2012-02-02 20:33 ` Tejun Heo
2012-02-02 20:55 ` Vivek Goyal
2012-02-01 21:19 ` [PATCH 02/11] block: relocate elevator initialized test from blk_cleanup_queue() to blk_drain_queue() Tejun Heo
2012-02-02 20:20 ` Vivek Goyal
2012-02-02 20:35 ` Tejun Heo
2012-02-02 20:37 ` Vivek Goyal
2012-02-02 20:38 ` Tejun Heo
2012-02-01 21:19 ` [PATCH 03/11] blkcg: add blkcg_{init|drain|exit}_queue() Tejun Heo
2012-02-01 21:19 ` Tejun Heo [this message]
2012-02-01 21:19 ` [PATCH 05/11] blkcg: let blkcg core handle policy private data allocation Tejun Heo
2012-02-01 21:19 ` [PATCH 06/11] blkcg: move refcnt to blkcg core Tejun Heo
2012-02-02 22:07 ` Vivek Goyal
2012-02-02 22:11 ` Tejun Heo
2012-02-01 21:19 ` [PATCH 07/11] blkcg: make blkg->pd an array and move configuration and stats into it Tejun Heo
2012-02-01 21:19 ` [PATCH 08/11] blkcg: don't use blkg->plid in stat related functions Tejun Heo
2012-02-01 21:19 ` [PATCH 09/11] blkcg: move per-queue blkg list heads and counters to queue and blkg Tejun Heo
2012-02-02 22:47 ` Vivek Goyal
2012-02-02 22:47 ` Tejun Heo
2012-02-01 21:19 ` [PATCH 10/11] blkcg: let blkcg core manage per-queue blkg list and counter Tejun Heo
2012-02-01 21:19 ` [PATCH 11/11] blkcg: unify blkg's for blkcg policies Tejun Heo
2012-02-02 0:37 ` [PATCH UPDATED " Tejun Heo
2012-02-03 19:41 ` Vivek Goyal
2012-02-03 20:59 ` Tejun Heo
2012-02-03 21:44 ` Vivek Goyal
2012-02-03 21:47 ` Tejun Heo
2012-02-03 21:53 ` Vivek Goyal
2012-02-03 22:14 ` Tejun Heo
2012-02-03 22:23 ` Vivek Goyal
2012-02-03 22:28 ` Tejun Heo
2012-02-03 21:06 ` Vivek Goyal
2012-02-03 21:09 ` Tejun Heo
2012-02-03 21:10 ` Tejun Heo
2012-02-14 1:33 ` [PATCH UPDATED2 " Tejun Heo
2012-02-15 17:02 ` Vivek Goyal
2012-02-16 22:42 ` Tejun Heo
2012-02-02 19:29 ` [PATCHSET] blkcg: unify blkgs for different policies Vivek Goyal
2012-02-02 20:36 ` Tejun Heo
2012-02-02 20:43 ` Vivek Goyal
2012-02-02 20:59 ` Tejun Heo
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=1328131156-13290-5-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=axboe@kernel.dk \
--cc=ctalbott@google.com \
--cc=linux-kernel@vger.kernel.org \
--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).