[dpdk-stable] patch 'mbuf: fix performance of freeing with non atomic refcnt' has been queued to LTS release 17.11.1

Yuanhan Liu yliu at fridaylinux.org
Wed Jan 24 16:33:14 CET 2018


Hi,

FYI, your patch has been queued to LTS release 17.11.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 01/26/18. So please
shout if anyone has objections.

Thanks.

	--yliu

---
>From 964b426f0087924f6d07d0009cf190d22a091e4f Mon Sep 17 00:00:00 2001
From: Olivier Matz <olivier.matz at 6wind.com>
Date: Fri, 8 Dec 2017 16:46:51 +0100
Subject: [PATCH] mbuf: fix performance of freeing with non atomic refcnt

[ upstream commit 6d714a237d8a306837a5f87711f9af9063376fed ]

When RTE_MBUF_REFCNT_ATOMIC=n, the decrement of the mbuf reference
counter uses an atomic operation. This is not necessary and impacts
the performance (seen with TRex traffic generator).

We cannot replace rte_atomic16_add_return() by rte_mbuf_refcnt_update()
because it would add an additional check.

Solves this by introducing __rte_mbuf_refcnt_update(), which
updates the reference counter without doing anything else.

Fixes: 8f094a9ac5d7 ("mbuf: set mbuf fields while in pool")

Suggested-by: Hanoch Haim <hhaim at cisco.com>
Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
---
 lib/librte_mbuf/rte_mbuf.h | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index e5d7643..bf85124 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -765,6 +765,13 @@ rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value)
 	rte_atomic16_set(&m->refcnt_atomic, new_value);
 }
 
+/* internal */
+static inline uint16_t
+__rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value)
+{
+	return (uint16_t)(rte_atomic16_add_return(&m->refcnt_atomic, value));
+}
+
 /**
  * Adds given value to an mbuf's refcnt and returns its new value.
  * @param m
@@ -789,19 +796,26 @@ rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value)
 		return 1 + value;
 	}
 
-	return (uint16_t)(rte_atomic16_add_return(&m->refcnt_atomic, value));
+	return __rte_mbuf_refcnt_update(m, value);
 }
 
 #else /* ! RTE_MBUF_REFCNT_ATOMIC */
 
+/* internal */
+static inline uint16_t
+__rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value)
+{
+	m->refcnt = (uint16_t)(m->refcnt + value);
+	return m->refcnt;
+}
+
 /**
  * Adds given value to an mbuf's refcnt and returns its new value.
  */
 static inline uint16_t
 rte_mbuf_refcnt_update(struct rte_mbuf *m, int16_t value)
 {
-	m->refcnt = (uint16_t)(m->refcnt + value);
-	return m->refcnt;
+	return __rte_mbuf_refcnt_update(m, value);
 }
 
 /**
@@ -1365,8 +1379,7 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m)
 
 		return m;
 
-       } else if (rte_atomic16_add_return(&m->refcnt_atomic, -1) == 0) {
-
+	} else if (__rte_mbuf_refcnt_update(m, -1) == 0) {
 
 		if (RTE_MBUF_INDIRECT(m))
 			rte_pktmbuf_detach(m);
-- 
2.7.4



More information about the stable mailing list