From: yang_y_yi@163.com
To: dev@dpdk.org
Cc: jiayu.hu@intel.com, thomas@monjalon.net, yangyi01@inspur.com,
yang_y_yi@163.com
Subject: [dpdk-dev] [PATCH V1 3/3] vhost: use new free_cb interface to fix mbuf free issue
Date: Thu, 30 Jul 2020 20:09:00 +0800 [thread overview]
Message-ID: <20200730120900.108232-4-yang_y_yi@163.com> (raw)
In-Reply-To: <20200730120900.108232-1-yang_y_yi@163.com>
From: Yi Yang <yangyi01@inspur.com>
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 <yangyi01@inspur.com>
---
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
prev parent reply other threads:[~2020-07-30 12:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-30 12:08 [dpdk-dev] [PATCH V1 0/3] Fix external mbuf free issue in GSO case yang_y_yi
2020-07-30 12:08 ` [dpdk-dev] [PATCH V1 1/3] gso: fix refcnt update issue for external mbuf yang_y_yi
2020-07-30 12:08 ` [dpdk-dev] [PATCH V1 2/3] mbuf: change free_cb interface to adapt to GSO case yang_y_yi
2020-07-31 15:15 ` Olivier Matz
2020-08-01 23:12 ` yang_y_yi
2020-08-02 20:29 ` Olivier Matz
2020-08-02 20:45 ` Olivier Matz
2020-08-03 1:32 ` yang_y_yi
2020-08-03 1:26 ` yang_y_yi
2020-08-03 8:11 ` Olivier Matz
2020-08-03 9:42 ` yang_y_yi
2020-08-03 12:34 ` Olivier Matz
2020-08-04 1:31 ` yang_y_yi
2020-09-27 5:55 ` yang_y_yi
2020-10-07 9:48 ` Olivier Matz
2020-10-09 9:51 ` yang_y_yi
2020-10-09 11:55 ` Olivier Matz
2020-10-10 1:49 ` yang_y_yi
2020-10-14 13:55 ` Olivier Matz
2020-10-15 2:52 ` yang_y_yi
2020-07-30 12:09 ` yang_y_yi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200730120900.108232-4-yang_y_yi@163.com \
--to=yang_y_yi@163.com \
--cc=dev@dpdk.org \
--cc=jiayu.hu@intel.com \
--cc=thomas@monjalon.net \
--cc=yangyi01@inspur.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).