mmc: block: Add write packing control
Subsystems (2)
Our experiments showed that the write packing causes degradation of the read throughput, in parallel read and write operations.
Since the read latency is critical for user experience we added a write packing control mechanism that disables the write packing in case of read requests.
This will ensure that read requests latency is not increased due to long write packed commands.
The trigger for enabling the write packing is managing to pack several write requests. The number of potential packed requests that will trigger the packing can be configured via sysfs.
The trigger for disabling the write packing is a fetch of a read request.
this patch is dependant in the follwoing patches:
[PATCH v6 1/3] mmc: core: Add packed command feature of eMMC4.5 [PATCH v6 2/3] mmc: core: Support packed write command for eMMC4.5 device
Maya Erez (1):
mmc: block: Add write packing control
drivers/mmc/card/block.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/card/queue.c | 2 ++ drivers/mmc/card/queue.h | 2 ++ drivers/mmc/core/host.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/mmc/host.h | 5 ++++- 5 files changed, 97 insertions(+), 1 deletions(-)
--
1.7.3.3
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
The write packing control will ensure that read requests latency is not increased due to long write packed commands.
The trigger for enabling the write packing is managing to pack several write requests. The number of potential packed requests that will trigger the packing can be configured via sysfs.
The trigger for disabling the write packing is a fetch of a read request.
--- drivers/mmc/card/block.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/card/queue.c | 2 ++ drivers/mmc/card/queue.h | 2 ++ drivers/mmc/core/host.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/mmc/host.h | 5 ++++- 5 files changed, 97 insertions(+), 1 deletions(-)
drivers/mmc/card/block.c +44 -0
@@ -1313,6 +1313,43 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,mmc_queue_bounce_pre (mqrq); } +static void mmc_blk_write_packing_control (struct mmc_queue *mq, +struct request *req) +{ +struct mmc_host *host = mq->card->host; +int data_dir =0 ; + +if (!(host->caps2 &MMC_CAP2_PACKED_WR )) +return ; + +if (!(host->caps2 &MMC_CAP2_PACKED_WR_CONTROL )) { + mq->write_packing_enabled =1 ; +return ; + } + +if (!req || (req && (req->cmd_flags &REQ_FLUSH ))) { +if (mq->num_of_potential_packed_wr_reqs > + host->num_wr_reqs_to_start_packing) + mq->write_packing_enabled =1 ; +return ; + } + + data_dir =rq_data_dir (req); + +if (data_dir ==READ ) { + mq->num_of_potential_packed_wr_reqs =0 ; + mq->write_packing_enabled =0 ; +return ; + }else if (data_dir ==WRITE ) { + mq->num_of_potential_packed_wr_reqs++; + } + +if (mq->num_of_potential_packed_wr_reqs > + host->num_wr_reqs_to_start_packing) + mq->write_packing_enabled =1 ; + +} +static u8 mmc_blk_prep_packed_list (struct mmc_queue *mq,struct request *req) {struct request_queue *q = mq->queue;
@@ -1332,6 +1369,9 @@ static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct request *req) !card->ext_csd.packed_event_en) goto no_packed; +if (!mq->write_packing_enabled) + goto no_packed; +if ((rq_data_dir (cur) ==WRITE ) && (card->host->caps2 &MMC_CAP2_PACKED_WR )) max_packed_rw = card->ext_csd.max_packed_writes;
@@ -1396,6 +1436,8 @@ static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct request *req)break ; } +if (rq_data_dir (next) ==WRITE ) + mq->num_of_potential_packed_wr_reqs++;list_add_tail (&next->queuelist, &mq->mqrq_cur->packed_list); cur = next; reqs++;
@@ -1780,6 +1822,8 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) goto out; } +mmc_blk_write_packing_control (mq, req); +if (req && req->cmd_flags &REQ_DISCARD ) {/* complete ongoing async transfer before issuing discard */ if (card->host->areq)
drivers/mmc/card/queue.c +2 -0
@@ -181,6 +181,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, mq->mqrq_cur = mqrq_cur; mq->mqrq_prev = mqrq_prev; mq->queue->queuedata = mq; + mq->write_packing_enabled =0 ; + mq->num_of_potential_packed_wr_reqs =0 ;blk_queue_prep_rq (mq->queue, mmc_prep_request);queue_flag_set_unlocked (QUEUE_FLAG_NONROT , mq->queue);
drivers/mmc/card/queue.h +2 -0
@@ -44,6 +44,8 @@ struct mmc_queue {struct mmc_queue_req mqrq[2 ];struct mmc_queue_req *mqrq_cur;struct mmc_queue_req *mqrq_prev; +int write_packing_enabled; +int num_of_potential_packed_wr_reqs; }; extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
drivers/mmc/core/host.c +45 -0
57 lines not on this page · raw message
include/linux/mmc/host.h +4 -1
@@ -242,7 +242,7 @@ struct mmc_host {#define MMC_CAP2_PACKED_WR (1 << 11)/* Allow packed write */ #define MMC_CAP2_PACKED_CMD (MMC_CAP2_PACKED_RD | \ MMC_CAP2_PACKED_WR)/* Allow packed commands */ - +#define MMC_CAP2_PACKED_WR_CONTROL (1 << 12)/* Allow write packing control */ mmc_pm_flag_t pm_caps;/* supported pm features */ unsigned int power_notify_type;#define MMC_HOST_PW_NOTIFY_NONE 0
@@ -324,6 +324,9 @@ struct mmc_host {unsigned int actual_clock;/* Actual HC clock rate */ +/* Write packing control attributes */ +int num_wr_reqs_to_start_packing; +unsigned long private[0 ]____cacheline_aligned ; };
--
1.7.3.3
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.