All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/1] mmc: block: Add write packing control
@ 2012-06-01 18:55 Maya Erez
  2012-06-01 18:55   ` Maya Erez
  0 siblings, 1 reply; 29+ messages in thread
From: Maya Erez @ 2012-06-01 18:55 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-arm-msm, Maya Erez

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 following 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

Changes in v2:
    - Move the attribute for setting the packing enabling trigger to the block device
    - Add documentation of the new attribute

Maya Erez (1):
  mmc: block: Add write packing control

 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(-)

--
1.7.3.3
-- 
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-01 18:55 [PATCH v2 0/1] mmc: block: Add write packing control Maya Erez
@ 2012-06-01 18:55   ` Maya Erez
  0 siblings, 0 replies; 29+ messages in thread
From: Maya Erez @ 2012-06-01 18:55 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-arm-msm, Maya Erez, open list:DOCUMENTATION, open list

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 by writing the required value to:
/sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
The trigger for disabling the write packing is fetching a read request.

---
 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(-)

diff --git a/Documentation/mmc/mmc-dev-attrs.txt b/Documentation/mmc/mmc-dev-attrs.txt
index 22ae844..08f7312 100644
--- a/Documentation/mmc/mmc-dev-attrs.txt
+++ b/Documentation/mmc/mmc-dev-attrs.txt
@@ -8,6 +8,23 @@ The following attributes are read/write.

 	force_ro		Enforce read-only access even if write protect switch is off.

+	num_wr_reqs_to_start_packing 	This attribute is used to determine
+	the trigger for activating the write packing, in case the write
+	packing control feature is enabled.
+
+	When the MMC manages to reach a point where num_wr_reqs_to_start_packing
+	write requests could be packed, it enables the write packing feature.
+	This allows us to start the write packing only when it is beneficial
+	and has minimum affect on the read latency.
+
+	The number of potential packed requests that will trigger the packing
+	can be configured via sysfs by writing the required value to:
+	/sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
+
+	The default value of num_wr_reqs_to_start_packing was determined by
+	running parallel lmdd write and lmdd read operations and calculating
+	the max number of packed writes requests.
+
 SD and MMC Device Attributes
 ============================

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 2785fd4..ef192fb 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -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;
 }

+static ssize_t
+num_wr_reqs_to_start_packing_show(struct device *dev,
+				  struct device_attribute *attr, char *buf)
+{
+	struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
+	int num_wr_reqs_to_start_packing;
+	int ret;
+
+	num_wr_reqs_to_start_packing = md->queue.num_wr_reqs_to_start_packing;
+
+	ret = snprintf(buf, PAGE_SIZE, "%d\n", num_wr_reqs_to_start_packing);
+
+	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)
+{
+	int value;
+	struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
+
+	sscanf(buf, "%d", &value);
+	if (value >= 0)
+		md->queue.num_wr_reqs_to_start_packing = value;
+
+	mmc_blk_put(md);
+	return count;
+}
+
 static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
 {
 	struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
@@ -1313,6 +1346,48 @@ 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;
+
+	if (!(host->caps2 & MMC_CAP2_PACKED_WR))
+		return;
+
+	/*
+	 * In case the packing control is not supported by the host, it should
+	 * not have an effect on the write packing. Therefore we have to 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;
+		return;
+	}
+
+	data_dir = rq_data_dir(req);
+
+	if (data_dir == READ) {
+		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;
+
+}
+
 static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct request *req)
 {
 	struct request_queue *q = mq->queue;
@@ -1332,6 +1407,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->wr_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 +1474,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,7 +1860,9 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
 		goto out;
 	}

-	if (req && req->cmd_flags & REQ_DISCARD) {
+	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)
 			mmc_blk_issue_rw_rq(mq, NULL);
@@ -2010,6 +2092,8 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md)

 	if (md) {
 		card = md->queue.card;
+		device_remove_file(disk_to_dev(md->disk),
+				   &md->num_wr_reqs_to_start_packing);
 		if (md->disk->flags & GENHD_FL_UP) {
 			device_remove_file(disk_to_dev(md->disk), &md->force_ro);
 			if ((md->area_type & MMC_BLK_DATA_AREA_BOOT) &&
@@ -2076,6 +2160,20 @@ static int mmc_add_disk(struct mmc_blk_data *md)
 		if (ret)
 			goto power_ro_lock_fail;
 	}
+
+	md->num_wr_reqs_to_start_packing.show =
+		num_wr_reqs_to_start_packing_show;
+	md->num_wr_reqs_to_start_packing.store =
+		num_wr_reqs_to_start_packing_store;
+	sysfs_attr_init(&md->num_wr_reqs_to_start_packing.attr);
+	md->num_wr_reqs_to_start_packing.attr.name =
+		"num_wr_reqs_to_start_packing";
+	md->num_wr_reqs_to_start_packing.attr.mode = S_IRUGO | S_IWUSR;
+	ret = device_create_file(disk_to_dev(md->disk),
+				 &md->num_wr_reqs_to_start_packing);
+	if (ret)
+		goto power_ro_lock_fail;
+
 	return ret;

 power_ro_lock_fail:
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 165d85a..79ef91b 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -25,6 +25,13 @@
 #define MMC_QUEUE_SUSPENDED	(1 << 0)

 /*
+ * Based on benchmark tests the default num of requests to trigger the write
+ * packing was determined, to keep the read latency as low as possible and
+ * manage to keep the high write throughput.
+ */
+#define DEFAULT_NUM_REQS_TO_START_PACK 17
+
+/*
  * Prepare a MMC request. This just filters out odd stuff.
  */
 static int mmc_prep_request(struct request_queue *q, struct request *req)
@@ -181,6 +188,7 @@ 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->num_wr_reqs_to_start_packing = DEFAULT_NUM_REQS_TO_START_PACK;

 	blk_queue_prep_rq(mq->queue, mmc_prep_request);
 	queue_flag_set_unlocked(QUEUE_FLAG_NONROT, mq->queue);
diff --git a/drivers/mmc/card/queue.h b/drivers/mmc/card/queue.h
index d761bf1..6c29e0e 100644
--- a/drivers/mmc/card/queue.h
+++ b/drivers/mmc/card/queue.h
@@ -44,6 +44,9 @@ struct mmc_queue {
 	struct mmc_queue_req	mqrq[2];
 	struct mmc_queue_req	*mqrq_cur;
 	struct mmc_queue_req	*mqrq_prev;
+	bool			wr_packing_enabled;
+	int			num_of_potential_packed_wr_reqs;
+	int			num_wr_reqs_to_start_packing;
 };

 extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 9d0d946..0eb6c7b 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -242,6 +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;
--
1.7.3.3
-- 
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH v2 1/1] mmc: block: Add write packing control
@ 2012-06-01 18:55   ` Maya Erez
  0 siblings, 0 replies; 29+ messages in thread
From: Maya Erez @ 2012-06-01 18:55 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-arm-msm, Maya Erez, open list:DOCUMENTATION, open list

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 by writing the required value to:
/sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
The trigger for disabling the write packing is fetching a read request.

---
 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(-)

diff --git a/Documentation/mmc/mmc-dev-attrs.txt b/Documentation/mmc/mmc-dev-attrs.txt
index 22ae844..08f7312 100644
--- a/Documentation/mmc/mmc-dev-attrs.txt
+++ b/Documentation/mmc/mmc-dev-attrs.txt
@@ -8,6 +8,23 @@ The following attributes are read/write.

 	force_ro		Enforce read-only access even if write protect switch is off.

+	num_wr_reqs_to_start_packing 	This attribute is used to determine
+	the trigger for activating the write packing, in case the write
+	packing control feature is enabled.
+
+	When the MMC manages to reach a point where num_wr_reqs_to_start_packing
+	write requests could be packed, it enables the write packing feature.
+	This allows us to start the write packing only when it is beneficial
+	and has minimum affect on the read latency.
+
+	The number of potential packed requests that will trigger the packing
+	can be configured via sysfs by writing the required value to:
+	/sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
+
+	The default value of num_wr_reqs_to_start_packing was determined by
+	running parallel lmdd write and lmdd read operations and calculating
+	the max number of packed writes requests.
+
 SD and MMC Device Attributes
 ============================

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 2785fd4..ef192fb 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -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;
 }

+static ssize_t
+num_wr_reqs_to_start_packing_show(struct device *dev,
+				  struct device_attribute *attr, char *buf)
+{
+	struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
+	int num_wr_reqs_to_start_packing;
+	int ret;
+
+	num_wr_reqs_to_start_packing = md->queue.num_wr_reqs_to_start_packing;
+
+	ret = snprintf(buf, PAGE_SIZE, "%d\n", num_wr_reqs_to_start_packing);
+
+	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)
+{
+	int value;
+	struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
+
+	sscanf(buf, "%d", &value);
+	if (value >= 0)
+		md->queue.num_wr_reqs_to_start_packing = value;
+
+	mmc_blk_put(md);
+	return count;
+}
+
 static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
 {
 	struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
@@ -1313,6 +1346,48 @@ 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;
+
+	if (!(host->caps2 & MMC_CAP2_PACKED_WR))
+		return;
+
+	/*
+	 * In case the packing control is not supported by the host, it should
+	 * not have an effect on the write packing. Therefore we have to 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;
+		return;
+	}
+
+	data_dir = rq_data_dir(req);
+
+	if (data_dir == READ) {
+		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;
+
+}
+
 static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct request *req)
 {
 	struct request_queue *q = mq->queue;
@@ -1332,6 +1407,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->wr_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 +1474,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,7 +1860,9 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
 		goto out;
 	}

-	if (req && req->cmd_flags & REQ_DISCARD) {
+	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)
 			mmc_blk_issue_rw_rq(mq, NULL);
@@ -2010,6 +2092,8 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md)

 	if (md) {
 		card = md->queue.card;
+		device_remove_file(disk_to_dev(md->disk),
+				   &md->num_wr_reqs_to_start_packing);
 		if (md->disk->flags & GENHD_FL_UP) {
 			device_remove_file(disk_to_dev(md->disk), &md->force_ro);
 			if ((md->area_type & MMC_BLK_DATA_AREA_BOOT) &&
@@ -2076,6 +2160,20 @@ static int mmc_add_disk(struct mmc_blk_data *md)
 		if (ret)
 			goto power_ro_lock_fail;
 	}
+
+	md->num_wr_reqs_to_start_packing.show =
+		num_wr_reqs_to_start_packing_show;
+	md->num_wr_reqs_to_start_packing.store =
+		num_wr_reqs_to_start_packing_store;
+	sysfs_attr_init(&md->num_wr_reqs_to_start_packing.attr);
+	md->num_wr_reqs_to_start_packing.attr.name =
+		"num_wr_reqs_to_start_packing";
+	md->num_wr_reqs_to_start_packing.attr.mode = S_IRUGO | S_IWUSR;
+	ret = device_create_file(disk_to_dev(md->disk),
+				 &md->num_wr_reqs_to_start_packing);
+	if (ret)
+		goto power_ro_lock_fail;
+
 	return ret;

 power_ro_lock_fail:
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 165d85a..79ef91b 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -25,6 +25,13 @@
 #define MMC_QUEUE_SUSPENDED	(1 << 0)

 /*
+ * Based on benchmark tests the default num of requests to trigger the write
+ * packing was determined, to keep the read latency as low as possible and
+ * manage to keep the high write throughput.
+ */
+#define DEFAULT_NUM_REQS_TO_START_PACK 17
+
+/*
  * Prepare a MMC request. This just filters out odd stuff.
  */
 static int mmc_prep_request(struct request_queue *q, struct request *req)
@@ -181,6 +188,7 @@ 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->num_wr_reqs_to_start_packing = DEFAULT_NUM_REQS_TO_START_PACK;

 	blk_queue_prep_rq(mq->queue, mmc_prep_request);
 	queue_flag_set_unlocked(QUEUE_FLAG_NONROT, mq->queue);
diff --git a/drivers/mmc/card/queue.h b/drivers/mmc/card/queue.h
index d761bf1..6c29e0e 100644
--- a/drivers/mmc/card/queue.h
+++ b/drivers/mmc/card/queue.h
@@ -44,6 +44,9 @@ struct mmc_queue {
 	struct mmc_queue_req	mqrq[2];
 	struct mmc_queue_req	*mqrq_cur;
 	struct mmc_queue_req	*mqrq_prev;
+	bool			wr_packing_enabled;
+	int			num_of_potential_packed_wr_reqs;
+	int			num_wr_reqs_to_start_packing;
 };

 extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 9d0d946..0eb6c7b 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -242,6 +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;
--
1.7.3.3
-- 
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* RE: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-01 18:55   ` Maya Erez
  (?)
