From: "Hu, Jiayu" <jiayu.hu@intel.com> To: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>, "yang_y_yi@163.com" <yang_y_yi@163.com>, "dev@dpdk.org" <dev@dpdk.org> Cc: "olivier.matz@6wind.com" <olivier.matz@6wind.com>, "thomas@monjalon.net" <thomas@monjalon.net>, "yangyi01@inspur.com" <yangyi01@inspur.com> Subject: Re: [dpdk-dev] [PATCH] gso: fix free issue of mbuf gso segments attach to Date: Wed, 14 Oct 2020 01:00:12 +0000 Message-ID: <6167423037704e3382f85275be79de30@intel.com> (raw) In-Reply-To: <BYAPR11MB3301BB7E22FF7268741D094F9A040@BYAPR11MB3301.namprd11.prod.outlook.com> > -----Original Message----- > From: Ananyev, Konstantin <konstantin.ananyev@intel.com> > Sent: Tuesday, October 13, 2020 11:39 PM > To: Hu, Jiayu <jiayu.hu@intel.com>; yang_y_yi@163.com; dev@dpdk.org > Cc: mark.b.kavanagh@intel.com; olivier.matz@6wind.com; > thomas@monjalon.net; yangyi01@inspur.com > Subject: RE: [PATCH] gso: fix free issue of mbuf gso segments attach to > > > > > rte_gso_segment decreased refcnt of pkt by one, but > > > it is wrong if pkt is external mbuf, pkt won't be > > > freed because of incorrect refcnt, the result is > > > application can't allocate mbuf from mempool because > > > mbufs in mempool are run out of. > > > > > > One correct way is application should call > > > rte_pktmbuf_free after calling rte_gso_segment to free > > > pkt explicitly. rte_gso_segment mustn't handle it, this > > > should be responsibility of application. > > > > GSO doesn't support the input pktmbuf has external buffer. > > Indeed, requiring users to free the input pktmbuf can avoid > > memory leak, but I'm afraid that it also changes the semantic > > of rte_gso_segment() which is defined in rte_gso.h. > > > > @Konstantin, any suggestions? > > Probably, a stupid question, but why can't we call mbuf_free() > here instead fo decrementing refcnt manually: > if (ret > 1) > rte_pktmbuf_free(pkt); > else if ... > ? You are right. Freeing mbuf inside GSO is a better way to solve the problem. Thanks, Jiayu > > > > > > > Thanks, > > Jiayu > > > > > > Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO") > > > Signed-off-by: Yi Yang <yangyi01@inspur.com> > > > --- > > > doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++- > - > > > lib/librte_gso/rte_gso.c | 9 +-------- > > > 2 files changed, 6 insertions(+), 10 deletions(-) > > > > > > diff --git a/doc/guides/prog_guide/generic_segmentation_offload_lib.rst > > > b/doc/guides/prog_guide/generic_segmentation_offload_lib.rst > > > index 205cb8a..8577572 100644 > > > --- a/doc/guides/prog_guide/generic_segmentation_offload_lib.rst > > > +++ b/doc/guides/prog_guide/generic_segmentation_offload_lib.rst > > > @@ -25,8 +25,9 @@ Bearing that in mind, the GSO library enables DPDK > > > applications to segment > > > packets in software. Note however, that GSO is implemented as a > > > standalone > > > library, and not via a 'fallback' mechanism (i.e. for when TSO is > unsupported > > > in the underlying hardware); that is, applications must explicitly invoke > the > > > -GSO library to segment packets. The size of GSO segments ``(segsz)`` is > > > -configurable by the application. > > > +GSO library to segment packets, they also must call > ``rte_pktmbuf_free()`` to > > > +free mbuf GSO segments attach to after calling ``rte_gso_segment()``. > The > > > size > > > +of GSO segments ``(segsz)`` is configurable by the application. > > > > > > Limitations > > > ----------- > > > @@ -233,6 +234,8 @@ To segment an outgoing packet, an application > must: > > > > > > #. Invoke the GSO segmentation API, ``rte_gso_segment()``. > > > > > > +#. Call ``rte_pktmbuf_free()`` to free mbuf ``rte_gso_segment()`` > segments. > > > + > > > #. If required, update the L3 and L4 checksums of the newly-created > > > segments. > > > For tunneled packets, the outer IPv4 headers' checksums should also > be > > > updated. Alternatively, the application may offload checksum > calculation > > > diff --git a/lib/librte_gso/rte_gso.c b/lib/librte_gso/rte_gso.c > > > index 751b5b6..0d6cae5 100644 > > > --- a/lib/librte_gso/rte_gso.c > > > +++ b/lib/librte_gso/rte_gso.c > > > @@ -30,7 +30,6 @@ > > > uint16_t nb_pkts_out) > > > { > > > struct rte_mempool *direct_pool, *indirect_pool; > > > -struct rte_mbuf *pkt_seg; > > > uint64_t ol_flags; > > > uint16_t gso_size; > > > uint8_t ipid_delta; > > > @@ -80,13 +79,7 @@ > > > return 1; > > > } > > > > > > -if (ret > 1) { > > > -pkt_seg = pkt; > > > -while (pkt_seg) { > > > -rte_mbuf_refcnt_update(pkt_seg, -1); > > > -pkt_seg = pkt_seg->next; > > > -} > > > -} else if (ret < 0) { > > > +if (ret < 0) { > > > /* Revert the ol_flags in the event of failure. */ > > > pkt->ol_flags = ol_flags; > > > } > > > -- > > > 1.8.3.1 > > >
next prev parent reply other threads:[~2020-10-14 1:00 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-10 3:10 yang_y_yi 2020-10-13 7:28 ` Hu, Jiayu 2020-10-13 15:39 ` Ananyev, Konstantin 2020-10-14 1:00 ` Hu, Jiayu [this message] 2020-10-14 2:56 ` yang_y_yi 2020-10-14 12:05 ` Ananyev, Konstantin 2020-10-15 5:14 ` Hu, Jiayu 2020-10-15 16:16 ` Ananyev, Konstantin 2020-10-16 0:53 ` Hu, Jiayu 2020-10-16 8:31 ` Ananyev, Konstantin 2020-10-19 3:17 ` Hu, Jiayu 2020-10-19 6:44 ` yang_y_yi 2020-10-19 8:47 ` Ananyev, Konstantin 2020-10-20 1:16 ` yang_y_yi 2020-10-19 2:29 ` yang_y_yi 2020-10-19 2:20 ` yang_y_yi
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=6167423037704e3382f85275be79de30@intel.com \ --to=jiayu.hu@intel.com \ --cc=dev@dpdk.org \ --cc=konstantin.ananyev@intel.com \ --cc=olivier.matz@6wind.com \ --cc=thomas@monjalon.net \ --cc=yang_y_yi@163.com \ --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
DPDK patches and discussions This inbox may be cloned and mirrored by anyone: git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \ dev@dpdk.org public-inbox-index dev Example config snippet for mirrors. Newsgroup available over NNTP: nntp://inbox.dpdk.org/inbox.dpdk.dev AGPL code for this site: git clone https://public-inbox.org/public-inbox.git