From: Jens Axboe <jens.axboe-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: carsteno-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org
Cc: Jimi Xenidis <jimix-aZOuKsOsJu3MbYB6QlFGEg@public.gmane.org>,
Stephen Rothwell <sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org>,
Xen Mailing List
<xen-devel-GuqFBffKawuULHF6PoxzQEEOCMrvLtNR@public.gmane.org>,
"jmk-zzFmDc4TPjtKvsKVC3L/VUEOCMrvLtNR@public.gmane.org"
<jmk-zzFmDc4TPjtKvsKVC3L/VUEOCMrvLtNR@public.gmane.org>,
Herbert Xu
<herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>,
kvm-devel
<kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
mschwid2-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org,
virtualization
<virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
Christian Borntraeger
<cborntra-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>,
Suzanne McIntosh
<skranjac-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH RFC 3/3] virtio infrastructure: example block driver
Date: Mon, 4 Jun 2007 16:31:15 +0200 [thread overview]
Message-ID: <20070604143115.GJ32105@kernel.dk> (raw)
In-Reply-To: <46641DC9.5050600-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
On Mon, Jun 04 2007, Carsten Otte wrote:
> Jens Axboe wrote:
> >Most people should not fiddle with it, the defaults are there for good
> >reason. I can provide a blk_queue_unplug_thresholds(q, depth, delay)
> >helper that you could use for the virtualized drivers, perhaps that
> >would be better for that use?
> Yea, we should'nt change the defaults without a good reason. That
> would change things for all device drivers.
> This interface provides all functionality we need. I think we need a
> knob in /sys/block/mydevice/queue/ in addition to that.
Something like this, totally untested (but trivial, so it should work
:-)
diff --git a/block/elevator.c b/block/elevator.c
index ce866eb..81e2a2d 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -638,7 +638,7 @@ void elv_insert(request_queue_t *q, struct request *rq, int where)
int nrq = q->rq.count[READ] + q->rq.count[WRITE]
- q->in_flight;
- if (nrq >= q->unplug_thresh)
+ if (nrq >= q->unplug_thresh || !q->unplug_delay)
__generic_unplug_device(q);
}
}
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 6b5173a..aaefb32 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -785,6 +785,30 @@ void blk_queue_dma_alignment(request_queue_t *q, int mask)
EXPORT_SYMBOL(blk_queue_dma_alignment);
/**
+ * blk_queue_unplug_threshold - set automatic unplug thresholds for the queue
+ * @q: the request queue for the device
+ * @depth: the queue depth at which to do unplug
+ * @delay: maximum unplug timer delay
+ *
+ * Description:
+ * Set the desired unplug depth/threshold and delay for a given queue.
+ * The block layer has a set of good defaults for this, so this function
+ * should ONLY be used by drivers for virtualized environments, where
+ * you could potentially have several layers of queues that each do their
+ * own delay.
+ *
+ * If in doubt, don't use this function! The settings can also be
+ * tweaked from sysfs.
+ *
+ **/
+void blk_queue_unplug_threshold(request_queue_t *q, unsigned int depth,
+ unsigned long delay)
+{
+ q->unplug_thresh = depth;
+ q->unplug_delay = delay;
+}
+
+/**
* blk_queue_find_tag - find a request by its tag and queue
* @q: The request queue for the device
* @tag: The tag of the request
@@ -1550,7 +1574,8 @@ void blk_plug_device(request_queue_t *q)
return;
if (!test_and_set_bit(QUEUE_FLAG_PLUGGED, &q->queue_flags)) {
- mod_timer(&q->unplug_timer, jiffies + q->unplug_delay);
+ if (q->unplug_delay)
+ mod_timer(&q->unplug_timer, jiffies + q->unplug_delay);
blk_add_trace_generic(q, NULL, 0, BLK_TA_PLUG);
}
}
@@ -3975,6 +4000,54 @@ static ssize_t queue_max_hw_sectors_show(struct request_queue *q, char *page)
return queue_var_show(max_hw_sectors_kb, (page));
}
+static ssize_t queue_unplug_delay_show(struct request_queue *q, char *page)
+{
+ return queue_var_show(q->unplug_delay, page);
+}
+
+/*
+ * We don't bother rearming a running timer. It's just not worth it, the
+ * next unplug will get it right.
+ */
+static ssize_t queue_unplug_delay_store(struct request_queue *q,
+ const char *page, size_t count)
+{
+ unsigned long delay;
+ int ret;
+
+ ret = queue_var_store(&delay, page, count);
+
+ spin_lock_irq(q->queue_lock);
+ q->unplug_delay = msecs_to_jiffies(delay);
+ spin_unlock_irq(q->queue_lock);
+
+ return ret;
+}
+
+static ssize_t queue_unplug_depth_show(struct request_queue *q, char *page)
+{
+ return queue_var_show(q->unplug_thresh, page);
+}
+
+/*
+ * We don't bother unplugging if we depth was reduced and we just happened
+ * to have a current queue depth of somewhere in between the old and new
+ * value.
+ */
+static ssize_t queue_unplug_depth_store(struct request_queue *q,
+ const char *page, size_t count)
+{
+ unsigned long depth;
+ int ret;
+
+ ret = queue_var_store(&depth, page, count);
+
+ spin_lock_irq(q->queue_lock);
+ q->unplug_thresh = depth;
+ spin_unlock_irq(q->queue_lock);
+
+ return ret;
+}
static struct queue_sysfs_entry queue_requests_entry = {
.attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR },
@@ -4005,12 +4078,26 @@ static struct queue_sysfs_entry queue_iosched_entry = {
.store = elv_iosched_store,
};
+static struct queue_sysfs_entry queue_unplug_depth_entry = {
+ .attr = {.name = "unplug_depth", .mode = S_IRUGO | S_IWUSR },
+ .show = queue_unplug_depth_show,
+ .store = queue_unplug_depth_store,
+};
+
+static struct queue_sysfs_entry queue_unplug_delay_entry = {
+ .attr = {.name = "unplug_delay_ms", .mode = S_IRUGO | S_IWUSR },
+ .show = queue_unplug_delay_show,
+ .store = queue_unplug_delay_store,
+};
+
static struct attribute *default_attrs[] = {
&queue_requests_entry.attr,
&queue_ra_entry.attr,
&queue_max_hw_sectors_entry.attr,
&queue_max_sectors_entry.attr,
&queue_iosched_entry.attr,
+ &queue_unplug_delay_entry.attr,
+ &queue_unplug_depth_entry.attr,
NULL,
};
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index db5b00a..04c09d6 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -747,6 +747,7 @@ extern void blk_queue_prep_rq(request_queue_t *, prep_rq_fn *pfn);
extern void blk_queue_merge_bvec(request_queue_t *, merge_bvec_fn *);
extern void blk_queue_dma_alignment(request_queue_t *, int);
extern void blk_queue_softirq_done(request_queue_t *, softirq_done_fn *);
+extern void blk_queue_unplug_threshold(request_queue_t *q, unsigned int, unsigned long);
extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev);
extern int blk_queue_ordered(request_queue_t *, unsigned, prepare_flush_fn *);
extern void blk_queue_issue_flush_fn(request_queue_t *, issue_flush_fn *);
--
Jens Axboe
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
next prev parent reply other threads:[~2007-06-04 14:31 UTC|newest]
Thread overview: 81+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-31 12:19 [PATCH RFC 1/3] virtio infrastructure Rusty Russell
[not found] ` <1180613947.11133.58.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-05-31 12:20 ` [PATCH RFC 2/3] virtio infrastructure: example net driver Rusty Russell
[not found] ` <1180614044.11133.61.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-05-31 12:21 ` [PATCH RFC 3/3] virtio infrastructure: example block driver Rusty Russell
2007-05-31 12:57 ` [kvm-devel] " Carsten Otte
[not found] ` <1180614091.11133.63.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-05-31 12:57 ` Carsten Otte
2007-05-31 15:02 ` [kvm-devel] " Troy Benjegerdes
2007-05-31 23:39 ` Rusty Russell
[not found] ` <465EC637.7020504-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-05-31 15:02 ` Troy Benjegerdes
2007-05-31 17:01 ` [kvm-devel] " Carsten Otte
[not found] ` <20070531150206.GB6474-na1kE3HDu0idQnJuSAr7PQ@public.gmane.org>
2007-05-31 17:01 ` Carsten Otte
[not found] ` <465EFF72.5070100-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-05-31 17:36 ` Avi Kivity
2007-05-31 17:36 ` [kvm-devel] " Avi Kivity
2007-05-31 23:39 ` Rusty Russell
2007-06-01 7:10 ` [kvm-devel] " Carsten Otte
[not found] ` <1180654765.10999.6.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-01 7:10 ` Carsten Otte
2007-06-01 13:13 ` [kvm-devel] " Jens Axboe
[not found] ` <465FC65C.6020905-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-06-01 13:13 ` Jens Axboe
2007-06-04 13:40 ` [kvm-devel] " Carsten Otte
[not found] ` <20070601131315.GW32105-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2007-06-04 13:40 ` Carsten Otte
[not found] ` <4664164A.40604-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-06-04 13:43 ` Jens Axboe
[not found] ` <20070604134322.GC32105-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2007-06-04 13:52 ` Rusty Russell
2007-06-04 13:54 ` [kvm-devel] " Jens Axboe
[not found] ` <1180965161.25878.47.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-04 13:54 ` Jens Axboe
2007-06-04 14:12 ` [kvm-devel] " Carsten Otte
[not found] ` <20070604135433.GG32105-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2007-06-04 14:12 ` Carsten Otte
2007-06-04 14:31 ` [kvm-devel] " Jens Axboe
[not found] ` <46641DC9.5050600-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-06-04 14:31 ` Jens Axboe [this message]
2007-06-04 13:52 ` Rusty Russell
2007-06-04 13:43 ` Jens Axboe
2007-06-02 9:28 ` Rusty Russell
[not found] ` <1180776482.9228.22.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-04 12:53 ` Carsten Otte
2007-06-04 12:53 ` [kvm-devel] " Carsten Otte
2007-06-02 9:28 ` Rusty Russell
2007-05-31 12:21 ` Rusty Russell
2007-05-31 12:53 ` [PATCH RFC 1/3] virtio infrastructure Carsten Otte
2007-05-31 13:01 ` Dor Laor
2007-06-02 6:30 ` Avi Kivity
[not found] ` <46610E8D.10706-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-02 9:50 ` Rusty Russell
2007-06-03 5:28 ` [kvm-devel] " Avi Kivity
[not found] ` <1180777836.9228.44.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-03 5:28 ` Avi Kivity
[not found] ` <46625192.5020108-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-03 10:29 ` Rusty Russell
2007-06-03 11:39 ` [Xen-devel] Re: [kvm-devel] " Avi Kivity
[not found] ` <1180866540.17442.74.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-03 11:39 ` [Xen-devel] " Avi Kivity
2007-06-03 23:53 ` [Xen-devel] Re: [kvm-devel] " Rusty Russell
[not found] ` <4662A86A.7010706-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-03 23:53 ` [Xen-devel] " Rusty Russell
2007-06-04 9:55 ` [Xen-devel] Re: [kvm-devel] " Avi Kivity
[not found] ` <1180914836.17442.104.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-04 9:55 ` [Xen-devel] " Avi Kivity
2007-06-04 10:32 ` [Xen-devel] Re: [kvm-devel] " Herbert Xu
2007-06-04 11:19 ` Rusty Russell
[not found] ` <4663E18D.4030007-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-04 10:32 ` [Xen-devel] " Herbert Xu
2007-06-04 11:19 ` Rusty Russell
[not found] ` <1180955964.25878.27.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-04 11:25 ` Avi Kivity
2007-06-04 11:40 ` [kvm-devel] " Rusty Russell
[not found] ` <4663F6AC.7070100-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-04 11:40 ` Rusty Russell
2007-06-04 12:17 ` Herbert Xu
2007-06-04 12:17 ` [kvm-devel] " Herbert Xu
2007-06-04 11:25 ` Avi Kivity
2007-06-03 10:29 ` Rusty Russell
2007-06-02 9:50 ` Rusty Russell
2007-05-31 12:20 ` [PATCH RFC 2/3] virtio infrastructure: example net driver Rusty Russell
2007-05-31 12:53 ` [kvm-devel] [PATCH RFC 1/3] virtio infrastructure Carsten Otte
2007-05-31 13:01 ` Dor Laor
2007-06-01 23:35 ` Santos, Jose Renato G
2007-06-02 10:12 ` Rusty Russell
[not found] ` <1180779167.9228.66.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-04 21:14 ` [Xen-devel] " Santos, Jose Renato G
[not found] ` <08CA2245AFCF444DB3AC415E47CC40AFBD2FD4-VylnnfFjWmASZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>
2007-06-04 21:19 ` Jeremy Fitzhardinge
2007-06-05 2:05 ` Santos, Jose Renato G
[not found] ` <466481ED.8050209-TSDbQ3PG+2Y@public.gmane.org>
2007-06-05 2:05 ` Santos, Jose Renato G
2007-06-05 2:27 ` Rusty Russell
[not found] ` <08CA2245AFCF444DB3AC415E47CC40AFBD30B4-VylnnfFjWmASZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>
2007-06-05 2:27 ` Rusty Russell
2007-06-05 2:49 ` Santos, Jose Renato G
2007-06-05 2:49 ` [Xen-devel] " Santos, Jose Renato G
2007-06-05 1:44 ` Rusty Russell
[not found] ` <1181007892.25878.112.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-05 2:39 ` Santos, Jose Renato G
2007-06-05 2:39 ` Santos, Jose Renato G
2007-06-04 21:19 ` Jeremy Fitzhardinge
2007-06-05 1:44 ` Rusty Russell
2007-06-04 21:14 ` Santos, Jose Renato G
2007-06-02 10:12 ` Rusty Russell
2007-06-01 23:35 ` Santos, Jose Renato G
2007-06-02 6:30 ` [kvm-devel] " Avi Kivity
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=20070604143115.GJ32105@kernel.dk \
--to=jens.axboe-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
--cc=carsteno-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org \
--cc=cborntra-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org \
--cc=herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org \
--cc=jimix-aZOuKsOsJu3MbYB6QlFGEg@public.gmane.org \
--cc=jmk-zzFmDc4TPjtKvsKVC3L/VUEOCMrvLtNR@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=mschwid2-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
--cc=sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org \
--cc=skranjac-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
--cc=virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=xen-devel-GuqFBffKawuULHF6PoxzQEEOCMrvLtNR@public.gmane.org \
/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.