From: Fengguang Wu <wfg@mail.ustc.edu.cn>
To: Jens Axboe <axboe@suse.de>
Cc: linux-kernel@vger.kernel.org, Andrew Morton <akpm@osdl.org>,
Nick Piggin <nickpiggin@yahoo.com.au>,
Lubos Lunak <l.lunak@suse.cz>,
Fengguang Wu <wfg@mail.ustc.edu.cn>
Subject: [PATCH 3/7] iosched: introduce deadline_add_drq_fifo()
Date: Sun, 25 Jun 2006 15:10:39 +0800 [thread overview]
Message-ID: <351162245.28395@ustc.edu.cn> (raw)
Message-ID: <20060625071729.587214182@localhost.localdomain> (raw)
In-Reply-To: 20060625071036.241325936@localhost.localdomain
[-- Attachment #1: iosched-deadline-fifo-enqueue.patch --]
[-- Type: text/plain, Size: 3091 bytes --]
deadline_rq.fifo is now a queue sorted by request expire time.
New requests can be inserted _anywhere_ into deadline_rq.fifo.
Introduce a new function deadline_add_drq_fifo() to do the work.
Signed-off-by: Wu Fengguang <wfg@mail.ustc.edu.cn>
---
block/deadline-iosched.c | 33 ++++++++++++++++++++++++---------
include/linux/blkdev.h | 1 +
2 files changed, 25 insertions(+), 9 deletions(-)
--- linux-2.6.17-rc6-mm2.orig/include/linux/blkdev.h
+++ linux-2.6.17-rc6-mm2/include/linux/blkdev.h
@@ -516,6 +516,7 @@ enum {
#define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist)
#define rq_data_dir(rq) ((rq)->flags & 1)
+#define rq_data_rwa(rq) ((rq)->flags & 3)
static inline int blk_queue_full(struct request_queue *q, int rw)
{
--- linux-2.6.17-rc6-mm2.orig/block/deadline-iosched.c
+++ linux-2.6.17-rc6-mm2/block/deadline-iosched.c
@@ -30,6 +30,7 @@ static const int deadline_hash_shift = 5
#define DL_HASH_FN(sec) (hash_long(DL_HASH_BLOCK((sec)), deadline_hash_shift))
#define DL_HASH_ENTRIES (1 << deadline_hash_shift)
#define rq_hash_key(rq) ((rq)->sector + (rq)->nr_sectors)
+#define list_entry_fifo(ptr) list_entry((ptr), struct deadline_rq, fifo)
#define ON_HASH(drq) (!hlist_unhashed(&(drq)->hash))
struct deadline_data {
@@ -264,6 +265,41 @@ deadline_find_first_drq(struct deadline_
}
/*
+ * set expire time (only used for reads) and add to fifo list
+ */
+static void
+deadline_add_drq_fifo(struct deadline_data *dd, struct request *rq)
+{
+ const int data_dir = rq_data_dir(rq);
+ struct deadline_rq *drq = RQ_DATA(rq);
+ struct list_head *ip; /* insert before me */
+ int expire;
+
+ expire = dd->fifo_expire[rq_data_rwa(rq)];
+ drq->expires = jiffies + expire;
+
+ /*
+ * Scan forward/backward and insert.
+ */
+ if (expire > dd->fifo_expire[READ]) {
+ list_for_each(ip, &dd->fifo_list[data_dir]) {
+ if (time_before(drq->expires,
+ list_entry_fifo(ip)->expires))
+ break;
+ }
+ list_add_tail(&drq->fifo, ip);
+ } else {
+ list_for_each_prev(ip, &dd->fifo_list[data_dir]) {
+ if (!time_before(drq->expires,
+ list_entry_fifo(ip)->expires))
+ break;
+ }
+ list_add(&drq->fifo, ip);
+ }
+
+}
+
+/*
* add drq to rbtree and fifo
*/
static void
@@ -272,14 +308,8 @@ deadline_add_request(struct request_queu
struct deadline_data *dd = q->elevator->elevator_data;
struct deadline_rq *drq = RQ_DATA(rq);
- const int data_dir = rq_data_dir(drq->request);
-
deadline_add_drq_rb(dd, drq);
- /*
- * set expire time (only used for reads) and add to fifo list
- */
- drq->expires = jiffies + dd->fifo_expire[data_dir];
- list_add_tail(&drq->fifo, &dd->fifo_list[data_dir]);
+ deadline_add_drq_fifo(dd, rq);
if (rq_mergeable(rq))
deadline_add_drq_hash(dd, drq);
@@ -439,8 +469,6 @@ deadline_move_request(struct deadline_da
deadline_move_to_dispatch(dd, drq);
}
-#define list_entry_fifo(ptr) list_entry((ptr), struct deadline_rq, fifo)
-
/*
* deadline_check_fifo returns 0 if there are no expired reads on the fifo,
* 1 otherwise. Requires !list_empty(&dd->fifo_list[data_dir])
--
next prev parent reply other threads:[~2006-06-24 15:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-25 7:10 [PATCH 0/7] [RFC] iosched: make a difference between read/readahead requests Fengguang Wu
2006-06-25 7:10 ` Fengguang Wu
2006-06-25 7:10 ` [PATCH 1/7] iosched: introduce WRITEA Fengguang Wu
2006-06-25 7:10 ` Fengguang Wu
2006-06-25 7:10 ` [PATCH 2/7] iosched: introduce parameter deadline.reada_expire Fengguang Wu
2006-06-25 7:10 ` Fengguang Wu
2006-06-25 7:10 ` Fengguang Wu [this message]
2006-06-25 7:10 ` [PATCH 3/7] iosched: introduce deadline_add_drq_fifo() Fengguang Wu
2006-06-25 7:10 ` [PATCH 6/7] iosched: run elv_kick_page() on sync read Fengguang Wu
2006-06-25 7:10 ` Fengguang Wu
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=351162245.28395@ustc.edu.cn \
--to=wfg@mail.ustc.edu.cn \
--cc=akpm@osdl.org \
--cc=axboe@suse.de \
--cc=l.lunak@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=nickpiggin@yahoo.com.au \
/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.