Skip to contentSkip to conversation

raw/ioat: added a flag to control copying handle parameters

PATCH Superseded Cheng Jiang 2 participants 9 messages Jul 13, 2020 – Jul 21, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 raw/ioat: added a flag to control copying handle parameters

Added a flag which controls whether rte_ioat_enqueue_copy and rte_ioat_completed_copies function should process handle parameters to improve the performance when handle parameters are not necessary to use. This is targeting 20.11 release.

---
 drivers/raw/ioat/ioat_rawdev.c     |  1 +
 drivers/raw/ioat/rte_ioat_rawdev.h | 14 +++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)
drivers/raw/ioat/ioat_rawdev.c +1 -0
index 87fd088aa..5bf030785 100644
@@ -57,6 +57,7 @@ ioat_dev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 		return -EINVAL;
 
 	ioat->ring_size = params->ring_size;
+	ioat->hdls_enable = params->hdls_enable;
 	if (ioat->desc_ring != NULL) {
 		rte_memzone_free(ioat->desc_mz);
 		ioat->desc_ring = NULL;
drivers/raw/ioat/rte_ioat_rawdev.h +11 -3
index f765a6557..daca04dd3 100644
@@ -35,6 +35,7 @@
  */
 struct rte_ioat_rawdev_config {
 	unsigned short ring_size;
+	bool hdls_enable;
 };
 
 /**
@@ -52,6 +53,8 @@ struct rte_ioat_rawdev {
 
 	unsigned short ring_size;
 	struct rte_ioat_generic_hw_desc *desc_ring;
+
+	bool hdls_enable; /* control if handles need to be copied */
 	__m128i *hdls; /* completion handles for returning to user */
 
 
@@ -121,8 +124,10 @@ rte_ioat_enqueue_copy(int dev_id, phys_addr_t src, phys_addr_t dst,
 	desc->u.control_raw = (uint32_t)((!!fence << 4) | (!(write & 0xF)) << 3);
 	desc->src_addr = src;
 	desc->dest_addr = dst;
+	if (ioat->hdls_enable)
+		ioat->hdls[write] = _mm_set_epi64x((int64_t)dst_hdl,
+					(int64_t)src_hdl);
 
-	ioat->hdls[write] = _mm_set_epi64x((int64_t)dst_hdl, (int64_t)src_hdl);
 	rte_prefetch0(&ioat->desc_ring[ioat->next_write & mask]);
 
 	ioat->enqueued++;
@@ -208,6 +213,11 @@ rte_ioat_completed_copies(int dev_id, uint8_t max_copies,
 	if (count > max_copies)
 		count = max_copies;
 
+	ioat->next_read = read + count;
+	ioat->completed += count;
+	if (!ioat->hdls_enable)
+		return count;
+
 	for (; i < count - 1; i += 2, read += 2) {
 		__m128i hdls0 = _mm_load_si128(&ioat->hdls[read & mask]);
 		__m128i hdls1 = _mm_load_si128(&ioat->hdls[(read + 1) & mask]);
@@ -223,8 +233,6 @@ rte_ioat_completed_copies(int dev_id, uint8_t max_copies,
 		dst_hdls[i] = hdls[1];
 	}
 
-	ioat->next_read = read;
-	ioat->completed += count;
 	return count;
 }
 
Signature · 1 line
2.27.0
#1 lore raw
Quoted 8 lines · Cheng Jiang

Added a flag which controls whether rte_ioat_enqueue_copy and rte_ioat_completed_copies function should process handle parameters to improve the performance when handle parameters are not necessary to use. This is targeting 20.11 release.

---

Thanks for this. I'm also preparing some changes to this driver for 20.11 release, so I'll base my changes on top of this one.

#2 lore raw
In reply to Cheng Jiang
Quoted 12 lines · Cheng Jiang

Added a flag which controls whether rte_ioat_enqueue_copy and rte_ioat_completed_copies function should process handle parameters to improve the performance when handle parameters are not necessary to use. This is targeting 20.11 release.

---
 drivers/raw/ioat/ioat_rawdev.c     |  1 +
 drivers/raw/ioat/rte_ioat_rawdev.h | 14 +++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

<snip>

Quoted 13 lines
drivers/raw/ioat/rte_ioat_rawdev.h +5 -0
@@ -208,6 +213,11 @@ rte_ioat_completed_copies(int dev_id, uint8_t max_copies,
 	if (count > max_copies)
 		count = max_copies;
 
+	ioat->next_read = read + count;
+	ioat->completed += count;
+	if (!ioat->hdls_enable)
+		return count;
+
 	for (; i < count - 1; i += 2, read += 2) {
 		__m128i hdls0 = _mm_load_si128(&ioat->hdls[read & mask]);
 		__m128i hdls1 = _mm_load_si128(&ioat->hdls[(read + 1) & mask]);

drivers/raw/ioat/rte_ioat_rawdev.h rte_ioat_completed_copies(int dev_id, uint8_t max_copies, · line 237

Quoted 7 lines
drivers/raw/ioat/rte_ioat_rawdev.h +0 -2
@@ -223,8 +233,6 @@ rte_ioat_completed_copies(int dev_id, uint8_t max_copies,
 		dst_hdls[i] = hdls[1];
 	}
 
-	ioat->next_read = read;
-	ioat->completed += count;
 	return count;
 }

This change I think may cause problems if we ever want to have one thread enqueuing and another taking completions. The next_read and completed counters should really only be updated after we have finished reading the completed handles array. Therefore, for safety, I tihnk it might be better to keep the updates in their original places and put an "end:" label before them. Then the "return count" in the middle of the function can be "goto end;"

Regards,
/Bruce

#3 lore raw
Quoted 30 lines · Bruce Richardson
Quoted 12 lines · Cheng Jiang

Added a flag which controls whether rte_ioat_enqueue_copy and rte_ioat_completed_copies function should process handle parameters to improve the performance when handle parameters are not necessary to use. This is targeting 20.11 release.

---
 drivers/raw/ioat/ioat_rawdev.c     |  1 +
 drivers/raw/ioat/rte_ioat_rawdev.h | 14 +++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

<snip>

Quoted 16 lines
drivers/raw/ioat/rte_ioat_rawdev.h +5 -0
@@ -208,6 +213,11 @@ rte_ioat_completed_copies(int dev_id, uint8_t max_copies,
 	if (count > max_copies)
 		count = max_copies;
 
+	ioat->next_read = read + count;
+	ioat->completed += count;
+	if (!ioat->hdls_enable)
+		return count;
+
 	for (; i < count - 1; i += 2, read += 2) {
 		__m128i hdls0 = _mm_load_si128(&ioat->hdls[read & mask]);
 		__m128i hdls1 = _mm_load_si128(&ioat->hdls[(read + 1) & mask]);
@@ -223,8 +233,6 @@ rte_ioat_completed_copies(int dev_id, uint8_t max_copies,
 		dst_hdls[i] = hdls[1];
 	}
 
Quoted 13 lines

drivers/raw/ioat/rte_ioat_rawdev.h rte_ioat_completed_copies(int dev_id, uint8_t max_copies, · line 237

Quoted 4 lines
drivers/raw/ioat/rte_ioat_rawdev.h +0 -2
-	ioat->next_read = read;
-	ioat->completed += count;
 	return count;
 }

This change I think may cause problems if we ever want to have one thread enqueuing and another taking completions. The next_read and completed counters should really only be updated after we have finished reading the completed handles array. Therefore, for safety, I tihnk it might be better to keep the updates in their original places and put an "end:" label before them. Then the "return count" in the middle of the function can be "goto end;"

A further suggestion to the changes to this function: if we are not actually returning completion handles, then there is no need to limit the count to "max_copies". Therefore move the "return count" or "goto end" above the previous length check, and update the doxygen comments to indicate that max_copies is ignored if "hdls_enable" is false, and that the final two parameters can also be NULL when calling the function in this case.

/Bruce

#4 lore raw
In reply to Cheng Jiang
Quoted 29 lines · Cheng Jiang

Added a flag which controls whether rte_ioat_enqueue_copy and rte_ioat_completed_copies function should process handle parameters to improve the performance when handle parameters are not necessary to use. This is targeting 20.11 release.

---
 drivers/raw/ioat/ioat_rawdev.c     |  1 +
 drivers/raw/ioat/rte_ioat_rawdev.h | 14 +++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)
drivers/raw/ioat/ioat_rawdev.c +1 -0
index 87fd088aa..5bf030785 100644
@@ -57,6 +57,7 @@ ioat_dev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 		return -EINVAL;
 
 	ioat->ring_size = params->ring_size;
+	ioat->hdls_enable = params->hdls_enable;
 	if (ioat->desc_ring != NULL) {
 		rte_memzone_free(ioat->desc_mz);
 		ioat->desc_ring = NULL;
drivers/raw/ioat/rte_ioat_rawdev.h +0 -0
index f765a6557..daca04dd3 100644

drivers/raw/ioat/rte_ioat_rawdev.h line 40

Quoted 6 lines
drivers/raw/ioat/rte_ioat_rawdev.h +1 -0
@@ -35,6 +35,7 @@
  */
 struct rte_ioat_rawdev_config {
 	unsigned short ring_size;
+	bool hdls_enable;
 };
 

You need a doxygen comment on the new structure member (and add to existing one). While it's fairly clear what ring_size parameter should do, the hdls_enable one needs a proper explanation.

I also think you might want to investigate changing it to "hdls_disable" so that the default zero-value is the current behaviour. Requiring it to be set as 1 means that existing code will likely recompile but fail to work. For example, the ioat_rawdev_autotest fails on completion checks now.

#5 lore raw

Hi Bruce,

Thank you very much for these comments which really make sense for me. I will correct these problems in the next version.

Thanks again.
Cheng

Quoted 54 lines

-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Monday, July 13, 2020 9:28 PM
To: Jiang, Cheng1 <[email protected]>
Cc: [email protected]; Fu, Patrick <[email protected]>
Subject: Re: [PATCH 20.11] raw/ioat: added a flag to control copying handle parameters

drivers/raw/ioat/ioat_rawdev.c ioat_dev_configure(const struct rte_rawdev *dev,

Quoted 17 lines · Cheng Jiang

Added a flag which controls whether rte_ioat_enqueue_copy and rte_ioat_completed_copies function should process handle parameters to improve the performance when handle parameters are not necessary to use. This is targeting
20.11 release.

---
 drivers/raw/ioat/ioat_rawdev.c     |  1 +
 drivers/raw/ioat/rte_ioat_rawdev.h | 14 +++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/raw/ioat/ioat_rawdev.c index 87fd088aa..5bf030785 100644

drivers/raw/ioat/ioat_rawdev.c +0 -0
@@ -57,6 +57,7 @@ ioat_dev_configure(const struct rte_rawdev *dev,

rte_rawdev_obj_t config)

Quoted 13 lines
drivers/raw/ioat/ioat_rawdev.c +1 -0
 		return -EINVAL;
 
 	ioat->ring_size = params->ring_size;
+	ioat->hdls_enable = params->hdls_enable;
 	if (ioat->desc_ring != NULL) {
 		rte_memzone_free(ioat->desc_mz);
 		ioat->desc_ring = NULL;
drivers/raw/ioat/rte_ioat_rawdev.h +0 -0
index f765a6557..daca04dd3 100644

drivers/raw/ioat/rte_ioat_rawdev.h line 40

Quoted 6 lines
drivers/raw/ioat/rte_ioat_rawdev.h +1 -0
@@ -35,6 +35,7 @@
  */
 struct rte_ioat_rawdev_config {
 	unsigned short ring_size;
+	bool hdls_enable;
 };
 

You need a doxygen comment on the new structure member (and add to existing one). While it's fairly clear what ring_size parameter should do, the hdls_enable one needs a proper explanation.

I also think you might want to investigate changing it to "hdls_disable" so that the default zero-value is the current behaviour. Requiring it to be set as 1 means that existing code will likely recompile but fail to work. For example, the ioat_rawdev_autotest fails on completion checks now.

#6 lore raw

PATCH v2 1/1 raw/ioat: add a flag to control copying handle parameters

In reply to Cheng Jiang

Add a flag which controls whether rte_ioat_enqueue_copy and rte_ioat_completed_copies function should process handle parameters to improve the performance when handle parameters are not necessary to use. This is targeting 20.11 release.

---
v2:
* optimized the logic of some codes
* added some comments

---
 drivers/raw/ioat/ioat_rawdev.c     |  1 +
 drivers/raw/ioat/rte_ioat_rawdev.h | 29 ++++++++++++++++++++++-------
 2 files changed, 23 insertions(+), 7 deletions(-)
drivers/raw/ioat/ioat_rawdev.c +1 -0
index 87fd088aa..d70e47d52 100644
@@ -57,6 +57,7 @@ ioat_dev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 		return -EINVAL;
 
 	ioat->ring_size = params->ring_size;
+	ioat->hdls_disable = params->hdls_disable;
 	if (ioat->desc_ring != NULL) {
 		rte_memzone_free(ioat->desc_mz);
 		ioat->desc_ring = NULL;
drivers/raw/ioat/rte_ioat_rawdev.h +22 -7
index f765a6557..cf0e634f3 100644
@@ -31,10 +31,13 @@
  *
  * This structure is to be passed as the ".dev_private" parameter when
  * calling the rte_rawdev_get_info() and rte_rawdev_configure() APIs on
- * an ioat rawdev instance.
+ * an ioat rawdev instance. The member hdls_disable controls if handles
+ * need to be copied when calling the rte_ioat_enqueue_copy() and
+ * rte_ioat_completed_copies() APIs.
  */
 struct rte_ioat_rawdev_config {
 	unsigned short ring_size;
+	bool hdls_disable;
 };
 
 /**
@@ -52,6 +55,7 @@ struct rte_ioat_rawdev {
 
 	unsigned short ring_size;
 	struct rte_ioat_generic_hw_desc *desc_ring;
+	bool hdls_disable;
 	__m128i *hdls; /* completion handles for returning to user */
 
 
@@ -84,10 +88,12 @@ struct rte_ioat_rawdev {
  *   The length of the data to be copied
  * @param src_hdl
  *   An opaque handle for the source data, to be returned when this operation
- *   has been completed and the user polls for the completion details
+ *   has been completed and the user polls for the completion details if
+ *   hdls_disable is false
  * @param dst_hdl
  *   An opaque handle for the destination data, to be returned when this
  *   operation has been completed and the user polls for the completion details
+ *   if hdls_disable is false
  * @param fence
  *   A flag parameter indicating that hardware should not begin to perform any
  *   subsequently enqueued copy operations until after this operation has
@@ -121,8 +127,10 @@ rte_ioat_enqueue_copy(int dev_id, phys_addr_t src, phys_addr_t dst,
 	desc->u.control_raw = (uint32_t)((!!fence << 4) | (!(write & 0xF)) << 3);
 	desc->src_addr = src;
 	desc->dest_addr = dst;
+	if (!ioat->hdls_disable)
+		ioat->hdls[write] = _mm_set_epi64x((int64_t)dst_hdl,
+					(int64_t)src_hdl);
 
-	ioat->hdls[write] = _mm_set_epi64x((int64_t)dst_hdl, (int64_t)src_hdl);
 	rte_prefetch0(&ioat->desc_ring[ioat->next_write & mask]);
 
 	ioat->enqueued++;
@@ -168,9 +176,11 @@ rte_ioat_get_last_completed(struct rte_ioat_rawdev *ioat, int *error)
 /**
  * Returns details of copy operations that have been completed
  *
- * Returns to the caller the user-provided "handles" for the copy operations
- * which have been completed by the hardware, and not already returned by
- * a previous call to this API.
+ * If the hdls_disable is false, the function will return to the caller the
+ * user-provided "handles" for the copy operations which have been completed
+ * by the hardware, and not already returned by a previous call to this API.
+ * If the hdls_disable is true, the max_copies will be ignored, and that the
+ * src_hdls and dst_hdls can be NULL when calling the function.
  *
  * @param dev_id
  *   The rawdev device id of the ioat instance
@@ -205,6 +215,11 @@ rte_ioat_completed_copies(int dev_id, uint8_t max_copies,
 		return -1;
 	}
 
+	if (ioat->hdls_disable) {
+		read += count;
+		goto end;
+	}
+
 	if (count > max_copies)
 		count = max_copies;
 
@@ -222,7 +237,7 @@ rte_ioat_completed_copies(int dev_id, uint8_t max_copies,
 		src_hdls[i] = hdls[0];
 		dst_hdls[i] = hdls[1];
 	}
-
+end:
 	ioat->next_read = read;
 	ioat->completed += count;
 	return count;

--
2.27.0

#7 lore raw

Re: [dpdk-dev] [PATCH 20.11 v2] raw/ioat: add a flag to control copying handle parameters

Quoted 56 lines · Cheng Jiang

Add a flag which controls whether rte_ioat_enqueue_copy and rte_ioat_completed_copies function should process handle parameters to improve the performance when handle parameters are not necessary to use. This is targeting 20.11 release.

---
v2:
* optimized the logic of some codes
* added some comments

---
 drivers/raw/ioat/ioat_rawdev.c     |  1 +
 drivers/raw/ioat/rte_ioat_rawdev.h | 29 ++++++++++++++++++++++-------
 2 files changed, 23 insertions(+), 7 deletions(-)
drivers/raw/ioat/ioat_rawdev.c +1 -0
index 87fd088aa..d70e47d52 100644
@@ -57,6 +57,7 @@ ioat_dev_configure(const struct rte_rawdev *dev, rte_rawdev_obj_t config)
 		return -EINVAL;
 
 	ioat->ring_size = params->ring_size;
+	ioat->hdls_disable = params->hdls_disable;
 	if (ioat->desc_ring != NULL) {
 		rte_memzone_free(ioat->desc_mz);
 		ioat->desc_ring = NULL;
drivers/raw/ioat/rte_ioat_rawdev.h +5 -1
index f765a6557..cf0e634f3 100644
@@ -31,10 +31,13 @@
  *
  * This structure is to be passed as the ".dev_private" parameter when
  * calling the rte_rawdev_get_info() and rte_rawdev_configure() APIs on
- * an ioat rawdev instance.
+ * an ioat rawdev instance. The member hdls_disable controls if handles
+ * need to be copied when calling the rte_ioat_enqueue_copy() and
+ * rte_ioat_completed_copies() APIs.
  */
 struct rte_ioat_rawdev_config {
 	unsigned short ring_size;
+	bool hdls_disable;
 };
 
 /**
@@ -52,6 +55,7 @@ struct rte_ioat_rawdev {
 
 	unsigned short ring_size;
 	struct rte_ioat_generic_hw_desc *desc_ring;
+	bool hdls_disable;
 	__m128i *hdls; /* completion handles for returning to user */
 
 

drivers/raw/ioat/rte_ioat_rawdev.h struct rte_ioat_rawdev { · line 96

Quoted 10 lines
drivers/raw/ioat/rte_ioat_rawdev.h +3 -1
@@ -84,10 +88,12 @@ struct rte_ioat_rawdev {
  *   The length of the data to be copied
  * @param src_hdl
  *   An opaque handle for the source data, to be returned when this operation
- *   has been completed and the user polls for the completion details
+ *   has been completed and the user polls for the completion details if
+ *   hdls_disable is false
  * @param dst_hdl
  *   An opaque handle for the destination data, to be returned when this
  *   operation has been completed and the user polls for the completion details
+ *   if hdls_disable is false

Minor nit - rather than adding "if hdls_disable is false" to the sentence, I think it would be clearer to just add on as an extra sentence: "NOTE: If hdls_disable configuration option is set, this parameter is ignored"

Quoted 17 lines
drivers/raw/ioat/rte_ioat_rawdev.h +3 -1
  * @param fence
  *   A flag parameter indicating that hardware should not begin to perform any
  *   subsequently enqueued copy operations until after this operation has
@@ -121,8 +127,10 @@ rte_ioat_enqueue_copy(int dev_id, phys_addr_t src, phys_addr_t dst,
 	desc->u.control_raw = (uint32_t)((!!fence << 4) | (!(write & 0xF)) << 3);
 	desc->src_addr = src;
 	desc->dest_addr = dst;
+	if (!ioat->hdls_disable)
+		ioat->hdls[write] = _mm_set_epi64x((int64_t)dst_hdl,
+					(int64_t)src_hdl);
 
-	ioat->hdls[write] = _mm_set_epi64x((int64_t)dst_hdl, (int64_t)src_hdl);
 	rte_prefetch0(&ioat->desc_ring[ioat->next_write & mask]);
 
 	ioat->enqueued++;
@@ -168,9 +176,11 @@ rte_ioat_get_last_completed(struct rte_ioat_rawdev *ioat, int *error)
 /**

drivers/raw/ioat/rte_ioat_rawdev.h rte_ioat_get_last_completed(struct rte_ioat_rawdev *ioat, int *error) · line 183

Quoted 10 lines
drivers/raw/ioat/rte_ioat_rawdev.h +5 -3
  * Returns details of copy operations that have been completed
  *
- * Returns to the caller the user-provided "handles" for the copy operations
- * which have been completed by the hardware, and not already returned by
- * a previous call to this API.
+ * If the hdls_disable is false, the function will return to the caller the
+ * user-provided "handles" for the copy operations which have been completed
+ * by the hardware, and not already returned by a previous call to this API.
+ * If the hdls_disable is true, the max_copies will be ignored, and that the
+ * src_hdls and dst_hdls can be NULL when calling the function.

Again I think this might be better left as originally stated, with the additional case of "hdls_disable" being set left till the end. Rather than referring to "true/false" set/not-set are better terms to use.

Quoted 27 lines
drivers/raw/ioat/rte_ioat_rawdev.h +6 -2
  *
  * @param dev_id
  *   The rawdev device id of the ioat instance
@@ -205,6 +215,11 @@ rte_ioat_completed_copies(int dev_id, uint8_t max_copies,
 		return -1;
 	}
 
+	if (ioat->hdls_disable) {
+		read += count;
+		goto end;
+	}
+
 	if (count > max_copies)
 		count = max_copies;
 
@@ -222,7 +237,7 @@ rte_ioat_completed_copies(int dev_id, uint8_t max_copies,
 		src_hdls[i] = hdls[0];
 		dst_hdls[i] = hdls[1];
 	}
-
+end:
 	ioat->next_read = read;
 	ioat->completed += count;
 	return count;
--

2.27.0

#8 lore raw

Re: [dpdk-dev] [PATCH 20.11 v2] raw/ioat: add a flag to control copying handle parameters

Quoted 9 lines · Bruce Richardson
Quoted 8 lines · Cheng Jiang

Add a flag which controls whether rte_ioat_enqueue_copy and rte_ioat_completed_copies function should process handle parameters to improve the performance when handle parameters are not necessary to use. This is targeting 20.11 release.

---

With Cheng's agreement, this patch has now been included in the bigger ioat update patchset for 20.11 [1], and does not need to be tracked separately.

[1] http://inbox.dpdk.org/dev/[email protected]/

Regards,
/Bruce