mmc: block: Add write packing control
Subsystems (2)
Quoted 8 lines · On Tue, Jun 12, 2012 at 1:40 AM, <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines · On Mon, Jun 11, 2012 at 7:25 PM, <[email protected]> wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines · Maya Erez
Quoted 4 lines
Hi,
How can we check the effect?
Do you have any result?We ran parallel lmdd read and write operations and found out that
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
write packing causes the read throughput to drop from 24MB/s to
12MB/s.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
The write packing control managed to increase the read throughput
back
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
to
the original value.
We also examined "real life" scenarios, such as performing a big
push
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
operation in parallel to launching several applications. We
measured
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
the
read latency and found out that with the write packing control the
worst
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
case of the read latency was smaller.
Quoted 4 lines
Please check the several comment below.
Quoted 1 line · Maya Erez
The write packing control will ensure that read requests latency
is
Quoted 3 lines
Quoted 3 lines
not increased due to long write packed commands.
The trigger for enabling the write packing is managing to pack
several
Quoted 1 line
Quoted 1 line
write requests. The number of potential packed requests that
will
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
trigger
the packing can be configured via sysfs by writing the requiredvalue
Quoted 2 lines
Quoted 2 lines
to:
/sys/block/<block_dev_name>/num_wr_reqs_to_start_packing. The
trigger for disabling the write packing is fetching a read
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
request.
Quoted 17 lines
Quoted 17 lines
---
Documentation/mmc/mmc-dev-attrs.txt | 17 ++++++drivers/mmc/card/block.c| 100
++++++++++++++++++++++++++++++++++-drivers/mmc/card/queue.c | 8 +++ drivers/mmc/card/queue.h | 3 + include/linux/mmc/host.h | 1 + 5 files changed, 128 insertions(+), 1 deletions(-)Documentation/mmc/mmc-dev-attrs.txt +0
-0@@ -8,6 +8,23 @@ The following attributes are read/write.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
force_roEnforce read-only access even if writeprotect switch is
Quoted 3 lines
Quoted 3 lines
off.
+
num_wr_reqs_to_start_packingThis attribute is used todetermine
Quoted 1 line
Quoted 1 line
+ the trigger for activating the write packing, in case the
write
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
+ packing control feature is enabled.
+
+ When the MMC manages to reach a point wherenum_wr_reqs_to_start_packing
+ write requests could be packed, it enables the write packing
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
feature.
Quoted 1 line
Quoted 1 line
+ This allows us to start the write packing only when it is
beneficial
Quoted 3 lines
Quoted 3 lines
+ and has minimum affect on the read latency.
+
+ The number of potential packed requests that will trigger thepacking
Quoted 1 line
Quoted 1 line
+ can be configured via sysfs by writing the required value to:
+ /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing. +
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line
+ The default value of
num_wr_reqs_to_start_packingwasdetermined
byQuoted 1 line
Quoted 1 line
+ running parallel lmdd write and lmdd read operations and
calculating
Quoted 6 lines
drivers/mmc/card/block.c
Quoted 6 lines
+ the max number of packed writes requests.
+
SD and MMC Device Attributes
============================drivers/mmc/card/block.c +0
-0
index 2785fd4..ef192fb 100644
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/mmc/card/block.c +1
-0@@ -114,6 +114,7 @@ struct mmc_blk_data { struct device_attribute force_ro; struct device_attribute power_ro_lock; int area_type; +struct device_attribute num_wr_reqs_to_start_packing; }; static DEFINE_MUTEX(open_lock);@@ -281,6 +282,38 @@ out: return ret; }
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
drivers/mmc/card/block.c out: · line 287
Quoted 3 lines
drivers/mmc/card/block.c +3
-0+static ssize_t +num_wr_reqs_to_start_packing_show (struct device *dev, + struct device_attribute *attr, char*buf)
Quoted 2 lines
Quoted 2 lines
drivers/mmc/card/block.c +2
-0+{ +struct mmc_blk_data *md =mmc_blk_get (dev_to_disk (dev)); + int
num_wr_reqs_to_start_packing;
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
drivers/mmc/card/block.c out: · line 292
Quoted 3 lines
drivers/mmc/card/block.c +3
-0+int ret; + + num_wr_reqs_to_start_packing =
md->queue.num_wr_reqs_to_start_packing;Quoted 2 lines
drivers/mmc/card/block.c out: · line 294
Quoted 2 lines
drivers/mmc/card/block.c +2
-0+ + ret = snprintf(buf, PAGE_SIZE, "%d\n",
num_wr_reqs_to_start_packing);
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/mmc/card/block.c out: · line 302
Quoted 8 lines
drivers/mmc/card/block.c +8
-0+ +mmc_blk_put (md); +return ret; +} + +static ssize_t +num_wr_reqs_to_start_packing_store(struct device *dev, + struct device_attribute *attr, +
const char *buf, size_t count) +{
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/mmc/card/block.c out: · line 304
Quoted 2 lines
drivers/mmc/card/block.c +2
-0+int value; + struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev)); + +
sscanf(buf, "%d", &value);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/mmc/card/block.c out: · line 306
Quoted 2 lines
drivers/mmc/card/block.c +2
-0+if (value >=0 ) + md->queue.num_wr_reqs_to_start_packing = value; + +
mmc_blk_put(md);
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/mmc/card/block.c +3
-0+return count; +} +static int mmc_blk_open(struct
block_device*bdev,fmode_t
mode)
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/mmc/card/block.c static void mmc_blk_rw_rq_prep(struct
Quoted 3 lines
{
structmmc_blk_data*md =mmc_blk_get(bdev->bd_disk);drivers/mmc/card/block.c +0
-0@@ -1313,6 +1346,48 @@ static void mmc_blk_rw_rq_prep(struct
mmc_queue_req *mqrq,
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/mmc/card/block.c static void mmc_blk_rw_rq_prep(struct · line 1349
Quoted 4 lines
drivers/mmc/card/block.c +1
-0mmc_queue_bounce_pre(mqrq); } +static void mmc_blk_write_packing_control(struct mmc_queue *mq,
+ struct request *req) +{
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/mmc/card/block.c static void mmc_blk_rw_rq_prep(struct · line 1357
Quoted 8 lines
drivers/mmc/card/block.c +8
-0+struct mmc_host *host = mq->card->host; +int data_dir; + +if (!(host->caps2 &MMC_CAP2_PACKED_WR )) + return; + +/* +* In case the packing control is not supported by the host,
it
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
should
Quoted 1 line
drivers/mmc/card/block.c static void mmc_blk_rw_rq_prep(struct · line 1358
Quoted 1 line
drivers/mmc/card/block.c +1
-0+ * not have an effect on the write packing. Therefore we haveto
Quoted 11 lines
Quoted 11 lines
enable
+ * the write packing
+ */
+ if (!(host->caps2 &MMC_CAP2_PACKED_WR_CONTROL)) {
+mq->wr_packing_enabled= true;
+ return;
+ }
+
+ if (!req || (req && (req->cmd_flags&REQ_FLUSH))) {
+ if (mq->num_of_potential_packed_wr_reqs>
+mq->num_wr_reqs_to_start_packing) +
mq->wr_packing_enabled = true;
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 6 lines
+ return;
+ }drivers/mmc/card/block.c +4
-0+ + data_dir =rq_data_dir (req); + +if (data_dir ==READ ) {drivers/mmc/card/block.c
Quoted 10 lines
drivers/mmc/card/block.c +10
-0+ mq->num_of_potential_packed_wr_reqs = 0; + mq->wr_packing_enabled = false; + return; + }else if (data_dir ==WRITE ) { + mq->num_of_potential_packed_wr_reqs++; + } + +if (mq->num_of_potential_packed_wr_reqs > + mq->num_wr_reqs_to_start_packing) + mq->wr_packing_enabled = true;Write Packing is available only if continuing write requests are
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
over
Quoted 2 lines
num_wr_reqs_to_start_packing?
That means individual request(1...17) will be issued withnon-packing.
Quoted 1 line
Could you explain your policy more?
We try to identify the case where there is parallel read and write
operations. In our experiments we found out that the number of write
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
requests between read requests in parallel read and write
operations
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
doesn't exceed 17 requests. Therefore, we can assume that fetching
more
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
than 17 write requests without hitting a read request can indicate
that
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
there is no read activity.
We can apply this experiment regardless I/O scheduler? Which I/O scheduler was used with this experiment?
The experiment was performed with the CFQ scheduler. Since the
deadline
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
uses a batch of 16 requests it should also fit the deadline
scheduler.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
In case another value is required, this value can be changed via
sysfs.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
You are right that this affects the write throughput a bit but the
goal
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
of
this algorithm is to make sure the read throughput and latency are
not
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
decreased due to write. If this is not the desired result, this
algorithm
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
can be disabled.
Quoted 4 lines
Quoted 4 lines
drivers/mmc/card/block.c +3
-0+ +} +static u8 mmc_blk_prep_packed_list(struct
mmc_queue*mq, structrequest
Quoted 4 lines
drivers/mmc/card/block.c static u8 mmc_blk_prep_packed_list(struct
Quoted 4 lines
*req)
{
structrequest_queue*q =mq->queue;drivers/mmc/card/block.c +0
-0@@ -1332,6 +1407,9 @@ static u8 mmc_blk_prep_packed_list(struct
mmc_queue *mq, struct request *req)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
drivers/mmc/card/block.c static u8 mmc_blk_prep_packed_list(struct · line 1411
Quoted 5 lines
drivers/mmc/card/block.c +2
-0!card->ext_csd.packed_event_en) goto no_packed; +if (!mq->wr_packing_enabled) + goto no_packed;If
wr_packing_enabledis set to true, several write requests canbe
Quoted 2 lines
packed.
We don't need to consider read request since packed write?I'm not sure I understand the question. We check if there was a
read
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
request in the
mmc_blk_write_packing_control, and in such a case
set
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
mq->wr_packing_enabledto false.
If I didn't answer the question, please explain it again.Packed write can be possible after exceeding 17 requests. Is it assured that read request doesn't follow immediately after
packed
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
write?
I wonder this case.Currently in such a case we will send the packed command followed by
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
read request. The latency of this read request will be high due to
waiting
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
for the completion of the packed write. However, since we will
disable
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
the
write packing, the latency of the following read requests will be
low.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
We are working on a solution where the read request will bypass the
write
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
requests in such a case. This change requires modification of the
scheduler in order to re-insert the write requests to the scheduler.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Thats the precise reason for using foreground HPI (shameless plug :-))
I understand the intent of write packing control, but using the number of requests
Quoted 1 line
Quoted 1 line
Quoted 1 line
as a metric is too coarse. Some writes could be for only one sector
(512B) and others
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
could be in 512KB or more, giving a 1000x variance. Foreground HPI solves this problem by interrupting only on a wait
threshold.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Another aspect is that if a packed write is in progress, and you have
a read request,
Quoted 1 line
Quoted 1 line
Quoted 1 line
you will most likely disable packing for the _next_ write, not the
ongoing one, right ?
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
That's too late an intervention IMHO.
If a write request is in progress and a read is fetched we pln to use
HPI
Quoted 1 line
Quoted 1 line
to stop it and re-insert the remider of the write packed command back
to
Quoted 2 lines
Quoted 1 line
the scheduler for a later dispatch.
IIUC, there were 2 reasons mentioned by you for introducing write
packing control -
Quoted 4 lines
1) Read bandwidth drop
2) Use case "latency" or if I were to guess, "sluggish UI".So if (2) is solved by HPI, we can investigate the reason for (1) and
fix that, rather
Quoted 1 line
than adding another functionality (which belongs in the I/O scheduler
anyway) to MMC.
According to our measurements the stop transmission (CMD12) + HPI is a heavy operation that takes several miliseconds. Intensive usage of HPI will cause degradation of the performance.
When there is a packed write followed by a read request, we will stop the packed write and issue the read request. Disabling the write packing due to this read request (by the packing control function) will eliminate the need for additional HPI operation to stop the next packed write request, in case of a flow of read requests. When the read requests flow will end, the write packing will be enabled again when there will be a flow of write requests.
Regarding the degradation of the read throughput in case of mix read/write operations:
Our test showed that there is a degradation of ~40% in the read throughput in mix read/write operations even without packing. Enabling the write packing increases this degradation to ~60%. Those numbers are applicable to CFQ scheduler while the deadline scheduler resulted in even lower read throughput in mix operations.
While investigating this degradation we found out that the main cause for it is the way the application issues the read requests and the policy of the scheduler.
Therefore, the write packing control is only one piece of the complete solution that we are working on. The complete solution will be released in a later phase and will include:
- Usage of stop transmission in order to stop a packed write in case of a read request
- Issue a read request that is fetched at the end of a packed list preparation before the packed write
- The ability to re-insert the write requests back to the scheduler in case of the above cases (re-queuing them back to the dispatch queue will not give a real solution in case of a flow of read requests).
- Modify the scheduler to ensure preferring of reads over writes in mix read/write scenarios
I hope this makes things a bit clearer. Let me know if you have additional questions.
Quoted 2 lines
Quoted 2 lines
Regarding the packing control trigger, we also tried using a trigger of
an
Quoted 1 line
Quoted 1 line
amount of write bytes between read. However, the number of potential
packed requests seemed like the reasonable trigger since we would like to
Quoted 1 line
Quoted 1 line
activate the packing only when it will be beneficial, regardless of the
write requests sizes.
Quoted 1 line
Why ? How do you know "when it will be beneficial" ? As I mentioned, the
number of
Quoted 1 line
blocks per request would vary over time, and also depends on the
filesystem. OTOH, even small
Quoted 1 line
writes could take a lot longer than usual (>500ms) due to garbage
collection etc.
Quoted 1 line
Based on our experiments the write packing is mostly beneficial in long sequential write scenarios. Therefore, we would still like the write packing to be enabled in such cases (as long as there are no parallel reads). The trigger of number of potential packed requests ensures that the packing will be enabled in case of a flow of write.
Can you please explain why you refer to the number of blocks per request when the write packing solution doesn't take into account the request size?
Thanks,
Maya Erez
--
Sent by consultant of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum