* [RFC patch] block: add round robin dispatch in noop IO scheduler
@ 2012-06-27 13:55 Hillf Danton
2012-07-02 19:36 ` Jeff Moyer
0 siblings, 1 reply; 3+ messages in thread
From: Hillf Danton @ 2012-06-27 13:55 UTC (permalink / raw)
To: LKML, Hillf Danton
Requests are grouped according to IO context, and dispatched in round
robin, one request per context a time, then noop serves flash based
disk "fair"?
--- a/block/noop-iosched.c Wed Jun 27 20:52:52 2012
+++ b/block/noop-iosched.c Wed Jun 27 21:24:10 2012
@@ -7,25 +7,76 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/init.h>
+#include "blk.h"
struct noop_data {
struct list_head queue;
};
+struct noop_ioc {
+ struct io_cq icq;
+
+ struct list_head rr, fifo;
+};
+
+static inline struct noop_ioc *ioc_of(struct io_cq *icq)
+{
+ return (struct noop_ioc *)icq;
+}
+static inline struct noop_ioc *ioc_of_rq(struct request *rq)
+{
+ return ioc_of(rq->elv.icq);
+}
+
static void noop_merged_requests(struct request_queue *q, struct request *rq,
struct request *next)
{
list_del_init(&next->queuelist);
}
+static int noop_dispatch_force(struct request_queue *q)
+{
+ struct noop_data *nd = q->elevator->elevator_data;
+ int cnt = 0;
+
+ while (!list_empty(&nd->queue)) {
+ struct noop_ioc *ioc;
+ ioc = list_first_entry(&nd->queue, struct noop_ioc, rr);
+ list_del_init(&ioc->rr);
+
+ while (!list_empty(&ioc->fifo)) {
+ struct request *rq;
+ rq = list_first_entry(&ioc->fifo, struct request,
+ queuelist);
+ list_del_init(&rq->queuelist);
+ elv_dispatch_sort(q, rq);
+ ++cnt;
+ }
+ }
+ return cnt;
+}
+
static int noop_dispatch(struct request_queue *q, int force)
{
struct noop_data *nd = q->elevator->elevator_data;
+ struct noop_ioc *ioc;
+
+ if (force)
+ return noop_dispatch_force(q);
+
+ if (list_empty(&nd->queue))
+ return 0;
+
+ ioc = list_first_entry(&nd->queue, struct noop_ioc, rr);
+ list_del_init(&ioc->rr);
- if (!list_empty(&nd->queue)) {
+ if (!list_empty(&ioc->fifo)) {
struct request *rq;
- rq = list_entry(nd->queue.next, struct request, queuelist);
+ rq = list_entry(ioc->fifo.next, struct request, queuelist);
list_del_init(&rq->queuelist);
+ /* dispatch round robin */
+ if (!list_empty(&ioc->fifo))
+ list_add_tail(&ioc->rr, &nd->queue);
elv_dispatch_sort(q, rq);
return 1;
}
@@ -35,16 +86,18 @@ static int noop_dispatch(struct request_
static void noop_add_request(struct request_queue *q, struct request *rq)
{
struct noop_data *nd = q->elevator->elevator_data;
+ struct noop_ioc *ioc = ioc_of_rq(rq);
- list_add_tail(&rq->queuelist, &nd->queue);
+ list_add_tail(&rq->queuelist, &ioc->fifo);
+
+ if (list_empty(&ioc->rr))
+ list_add_tail(&ioc->rr, &nd->queue);
}
static struct request *
noop_former_request(struct request_queue *q, struct request *rq)
{
- struct noop_data *nd = q->elevator->elevator_data;
-
- if (rq->queuelist.prev == &nd->queue)
+ if (rq->queuelist.prev == &ioc_of_rq(rq)->fifo)
return NULL;
return list_entry(rq->queuelist.prev, struct request, queuelist);
}
@@ -52,9 +105,7 @@ noop_former_request(struct request_queue
static struct request *
noop_latter_request(struct request_queue *q, struct request *rq)
{
- struct noop_data *nd = q->elevator->elevator_data;
-
- if (rq->queuelist.next == &nd->queue)
+ if (rq->queuelist.next == &ioc_of_rq(rq)->fifo)
return NULL;
return list_entry(rq->queuelist.next, struct request, queuelist);
}
@@ -80,6 +131,14 @@ static void noop_exit_queue(struct eleva
kfree(nd);
}
+static void noop_init_icq(struct io_cq *icq)
+{
+ struct noop_ioc *ioc = ioc_of(icq);
+
+ INIT_LIST_HEAD(&ioc->rr);
+ INIT_LIST_HEAD(&ioc->fifo);
+}
+
static struct elevator_type elevator_noop = {
.ops = {
.elevator_merge_req_fn = noop_merged_requests,
@@ -89,7 +148,10 @@ static struct elevator_type elevator_noo
.elevator_latter_req_fn = noop_latter_request,
.elevator_init_fn = noop_init_queue,
.elevator_exit_fn = noop_exit_queue,
+ .elevator_init_icq_fn = noop_init_icq,
},
+ .icq_size = sizeof(struct noop_ioc),
+ .icq_align = __alignof__(struct noop_ioc),
.elevator_name = "noop",
.elevator_owner = THIS_MODULE,
};
--
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFC patch] block: add round robin dispatch in noop IO scheduler
2012-06-27 13:55 [RFC patch] block: add round robin dispatch in noop IO scheduler Hillf Danton
@ 2012-07-02 19:36 ` Jeff Moyer
2012-07-03 12:33 ` Hillf Danton
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Moyer @ 2012-07-02 19:36 UTC (permalink / raw)
To: Hillf Danton; +Cc: LKML
Hillf Danton <dhillf@gmail.com> writes:
> Requests are grouped according to IO context, and dispatched in round
> robin, one request per context a time, then noop serves flash based
> disk "fair"?
NACK. Noop means noop. You can have a look, and maybe contribute to
the work that Shaohua Li is doing. He proposed an IOPS-based scheduler
here:
http://lwn.net/Articles/474164/
Cheers,
Jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC patch] block: add round robin dispatch in noop IO scheduler
2012-07-02 19:36 ` Jeff Moyer
@ 2012-07-03 12:33 ` Hillf Danton
0 siblings, 0 replies; 3+ messages in thread
From: Hillf Danton @ 2012-07-03 12:33 UTC (permalink / raw)
To: Jeff Moyer; +Cc: LKML
On Tue, Jul 3, 2012 at 3:36 AM, Jeff Moyer <jmoyer@redhat.com> wrote:
>
> NACK. Noop means noop. You can have a look, and maybe contribute to
> the work that Shaohua Li is doing. He proposed an IOPS-based scheduler
> here:
> http://lwn.net/Articles/474164/
>
I did find a bug in iops v2:)
After adding fairness, I want to use noop to drive SSD in desktop box,
and if more than 100 MB/s, I am happy with the minor change.
Non RFC should have been posted if a SSD on hand.
Thanks,
Hillf
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-07-03 12:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27 13:55 [RFC patch] block: add round robin dispatch in noop IO scheduler Hillf Danton
2012-07-02 19:36 ` Jeff Moyer
2012-07-03 12:33 ` Hillf Danton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®