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 <[email protected]>
Tested-By: Stephen Bates <[email protected]>
Reviewed-By: Stephen Bates <[email protected]>
This commit is contained in:
Jens Axboe 2016-11-14 13:03:03 -07:00
commit 64f1c21e86
3 changed files with 83 additions and 12 deletions

View file

@ -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)