From: Chad Talbott <ctalbott@google.com>
To: jaxboe@fusionio.com, vgoyal@redhat.com
Cc: linux-kernel@vger.kernel.org, mrubin@google.com,
teravest@google.com, Chad Talbott <ctalbott@google.com>
Subject: [PATCH 2/3] cfq-iosched: Fair cross-group preemption (implementation)
Date: Mon, 21 Mar 2011 18:10:44 -0700 [thread overview]
Message-ID: <1300756245-12380-3-git-send-email-ctalbott@google.com> (raw)
In-Reply-To: <1300756245-12380-1-git-send-email-ctalbott@google.com>
Add a new function cfq_group_should_preempt() which uses the new
service classes to decide if a task in one cgroup should preempt a
task in another. We only allow it if the preempting task's vdisktime
is "behind" the preempted task.
Signed-off-by: Chad Talbott <ctalbott@google.com>
---
block/cfq-iosched.c | 41 ++++++++++++++++++++++++++++++++++++++---
1 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 55e78b7..dfcce80 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1157,6 +1157,32 @@ void cfq_unlink_blkio_group(void *key, struct blkio_group *blkg)
spin_unlock_irqrestore(cfqd->queue->queue_lock, flags);
}
+/*
+ * Return true if new_cfqg should preempt cfqg. A return value of
+ * false means "don't care." In that case, cfq has other heuristics
+ * to decide
+ */
+static bool
+cfq_group_should_preempt(struct cfq_queue *new_cfqq, struct cfq_queue *cfqq,
+ struct request *rq)
+{
+ struct cfq_group *cfqg = cfqq->cfqg;
+ struct cfq_group *new_cfqg = new_cfqq->cfqg;
+ u64 grace_period;
+
+ /* in-group preemption is handled elsewhere */
+ if (new_cfqg == cfqg)
+ return false;
+
+ if (!(new_cfqg->class == BLKIO_RT_CLASS &&
+ cfqg->class == BLKIO_BE_CLASS))
+ return false;
+
+ grace_period = cfq_scale_slice(cfqq->allocated_slice, cfqg);
+ return time_before64(new_cfqg->vdisktime,
+ cfqg->vdisktime + grace_period);
+}
+
#else /* GROUP_IOSCHED */
static struct cfq_group *cfq_get_cfqg(struct cfq_data *cfqd, int create)
{
@@ -1176,6 +1202,12 @@ cfq_link_cfqq_cfqg(struct cfq_queue *cfqq, struct cfq_group *cfqg) {
static void cfq_release_cfq_groups(struct cfq_data *cfqd) {}
static inline void cfq_put_cfqg(struct cfq_group *cfqg) {}
+static bool
+cfq_group_should_preempt(struct cfq_queue *new_cfqq, struct cfq_queue *cfqq,
+ struct request *rq)
+{
+ return false;
+}
#endif /* GROUP_IOSCHED */
/*
@@ -3234,6 +3266,12 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
if (!cfqq)
return false;
+ if (cfq_group_should_preempt(new_cfqq, cfqq, rq))
+ return true;
+
+ if (new_cfqq->cfqg != cfqq->cfqg)
+ return false;
+
if (cfq_class_idle(new_cfqq))
return false;
@@ -3253,9 +3291,6 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
if (rq_is_sync(rq) && !cfq_cfqq_sync(cfqq))
return true;
- if (new_cfqq->cfqg != cfqq->cfqg)
- return false;
-
if (cfq_slice_used(cfqq))
return true;
--
1.7.3.1
next prev parent reply other threads:[~2011-03-22 1:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-22 1:10 [PATCH 0/3] cfq-iosched: Fair cross-group preemption Chad Talbott
2011-03-22 1:10 ` [PATCH 1/3] cfq-iosched: Fair cross-group preemption (interface and documentation) Chad Talbott
2011-03-22 10:03 ` Gui Jianfeng
2011-03-22 18:07 ` Chad Talbott
2011-03-22 1:10 ` Chad Talbott [this message]
2011-03-22 1:10 ` [PATCH 3/3] cfq-iosched: Fair cross-group preemption (stats) Chad Talbott
2011-03-22 15:09 ` [PATCH 0/3] cfq-iosched: Fair cross-group preemption Vivek Goyal
2011-03-22 17:39 ` Chad Talbott
2011-03-22 18:12 ` Vivek Goyal
2011-03-22 23:46 ` Chad Talbott
2011-03-23 1:43 ` Vivek Goyal
2011-03-23 20:10 ` Chad Talbott
2011-03-23 20:41 ` Vivek Goyal
2011-03-24 21:47 ` Chad Talbott
2011-03-25 5:43 ` Gui Jianfeng
2011-03-25 21:32 ` Vivek Goyal
2011-03-25 23:53 ` Chad Talbott
2011-03-28 13:15 ` Vivek Goyal
2011-03-28 16:59 ` Chad Talbott
2011-03-28 17:24 ` Vivek Goyal
2011-03-28 13:17 ` Vivek Goyal
2011-03-28 17:02 ` Chad Talbott
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=1300756245-12380-3-git-send-email-ctalbott@google.com \
--to=ctalbott@google.com \
--cc=jaxboe@fusionio.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mrubin@google.com \
--cc=teravest@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
Powered by JetHome