Thread (21 messages) 21 messages, 2 authors, 2020-10-15

[dpdk-dev] [PATCH V1 3/3] vhost: use new free_cb interface to fix mbuf free issue

From: <hidden>
Date: 2020-07-30 12:09:25
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

From: Yi Yang <redacted>

New free_cb interface can help fix original external
mbuf free issue in GSO case, it still can be compatible
with normal non-GSO case. dpdkvhostuser port can work
both in GSO case and in non-GSO case by this fix.

Signed-off-by: Yi Yang <redacted>
---
 lib/librte_vhost/virtio_net.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index e663fd4..3b69cbb 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -2136,10 +2136,20 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
 	return NULL;
 }
 
+struct shinfo_arg {
+	void *buf;
+	struct rte_mbuf *mbuf;
+};
+
 static void
-virtio_dev_extbuf_free(struct rte_mbuf * caller_m __rte_unused, void *opaque)
+virtio_dev_extbuf_free(struct rte_mbuf *caller_m, void *opaque)
 {
-	rte_free(opaque);
+	struct shinfo_arg *arg = (struct shinfo_arg *)opaque;
+
+	rte_free(arg->buf);
+	if (caller_m != arg->mbuf)
+		rte_pktmbuf_free(arg->mbuf);
+	rte_free(arg);
 }
 
 static int
@@ -2172,8 +2182,14 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
 
 	/* Initialize shinfo */
 	if (shinfo) {
+		struct shinfo_arg *arg = (struct shinfo_arg *)
+			rte_malloc(NULL, sizeof(struct shinfo_arg),
+				   RTE_CACHE_LINE_SIZE);
+
+		arg->buf = buf;
+		arg->mbuf = pkt;
 		shinfo->free_cb = virtio_dev_extbuf_free;
-		shinfo->fcb_opaque = buf;
+		shinfo->fcb_opaque = arg;
 		rte_mbuf_ext_refcnt_set(shinfo, 1);
 	} else {
 		shinfo = rte_pktmbuf_ext_shinfo_init_helper(buf, &buf_len,
-- 
1.8.3.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help