[v5,5/7] lib: move mbuf next pointer to first cache line

Message ID e106960c78ac4b03a6ae276b009f1c3f05e66b69.1665176094.git.sthotton@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series mbuf dynamic field expansion |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Shijith Thotton Oct. 7, 2022, 9:02 p.m. UTC
  Swapped position of mbuf next pointer and second dynamic field (dynfield2)
if the build is configured to disable IOVA as PA. This is to move the
mbuf next pointer to first cache line.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
---
 doc/guides/rel_notes/release_22_11.rst |  3 +++
 lib/mbuf/rte_mbuf_core.h               | 19 ++++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)
  

Comments

Stephen Hemminger Oct. 7, 2022, 9:22 p.m. UTC | #1
On Sat, 8 Oct 2022 02:32:09 +0530
Shijith Thotton <sthotton@marvell.com> wrote:

> Swapped position of mbuf next pointer and second dynamic field (dynfield2)
> if the build is configured to disable IOVA as PA. This is to move the
> mbuf next pointer to first cache line.
> 
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

Why not always move it?
Having things on different cache lines based on config options
could cause surprising performance impacts.
  
Shijith Thotton Oct. 7, 2022, 9:30 p.m. UTC | #2
>> Swapped position of mbuf next pointer and second dynamic field (dynfield2)
>> if the build is configured to disable IOVA as PA. This is to move the
>> mbuf next pointer to first cache line.
>>
>> Signed-off-by: Shijith Thotton <sthotton@marvell.com>
>> Acked-by: Olivier Matz <olivier.matz@6wind.com>
>
>Why not always move it?
>Having things on different cache lines based on config options
>could cause surprising performance impacts.

Some drivers are using the offset of buf_iova.
  

Patch

diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
index 7431dda461..ab69db8d70 100644
--- a/doc/guides/rel_notes/release_22_11.rst
+++ b/doc/guides/rel_notes/release_22_11.rst
@@ -385,6 +385,9 @@  ABI Changes
 * eventdev: Added ``weight`` and ``affinity`` fields
   to ``rte_event_queue_conf`` structure.
 
+* mbuf: Replaced ``buf_iova`` field with ``next`` field and added a new field
+  ``dynfield2`` at its place in second cacheline if ``RTE_IOVA_AS_PA`` is 0.
+
 
 Known Issues
 ------------
diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h
index dc6c54015e..37d3fcc3b8 100644
--- a/lib/mbuf/rte_mbuf_core.h
+++ b/lib/mbuf/rte_mbuf_core.h
@@ -479,10 +479,11 @@  struct rte_mbuf {
 	rte_iova_t buf_iova __rte_aligned(sizeof(rte_iova_t));
 #else
 	/**
-	 * Reserved for dynamic field in builds where physical address
-	 * field is undefined.
+	 * Next segment of scattered packet.
+	 * This field is valid when physical address field is undefined.
+	 * Otherwise next pointer in the second cache line will be used.
 	 */
-	uint64_t dynfield2;
+	struct rte_mbuf *next;
 #endif
 
 	/* next 8 bytes are initialised on RX descriptor rearm */
@@ -599,11 +600,19 @@  struct rte_mbuf {
 	/* second cache line - fields only used in slow path or on TX */
 	RTE_MARKER cacheline1 __rte_cache_min_aligned;
 
+#if RTE_IOVA_AS_PA
 	/**
-	 * Next segment of scattered packet. Must be NULL in the last segment or
-	 * in case of non-segmented packet.
+	 * Next segment of scattered packet. Must be NULL in the last
+	 * segment or in case of non-segmented packet.
 	 */
 	struct rte_mbuf *next;
+#else
+	/**
+	 * Reserved for dynamic field when the next pointer is in first
+	 * cache line (i.e. RTE_IOVA_AS_PA is 0).
+	 */
+	uint64_t dynfield2;
+#endif
 
 	/* fields to support TX offloads */
 	RTE_STD_C11