From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 523C3A0518; Thu, 30 Jul 2020 11:56:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 863F51C042; Thu, 30 Jul 2020 11:56:22 +0200 (CEST) Received: from mail-m972.mail.163.com (mail-m972.mail.163.com [123.126.97.2]) by dpdk.org (Postfix) with ESMTP id 657BD1BFFA for ; Thu, 30 Jul 2020 11:56:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=lFDu0 tBdjS+Pgn1WClXzcYpD7IRxZ1x0v3sOwg3KcrI=; b=l6L/lh9g4gSmvcrFmD0S/ zHcn7bp+kPA/Ot6JbSA3xzXPZoKc6sQDEoY+6Jkm/8ONR9aYHrGm8ybaPF1wv1yW H1XJSTuG7qqGGjVfV9GMoSCv6aiz8j/SpvpdPI3W2zftHGbAuRsapHceZqLHD1EY COw4jsKjBmgJYldcKlW108= Received: from yangyi0100.home.langchao.com (unknown [111.207.123.56]) by smtp2 (Coremail) with SMTP id GtxpCgCXFdk6mSJfhBGTHg--.3074S5; Thu, 30 Jul 2020 17:56:11 +0800 (CST) 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 Date: Thu, 30 Jul 2020 17:56:10 +0800 Message-Id: <20200730095610.93384-4-yang_y_yi@163.com> X-Mailer: git-send-email 2.19.2.windows.1 In-Reply-To: <20200730095610.93384-1-yang_y_yi@163.com> References: <20200730095610.93384-1-yang_y_yi@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GtxpCgCXFdk6mSJfhBGTHg--.3074S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7ZrWfXF1DZF1Utw4UArykAFb_yoW8Ar45pF 43Gry5Ar1rJr4xKrsxCr4fK3Z3Kayvk3W7CrZa9w1F9r4xX34xXFykKFWrur13Kr97Ar43 XF40qF1UK3WUuFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jFrWrUUUUU= X-Originating-IP: [111.207.123.56] X-CM-SenderInfo: 51dqwsp1b1xqqrwthudrp/1tbiMxtxi1Xl5dl34gAAsL Subject: [dpdk-dev] [PATCH 3/3] vhost: use new free_cb interface to fix mbuf free issue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Yi Yang 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 --- 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