@ 2012-06-08  9:37   ` Seungwon Jeon
  2012-06-09 14:46     ` merez
  -1 siblings, 1 reply; 29+ messages in thread
From: Seungwon Jeon @ 2012-06-08  9:37 UTC (permalink / raw)
  To: 'Maya Erez', linux-mmc
  Cc: linux-arm-msm, 'open list:DOCUMENTATION', 'open list'

Hi,

How can we check the effect?
Do you have any result?
Please check the several comment below.

Maya Erez <merez@codeaurora.org> wrote:
> 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 by writing the required value to:
> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
> The trigger for disabling the write packing is fetching a read request.
> 
> ---
>  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(-)
> 
> diff --git a/Documentation/mmc/mmc-dev-attrs.txt b/Documentation/mmc/mmc-dev-attrs.txt
> index 22ae844..08f7312 100644
> --- a/Documentation/mmc/mmc-dev-attrs.txt
> +++ b/Documentation/mmc/mmc-dev-attrs.txt
> @@ -8,6 +8,23 @@ The following attributes are read/write.
> 
>  	force_ro		Enforce read-only access even if write protect switch is off.
> 
> +	num_wr_reqs_to_start_packing 	This attribute is used to determine
> +	the trigger for activating the write packing, in case the write
> +	packing control feature is enabled.
> +
> +	When the MMC manages to reach a point where num_wr_reqs_to_start_packing
> +	write requests could be packed, it enables the write packing feature.
> +	This allows us to start the write packing only when it is beneficial
> +	and has minimum affect on the read latency.
> +
> +	The number of potential packed requests that will trigger the packing
> +	can be configured via sysfs by writing the required value to:
> +	/sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
> +
> +	The default value of num_wr_reqs_to_start_packing was determined by
> +	running parallel lmdd write and lmdd read operations and calculating
> +	the max number of packed writes requests.
> +
>  SD and MMC Device Attributes
>  ============================
> 
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 2785fd4..ef192fb 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -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;
>  }
> 
> +static ssize_t
> +num_wr_reqs_to_start_packing_show(struct device *dev,
> +				  struct device_attribute *attr, char *buf)
> +{
> +	struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
> +	int num_wr_reqs_to_start_packing;
> +	int ret;
> +
> +	num_wr_reqs_to_start_packing = md->queue.num_wr_reqs_to_start_packing;
> +
> +	ret = snprintf(buf, PAGE_SIZE, "%d\n", num_wr_reqs_to_start_packing);
> +
> +	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)
> +{
> +	int value;
> +	struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
> +
> +	sscanf(buf, "%d", &value);
> +	if (value >= 0)
> +		md->queue.num_wr_reqs_to_start_packing = value;
> +
> +	mmc_blk_put(md);
> +	return count;
> +}
> +
>  static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
>  {
>  	struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
> @@ -1313,6 +1346,48 @@ 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;
> +
> +	if (!(host->caps2 & MMC_CAP2_PACKED_WR))
> +		return;
> +
> +	/*
> +	 * In case the packing control is not supported by the host, it should
> +	 * not have an effect on the write packing. Therefore we have to 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;
> +		return;
> +	}
> +
> +	data_dir = rq_data_dir(req);
> +
> +	if (data_dir == READ) {
> +		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 over num_wr_reqs_to_start_packing?
That means individual request(1...17) will be issued with non-packing.
Could you explain your policy more?
> +
> +}
> +
>  static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct request *req)
>  {
>  	struct request_queue *q = mq->queue;
> @@ -1332,6 +1407,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->wr_packing_enabled)
> +		goto no_packed;
If wr_packing_enabled is set to true, several write requests can be packed.
We don't need to consider read request since packed write?

Thanks,
Seungwon Jeon
> +
>  	if ((rq_data_dir(cur) == WRITE) &&
>  			(card->host->caps2 & MMC_CAP2_PACKED_WR))
>  		max_packed_rw = card->ext_csd.max_packed_writes;
> @@ -1396,6 +1474,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,7 +1860,9 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
>  		goto out;
>  	}
> 
> -	if (req && req->cmd_flags & REQ_DISCARD) {
> +	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)
>  			mmc_blk_issue_rw_rq(mq, NULL);
> @@ -2010,6 +2092,8 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md)
> 
>  	if (md) {
>  		card = md->queue.card;
> +		device_remove_file(disk_to_dev(md->disk),
> +				   &md->num_wr_reqs_to_start_packing);
>  		if (md->disk->flags & GENHD_FL_UP) {
>  			device_remove_file(disk_to_dev(md->disk), &md->force_ro);
>  			if ((md->area_type & MMC_BLK_DATA_AREA_BOOT) &&
> @@ -2076,6 +2160,20 @@ static int mmc_add_disk(struct mmc_blk_data *md)
>  		if (ret)
>  			goto power_ro_lock_fail;
>  	}
> +
> +	md->num_wr_reqs_to_start_packing.show =
> +		num_wr_reqs_to_start_packing_show;
> +	md->num_wr_reqs_to_start_packing.store =
> +		num_wr_reqs_to_start_packing_store;
> +	sysfs_attr_init(&md->num_wr_reqs_to_start_packing.attr);
> +	md->num_wr_reqs_to_start_packing.attr.name =
> +		"num_wr_reqs_to_start_packing";
> +	md->num_wr_reqs_to_start_packing.attr.mode = S_IRUGO | S_IWUSR;
> +	ret = device_create_file(disk_to_dev(md->disk),
> +				 &md->num_wr_reqs_to_start_packing);
> +	if (ret)
> +		goto power_ro_lock_fail;
> +
>  	return ret;
> 
>  power_ro_lock_fail:
> diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
> index 165d85a..79ef91b 100644
> --- a/drivers/mmc/card/queue.c
> +++ b/drivers/mmc/card/queue.c
> @@ -25,6 +25,13 @@
>  #define MMC_QUEUE_SUSPENDED	(1 << 0)
> 
>  /*
> + * Based on benchmark tests the default num of requests to trigger the write
> + * packing was determined, to keep the read latency as low as possible and
> + * manage to keep the high write throughput.
> + */
> +#define DEFAULT_NUM_REQS_TO_START_PACK 17
> +
> +/*
>   * Prepare a MMC request. This just filters out odd stuff.
>   */
>  static int mmc_prep_request(struct request_queue *q, struct request *req)
> @@ -181,6 +188,7 @@ 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->num_wr_reqs_to_start_packing = DEFAULT_NUM_REQS_TO_START_PACK;
> 
>  	blk_queue_prep_rq(mq->queue, mmc_prep_request);
>  	queue_flag_set_unlocked(QUEUE_FLAG_NONROT, mq->queue);
> diff --git a/drivers/mmc/card/queue.h b/drivers/mmc/card/queue.h
> index d761bf1..6c29e0e 100644
> --- a/drivers/mmc/card/queue.h
> +++ b/drivers/mmc/card/queue.h
> @@ -44,6 +44,9 @@ struct mmc_queue {
>  	struct mmc_queue_req	mqrq[2];
>  	struct mmc_queue_req	*mqrq_cur;
>  	struct mmc_queue_req	*mqrq_prev;
> +	bool			wr_packing_enabled;
> +	int			num_of_potential_packed_wr_reqs;
> +	int			num_wr_reqs_to_start_packing;
>  };
> 
>  extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
> index 9d0d946..0eb6c7b 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -242,6 +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;
> --
> 1.7.3.3
> --
> Sent by a consultant of the Qualcomm Innovation Center, Inc.
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 29+ messages in thread

* RE: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-08  9:37   ` Seungwon Jeon
@ 2012-06-09 14:46     ` merez
  2012-06-11  9:10       ` Seungwon Jeon
  2012-06-11 17:19       ` S, Venkatraman
  0 siblings, 2 replies; 29+ messages in thread
From: merez @ 2012-06-09 14:46 UTC (permalink / raw)
  To: Seungwon Jeon
  Cc: 'Maya Erez', linux-mmc, linux-arm-msm, DOCUMENTATION',
	'open list'


> 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
write packing causes the read throughput to drop from 24MB/s to 12MB/s.
The write packing control managed to increase the read throughput back to
the original value.
We also examined "real life" scenarios, such as performing a big push
operation in parallel to launching several applications. We measured the
read latency and found out that with the write packing control the worst
case of the read latency was smaller.

> Please check the several comment below.
>
> Maya Erez <merez@codeaurora.org> wrote:
>> 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 by writing the required value
>> to:
>> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>> The trigger for disabling the write packing is fetching a read request.
>>
>> ---
>>  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(-)
>>
>> diff --git a/Documentation/mmc/mmc-dev-attrs.txt
>> b/Documentation/mmc/mmc-dev-attrs.txt
>> index 22ae844..08f7312 100644
>> --- a/Documentation/mmc/mmc-dev-attrs.txt
>> +++ b/Documentation/mmc/mmc-dev-attrs.txt
>> @@ -8,6 +8,23 @@ The following attributes are read/write.
>>
>>  	force_ro		Enforce read-only access even if write protect switch is
>> off.
>>
>> +	num_wr_reqs_to_start_packing 	This attribute is used to determine
>> +	the trigger for activating the write packing, in case the write
>> +	packing control feature is enabled.
>> +
>> +	When the MMC manages to reach a point where
>> num_wr_reqs_to_start_packing
>> +	write requests could be packed, it enables the write packing feature.
>> +	This allows us to start the write packing only when it is beneficial
>> +	and has minimum affect on the read latency.
>> +
>> +	The number of potential packed requests that will trigger the packing
>> +	can be configured via sysfs by writing the required value to:
>> +	/sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>> +
>> +	The default value of num_wr_reqs_to_start_packing was determined by
>> +	running parallel lmdd write and lmdd read operations and calculating
>> +	the max number of packed writes requests.
>> +
>>  SD and MMC Device Attributes
>>  ============================
>>
>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>> index 2785fd4..ef192fb 100644
>> --- a/drivers/mmc/card/block.c
>> +++ b/drivers/mmc/card/block.c
>> @@ -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;
>>  }
>>
>> +static ssize_t
>> +num_wr_reqs_to_start_packing_show(struct device *dev,
>> +				  struct device_attribute *attr, char *buf)
>> +{
>> +	struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
>> +	int num_wr_reqs_to_start_packing;
>> +	int ret;
>> +
>> +	num_wr_reqs_to_start_packing = md->queue.num_wr_reqs_to_start_packing;
>> +
>> +	ret = snprintf(buf, PAGE_SIZE, "%d\n", num_wr_reqs_to_start_packing);
>> +
>> +	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)
>> +{
>> +	int value;
>> +	struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
>> +
>> +	sscanf(buf, "%d", &value);
>> +	if (value >= 0)
>> +		md->queue.num_wr_reqs_to_start_packing = value;
>> +
>> +	mmc_blk_put(md);
>> +	return count;
>> +}
>> +
>>  static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
>>  {
>>  	struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
>> @@ -1313,6 +1346,48 @@ 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;
>> +
>> +	if (!(host->caps2 & MMC_CAP2_PACKED_WR))
>> +		return;
>> +
>> +	/*
>> +	 * In case the packing control is not supported by the host, it should
>> +	 * not have an effect on the write packing. Therefore we have to
>> 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;
>> +		return;
>> +	}
>> +
>> +	data_dir = rq_data_dir(req);
>> +
>> +	if (data_dir == READ) {
>> +		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 over
> num_wr_reqs_to_start_packing?
> That means individual request(1...17) will be issued with non-packing.
> 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
requests between read requests in parallel read and write operations
doesn't exceed 17 requests. Therefore, we can assume that fetching more
than 17 write requests without hitting a read request can indicate that
there is no read activity.
You are right that this affects the write throughput a bit but the goal of
this algorithm is to make sure the read throughput and latency are not
decreased due to write. If this is not the desired result, this algorithm
can be disabled.
>> +
>> +}
>> +
>>  static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct request
>> *req)
>>  {
>>  	struct request_queue *q = mq->queue;
>> @@ -1332,6 +1407,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->wr_packing_enabled)
>> +		goto no_packed;
> If wr_packing_enabled is set to true, several write requests can be
> 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
request in the mmc_blk_write_packing_control, and in such a case set
mq->wr_packing_enabled to false.
If I didn't answer the question, please explain it again.

>
> Thanks,
> Seungwon Jeon

Thanks,
Maya Erez
--
Sent by a consultant of the Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply	[flat|nested] 29+ messages in thread

* RE: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-09 14:46     ` merez
@ 2012-06-11  9:10       ` Seungwon Jeon
  2012-06-11 13:55         ` merez
  2012-06-11 17:19       ` S, Venkatraman
  1 sibling, 1 reply; 29+ messages in thread
From: Seungwon Jeon @ 2012-06-11  9:10 UTC (permalink / raw)
  To: 'Maya Erez'
  Cc: linux-mmc, linux-arm-msm, 'DOCUMENTATION'',
	'open list'

Maya Erez <merez@codeaurora.org> wrote:
> 
> > 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
> write packing causes the read throughput to drop from 24MB/s to 12MB/s.
> The write packing control managed to increase the read throughput back to
> the original value.
> We also examined "real life" scenarios, such as performing a big push
> operation in parallel to launching several applications. We measured the
> read latency and found out that with the write packing control the worst
> case of the read latency was smaller.
> 
> > Please check the several comment below.
> >
> > Maya Erez <merez@codeaurora.org> wrote:
> >> 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 by writing the required value
> >> to:
> >> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
> >> The trigger for disabling the write packing is fetching a read request.
> >>
> >> ---
> >>  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(-)
> >>
> >> diff --git a/Documentation/mmc/mmc-dev-attrs.txt
> >> b/Documentation/mmc/mmc-dev-attrs.txt
> >> index 22ae844..08f7312 100644
> >> --- a/Documentation/mmc/mmc-dev-attrs.txt
> >> +++ b/Documentation/mmc/mmc-dev-attrs.txt
> >> @@ -8,6 +8,23 @@ The following attributes are read/write.
> >>
> >>  	force_ro		Enforce read-only access even if write protect switch is
> >> off.
> >>
> >> +	num_wr_reqs_to_start_packing 	This attribute is used to determine
> >> +	the trigger for activating the write packing, in case the write
> >> +	packing control feature is enabled.
> >> +
> >> +	When the MMC manages to reach a point where
> >> num_wr_reqs_to_start_packing
> >> +	write requests could be packed, it enables the write packing feature.
> >> +	This allows us to start the write packing only when it is beneficial
> >> +	and has minimum affect on the read latency.
> >> +
> >> +	The number of potential packed requests that will trigger the packing
> >> +	can be configured via sysfs by writing the required value to:
> >> +	/sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
> >> +
> >> +	The default value of num_wr_reqs_to_start_packing was determined by
> >> +	running parallel lmdd write and lmdd read operations and calculating
> >> +	the max number of packed writes requests.
> >> +
> >>  SD and MMC Device Attributes
> >>  ============================
> >>
> >> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> >> index 2785fd4..ef192fb 100644
> >> --- a/drivers/mmc/card/block.c
> >> +++ b/drivers/mmc/card/block.c
> >> @@ -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;
> >>  }
> >>
> >> +static ssize_t
> >> +num_wr_reqs_to_start_packing_show(struct device *dev,
> >> +				  struct device_attribute *attr, char *buf)
> >> +{
> >> +	struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
> >> +	int num_wr_reqs_to_start_packing;
> >> +	int ret;
> >> +
> >> +	num_wr_reqs_to_start_packing = md->queue.num_wr_reqs_to_start_packing;
> >> +
> >> +	ret = snprintf(buf, PAGE_SIZE, "%d\n", num_wr_reqs_to_start_packing);
> >> +
> >> +	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)
> >> +{
> >> +	int value;
> >> +	struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
> >> +
> >> +	sscanf(buf, "%d", &value);
> >> +	if (value >= 0)
> >> +		md->queue.num_wr_reqs_to_start_packing = value;
> >> +
> >> +	mmc_blk_put(md);
> >> +	return count;
> >> +}
> >> +
> >>  static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
> >>  {
> >>  	struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
> >> @@ -1313,6 +1346,48 @@ 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;
> >> +
> >> +	if (!(host->caps2 & MMC_CAP2_PACKED_WR))
> >> +		return;
> >> +
> >> +	/*
> >> +	 * In case the packing control is not supported by the host, it should
> >> +	 * not have an effect on the write packing. Therefore we have to
> >> 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;
> >> +		return;
> >> +	}
> >> +
> >> +	data_dir = rq_data_dir(req);
> >> +
> >> +	if (data_dir == READ) {
> >> +		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 over
> > num_wr_reqs_to_start_packing?
> > That means individual request(1...17) will be issued with non-packing.
> > 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
> requests between read requests in parallel read and write operations
> doesn't exceed 17 requests. Therefore, we can assume that fetching more
> than 17 write requests without hitting a read request can indicate that
> there is no read activity.
We can apply this experiment regardless I/O scheduler?
Which I/O scheduler was used with this experiment?

> You are right that this affects the write throughput a bit but the goal of
> this algorithm is to make sure the read throughput and latency are not
> decreased due to write. If this is not the desired result, this algorithm
> can be disabled.
> >> +
> >> +}
> >> +
> >>  static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct request
> >> *req)
> >>  {
> >>  	struct request_queue *q = mq->queue;
> >> @@ -1332,6 +1407,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->wr_packing_enabled)
> >> +		goto no_packed;
> > If wr_packing_enabled is set to true, several write requests can be
> > 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
> request in the mmc_blk_write_packing_control, and in such a case set
> mq->wr_packing_enabled to 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 write?
I wonder this case.

Thanks,
Seungwon Jeon.
> 
> >
> > Thanks,
> > Seungwon Jeon
> 
> Thanks,
> Maya Erez
> --
> Sent by a consultant of the Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 29+ messages in thread

* RE: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-11  9:10       ` Seungwon Jeon
@ 2012-06-11 13:55         ` merez
  2012-06-11 14:39           ` S, Venkatraman
  0 siblings, 1 reply; 29+ messages in thread
From: merez @ 2012-06-11 13:55 UTC (permalink / raw)
  To: Seungwon Jeon
  Cc: 'Maya Erez',
	linux-mmc, linux-arm-msm, 'DOCUMENTATION'',
	'open list'


> Maya Erez <merez@codeaurora.org> wrote:
>>
>> > 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
>> write packing causes the read throughput to drop from 24MB/s to 12MB/s.
>> The write packing control managed to increase the read throughput back
>> to
>> the original value.
>> We also examined "real life" scenarios, such as performing a big push
>> operation in parallel to launching several applications. We measured the
>> read latency and found out that with the write packing control the worst
>> case of the read latency was smaller.
>>
>> > Please check the several comment below.
>> >
>> > Maya Erez <merez@codeaurora.org> wrote:
>> >> 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 by writing the required value
>> >> to:
>> >> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>> >> The trigger for disabling the write packing is fetching a read
>> request.
>> >>
>> >> ---
>> >>  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(-)
>> >>
>> >> diff --git a/Documentation/mmc/mmc-dev-attrs.txt
>> >> b/Documentation/mmc/mmc-dev-attrs.txt
>> >> index 22ae844..08f7312 100644
>> >> --- a/Documentation/mmc/mmc-dev-attrs.txt
>> >> +++ b/Documentation/mmc/mmc-dev-attrs.txt
>> >> @@ -8,6 +8,23 @@ The following attributes are read/write.
>> >>
>> >>  	force_ro		Enforce read-only access even if write protect switch is
>> >> off.
>> >>
>> >> +	num_wr_reqs_to_start_packing 	This attribute is used to determine
>> >> +	the trigger for activating the write packing, in case the write
>> >> +	packing control feature is enabled.
>> >> +
>> >> +	When the MMC manages to reach a point where
>> >> num_wr_reqs_to_start_packing
>> >> +	write requests could be packed, it enables the write packing
>> feature.
>> >> +	This allows us to start the write packing only when it is
>> beneficial
>> >> +	and has minimum affect on the read latency.
>> >> +
>> >> +	The number of potential packed requests that will trigger the
>> packing
>> >> +	can be configured via sysfs by writing the required value to:
>> >> +	/sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>> >> +
>> >> +	The default value of num_wr_reqs_to_start_packing was determined by
>> >> +	running parallel lmdd write and lmdd read operations and
>> calculating
>> >> +	the max number of packed writes requests.
>> >> +
>> >>  SD and MMC Device Attributes
>> >>  ============================
>> >>
>> >> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>> >> index 2785fd4..ef192fb 100644
>> >> --- a/drivers/mmc/card/block.c
>> >> +++ b/drivers/mmc/card/block.c
>> >> @@ -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;
>> >>  }
>> >>
>> >> +static ssize_t
>> >> +num_wr_reqs_to_start_packing_show(struct device *dev,
>> >> +				  struct device_attribute *attr, char *buf)
>> >> +{
>> >> +	struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
>> >> +	int num_wr_reqs_to_start_packing;
>> >> +	int ret;
>> >> +
>> >> +	num_wr_reqs_to_start_packing =
>> md->queue.num_wr_reqs_to_start_packing;
>> >> +
>> >> +	ret = snprintf(buf, PAGE_SIZE, "%d\n",
>> num_wr_reqs_to_start_packing);
>> >> +
>> >> +	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)
>> >> +{
>> >> +	int value;
>> >> +	struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
>> >> +
>> >> +	sscanf(buf, "%d", &value);
>> >> +	if (value >= 0)
>> >> +		md->queue.num_wr_reqs_to_start_packing = value;
>> >> +
>> >> +	mmc_blk_put(md);
>> >> +	return count;
>> >> +}
>> >> +
>> >>  static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
>> >>  {
>> >>  	struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
>> >> @@ -1313,6 +1346,48 @@ 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;
>> >> +
>> >> +	if (!(host->caps2 & MMC_CAP2_PACKED_WR))
>> >> +		return;
>> >> +
>> >> +	/*
>> >> +	 * In case the packing control is not supported by the host, it
>> should
>> >> +	 * not have an effect on the write packing. Therefore we have to
>> >> 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;
>> >> +		return;
>> >> +	}
>> >> +
>> >> +	data_dir = rq_data_dir(req);
>> >> +
>> >> +	if (data_dir == READ) {
>> >> +		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 over
>> > num_wr_reqs_to_start_packing?
>> > That means individual request(1...17) will be issued with non-packing.
>> > 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
>> requests between read requests in parallel read and write operations
>> doesn't exceed 17 requests. Therefore, we can assume that fetching more
>> than 17 write requests without hitting a read request can indicate that
>> 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
uses a batch of 16 requests it should also fit the deadline scheduler.
In case another value is required, this value can be changed via sysfs.
>
>> You are right that this affects the write throughput a bit but the goal
>> of
>> this algorithm is to make sure the read throughput and latency are not
>> decreased due to write. If this is not the desired result, this
>> algorithm
>> can be disabled.
>> >> +
>> >> +}
>> >> +
>> >>  static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct
>> request
>> >> *req)
>> >>  {
>> >>  	struct request_queue *q = mq->queue;
>> >> @@ -1332,6 +1407,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->wr_packing_enabled)
>> >> +		goto no_packed;
>> > If wr_packing_enabled is set to true, several write requests can be
>> > 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
>> request in the mmc_blk_write_packing_control, and in such a case set
>> mq->wr_packing_enabled to 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
> write?
> I wonder this case.
Currently in such a case we will send the packed command followed by the
read request. The latency of this read request will be high due to waiting
for the completion of the packed write. However, since we will disable the
write packing, the latency of the following read requests will be low.
We are working on a solution where the read request will bypass the write
requests in such a case. This change requires modification of the
scheduler in order to re-insert the write requests to the scheduler.
>
> Thanks,
> Seungwon Jeon.
>>
>> >
>> > Thanks,
>> > Seungwon Jeon
>>
>> Thanks,
>> Maya Erez
>> --
>> Sent by a consultant of the Qualcomm Innovation Center, Inc.
>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>

Thanks,
Maya Erez
Consultant for Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-11 13:55         ` merez
@ 2012-06-11 14:39           ` S, Venkatraman
  2012-06-11 20:10             ` merez
  0 siblings, 1 reply; 29+ messages in thread
From: S, Venkatraman @ 2012-06-11 14:39 UTC (permalink / raw)
  To: merez
  Cc: Seungwon Jeon, linux-mmc, linux-arm-msm, DOCUMENTATION', open list

On Mon, Jun 11, 2012 at 7:25 PM,  <merez@codeaurora.org> wrote:
>
>> Maya Erez <merez@codeaurora.org> wrote:
>>>
>>> > 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
>>> write packing causes the read throughput to drop from 24MB/s to 12MB/s.
>>> The write packing control managed to increase the read throughput back
>>> to
>>> the original value.
>>> We also examined "real life" scenarios, such as performing a big push
>>> operation in parallel to launching several applications. We measured the
>>> read latency and found out that with the write packing control the worst
>>> case of the read latency was smaller.
>>>
>>> > Please check the several comment below.
>>> >
>>> > Maya Erez <merez@codeaurora.org> wrote:
>>> >> 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 by writing the required value
>>> >> to:
>>> >> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>> >> The trigger for disabling the write packing is fetching a read
>>> request.
>>> >>
>>> >> ---
>>> >>  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(-)
>>> >>
>>> >> diff --git a/Documentation/mmc/mmc-dev-attrs.txt
>>> >> b/Documentation/mmc/mmc-dev-attrs.txt
>>> >> index 22ae844..08f7312 100644
>>> >> --- a/Documentation/mmc/mmc-dev-attrs.txt
>>> >> +++ b/Documentation/mmc/mmc-dev-attrs.txt
>>> >> @@ -8,6 +8,23 @@ The following attributes are read/write.
>>> >>
>>> >>   force_ro                Enforce read-only access even if write protect switch is
>>> >> off.
>>> >>
>>> >> + num_wr_reqs_to_start_packing    This attribute is used to determine
>>> >> + the trigger for activating the write packing, in case the write
>>> >> + packing control feature is enabled.
>>> >> +
>>> >> + When the MMC manages to reach a point where
>>> >> num_wr_reqs_to_start_packing
>>> >> + write requests could be packed, it enables the write packing
>>> feature.
>>> >> + This allows us to start the write packing only when it is
>>> beneficial
>>> >> + and has minimum affect on the read latency.
>>> >> +
>>> >> + The number of potential packed requests that will trigger the
>>> packing
>>> >> + can be configured via sysfs by writing the required value to:
>>> >> + /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>> >> +
>>> >> + The default value of num_wr_reqs_to_start_packing was determined by
>>> >> + running parallel lmdd write and lmdd read operations and
>>> calculating
>>> >> + the max number of packed writes requests.
>>> >> +
>>> >>  SD and MMC Device Attributes
>>> >>  ============================
>>> >>
>>> >> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>>> >> index 2785fd4..ef192fb 100644
>>> >> --- a/drivers/mmc/card/block.c
>>> >> +++ b/drivers/mmc/card/block.c
>>> >> @@ -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;
>>> >>  }
>>> >>
>>> >> +static ssize_t
>>> >> +num_wr_reqs_to_start_packing_show(struct device *dev,
>>> >> +                           struct device_attribute *attr, char *buf)
>>> >> +{
>>> >> + struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
>>> >> + int num_wr_reqs_to_start_packing;
>>> >> + int ret;
>>> >> +
>>> >> + num_wr_reqs_to_start_packing =
>>> md->queue.num_wr_reqs_to_start_packing;
>>> >> +
>>> >> + ret = snprintf(buf, PAGE_SIZE, "%d\n",
>>> num_wr_reqs_to_start_packing);
>>> >> +
>>> >> + 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)
>>> >> +{
>>> >> + int value;
>>> >> + struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
>>> >> +
>>> >> + sscanf(buf, "%d", &value);
>>> >> + if (value >= 0)
>>> >> +         md->queue.num_wr_reqs_to_start_packing = value;
>>> >> +
>>> >> + mmc_blk_put(md);
>>> >> + return count;
>>> >> +}
>>> >> +
>>> >>  static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
>>> >>  {
>>> >>   struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
>>> >> @@ -1313,6 +1346,48 @@ 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;
>>> >> +
>>> >> + if (!(host->caps2 & MMC_CAP2_PACKED_WR))
>>> >> +         return;
>>> >> +
>>> >> + /*
>>> >> +  * In case the packing control is not supported by the host, it
>>> should
>>> >> +  * not have an effect on the write packing. Therefore we have to
>>> >> 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;
>>> >> +         return;
>>> >> + }
>>> >> +
>>> >> + data_dir = rq_data_dir(req);
>>> >> +
>>> >> + if (data_dir == READ) {
>>> >> +         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 over
>>> > num_wr_reqs_to_start_packing?
>>> > That means individual request(1...17) will be issued with non-packing.
>>> > 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
>>> requests between read requests in parallel read and write operations
>>> doesn't exceed 17 requests. Therefore, we can assume that fetching more
>>> than 17 write requests without hitting a read request can indicate that
>>> 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
> uses a batch of 16 requests it should also fit the deadline scheduler.
> In case another value is required, this value can be changed via sysfs.
>>
>>> You are right that this affects the write throughput a bit but the goal
>>> of
>>> this algorithm is to make sure the read throughput and latency are not
>>> decreased due to write. If this is not the desired result, this
>>> algorithm
>>> can be disabled.
>>> >> +
>>> >> +}
>>> >> +
>>> >>  static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct
>>> request
>>> >> *req)
>>> >>  {
>>> >>   struct request_queue *q = mq->queue;
>>> >> @@ -1332,6 +1407,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->wr_packing_enabled)
>>> >> +         goto no_packed;
>>> > If wr_packing_enabled is set to true, several write requests can be
>>> > 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
>>> request in the mmc_blk_write_packing_control, and in such a case set
>>> mq->wr_packing_enabled to 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
>> write?
>> I wonder this case.
> Currently in such a case we will send the packed command followed by the
> read request. The latency of this read request will be high due to waiting
> for the completion of the packed write. However, since we will disable the
> write packing, the latency of the following read requests will be low.
> We are working on a solution where the read request will bypass the write
> requests in such a case. This change requires modification of the
> scheduler in order to re-insert the write requests to the scheduler.
>>

Thats the precise reason for using foreground HPI (shameless plug :-))
I understand the intent of write packing control, but using the number
of requests
as a metric is too coarse. Some writes could be for only one sector
(512B) and others
could be in 512KB or more, giving a 1000x variance.

Foreground HPI solves this problem by interrupting only on a wait threshold.

Another aspect is that if a packed write is in progress, and you have
a read request,
you will most likely disable packing for the _next_ write, not the
ongoing one, right ?
That's too late an intervention IMHO.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-09 14:46     ` merez
  2012-06-11  9:10       ` Seungwon Jeon
@ 2012-06-11 17:19       ` S, Venkatraman
  2012-06-11 20:19         ` merez
  1 sibling, 1 reply; 29+ messages in thread
From: S, Venkatraman @ 2012-06-11 17:19 UTC (permalink / raw)
  To: merez
  Cc: Seungwon Jeon, linux-mmc, linux-arm-msm, DOCUMENTATION', open list

On Sat, Jun 9, 2012 at 8:16 PM,  <merez@codeaurora.org> wrote:
>
>> 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
> write packing causes the read throughput to drop from 24MB/s to 12MB/s.

Whoa! That's a big drop.
BTW, is there a problem with throughput or latency, or both ?
If these numbers are over long duration (>5 seconds), then where are
the cycles going?
It would be nice to see some blktrace figures for the issue, and then fix it,
rather than apply a band aid like the write-packing-control on top..


> The write packing control managed to increase the read throughput back to
> the original value.
> We also examined "real life" scenarios, such as performing a big push
> operation in parallel to launching several applications. We measured the
> read latency and found out that with the write packing control the worst
> case of the read latency was smaller.
>
>> Please check the several comment below.
>>
>> Maya Erez <merez@codeaurora.org> wrote:
>>> 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 by writing the required value
>>> to:
>>> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>> The trigger for disabling the write packing is fetching a read request.
>>>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-11 14:39           ` S, Venkatraman
@ 2012-06-11 20:10             ` merez
  2012-06-12  4:16               ` S, Venkatraman
  0 siblings, 1 reply; 29+ messages in thread
From: merez @ 2012-06-11 20:10 UTC (permalink / raw)
  To: S, Venkatraman
  Cc: merez, Seungwon Jeon, linux-mmc, linux-arm-msm,
	DOCUMENTATION',
	open list


> On Mon, Jun 11, 2012 at 7:25 PM,  <merez@codeaurora.org> wrote:
>>
>>> Maya Erez <merez@codeaurora.org> wrote:
>>>>
>>>> > 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
>>>> write packing causes the read throughput to drop from 24MB/s to
>>>> 12MB/s.
>>>> The write packing control managed to increase the read throughput back
>>>> to
>>>> the original value.
>>>> We also examined "real life" scenarios, such as performing a big push
>>>> operation in parallel to launching several applications. We measured
>>>> the
>>>> read latency and found out that with the write packing control the
>>>> worst
>>>> case of the read latency was smaller.
>>>>
>>>> > Please check the several comment below.
>>>> >
>>>> > Maya Erez <merez@codeaurora.org> wrote:
>>>> >> 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 by writing the required
>>>> value
>>>> >> to:
>>>> >> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>>> >> The trigger for disabling the write packing is fetching a read
>>>> request.
>>>> >>
>>>> >> ---
>>>> >>  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(-)
>>>> >>
>>>> >> diff --git a/Documentation/mmc/mmc-dev-attrs.txt
>>>> >> b/Documentation/mmc/mmc-dev-attrs.txt
>>>> >> index 22ae844..08f7312 100644
>>>> >> --- a/Documentation/mmc/mmc-dev-attrs.txt
>>>> >> +++ b/Documentation/mmc/mmc-dev-attrs.txt
>>>> >> @@ -8,6 +8,23 @@ The following attributes are read/write.
>>>> >>
>>>> >>   force_ro                Enforce read-only access even if write
>>>> protect switch is
>>>> >> off.
>>>> >>
>>>> >> + num_wr_reqs_to_start_packing    This attribute is used to
>>>> determine
>>>> >> + the trigger for activating the write packing, in case the write
>>>> >> + packing control feature is enabled.
>>>> >> +
>>>> >> + When the MMC manages to reach a point where
>>>> >> num_wr_reqs_to_start_packing
>>>> >> + write requests could be packed, it enables the write packing
>>>> feature.
>>>> >> + This allows us to start the write packing only when it is
>>>> beneficial
>>>> >> + and has minimum affect on the read latency.
>>>> >> +
>>>> >> + The number of potential packed requests that will trigger the
>>>> packing
>>>> >> + can be configured via sysfs by writing the required value to:
>>>> >> + /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>>> >> +
>>>> >> + The default value of num_wr_reqs_to_start_packing was determined
>>>> by
>>>> >> + running parallel lmdd write and lmdd read operations and
>>>> calculating
>>>> >> + the max number of packed writes requests.
>>>> >> +
>>>> >>  SD and MMC Device Attributes
>>>> >>  ============================
>>>> >>
>>>> >> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>>>> >> index 2785fd4..ef192fb 100644
>>>> >> --- a/drivers/mmc/card/block.c
>>>> >> +++ b/drivers/mmc/card/block.c
>>>> >> @@ -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;
>>>> >>  }
>>>> >>
>>>> >> +static ssize_t
>>>> >> +num_wr_reqs_to_start_packing_show(struct device *dev,
>>>> >> +                           struct device_attribute *attr, char
>>>> *buf)
>>>> >> +{
>>>> >> + struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
>>>> >> + int num_wr_reqs_to_start_packing;
>>>> >> + int ret;
>>>> >> +
>>>> >> + num_wr_reqs_to_start_packing =
>>>> md->queue.num_wr_reqs_to_start_packing;
>>>> >> +
>>>> >> + ret = snprintf(buf, PAGE_SIZE, "%d\n",
>>>> num_wr_reqs_to_start_packing);
>>>> >> +
>>>> >> + 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)
>>>> >> +{
>>>> >> + int value;
>>>> >> + struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
>>>> >> +
>>>> >> + sscanf(buf, "%d", &value);
>>>> >> + if (value >= 0)
>>>> >> +         md->queue.num_wr_reqs_to_start_packing = value;
>>>> >> +
>>>> >> + mmc_blk_put(md);
>>>> >> + return count;
>>>> >> +}
>>>> >> +
>>>> >>  static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
>>>> >>  {
>>>> >>   struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
>>>> >> @@ -1313,6 +1346,48 @@ 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;
>>>> >> +
>>>> >> + if (!(host->caps2 & MMC_CAP2_PACKED_WR))
>>>> >> +         return;
>>>> >> +
>>>> >> + /*
>>>> >> +  * In case the packing control is not supported by the host, it
>>>> should
>>>> >> +  * not have an effect on the write packing. Therefore we have to
>>>> >> 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;
>>>> >> +         return;
>>>> >> + }
>>>> >> +
>>>> >> + data_dir = rq_data_dir(req);
>>>> >> +
>>>> >> + if (data_dir == READ) {
>>>> >> +         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
>>>> over
>>>> > num_wr_reqs_to_start_packing?
>>>> > That means individual request(1...17) will be issued with
>>>> non-packing.
>>>> > 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
>>>> requests between read requests in parallel read and write operations
>>>> doesn't exceed 17 requests. Therefore, we can assume that fetching
>>>> more
>>>> than 17 write requests without hitting a read request can indicate
>>>> that
>>>> 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
>> uses a batch of 16 requests it should also fit the deadline scheduler.
>> In case another value is required, this value can be changed via sysfs.
>>>
>>>> You are right that this affects the write throughput a bit but the
>>>> goal
>>>> of
>>>> this algorithm is to make sure the read throughput and latency are not
>>>> decreased due to write. If this is not the desired result, this
>>>> algorithm
>>>> can be disabled.
>>>> >> +
>>>> >> +}
>>>> >> +
>>>> >>  static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct
>>>> request
>>>> >> *req)
>>>> >>  {
>>>> >>   struct request_queue *q = mq->queue;
>>>> >> @@ -1332,6 +1407,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->wr_packing_enabled)
>>>> >> +         goto no_packed;
>>>> > If wr_packing_enabled is set to true, several write requests can be
>>>> > 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
>>>> request in the mmc_blk_write_packing_control, and in such a case set
>>>> mq->wr_packing_enabled to 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
>>> write?
>>> I wonder this case.
>> Currently in such a case we will send the packed command followed by the
>> read request. The latency of this read request will be high due to
>> waiting
>> for the completion of the packed write. However, since we will disable
>> the
>> write packing, the latency of the following read requests will be low.
>> We are working on a solution where the read request will bypass the
>> write
>> requests in such a case. This change requires modification of the
>> scheduler in order to re-insert the write requests to the scheduler.
>>>
>
> Thats the precise reason for using foreground HPI (shameless plug :-))
> I understand the intent of write packing control, but using the number
> of requests
> as a metric is too coarse. Some writes could be for only one sector
> (512B) and others
> could be in 512KB or more, giving a 1000x variance.
>
> Foreground HPI solves this problem by interrupting only on a wait
> threshold.
>
> Another aspect is that if a packed write is in progress, and you have
> a read request,
> you will most likely disable packing for the _next_ write, not the
> ongoing one, right ?
> That's too late an intervention IMHO.
>
If a write request is in progress and a read is fetched we pln to use HPI
to stop it and re-insert the remider of the write packed command back to
the scheduler for a later dispatch.
Regarding the packing control trigger, we also tried using a trigger of an
amount of write bytes between read. However, the number of potential
packed requests seemed like the reasonable trigger since we would like to
activate the packing only when it will be beneficial, regardless of the
write requests sizes.

Thanks,
Maya Erez
Consultant for Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-11 17:19       ` S, Venkatraman
@ 2012-06-11 20:19         ` merez
  2012-06-12  4:07           ` S, Venkatraman
  0 siblings, 1 reply; 29+ messages in thread
From: merez @ 2012-06-11 20:19 UTC (permalink / raw)
  To: S, Venkatraman
  Cc: merez, Seungwon Jeon, linux-mmc, linux-arm-msm,
	DOCUMENTATION',
	open list


> On Sat, Jun 9, 2012 at 8:16 PM,  <merez@codeaurora.org> wrote:
>>
>>> 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
>> write packing causes the read throughput to drop from 24MB/s to 12MB/s.
>
> Whoa! That's a big drop.
> BTW, is there a problem with throughput or latency, or both ?
> If these numbers are over long duration (>5 seconds), then where are
> the cycles going?
> It would be nice to see some blktrace figures for the issue, and then fix
> it,
> rather than apply a band aid like the write-packing-control on top..
I believe this is because the write packing changes the dispatching policy
of the scheduler. Without write packing only 2 write requests were
fetched, giving the read requests a chance to be inserted into the
scheduler while we wait for the completion of the first write request.
Then when the next fetch was performed the read request would be the
chosen one. When write packing is enabled we keep fetching all the write
requests that are queued (assuming there are no read requests inserted
yet) and when the read is inserted and fetched is has to wait for the
completion of a bigger amount of write requests.

>
>
>> The write packing control managed to increase the read throughput back
>> to
>> the original value.
>> We also examined "real life" scenarios, such as performing a big push
>> operation in parallel to launching several applications. We measured the
>> read latency and found out that with the write packing control the worst
>> case of the read latency was smaller.
>>
>>> Please check the several comment below.
>>>
>>> Maya Erez <merez@codeaurora.org> wrote:
>>>> 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 by writing the required value
>>>> to:
>>>> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>>> The trigger for disabling the write packing is fetching a read
>>>> request.
>>>>
>

Thanks,
Maya Erez
Consultant for Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-01 18:55   ` Maya Erez
  (?)
  (?)
@ 2012-06-11 21:19   ` Muthu Kumar
  2012-06-12  0:28     ` Muthu Kumar
  -1 siblings, 1 reply; 29+ messages in thread
From: Muthu Kumar @ 2012-06-11 21:19 UTC (permalink / raw)
  To: Maya Erez; +Cc: linux-mmc, linux-arm-msm, open list:DOCUMENTATION, open list

On Fri, Jun 1, 2012 at 11:55 AM, Maya Erez <merez@codeaurora.org> wrote:
> 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 by writing the required value to:
> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
> The trigger for disabling the write packing is fetching a read request.
>

If it is applicable only to MMC why do we have this sysfs attr for all
block devices?

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-11 21:19   ` Muthu Kumar
@ 2012-06-12  0:28     ` Muthu Kumar
  2012-06-12 20:08       ` merez
  2012-06-13 19:52       ` merez
  0 siblings, 2 replies; 29+ messages in thread
From: Muthu Kumar @ 2012-06-12  0:28 UTC (permalink / raw)
  To: Maya Erez; +Cc: linux-mmc, linux-arm-msm, open list:DOCUMENTATION, open list

On Mon, Jun 11, 2012 at 2:19 PM, Muthu Kumar <muthu.lkml@gmail.com> wrote:
> On Fri, Jun 1, 2012 at 11:55 AM, Maya Erez <merez@codeaurora.org> wrote:
>> 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 by writing the required value to:
>> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>> The trigger for disabling the write packing is fetching a read request.
>>
>
> If it is applicable only to MMC why do we have this sysfs attr for all
> block devices?

Just to be clear, please create a directory, say mmc, under
/sys/block/<dev>/ and create the attr inside that.

You can refer to dm (dm-sysfs.c) for sample implementation.

Regards,
Muthu

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-11 20:19         ` merez
@ 2012-06-12  4:07           ` S, Venkatraman
  0 siblings, 0 replies; 29+ messages in thread
From: S, Venkatraman @ 2012-06-12  4:07 UTC (permalink / raw)
  To: merez
  Cc: Seungwon Jeon, linux-mmc, linux-arm-msm, DOCUMENTATION', open list

On Tue, Jun 12, 2012 at 1:49 AM,  <merez@codeaurora.org> wrote:
>
>> On Sat, Jun 9, 2012 at 8:16 PM,  <merez@codeaurora.org> wrote:
>>>
>>>> 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
>>> write packing causes the read throughput to drop from 24MB/s to 12MB/s.
>>
>> Whoa! That's a big drop.
>> BTW, is there a problem with throughput or latency, or both ?
>> If these numbers are over long duration (>5 seconds), then where are
>> the cycles going?
>> It would be nice to see some blktrace figures for the issue, and then fix
>> it,
>> rather than apply a band aid like the write-packing-control on top..
> I believe this is because the write packing changes the dispatching policy
> of the scheduler. Without write packing only 2 write requests were
> fetched, giving the read requests a chance to be inserted into the
> scheduler while we wait for the completion of the first write request.

Which I/O scheduler are you using ? Both CFQ and deadline would do the
balancing
act to prevent writes overwhelming reads. Writes are async and reads
are sync (usually),
so this imbalance would have existed otherwise, packed command or not.

> Then when the next fetch was performed the read request would be the
> chosen one. When write packing is enabled we keep fetching all the write
> requests that are queued (assuming there are no read requests inserted
> yet) and when the read is inserted and fetched is has to wait for the
> completion of a bigger amount of write requests.
>

Yes - but that should introduce latency, not bandwidth drop - unless you are
using the no-op scheduler.

>>
>>
>>> The write packing control managed to increase the read throughput back
>>> to
>>> the original value.
>>> We also examined "real life" scenarios, such as performing a big push
>>> operation in parallel to launching several applications. We measured the
>>> read latency and found out that with the write packing control the worst
>>> case of the read latency was smaller.
>>>
>>>> Please check the several comment below.
>>>>
>>>> Maya Erez <merez@codeaurora.org> wrote:
>>>>> 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 by writing the required value
>>>>> to:
>>>>> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>>>> The trigger for disabling the write packing is fetching a read
>>>>> request.
>>>>>
>>
>
> Thanks,
> Maya Erez
> Consultant for Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-11 20:10             ` merez
@ 2012-06-12  4:16               ` S, Venkatraman
  0 siblings, 0 replies; 29+ messages in thread
From: S, Venkatraman @ 2012-06-12  4:16 UTC (permalink / raw)
  To: merez
  Cc: Seungwon Jeon, linux-mmc, linux-arm-msm, DOCUMENTATION', open list

On Tue, Jun 12, 2012 at 1:40 AM,  <merez@codeaurora.org> wrote:
>
>> On Mon, Jun 11, 2012 at 7:25 PM,  <merez@codeaurora.org> wrote:
>>>
>>>> Maya Erez <merez@codeaurora.org> wrote:
>>>>>
>>>>> > 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
>>>>> write packing causes the read throughput to drop from 24MB/s to
>>>>> 12MB/s.
>>>>> The write packing control managed to increase the read throughput back
>>>>> to
>>>>> the original value.
>>>>> We also examined "real life" scenarios, such as performing a big push
>>>>> operation in parallel to launching several applications. We measured
>>>>> the
>>>>> read latency and found out that with the write packing control the
>>>>> worst
>>>>> case of the read latency was smaller.
>>>>>
>>>>> > Please check the several comment below.
>>>>> >
>>>>> > Maya Erez <merez@codeaurora.org> wrote:
>>>>> >> 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 by writing the required
>>>>> value
>>>>> >> to:
>>>>> >> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>>>> >> The trigger for disabling the write packing is fetching a read
>>>>> request.
>>>>> >>
>>>>> >> ---
>>>>> >>  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(-)
>>>>> >>
>>>>> >> diff --git a/Documentation/mmc/mmc-dev-attrs.txt
>>>>> >> b/Documentation/mmc/mmc-dev-attrs.txt
>>>>> >> index 22ae844..08f7312 100644
>>>>> >> --- a/Documentation/mmc/mmc-dev-attrs.txt
>>>>> >> +++ b/Documentation/mmc/mmc-dev-attrs.txt
>>>>> >> @@ -8,6 +8,23 @@ The following attributes are read/write.
>>>>> >>
>>>>> >>   force_ro                Enforce read-only access even if write
>>>>> protect switch is
>>>>> >> off.
>>>>> >>
>>>>> >> + num_wr_reqs_to_start_packing    This attribute is used to
>>>>> determine
>>>>> >> + the trigger for activating the write packing, in case the write
>>>>> >> + packing control feature is enabled.
>>>>> >> +
>>>>> >> + When the MMC manages to reach a point where
>>>>> >> num_wr_reqs_to_start_packing
>>>>> >> + write requests could be packed, it enables the write packing
>>>>> feature.
>>>>> >> + This allows us to start the write packing only when it is
>>>>> beneficial
>>>>> >> + and has minimum affect on the read latency.
>>>>> >> +
>>>>> >> + The number of potential packed requests that will trigger the
>>>>> packing
>>>>> >> + can be configured via sysfs by writing the required value to:
>>>>> >> + /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>>>> >> +
>>>>> >> + The default value of num_wr_reqs_to_start_packing was determined
>>>>> by
>>>>> >> + running parallel lmdd write and lmdd read operations and
>>>>> calculating
>>>>> >> + the max number of packed writes requests.
>>>>> >> +
>>>>> >>  SD and MMC Device Attributes
>>>>> >>  ============================
>>>>> >>
>>>>> >> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>>>>> >> index 2785fd4..ef192fb 100644
>>>>> >> --- a/drivers/mmc/card/block.c
>>>>> >> +++ b/drivers/mmc/card/block.c
>>>>> >> @@ -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;
>>>>> >>  }
>>>>> >>
>>>>> >> +static ssize_t
>>>>> >> +num_wr_reqs_to_start_packing_show(struct device *dev,
>>>>> >> +                           struct device_attribute *attr, char
>>>>> *buf)
>>>>> >> +{
>>>>> >> + struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
>>>>> >> + int num_wr_reqs_to_start_packing;
>>>>> >> + int ret;
>>>>> >> +
>>>>> >> + num_wr_reqs_to_start_packing =
>>>>> md->queue.num_wr_reqs_to_start_packing;
>>>>> >> +
>>>>> >> + ret = snprintf(buf, PAGE_SIZE, "%d\n",
>>>>> num_wr_reqs_to_start_packing);
>>>>> >> +
>>>>> >> + 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)
>>>>> >> +{
>>>>> >> + int value;
>>>>> >> + struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
>>>>> >> +
>>>>> >> + sscanf(buf, "%d", &value);
>>>>> >> + if (value >= 0)
>>>>> >> +         md->queue.num_wr_reqs_to_start_packing = value;
>>>>> >> +
>>>>> >> + mmc_blk_put(md);
>>>>> >> + return count;
>>>>> >> +}
>>>>> >> +
>>>>> >>  static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
>>>>> >>  {
>>>>> >>   struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
>>>>> >> @@ -1313,6 +1346,48 @@ 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;
>>>>> >> +
>>>>> >> + if (!(host->caps2 & MMC_CAP2_PACKED_WR))
>>>>> >> +         return;
>>>>> >> +
>>>>> >> + /*
>>>>> >> +  * In case the packing control is not supported by the host, it
>>>>> should
>>>>> >> +  * not have an effect on the write packing. Therefore we have to
>>>>> >> 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;
>>>>> >> +         return;
>>>>> >> + }
>>>>> >> +
>>>>> >> + data_dir = rq_data_dir(req);
>>>>> >> +
>>>>> >> + if (data_dir == READ) {
>>>>> >> +         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
>>>>> over
>>>>> > num_wr_reqs_to_start_packing?
>>>>> > That means individual request(1...17) will be issued with
>>>>> non-packing.
>>>>> > 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
>>>>> requests between read requests in parallel read and write operations
>>>>> doesn't exceed 17 requests. Therefore, we can assume that fetching
>>>>> more
>>>>> than 17 write requests without hitting a read request can indicate
>>>>> that
>>>>> 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
>>> uses a batch of 16 requests it should also fit the deadline scheduler.
>>> In case another value is required, this value can be changed via sysfs.
>>>>
>>>>> You are right that this affects the write throughput a bit but the
>>>>> goal
>>>>> of
>>>>> this algorithm is to make sure the read throughput and latency are not
>>>>> decreased due to write. If this is not the desired result, this
>>>>> algorithm
>>>>> can be disabled.
>>>>> >> +
>>>>> >> +}
>>>>> >> +
>>>>> >>  static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct
>>>>> request
>>>>> >> *req)
>>>>> >>  {
>>>>> >>   struct request_queue *q = mq->queue;
>>>>> >> @@ -1332,6 +1407,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->wr_packing_enabled)
>>>>> >> +         goto no_packed;
>>>>> > If wr_packing_enabled is set to true, several write requests can be
>>>>> > 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
>>>>> request in the mmc_blk_write_packing_control, and in such a case set
>>>>> mq->wr_packing_enabled to 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
>>>> write?
>>>> I wonder this case.
>>> Currently in such a case we will send the packed command followed by the
>>> read request. The latency of this read request will be high due to
>>> waiting
>>> for the completion of the packed write. However, since we will disable
>>> the
>>> write packing, the latency of the following read requests will be low.
>>> We are working on a solution where the read request will bypass the
>>> write
>>> requests in such a case. This change requires modification of the
>>> scheduler in order to re-insert the write requests to the scheduler.
>>>>
>>
>> Thats the precise reason for using foreground HPI (shameless plug :-))
>> I understand the intent of write packing control, but using the number
>> of requests
>> as a metric is too coarse. Some writes could be for only one sector
>> (512B) and others
>> could be in 512KB or more, giving a 1000x variance.
>>
>> Foreground HPI solves this problem by interrupting only on a wait
>> threshold.
>>
>> Another aspect is that if a packed write is in progress, and you have
>> a read request,
>> you will most likely disable packing for the _next_ write, not the
>> ongoing one, right ?
>> That's too late an intervention IMHO.
>>
> If a write request is in progress and a read is fetched we pln to use HPI
> to stop it and re-insert the remider of the write packed command back to
> the scheduler for a later dispatch.
IIUC, there were 2 reasons mentioned by you for introducing write
packing control -
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
than adding another functionality (which belongs in the I/O scheduler
anyway) to MMC.

> Regarding the packing control trigger, we also tried using a trigger of an
> amount of write bytes between read. However, the number of potential
> packed requests seemed like the reasonable trigger since we would like to
> activate the packing only when it will be beneficial, regardless of the
> write requests sizes.
>
Why ? How do you know "when it will be beneficial" ? As I mentioned,
the number of
blocks per request would vary over time, and also depends on the
filesystem. OTOH, even small
writes could take a lot longer than usual (>500ms) due to garbage
collection etc.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-12  0:28     ` Muthu Kumar
@ 2012-06-12 20:08       ` merez
  2012-06-13 19:52       ` merez
  1 sibling, 0 replies; 29+ messages in thread
From: merez @ 2012-06-12 20:08 UTC (permalink / raw)
  To: Muthu Kumar; +Cc: Maya Erez, linux-mmc, linux-arm-msm, DOCUMENTATION, open list


On Mon, June 11, 2012 5:28 pm, Muthu Kumar wrote:
> On Mon, Jun 11, 2012 at 2:19 PM, Muthu Kumar <muthu.lkml@gmail.com> wrote:
>> On Fri, Jun 1, 2012 at 11:55 AM, Maya Erez <merez@codeaurora.org> wrote:
>>> 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 by writing the required value
>>> to:
>>> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>> The trigger for disabling the write packing is fetching a read request.
>>>
>>
>> If it is applicable only to MMC why do we have this sysfs attr for all
>> block devices?
>
> Just to be clear, please create a directory, say mmc, under
> /sys/block/<dev>/ and create the attr inside that.
>
> You can refer to dm (dm-sysfs.c) for sample implementation.
>
> Regards,
> Muthu
>

I will apply this change in the next patch.

Thanks,
Maya Erez

-- 
Sent by consultant of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-12  0:28     ` Muthu Kumar
  2012-06-12 20:08       ` merez
@ 2012-06-13 19:52       ` merez
  2012-06-13 22:21         ` Muthu Kumar
  1 sibling, 1 reply; 29+ messages in thread
From: merez @ 2012-06-13 19:52 UTC (permalink / raw)
  To: Muthu Kumar; +Cc: Maya Erez, linux-mmc, linux-arm-msm, DOCUMENTATION, open list


On Mon, June 11, 2012 5:28 pm, Muthu Kumar wrote:
> On Mon, Jun 11, 2012 at 2:19 PM, Muthu Kumar <muthu.lkml@gmail.com> wrote:
>> On Fri, Jun 1, 2012 at 11:55 AM, Maya Erez <merez@codeaurora.org> wrote:
>>> 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 by writing the required value
>>> to:
>>> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>> The trigger for disabling the write packing is fetching a read request.
>>>
>>
>> If it is applicable only to MMC why do we have this sysfs attr for all
>> block devices?
>
> Just to be clear, please create a directory, say mmc, under
> /sys/block/<dev>/ and create the attr inside that.
>
> You can refer to dm (dm-sysfs.c) for sample implementation.
>
> Regards,
> Muthu
>
Hi Muthu,

I released a new version of this patch which doesn't include this change yet.

I understand why you think it would be best to distinguish the MMC
specific attribute from the general block devices attributes.
However, since this attribute is created only for the MMC block device,
other block devices won't be aware of it. Therefore, it doesn't
necessarily require a separation to a different folder.
Currently there is another MMC specific attribute (force_ro) which is also
created in the root directory. I think it would be better to also create
the num_wr_reqs_to_start_packing in the same folder as force_ro and not
make it an exceptional attribute in its location and the code that handles
it.
I would appreciate your opinion on that.

Thanks,
Maya
-- 
Sent by consultant of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-13 19:52       ` merez
@ 2012-06-13 22:21         ` Muthu Kumar
  2012-06-14  7:46           ` merez
  2012-07-14 19:12           ` Chris Ball
  0 siblings, 2 replies; 29+ messages in thread
From: Muthu Kumar @ 2012-06-13 22:21 UTC (permalink / raw)
  To: merez; +Cc: linux-mmc, linux-arm-msm, DOCUMENTATION, open list

On Wed, Jun 13, 2012 at 12:52 PM,  <merez@codeaurora.org> wrote:
>
> On Mon, June 11, 2012 5:28 pm, Muthu Kumar wrote:
>> On Mon, Jun 11, 2012 at 2:19 PM, Muthu Kumar <muthu.lkml@gmail.com> wrote:
>>> On Fri, Jun 1, 2012 at 11:55 AM, Maya Erez <merez@codeaurora.org> wrote:
>>>> trigger
>>>> the packing can be configured via sysfs by writing the required value
>>>> to:
>>>> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>>> The trigger for disabling the write packing is fetching a read request.
>>>>
>>>
>>> If it is applicable only to MMC why do we have this sysfs attr for all
>>> block devices?
>>
>> Just to be clear, please create a directory, say mmc, under
>> /sys/block/<dev>/ and create the attr inside that.
>>
>> You can refer to dm (dm-sysfs.c) for sample implementation.
> I understand why you think it would be best to distinguish the MMC
> specific attribute from the general block devices attributes.
> However, since this attribute is created only for the MMC block device,
> other block devices won't be aware of it.

I understand its created by the MMC code so will not be there for
other block devices. But having the device specific attributes inside
one <device> directory is better/cleaner. And since we are already
following that model for other devices, why not follow that for MMC
also?

> Therefore, it doesn't
> necessarily require a separation to a different folder.
> Currently there is another MMC specific attribute (force_ro) which is also
> created in the root directory. I think it would be better to also create
> the num_wr_reqs_to_start_packing in the same folder as force_ro and not
> make it an exceptional attribute in its location and the code that handles
> it.

Then time to move that as well to "mmc" directory.

Regards,
Muthu


> I would appreciate your opinion on that.
>
> Thanks,
> Maya
> --
> Sent by consultant of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-13 22:21         ` Muthu Kumar
@ 2012-06-14  7:46           ` merez
  2012-07-14 19:12           ` Chris Ball
  1 sibling, 0 replies; 29+ messages in thread
From: merez @ 2012-06-14  7:46 UTC (permalink / raw)
  To: Muthu Kumar; +Cc: merez, linux-mmc, linux-arm-msm, DOCUMENTATION, open list


On Wed, June 13, 2012 3:21 pm, Muthu Kumar wrote:
> On Wed, Jun 13, 2012 at 12:52 PM,  <merez@codeaurora.org> wrote:
>>
>> On Mon, June 11, 2012 5:28 pm, Muthu Kumar wrote:
>>> On Mon, Jun 11, 2012 at 2:19 PM, Muthu Kumar <muthu.lkml@gmail.com>
>>> wrote:
>>>> On Fri, Jun 1, 2012 at 11:55 AM, Maya Erez <merez@codeaurora.org>
>>>> wrote:
>>>>> trigger
>>>>> the packing can be configured via sysfs by writing the required value
>>>>> to:
>>>>> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>>>> The trigger for disabling the write packing is fetching a read
>>>>> request.
>>>>>
>>>>
>>>> If it is applicable only to MMC why do we have this sysfs attr for all
>>>> block devices?
>>>
>>> Just to be clear, please create a directory, say mmc, under
>>> /sys/block/<dev>/ and create the attr inside that.
>>>
>>> You can refer to dm (dm-sysfs.c) for sample implementation.
>> I understand why you think it would be best to distinguish the MMC
>> specific attribute from the general block devices attributes.
>> However, since this attribute is created only for the MMC block device,
>> other block devices won't be aware of it.
>
> I understand its created by the MMC code so will not be there for
> other block devices. But having the device specific attributes inside
> one <device> directory is better/cleaner. And since we are already
> following that model for other devices, why not follow that for MMC
> also?
>
>> Therefore, it doesn't
>> necessarily require a separation to a different folder.
>> Currently there is another MMC specific attribute (force_ro) which is
>> also
>> created in the root directory. I think it would be better to also create
>> the num_wr_reqs_to_start_packing in the same folder as force_ro and not
>> make it an exceptional attribute in its location and the code that
>> handles
>> it.
>
> Then time to move that as well to "mmc" directory.
>
> Regards,
> Muthu

I will make this change for the new attribute and for force_ro as well.

Thanks,
Maya

>
>
>> I would appreciate your opinion on that.
>>
>> Thanks,
>> Maya
>> --
>> Sent by consultant of Qualcomm Innovation Center, Inc.
>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
>>
>


-- 
Sent by consultant of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-06-13 22:21         ` Muthu Kumar
  2012-06-14  7:46           ` merez
@ 2012-07-14 19:12           ` Chris Ball
  2012-07-16  1:49             ` Muthu Kumar
  1 sibling, 1 reply; 29+ messages in thread
From: Chris Ball @ 2012-07-14 19:12 UTC (permalink / raw)
  To: Muthu Kumar; +Cc: merez, linux-mmc, linux-arm-msm, DOCUMENTATION, open list

Hi,

On Wed, Jun 13 2012, Muthu Kumar wrote:
> On Wed, Jun 13, 2012 at 12:52 PM,  <merez@codeaurora.org> wrote:
>>
>> On Mon, June 11, 2012 5:28 pm, Muthu Kumar wrote:
>>> On Mon, Jun 11, 2012 at 2:19 PM, Muthu Kumar <muthu.lkml@gmail.com> wrote:
>>>> On Fri, Jun 1, 2012 at 11:55 AM, Maya Erez <merez@codeaurora.org> wrote:
>>>>> trigger
>>>>> the packing can be configured via sysfs by writing the required value
>>>>> to:
>>>>> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>>>> The trigger for disabling the write packing is fetching a read request.
>>>>>
>>>>
>>>> If it is applicable only to MMC why do we have this sysfs attr for all
>>>> block devices?
>>>
>>> Just to be clear, please create a directory, say mmc, under
>>> /sys/block/<dev>/ and create the attr inside that.
>>>
>>> You can refer to dm (dm-sysfs.c) for sample implementation.
>> I understand why you think it would be best to distinguish the MMC
>> specific attribute from the general block devices attributes.
>> However, since this attribute is created only for the MMC block device,
>> other block devices won't be aware of it.
>
> I understand its created by the MMC code so will not be there for
> other block devices. But having the device specific attributes inside
> one <device> directory is better/cleaner. And since we are already
> following that model for other devices, why not follow that for MMC
> also?

I've already replied to a later version of the patch, but just to get
this comment in at the appropriate point of the discussion as well:

Even though it would result in a cleaner sysfs, I don't want to do
this now because it will break userspace scripts that are depending
on the current locations of these attributes.

Thanks,

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-07-14 19:12           ` Chris Ball
@ 2012-07-16  1:49             ` Muthu Kumar
  2012-07-16  2:46               ` Chris Ball
  0 siblings, 1 reply; 29+ messages in thread
From: Muthu Kumar @ 2012-07-16  1:49 UTC (permalink / raw)
  To: Chris Ball; +Cc: merez, linux-mmc, linux-arm-msm, DOCUMENTATION, open list

Chris,

On Sat, Jul 14, 2012 at 12:12 PM, Chris Ball <cjb@laptop.org> wrote:
> Hi,
>
> On Wed, Jun 13 2012, Muthu Kumar wrote:
>> On Wed, Jun 13, 2012 at 12:52 PM,  <merez@codeaurora.org> wrote:
>>>
>>> On Mon, June 11, 2012 5:28 pm, Muthu Kumar wrote:
>>>> On Mon, Jun 11, 2012 at 2:19 PM, Muthu Kumar <muthu.lkml@gmail.com> wrote:
>>>>> On Fri, Jun 1, 2012 at 11:55 AM, Maya Erez <merez@codeaurora.org> wrote:
>>>>>> trigger
>>>>>> the packing can be configured via sysfs by writing the required value
>>>>>> to:
>>>>>> /sys/block/<block_dev_name>/num_wr_reqs_to_start_packing.
>>>>>> The trigger for disabling the write packing is fetching a read request.
>>>>>>
>>>>>
>>>>> If it is applicable only to MMC why do we have this sysfs attr for all
>>>>> block devices?
>>>>
>>>> Just to be clear, please create a directory, say mmc, under
>>>> /sys/block/<dev>/ and create the attr inside that.
>>>>
>>>> You can refer to dm (dm-sysfs.c) for sample implementation.
>>> I understand why you think it would be best to distinguish the MMC
>>> specific attribute from the general block devices attributes.
>>> However, since this attribute is created only for the MMC block device,
>>> other block devices won't be aware of it.
>>
>> I understand its created by the MMC code so will not be there for
>> other block devices. But having the device specific attributes inside
>> one <device> directory is better/cleaner. And since we are already
>> following that model for other devices, why not follow that for MMC
>> also?
>
> I've already replied to a later version of the patch, but just to get
> this comment in at the appropriate point of the discussion as well:
>
> Even though it would result in a cleaner sysfs, I don't want to do
> this now because it will break userspace scripts that are depending
> on the current locations of these attributes.
>

Maya is adding a new sysfs attribute with that patch. So, there should
not be any user space stuff that depends on it.

Regards,
Muthu


> Thanks,
>
> - Chris.
> --
> Chris Ball   <cjb@laptop.org>   <http://printf.net/>
> One Laptop Per Child

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-07-16  1:49             ` Muthu Kumar
@ 2012-07-16  2:46               ` Chris Ball
  2012-07-16 16:44                 ` Muthu Kumar
  2012-07-17  4:15                 ` S, Venkatraman
  0 siblings, 2 replies; 29+ messages in thread
From: Chris Ball @ 2012-07-16  2:46 UTC (permalink / raw)
  To: Muthu Kumar; +Cc: merez, linux-mmc, linux-arm-msm, DOCUMENTATION, open list

Hi,

On Sun, Jul 15 2012, Muthu Kumar wrote:
>> I've already replied to a later version of the patch, but just to get
>> this comment in at the appropriate point of the discussion as well:
>>
>> Even though it would result in a cleaner sysfs, I don't want to do
>> this now because it will break userspace scripts that are depending
>> on the current locations of these attributes.
>
> Maya is adding a new sysfs attribute with that patch. So, there should
> not be any user space stuff that depends on it.

In the later patchset, Maya's "[PATCH v4 1/2] mmc: card: Move MMC
specific attributes to mmc sub-directory" moves the existing attributes
into the mmc/ directory.

It's that move that I'm objecting to, rather than the creation of a new
directory -- although since we're going to leave the current attributes
where they are, it might not make sense to add the new directory.

We'd be creating two places that people have to look for mmc-related
attributes, which is arguably less clean than having one place to look
even though it's mixed in with the other block device attributes.

Thanks,

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-07-16  2:46               ` Chris Ball
@ 2012-07-16 16:44                 ` Muthu Kumar
  2012-07-17 22:50                   ` Chris Ball
  2012-07-17  4:15                 ` S, Venkatraman
  1 sibling, 1 reply; 29+ messages in thread
From: Muthu Kumar @ 2012-07-16 16:44 UTC (permalink / raw)
  To: Chris Ball, Jens Axboe
  Cc: merez, linux-mmc, linux-arm-msm, DOCUMENTATION, open list

On Sun, Jul 15, 2012 at 7:46 PM, Chris Ball <cjb@laptop.org> wrote:
> Hi,
>
> On Sun, Jul 15 2012, Muthu Kumar wrote:
>>> I've already replied to a later version of the patch, but just to get
>>> this comment in at the appropriate point of the discussion as well:
>>>
>>> Even though it would result in a cleaner sysfs, I don't want to do
>>> this now because it will break userspace scripts that are depending
>>> on the current locations of these attributes.
>>
>> Maya is adding a new sysfs attribute with that patch. So, there should
>> not be any user space stuff that depends on it.
>
> In the later patchset, Maya's "[PATCH v4 1/2] mmc: card: Move MMC
> specific attributes to mmc sub-directory" moves the existing attributes
> into the mmc/ directory.
>
> It's that move that I'm objecting to, rather than the creation of a new
> directory -- although since we're going to leave the current attributes
> where they are, it might not make sense to add the new directory.
>
> We'd be creating two places that people have to look for mmc-related
> attributes, which is arguably less clean than having one place to look
> even though it's mixed in with the other block device attributes.

So, what is the plan for fixing the user land tools and cleaning this up?

Jens,
What do you think?


Regards,
Muthu




>
> Thanks,
>
> - Chris.
> --
> Chris Ball   <cjb@laptop.org>   <http://printf.net/>
> One Laptop Per Child

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-07-16  2:46               ` Chris Ball
  2012-07-16 16:44                 ` Muthu Kumar
@ 2012-07-17  4:15                 ` S, Venkatraman
  1 sibling, 0 replies; 29+ messages in thread
From: S, Venkatraman @ 2012-07-17  4:15 UTC (permalink / raw)
  To: Chris Ball
  Cc: Muthu Kumar, merez, linux-mmc, linux-arm-msm, DOCUMENTATION, open list

On Mon, Jul 16, 2012 at 8:16 AM, Chris Ball <cjb@laptop.org> wrote:
> Hi,
>
> On Sun, Jul 15 2012, Muthu Kumar wrote:
>>> I've already replied to a later version of the patch, but just to get
>>> this comment in at the appropriate point of the discussion as well:
>>>
>>> Even though it would result in a cleaner sysfs, I don't want to do
>>> this now because it will break userspace scripts that are depending
>>> on the current locations of these attributes.
>>
>> Maya is adding a new sysfs attribute with that patch. So, there should
>> not be any user space stuff that depends on it.
>
> In the later patchset, Maya's "[PATCH v4 1/2] mmc: card: Move MMC
> specific attributes to mmc sub-directory" moves the existing attributes
> into the mmc/ directory.
>
> It's that move that I'm objecting to, rather than the creation of a new
> directory -- although since we're going to leave the current attributes
> where they are, it might not make sense to add the new directory.
>
> We'd be creating two places that people have to look for mmc-related
> attributes, which is arguably less clean than having one place to look
> even though it's mixed in with the other block device attributes.
>

It's better to normalise this eventually. It would be better if we create a
duplicate sysfs entry within MMC, which is identical to the current
block layer attribute. Then schedule the block layer attribute to be
removed by, say, 3.9. [Add it to Documentation/feature-removal-schedule.txt]

Since it is a MMC specific attribute, generic tools wouldn't depend on it.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-07-16 16:44                 ` Muthu Kumar
@ 2012-07-17 22:50                   ` Chris Ball
  2012-07-18  6:34                     ` merez
  2012-07-19  0:33                     ` Muthu Kumar
  0 siblings, 2 replies; 29+ messages in thread
From: Chris Ball @ 2012-07-17 22:50 UTC (permalink / raw)
  To: Muthu Kumar
  Cc: Jens Axboe, merez, linux-mmc, linux-arm-msm, DOCUMENTATION, open list

Hi Muthu,

On Mon, Jul 16 2012, Muthu Kumar wrote:
> On Sun, Jul 15, 2012 at 7:46 PM, Chris Ball <cjb@laptop.org> wrote:
>> Hi,
>>
>> On Sun, Jul 15 2012, Muthu Kumar wrote:
>>>> I've already replied to a later version of the patch, but just to get
>>>> this comment in at the appropriate point of the discussion as well:
>>>>
>>>> Even though it would result in a cleaner sysfs, I don't want to do
>>>> this now because it will break userspace scripts that are depending
>>>> on the current locations of these attributes.
>>>
>>> Maya is adding a new sysfs attribute with that patch. So, there should
>>> not be any user space stuff that depends on it.
>>
>> In the later patchset, Maya's "[PATCH v4 1/2] mmc: card: Move MMC
>> specific attributes to mmc sub-directory" moves the existing attributes
>> into the mmc/ directory.
>>
>> It's that move that I'm objecting to, rather than the creation of a new
>> directory -- although since we're going to leave the current attributes
>> where they are, it might not make sense to add the new directory.
>>
>> We'd be creating two places that people have to look for mmc-related
>> attributes, which is arguably less clean than having one place to look
>> even though it's mixed in with the other block device attributes.
>
> So, what is the plan for fixing the user land tools and cleaning this up?

At the moment I don't have any plan to do that, because the cure
(potentially breaking userland scripts that are writing to some
read/write attributes, by breaking ABI to move everything into a
new directory) seems worse than the disease (having some attributes
in a directory that isn't the ideal one).

I'd be willing to explore something like Venkat's idea if the block
layer maintainers insist, though.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-07-17 22:50                   ` Chris Ball
@ 2012-07-18  6:34                     ` merez
  2012-07-18  7:26                         ` Chris Ball
  2012-07-19  0:33                     ` Muthu Kumar
  1 sibling, 1 reply; 29+ messages in thread
From: merez @ 2012-07-18  6:34 UTC (permalink / raw)
  To: Chris Ball
  Cc: Muthu Kumar, Jens Axboe, merez, linux-mmc, linux-arm-msm,
	DOCUMENTATION, open list

Hi Chris,

Is there anything else that holds this patch from being pushed to mmc-next?

Thanks,
Maya
On Tue, July 17, 2012 3:50 pm, Chris Ball wrote:
> Hi Muthu,
>
> On Mon, Jul 16 2012, Muthu Kumar wrote:
>> On Sun, Jul 15, 2012 at 7:46 PM, Chris Ball <cjb@laptop.org> wrote:
>>> Hi,
>>>
>>> On Sun, Jul 15 2012, Muthu Kumar wrote:
>>>>> I've already replied to a later version of the patch, but just to get
>>>>> this comment in at the appropriate point of the discussion as well:
>>>>>
>>>>> Even though it would result in a cleaner sysfs, I don't want to do
>>>>> this now because it will break userspace scripts that are depending
>>>>> on the current locations of these attributes.
>>>>
>>>> Maya is adding a new sysfs attribute with that patch. So, there should
>>>> not be any user space stuff that depends on it.
>>>
>>> In the later patchset, Maya's "[PATCH v4 1/2] mmc: card: Move MMC
>>> specific attributes to mmc sub-directory" moves the existing attributes
>>> into the mmc/ directory.
>>>
>>> It's that move that I'm objecting to, rather than the creation of a new
>>> directory -- although since we're going to leave the current attributes
>>> where they are, it might not make sense to add the new directory.
>>>
>>> We'd be creating two places that people have to look for mmc-related
>>> attributes, which is arguably less clean than having one place to look
>>> even though it's mixed in with the other block device attributes.
>>
>> So, what is the plan for fixing the user land tools and cleaning this
>> up?
>
> At the moment I don't have any plan to do that, because the cure
> (potentially breaking userland scripts that are writing to some
> read/write attributes, by breaking ABI to move everything into a
> new directory) seems worse than the disease (having some attributes
> in a directory that isn't the ideal one).
>
> I'd be willing to explore something like Venkat's idea if the block
> layer maintainers insist, though.
>
> - Chris.
> --
> Chris Ball   <cjb@laptop.org>   <http://printf.net/>
> One Laptop Per Child
>


-- 
Sent by consultant of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-07-18  6:34                     ` merez
@ 2012-07-18  7:26                         ` Chris Ball
  0 siblings, 0 replies; 29+ messages in thread
From: Chris Ball @ 2012-07-18  7:26 UTC (permalink / raw)
  To: merez
  Cc: Muthu Kumar, linux-mmc, linux-arm-msm, open list, S, Venkatraman,
	Seungwon Jeon

Hi,  [removing Jens and the documentation list, since now we're
talking about the MMC side only]

On Wed, Jul 18 2012, merez@codeaurora.org wrote:
> Is there anything else that holds this patch from being pushed to mmc-next?

Yes, I'm still uncomfortable with the write packing patchsets for a
couple of reasons, and I suspect that the sum of those reasons means
that we should probably plan on holding off merging it until after 3.6.

Here are the open issues; please correct any misunderstandings:

With Seungwon's patchset ("Support packed write command"):

* I still don't have a good set of representative benchmarks showing
  what kind of performance changes come with this patchset.  It seems
  like we've had a small amount of testing on one controller/eMMC part
  combo from Seungwon, and an entirely different test from Maya, and the
  results aren't documented fully anywhere to the level of describing
  what the hardware was, what the test was, and what the results were
  before and after the patchset.

With the reads-during-writes regression:

* Venkat still has open questions about the nature of the read
  regression, and thinks we should understand it with blktrace before
  trying to fix it.  Maya has a theory about writes overwhelming reads,
  but Venkat doesn't understand why this would explain the observed
  bandwidth drop.

With Maya's patchset ("write packing control"):

* Venkat thinks that HPI should be used, and the number-of-requests
  metric is too coarse, and it doesn't let you disable packing at the
  right time, and you're essentially implementing a new I/O scheduler
  inside the MMC subsystem without understanding the root cause for
  why that's necessary.

My sense is that there's no way we can solve all of these to
satisfaction in the next week (which is when the merge window will
open), but that by waiting a cycle we might come up with some good
answers.

What do other people think?  If you're excited about these patchsets,
now would be a fine time to come forward with your benchmarking results
and to help understand the reads-during-writes regression.

Thanks!

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
@ 2012-07-18  7:26                         ` Chris Ball
  0 siblings, 0 replies; 29+ messages in thread
From: Chris Ball @ 2012-07-18  7:26 UTC (permalink / raw)
  To: merez
  Cc: Muthu Kumar, linux-mmc, linux-arm-msm, open list, S, Venkatraman,
	Seungwon Jeon

Hi,  [removing Jens and the documentation list, since now we're
talking about the MMC side only]

On Wed, Jul 18 2012, merez@codeaurora.org wrote:
> Is there anything else that holds this patch from being pushed to mmc-next?

Yes, I'm still uncomfortable with the write packing patchsets for a
couple of reasons, and I suspect that the sum of those reasons means
that we should probably plan on holding off merging it until after 3.6.

Here are the open issues; please correct any misunderstandings:

With Seungwon's patchset ("Support packed write command"):

* I still don't have a good set of representative benchmarks showing
  what kind of performance changes come with this patchset.  It seems
  like we've had a small amount of testing on one controller/eMMC part
  combo from Seungwon, and an entirely different test from Maya, and the
  results aren't documented fully anywhere to the level of describing
  what the hardware was, what the test was, and what the results were
  before and after the patchset.

With the reads-during-writes regression:

* Venkat still has open questions about the nature of the read
  regression, and thinks we should understand it with blktrace before
  trying to fix it.  Maya has a theory about writes overwhelming reads,
  but Venkat doesn't understand why this would explain the observed
  bandwidth drop.

With Maya's patchset ("write packing control"):

* Venkat thinks that HPI should be used, and the number-of-requests
  metric is too coarse, and it doesn't let you disable packing at the
  right time, and you're essentially implementing a new I/O scheduler
  inside the MMC subsystem without understanding the root cause for
  why that's necessary.

My sense is that there's no way we can solve all of these to
satisfaction in the next week (which is when the merge window will
open), but that by waiting a cycle we might come up with some good
answers.

What do other people think?  If you're excited about these patchsets,
now would be a fine time to come forward with your benchmarking results
and to help understand the reads-during-writes regression.

Thanks!

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH v2 1/1] mmc: block: Add write packing control
  2012-07-17 22:50                   ` Chris Ball
  2012-07-18  6:34                     ` merez
@ 2012-07-19  0:33                     ` Muthu Kumar
  1 sibling, 0 replies; 29+ messages in thread
From: Muthu Kumar @ 2012-07-19  0:33 UTC (permalink / raw)
  To: Chris Ball
  Cc: Jens Axboe, merez, linux-mmc, linux-arm-msm, DOCUMENTATION, open list

>
> I'd be willing to explore something like Venkat's idea if the block
> layer maintainers insist, though.


Yeah... I guess it's upto Jens.


>
> - Chris.
> --
> Chris Ball   <cjb@laptop.org>   <http://printf.net/>
> One Laptop Per Child

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2012-07-19  0:33 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-01 18:55 [PATCH v2 0/1] mmc: block: Add write packing control Maya Erez
2012-06-01 18:55 ` [PATCH v2 1/1] " Maya Erez
2012-06-01 18:55   ` Maya Erez
2012-06-08  9:37   ` Seungwon Jeon
2012-06-09 14:46     ` merez
2012-06-11  9:10       ` Seungwon Jeon
2012-06-11 13:55         ` merez
2012-06-11 14:39           ` S, Venkatraman
2012-06-11 20:10             ` merez
2012-06-12  4:16               ` S, Venkatraman
2012-06-11 17:19       ` S, Venkatraman
2012-06-11 20:19         ` merez
2012-06-12  4:07           ` S, Venkatraman
2012-06-11 21:19   ` Muthu Kumar
2012-06-12  0:28     ` Muthu Kumar
2012-06-12 20:08       ` merez
2012-06-13 19:52       ` merez
2012-06-13 22:21         ` Muthu Kumar
2012-06-14  7:46           ` merez
2012-07-14 19:12           ` Chris Ball
2012-07-16  1:49             ` Muthu Kumar
2012-07-16  2:46               ` Chris Ball
2012-07-16 16:44                 ` Muthu Kumar
2012-07-17 22:50                   ` Chris Ball
2012-07-18  6:34                     ` merez
2012-07-18  7:26                       ` Chris Ball
2012-07-18  7:26                         ` Chris Ball
2012-07-19  0:33                     ` Muthu Kumar
2012-07-17  4:15                 ` S, Venkatraman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.