Commit 4b570521 authored by Jens Axboe's avatar Jens Axboe

blk-mq: request initialization optimizations

We currently clear a lot more than we need to, so make that a bit
more clever. Make some of the init dependent on features, like
only setting start_time if we are going to use it.
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 05f1dd53
...@@ -199,19 +199,12 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx, ...@@ -199,19 +199,12 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
rq->q = q; rq->q = q;
rq->mq_ctx = ctx; rq->mq_ctx = ctx;
rq->cmd_flags |= rw_flags; rq->cmd_flags |= rw_flags;
rq->cmd_type = 0;
/* do not touch atomic flags, it needs atomic ops against the timer */ /* do not touch atomic flags, it needs atomic ops against the timer */
rq->cpu = -1; rq->cpu = -1;
rq->__data_len = 0;
rq->__sector = (sector_t) -1;
rq->bio = NULL;
rq->biotail = NULL;
INIT_HLIST_NODE(&rq->hash); INIT_HLIST_NODE(&rq->hash);
RB_CLEAR_NODE(&rq->rb_node); RB_CLEAR_NODE(&rq->rb_node);
memset(&rq->flush, 0, max(sizeof(rq->flush), sizeof(rq->elv)));
rq->rq_disk = NULL; rq->rq_disk = NULL;
rq->part = NULL; rq->part = NULL;
rq->start_time = jiffies;
#ifdef CONFIG_BLK_CGROUP #ifdef CONFIG_BLK_CGROUP
rq->rl = NULL; rq->rl = NULL;
set_start_time_ns(rq); set_start_time_ns(rq);
...@@ -221,23 +214,16 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx, ...@@ -221,23 +214,16 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
#if defined(CONFIG_BLK_DEV_INTEGRITY) #if defined(CONFIG_BLK_DEV_INTEGRITY)
rq->nr_integrity_segments = 0; rq->nr_integrity_segments = 0;
#endif #endif
rq->ioprio = 0;
rq->special = NULL; rq->special = NULL;
/* tag was already set */ /* tag was already set */
rq->errors = 0; rq->errors = 0;
memset(rq->__cmd, 0, sizeof(rq->__cmd));
rq->cmd = rq->__cmd;
rq->cmd_len = BLK_MAX_CDB;
rq->extra_len = 0; rq->extra_len = 0;
rq->sense_len = 0; rq->sense_len = 0;
rq->resid_len = 0; rq->resid_len = 0;
rq->sense = NULL; rq->sense = NULL;
rq->deadline = 0;
INIT_LIST_HEAD(&rq->timeout_list); INIT_LIST_HEAD(&rq->timeout_list);
rq->timeout = 0;
rq->retries = 0;
rq->end_io = NULL; rq->end_io = NULL;
rq->end_io_data = NULL; rq->end_io_data = NULL;
rq->next_rq = NULL; rq->next_rq = NULL;
...@@ -449,8 +435,10 @@ static void blk_mq_start_request(struct request *rq, bool last) ...@@ -449,8 +435,10 @@ static void blk_mq_start_request(struct request *rq, bool last)
* complete. So be sure to clear complete again when we start * complete. So be sure to clear complete again when we start
* the request, otherwise we'll ignore the completion event. * the request, otherwise we'll ignore the completion event.
*/ */
set_bit(REQ_ATOM_STARTED, &rq->atomic_flags); if (!test_bit(REQ_ATOM_STARTED, &rq->atomic_flags))
clear_bit(REQ_ATOM_COMPLETE, &rq->atomic_flags); set_bit(REQ_ATOM_STARTED, &rq->atomic_flags);
if (test_bit(REQ_ATOM_COMPLETE, &rq->atomic_flags))
clear_bit(REQ_ATOM_COMPLETE, &rq->atomic_flags);
if (q->dma_drain_size && blk_rq_bytes(rq)) { if (q->dma_drain_size && blk_rq_bytes(rq)) {
/* /*
...@@ -1112,7 +1100,11 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule) ...@@ -1112,7 +1100,11 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
static void blk_mq_bio_to_request(struct request *rq, struct bio *bio) static void blk_mq_bio_to_request(struct request *rq, struct bio *bio)
{ {
init_request_from_bio(rq, bio); init_request_from_bio(rq, bio);
blk_account_io_start(rq, 1);
if (blk_do_io_stat(rq)) {
rq->start_time = jiffies;
blk_account_io_start(rq, 1);
}
} }
static inline bool blk_mq_merge_queue_io(struct blk_mq_hw_ctx *hctx, static inline bool blk_mq_merge_queue_io(struct blk_mq_hw_ctx *hctx,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment