summaryrefslogtreecommitdiffstats
path: root/block/blk-sysfs.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2016-11-14 13:03:03 -0700
committerJens Axboe <axboe@fb.com>2016-11-17 13:34:57 -0700
commit64f1c21e86f7fe63337b5c23c129de3ec506431d (patch)
treec5cfcf1875785d425b7da3f9d47388d39c9e7793 /block/blk-sysfs.c
parent06426adf072bca62ac31ea396ff2159a34f276c2 (diff)
downloadlinux-64f1c21e86f7fe63337b5c23c129de3ec506431d.tar.gz
linux-64f1c21e86f7fe63337b5c23c129de3ec506431d.tar.bz2
linux-64f1c21e86f7fe63337b5c23c129de3ec506431d.zip
blk-mq: make the polling code adaptive
The previous commit introduced the hybrid sleep/poll mode. Take that one step further, and use the completion latencies to automatically sleep for half the mean completion time. This is a good approximation. This changes the 'io_poll_delay' sysfs file a bit to expose the various options. Depending on the value, the polling code will behave differently: -1 Never enter hybrid sleep mode 0 Use half of the completion mean for the sleep delay >0 Use this specific value as the sleep delay Signed-off-by: Jens Axboe <axboe@fb.com> Tested-By: Stephen Bates <sbates@raithlin.com> Reviewed-By: Stephen Bates <sbates@raithlin.com>
Diffstat (limited to 'block/blk-sysfs.c')
-rw-r--r--block/blk-sysfs.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index dcdfcaa12653..1855c6770045 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -352,24 +352,34 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)
static ssize_t queue_poll_delay_show(struct request_queue *q, char *page)
{
- return queue_var_show(q->poll_nsec / 1000, page);
+ int val;
+
+ if (q->poll_nsec == -1)
+ val = -1;
+ else
+ val = q->poll_nsec / 1000;
+
+ return sprintf(page, "%d\n", val);
}
static ssize_t queue_poll_delay_store(struct request_queue *q, const char *page,
size_t count)
{
- unsigned long poll_usec;
- ssize_t ret;
+ int err, val;
if (!q->mq_ops || !q->mq_ops->poll)
return -EINVAL;
- ret = queue_var_store(&poll_usec, page, count);
- if (ret < 0)
- return ret;
+ err = kstrtoint(page, 10, &val);
+ if (err < 0)
+ return err;
- q->poll_nsec = poll_usec * 1000;
- return ret;
+ if (val == -1)
+ q->poll_nsec = -1;
+ else
+ q->poll_nsec = val * 1000;
+
+ return count;
}
static ssize_t queue_poll_show(struct request_queue *q, char *page)