blk-mq: prefetch request in blk_mq_tag_to_rq()
authorJens Axboe <axboe@fb.com>
Thu, 25 Aug 2016 14:07:30 +0000 (08:07 -0600)
committerJens Axboe <axboe@fb.com>
Mon, 29 Aug 2016 14:13:21 +0000 (08:13 -0600)
When drivers or the core calls this function, they usually
dereference the request shortly there after. Prefetch the first
cache line.

Profiling IO workloads shows that this is the most common cache
miss on the block side of things.

Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-mq.c

index b68fdcb..eea0d23 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/sched/sysctl.h>
 #include <linux/delay.h>
 #include <linux/crash_dump.h>
+#include <linux/prefetch.h>
 
 #include <trace/events/block.h>
 
@@ -588,8 +589,10 @@ EXPORT_SYMBOL(blk_mq_abort_requeue_list);
 
 struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)
 {
-       if (tag < tags->nr_tags)
+       if (tag < tags->nr_tags) {
+               prefetch(tags->rqs[tag]);
                return tags->rqs[tag];
+       }
 
        return NULL;
 }