Skip to content

Commit c351de7

Browse files
author
Wenchao Chen
committed
UPSTREAM: mmc: hsq: Improve random I/O write performance for 4k buffers
By dynamically adjusting the host->hsq_depth, based upon the buffer size being 4k and that we get at least two I/O write requests in flight, we can improve the throughput a bit. This is typical for a random I/O write pattern. More precisely, by dynamically changing the number of requests in flight from 2 to 5, we can on some platforms observe ~4-5% increase in throughput. Signed-off-by: Wenchao Chen <wenchao.chen@unisoc.com> Link: https://lore.kernel.org/r/20230919074707.25517-3-wenchao.chen@unisoc.com [Ulf: Re-wrote the commitmsg, minor adjustment to the code - all to clarify.] Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Bug: 317687218 Change-Id: I5ea52355ef39d9f400ae01672a68ad5dec88cbbe (cherry picked from commit 68df98c) Signed-off-by: Wenchao Chen <wenchao.chen@unisoc.com>
1 parent 949106b commit c351de7

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

drivers/mmc/host/mmc_hsq.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,25 @@ static void mmc_hsq_retry_handler(struct work_struct *work)
2121
mmc->ops->request(mmc, hsq->mrq);
2222
}
2323

24+
static void mmc_hsq_modify_threshold(struct mmc_hsq *hsq)
25+
{
26+
struct mmc_host *mmc = hsq->mmc;
27+
struct mmc_request *mrq;
28+
unsigned int tag, need_change = 0;
29+
30+
mmc->hsq_depth = HSQ_NORMAL_DEPTH;
31+
for (tag = 0; tag < HSQ_NUM_SLOTS; tag++) {
32+
mrq = hsq->slot[tag].mrq;
33+
if (mrq && mrq->data &&
34+
(mrq->data->blksz * mrq->data->blocks == 4096) &&
35+
(mrq->data->flags & MMC_DATA_WRITE) &&
36+
(++need_change == 2)) {
37+
mmc->hsq_depth = HSQ_PERFORMANCE_DEPTH;
38+
break;
39+
}
40+
}
41+
}
42+
2443
static void mmc_hsq_pump_requests(struct mmc_hsq *hsq)
2544
{
2645
struct mmc_host *mmc = hsq->mmc;
@@ -42,6 +61,8 @@ static void mmc_hsq_pump_requests(struct mmc_hsq *hsq)
4261
return;
4362
}
4463

64+
mmc_hsq_modify_threshold(hsq);
65+
4566
slot = &hsq->slot[hsq->next_tag];
4667
hsq->mrq = slot->mrq;
4768
hsq->qcnt--;

drivers/mmc/host/mmc_hsq.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
* flight to avoid a long latency.
1111
*/
1212
#define HSQ_NORMAL_DEPTH 2
13+
/*
14+
* For 4k random writes, we allow hsq_depth to increase to 5
15+
* for better performance.
16+
*/
17+
#define HSQ_PERFORMANCE_DEPTH 5
1318

1419
struct hsq_slot {
1520
struct mmc_request *mrq;

0 commit comments

Comments
 (0)