aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-sysfs.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2015-11-05 12:44:55 -0500
committerJens Axboe <axboe@fb.com>2015-11-07 12:40:47 -0500
commit05229beeddf7e75e2e616ddaad4b70e7fca9528d (patch)
tree2f8c5efffcdba6f6fd113960da9009979cf679e4 /block/blk-sysfs.c
parent7b371636fb6d187873d9d2730c2b1febc48a9b47 (diff)
block: add block polling support
Add basic support for polling for specific IO to complete. This uses the cookie that blk-mq passes back, which enables the block layer to pass this cookie to the driver to spin for a specific request. This will be combined with request latency tracking, so we can make qualified decisions about when to poll and when not to. For now, for benchmark purposes, we add a sysfs file that controls whether polling is enabled or not. Signed-off-by: Jens Axboe <axboe@fb.com> Acked-by: Christoph Hellwig <hch@lst.de> Acked-by: Keith Busch <keith.busch@intel.com>
Diffstat (limited to 'block/blk-sysfs.c')
-rw-r--r--block/blk-sysfs.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 31849e328b45..565b8dac5782 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -317,6 +317,34 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)
317 return ret; 317 return ret;
318} 318}
319 319
320static ssize_t queue_poll_show(struct request_queue *q, char *page)
321{
322 return queue_var_show(test_bit(QUEUE_FLAG_POLL, &q->queue_flags), page);
323}
324
325static ssize_t queue_poll_store(struct request_queue *q, const char *page,
326 size_t count)
327{
328 unsigned long poll_on;
329 ssize_t ret;
330
331 if (!q->mq_ops || !q->mq_ops->poll)
332 return -EINVAL;
333
334 ret = queue_var_store(&poll_on, page, count);
335 if (ret < 0)
336 return ret;
337
338 spin_lock_irq(q->queue_lock);
339 if (poll_on)
340 queue_flag_set(QUEUE_FLAG_POLL, q);
341 else
342 queue_flag_clear(QUEUE_FLAG_POLL, q);
343 spin_unlock_irq(q->queue_lock);
344
345 return ret;
346}
347
320static struct queue_sysfs_entry queue_requests_entry = { 348static struct queue_sysfs_entry queue_requests_entry = {
321 .attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR }, 349 .attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR },
322 .show = queue_requests_show, 350 .show = queue_requests_show,
@@ -442,6 +470,12 @@ static struct queue_sysfs_entry queue_random_entry = {
442 .store = queue_store_random, 470 .store = queue_store_random,
443}; 471};
444 472
473static struct queue_sysfs_entry queue_poll_entry = {
474 .attr = {.name = "io_poll", .mode = S_IRUGO | S_IWUSR },
475 .show = queue_poll_show,
476 .store = queue_poll_store,
477};
478
445static struct attribute *default_attrs[] = { 479static struct attribute *default_attrs[] = {
446 &queue_requests_entry.attr, 480 &queue_requests_entry.attr,
447 &queue_ra_entry.attr, 481 &queue_ra_entry.attr,
@@ -466,6 +500,7 @@ static struct attribute *default_attrs[] = {
466 &queue_rq_affinity_entry.attr, 500 &queue_rq_affinity_entry.attr,
467 &queue_iostats_entry.attr, 501 &queue_iostats_entry.attr,
468 &queue_random_entry.attr, 502 &queue_random_entry.attr,
503 &queue_poll_entry.attr,
469 NULL, 504 NULL,
470}; 505};
471 506