Commit ecf8b5d0 authored by Subhash Jadavani's avatar Subhash Jadavani Committed by Chris Ball

mmc: block: replace __blk_end_request() with blk_end_request()

For completing any block request, MMC block driver is calling:
	spin_lock_irq(queue)
	__blk_end_request()
	spin_unlock_irq(queue)

But if we analyze the sources of latency in kernel using ftrace,
__blk_end_request() function at times may take up to 6.5ms with
spinlock held and irq disabled.

__blk_end_request() calls couple of functions and ftrace output
shows that blk_update_bidi_request() function is almost taking 6ms.
There are 2 function to end the current request: ___blk_end_request()
and blk_end_request(). Both these functions do same thing except
that blk_end_request() function doesn't take up the spinlock
while calling the blk_update_bidi_request().

This patch replaces all __blk_end_request() calls with
blk_end_request() and __blk_end_request_all() calls with
blk_end_request_all().

Testing done: 20 process concurrent read/write on sd card
and eMMC. Ran this test for almost a day on multicore system
and no errors observed.

This change is not meant for improving MMC throughput; it's basically
about becoming fair to other threads/interrupts in the system. By
holding spin lock and interrupts disabled for longer duration, we
won't allow other threads/interrupts to run at all.  Actually slight
performance degradation at file system level can be expected as we
are not holding the spin lock during blk_update_bidi_request() which
means our mmcqd thread may get preempted for other high priority
thread or any interrupt in the system.

These are performance numbers (100MB file write) with eMMC running
in DDR mode:

Without this patch:
	Name of the Test   Value   Unit
	LMDD Read Test     53.79   MBPS
	LMDD Write Test    18.86   MBPS
	IOZONE  Read Test  51.65   MBPS
	IOZONE  Write Test 24.36   MBPS

With this patch:
	Name of the Test    Value  Unit
	LMDD Read Test      52.94  MBPS
	LMDD Write Test     16.70  MBPS
	IOZONE  Read Test   52.08  MBPS
	IOZONE  Write Test  23.29  MBPS

Read numbers are fine. Write numbers are bit down (especially LMDD
write), may be because write requests normally have large transfer
size and which means there are chances that while mmcq is executing
blk_update_bidi_request(), it may get interrupted by interrupts or
other high priority thread.
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
Reviewed-by: default avatarNamjae Jeon <linkinjeon@gmail.com>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 6af9e96e
...@@ -850,9 +850,7 @@ static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req) ...@@ -850,9 +850,7 @@ static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
goto retry; goto retry;
if (!err) if (!err)
mmc_blk_reset_success(md, type); mmc_blk_reset_success(md, type);
spin_lock_irq(&md->lock); blk_end_request(req, err, blk_rq_bytes(req));
__blk_end_request(req, err, blk_rq_bytes(req));
spin_unlock_irq(&md->lock);
return err ? 0 : 1; return err ? 0 : 1;
} }
...@@ -934,9 +932,7 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq, ...@@ -934,9 +932,7 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
if (!err) if (!err)
mmc_blk_reset_success(md, type); mmc_blk_reset_success(md, type);
out: out:
spin_lock_irq(&md->lock); blk_end_request(req, err, blk_rq_bytes(req));
__blk_end_request(req, err, blk_rq_bytes(req));
spin_unlock_irq(&md->lock);
return err ? 0 : 1; return err ? 0 : 1;
} }
...@@ -951,9 +947,7 @@ static int mmc_blk_issue_flush(struct mmc_queue *mq, struct request *req) ...@@ -951,9 +947,7 @@ static int mmc_blk_issue_flush(struct mmc_queue *mq, struct request *req)
if (ret) if (ret)
ret = -EIO; ret = -EIO;
spin_lock_irq(&md->lock); blk_end_request_all(req, ret);
__blk_end_request_all(req, ret);
spin_unlock_irq(&md->lock);
return ret ? 0 : 1; return ret ? 0 : 1;
} }
...@@ -1252,14 +1246,10 @@ static int mmc_blk_cmd_err(struct mmc_blk_data *md, struct mmc_card *card, ...@@ -1252,14 +1246,10 @@ static int mmc_blk_cmd_err(struct mmc_blk_data *md, struct mmc_card *card,
blocks = mmc_sd_num_wr_blocks(card); blocks = mmc_sd_num_wr_blocks(card);
if (blocks != (u32)-1) { if (blocks != (u32)-1) {
spin_lock_irq(&md->lock); ret = blk_end_request(req, 0, blocks << 9);
ret = __blk_end_request(req, 0, blocks << 9);
spin_unlock_irq(&md->lock);
} }
} else { } else {
spin_lock_irq(&md->lock); ret = blk_end_request(req, 0, brq->data.bytes_xfered);
ret = __blk_end_request(req, 0, brq->data.bytes_xfered);
spin_unlock_irq(&md->lock);
} }
return ret; return ret;
} }
...@@ -1311,10 +1301,8 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) ...@@ -1311,10 +1301,8 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
* A block was successfully transferred. * A block was successfully transferred.
*/ */
mmc_blk_reset_success(md, type); mmc_blk_reset_success(md, type);
spin_lock_irq(&md->lock); ret = blk_end_request(req, 0,
ret = __blk_end_request(req, 0,
brq->data.bytes_xfered); brq->data.bytes_xfered);
spin_unlock_irq(&md->lock);
/* /*
* If the blk_end_request function returns non-zero even * If the blk_end_request function returns non-zero even
* though all data has been transferred and no errors * though all data has been transferred and no errors
...@@ -1364,10 +1352,8 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) ...@@ -1364,10 +1352,8 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
* time, so we only reach here after trying to * time, so we only reach here after trying to
* read a single sector. * read a single sector.
*/ */
spin_lock_irq(&md->lock); ret = blk_end_request(req, -EIO,
ret = __blk_end_request(req, -EIO,
brq->data.blksz); brq->data.blksz);
spin_unlock_irq(&md->lock);
if (!ret) if (!ret)
goto start_new_req; goto start_new_req;
break; break;
...@@ -1388,12 +1374,10 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) ...@@ -1388,12 +1374,10 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
return 1; return 1;
cmd_abort: cmd_abort:
spin_lock_irq(&md->lock);
if (mmc_card_removed(card)) if (mmc_card_removed(card))
req->cmd_flags |= REQ_QUIET; req->cmd_flags |= REQ_QUIET;
while (ret) while (ret)
ret = __blk_end_request(req, -EIO, blk_rq_cur_bytes(req)); ret = blk_end_request(req, -EIO, blk_rq_cur_bytes(req));
spin_unlock_irq(&md->lock);
start_new_req: start_new_req:
if (rqc) { if (rqc) {
...@@ -1417,9 +1401,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) ...@@ -1417,9 +1401,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
ret = mmc_blk_part_switch(card, md); ret = mmc_blk_part_switch(card, md);
if (ret) { if (ret) {
if (req) { if (req) {
spin_lock_irq(&md->lock); blk_end_request_all(req, -EIO);
__blk_end_request_all(req, -EIO);
spin_unlock_irq(&md->lock);
} }
ret = 0; ret = 0;
goto out; goto out;
......
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