[dpdk-dev] [PATCH RFC 05/11] mbuf: merge physaddr and buf_len in a bitfield

Shaw, Jeffrey B jeffrey.b.shaw at intel.com
Fri May 9 17:39:42 CEST 2014


Hello Olivier, have you tested this patch to see if there is a negative impact to performance?
Wouldn't the processor have to mask the high bytes of the physical address when it is used, for example, to populate descriptors with buffer addresses?  When compute bound, this could steal CPU cycles away from packet processing.  I think we should understand the performance trade-off in order to save these 2 bytes.

It would be interesting to see how throughput is impacted when the workload is core-bound.  This could be accomplished by running testpmd in io-fwd mode across 4x 10G ports.

Thanks,
Jeff

-----Original Message-----
From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Olivier Matz
Sent: Friday, May 09, 2014 7:51 AM
To: dev at dpdk.org
Subject: [dpdk-dev] [PATCH RFC 05/11] mbuf: merge physaddr and buf_len in a bitfield

The physical address is never greater than (1 << 48) = 256 TB.
We can win 2 bytes in the mbuf structure by merging the physical address and the buffer length in the same bitfield.

Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
---
 lib/librte_mbuf/rte_mbuf.c | 3 ++-
 lib/librte_mbuf/rte_mbuf.h | 7 ++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index c229525..9879095 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -104,7 +104,8 @@ rte_pktmbuf_init(struct rte_mempool *mp,
 	m->buf_len = (uint16_t)buf_len;
 
 	/* keep some headroom between start of buffer and data */
-	m->data = (char*) m->buf_addr + RTE_MIN(RTE_PKTMBUF_HEADROOM, m->buf_len);
+	m->data = (char*) m->buf_addr + RTE_MIN(RTE_PKTMBUF_HEADROOM,
+		(uint16_t)m->buf_len);
 
 	/* init some constant fields */
 	m->pool = mp;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 803b223..275f6b2 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -130,8 +130,8 @@ union rte_vlan_macip {  struct rte_mbuf {
 	struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */
 	void *buf_addr;           /**< Virtual address of segment buffer. */
-	phys_addr_t buf_physaddr; /**< Physical address of segment buffer. */
-	uint16_t buf_len;         /**< Length of segment buffer. */
+	uint64_t buf_physaddr:48; /**< Physical address of segment buffer. */
+	uint64_t buf_len:16;      /**< Length of segment buffer. */
 #ifdef RTE_MBUF_REFCNT
 	/**
 	 * 16-bit Reference counter.
@@ -148,8 +148,9 @@ struct rte_mbuf {
 #else
 	uint16_t refcnt_reserved;     /**< Do not use this field */
 #endif
-	uint16_t reserved;             /**< Unused field. Required for padding. */
+
 	uint16_t ol_flags;            /**< Offload features. */
+	uint32_t reserved;             /**< Unused field. Required for padding. */
 
 	/* valid for any segment */
 	struct rte_mbuf *next;  /**< Next segment of scattered packet. */
--
1.9.2



More information about the dev mailing list