Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Wenchao Chen and committed by
Ulf Hansson
68df98c4 2e2b5479

+26
+21
drivers/mmc/host/mmc_hsq.c
··· 21 21 mmc->ops->request(mmc, hsq->mrq); 22 22 } 23 23 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 + 24 43 static void mmc_hsq_pump_requests(struct mmc_hsq *hsq) 25 44 { 26 45 struct mmc_host *mmc = hsq->mmc; ··· 60 41 spin_unlock_irqrestore(&hsq->lock, flags); 61 42 return; 62 43 } 44 + 45 + mmc_hsq_modify_threshold(hsq); 63 46 64 47 slot = &hsq->slot[hsq->next_tag]; 65 48 hsq->mrq = slot->mrq;
+5
drivers/mmc/host/mmc_hsq.h
··· 10 10 * flight to avoid a long latency. 11 11 */ 12 12 #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 13 18 14 19 struct hsq_slot { 15 20 struct mmc_request *mrq;