All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] mbuf: cleanup rte_pktmbuf_lastseg(), fix atomic usage
@ 2017-11-15  9:14 Hanoh Haim
  2017-11-15 11:13 ` Ilya Matveychikov
  2017-12-08 15:46 ` [PATCH v4] mbuf: fix mbuf free performance with non atomic refcnt Olivier Matz
  0 siblings, 2 replies; 19+ messages in thread
From: Hanoh Haim @ 2017-11-15  9:14 UTC (permalink / raw)
  To: dev; +Cc: Hanoh Haim

Signed-off-by: Hanoh Haim <hhaim@cisco.com>
---
 lib/librte_mbuf/rte_mbuf.h | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 7e326bb..ab110f8 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -1159,6 +1159,15 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m)
	__rte_mbuf_sanity_check(m, 1);
 }
 
+
+static __rte_always_inline void rte_pktmbuf_reset_before_free(struct rte_mbuf *m)
+{
+	if (m->next != NULL) {
+		m->next = NULL;
+		m->nb_segs = 1;
+	}
+}
+
 /**
  * Allocate a new mbuf from a mempool.
  *
@@ -1323,8 +1332,7 @@ static inline void rte_pktmbuf_detach(struct rte_mbuf *m)
	m->ol_flags = 0;
 
	if (rte_mbuf_refcnt_update(md, -1) == 0) {
-		md->next = NULL;
-		md->nb_segs = 1;
+		rte_pktmbuf_reset_before_free(md);
		rte_mbuf_refcnt_set(md, 1);
		rte_mbuf_raw_free(md);
	}
@@ -1354,25 +1362,16 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m)
		if (RTE_MBUF_INDIRECT(m))
			rte_pktmbuf_detach(m);
 
-		if (m->next != NULL) {
-			m->next = NULL;
-			m->nb_segs = 1;
-		}
-
+		rte_pktmbuf_reset_before_free(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);
 
-		if (m->next != NULL) {
-			m->next = NULL;
-			m->nb_segs = 1;
-		}
+		rte_pktmbuf_reset_before_free(m);
		rte_mbuf_refcnt_set(m, 1);
-
		return m;
	}
	return NULL;
-- 
2.9.3

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

end of thread, other threads:[~2018-01-18 23:23 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-15  9:14 [PATCH v3] mbuf: cleanup rte_pktmbuf_lastseg(), fix atomic usage Hanoh Haim
2017-11-15 11:13 ` Ilya Matveychikov
2017-11-15 12:46   ` Hanoch Haim (hhaim)
2017-11-15 17:30     ` Olivier MATZ
2017-11-16  7:16       ` Hanoch Haim (hhaim)
2017-11-16  8:07         ` Ilya Matveychikov
2017-11-16  8:42         ` Olivier MATZ
2017-11-16  9:06           ` Hanoch Haim (hhaim)
2017-11-16  9:32             ` Ilya Matveychikov
2017-11-16  9:37               ` Olivier MATZ
2017-11-16  9:44                 ` Ilya Matveychikov
2017-11-16 10:54       ` Ananyev, Konstantin
2017-12-08 15:46 ` [PATCH v4] mbuf: fix mbuf free performance with non atomic refcnt Olivier Matz
2017-12-08 16:04   ` Ilya Matveychikov
2017-12-08 16:19     ` Olivier MATZ
2017-12-08 16:37   ` Stephen Hemminger
2017-12-10  8:37   ` Hanoch Haim (hhaim)
2017-12-11 10:28   ` Olivier MATZ
2018-01-18 23:23   ` Thomas Monjalon

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.