From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 8C83EA04E7;
	Tue,  3 Nov 2020 22:35:02 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 937C3A8E9;
	Tue,  3 Nov 2020 22:35:00 +0100 (CET)
Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com
 [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id D867E69A4;
 Tue,  3 Nov 2020 22:34:57 +0100 (CET)
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42])
 by mailout.nyi.internal (Postfix) with ESMTP id 137935C0199;
 Tue,  3 Nov 2020 16:34:56 -0500 (EST)
Received: from mailfrontend1 ([10.202.2.162])
 by compute2.internal (MEProxy); Tue, 03 Nov 2020 16:34:56 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h=
 from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding:content-type; s=fm2; bh=
 bG14sIe23zYeIjJJKE6qDOn+nZMAkXjjUDQW4H8jgzo=; b=fUASwsWvW2D6EbaO
 P0hmqv9aXNYUpgio79HaZxFudJFRMLVOpAC7e1qFoV8c0ng4WF+Mw0BV1Ohc3ZWt
 BmwEJ3cDjfIWGfZFDfWZnBZWB6slo/6zZYXxlc+YbdAk06dEIfBeGuso0OL6KbSi
 OO26E3o+ewt7IsfiW+SlCk6+JqEmx1CxXOYn4VCePngzfKTWwBzSZckAcGP8wN9d
 ZnmrvZLMKzBt1nyNxJ/WcUNojR5Y/RobddOGDh7M4bwFw71wHYZyreNGh/yYJP7l
 qo1udQ1f8Dlp9A26PODY9ceozVv32yCU182m3b+J32dFl44I7s1G74hz8aLOCazt
 hCrLeQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-transfer-encoding:content-type
 :date:from:in-reply-to:message-id:mime-version:references
 :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender
 :x-sasl-enc; s=fm1; bh=bG14sIe23zYeIjJJKE6qDOn+nZMAkXjjUDQW4H8jg
 zo=; b=OKYpv9MRjbAJ3x8SKK/4RYgG4QpQlNeTpBs4U1FTlhXqatxAIMX6M9QIz
 RnAq8XrP0aM8wV0ZPQrnYOSJpbXUqlMx6M2gudEYpHtFVbOOXAgLy4gcC62OF2x3
 XsA5C7cxS1QIKJrJfU1hXuwQIBV1FAmT9LCIrNvoVRe8OXsjwIaGSBYNw3aZwg2u
 8ZAlG97tNmFOTlazRFcQyzZbi7pX1OM33GJhtDMPLvyzHXMUs0unPaVQSH+/w+sp
 wfi2xfCc1wmwZ+RzATWse3Y8/DaBW4yHUb3hBKUqEnTNbG+GZNj4+0z8K8TaoreV
 GwZ6r0Rt0m+o7XlM4hAQo/U7Qialg==
X-ME-Sender: <xms:_8yhX4WDcZ41MOQiX2s8TVYjVn0xwCcD6IjYXuEGx-artc32Ib1prw>
 <xme:_8yhX8mZEE-kIXDeC-MjaemPlLdDVzEDQuzX9W9b575Yl3MyGO-eGVs2JSyW7esSV
 8cpZHJvmnr-jVdaLw>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddtfedgudeglecutefuodetggdotefrod
 ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh
 necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd
 enucfjughrpefhvffufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhm
 rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc
 ggtffrrghtthgvrhhnpedugefgvdefudfftdefgeelgffhueekgfffhfeujedtteeutdej
 ueeiiedvffegheenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrh
 fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgr
 lhhonhdrnhgvth
X-ME-Proxy: <xmx:_8yhX8Zo6J5AdcetRqVdeHFCZ80CeawqJwOVEhmp_vpYqIPI3Tekbg>
 <xmx:_8yhX3XsgQZguV3I-evkbB9zu_ncaT1Wvq8lPeewv8f1WwT7se1tVQ>
 <xmx:_8yhXymQ4i3bbtaXPnqkNQRe8OFt1v59uGxb3yXGQaMpOCTOd2a4vA>
 <xmx:AM2hXzBd71JmEjlFpgzYuE9mJXiSkALVDFo2553BVkYWJ1BzBhByMw>
Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184])
 by mail.messagingengine.com (Postfix) with ESMTPA id 36324328018B;
 Tue,  3 Nov 2020 16:34:54 -0500 (EST)
From: Thomas Monjalon <thomas@monjalon.net>
To: "yang_y_yi@163.com" <yang_y_yi@163.com>,
 "yangyi01@inspur.com" <yangyi01@inspur.com>
Cc: "techboard@dpdk.org" <techboard@dpdk.org>, "Ananyev,
 Konstantin" <konstantin.ananyev@intel.com>, dev@dpdk.org,
 "dev@dpdk.org" <dev@dpdk.org>, "Hu, Jiayu" <jiayu.hu@intel.com>,
 olivier.matz@6wind.com
Date: Tue, 03 Nov 2020 22:34:52 +0100
Message-ID: <2280167.6YWU9ATIUA@thomas>
In-Reply-To: <1680723.gEWeqp86JR@thomas>
References: <20201026064713.33316-1-yang_y_yi@163.com>
 <BYAPR11MB3301B32FA2889BDDBEF806899A160@BYAPR11MB3301.namprd11.prod.outlook.com>
 <1680723.gEWeqp86JR@thomas>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
Subject: Re: [dpdk-dev] [PATCH v3] gso: fix free issue of mbuf gso segments
	attach to
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

29/10/2020 22:39, Thomas Monjalon:
> I don't have a clear opinion on this patch.
> Techboard members, ping for feedbacks.
> If no objection, I will merge it soon, but I would prefer having more acks.
> 
> 
> 27/10/2020 20:55, Ananyev, Konstantin:
> > From: yang_y_yi@163.com <yang_y_yi@163.com>
> > > From: Yi Yang <yangyi01@inspur.com>
> > > 
> > > 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.
> > > 
> > > This commit changed rte_gso_segment in functional behavior
> > > and return value, so the application must take appropriate
> > > actions according to return values, "ret < 0" means it
> > > should free and drop 'pkt', "ret == 0" means 'pkt' isn't
> > > GSOed but 'pkt' can be transimmitted as a normal packet,
> > > "ret > 0" means 'pkt' has been GSOed into two or multiple
> > > segments, it should use "pkts_out" to transmit these
> > > segments. The application must free 'pkt' after call
> > > rte_gso_segment when return value isn't equal to 0.
> > 
> > Tech-board members: this is not a formal API breakage,
> > but it is a functional change (i.e. all code that uses that API will need to be changed).
> > There was no deprecation note in advance.
> > So please provide your input: are you ok with such change or not.
> > 
> > I am ok with the proposed changes.
> > Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> 
> [...]
> > >  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.
> [...]
> > >  #. Invoke the GSO segmentation API, ``rte_gso_segment()``.
> > > 
> > > +#. Call ``rte_pktmbuf_free()`` to free mbuf ``rte_gso_segment()`` segments.
> [...]
> > > --- a/doc/guides/rel_notes/release_20_11.rst
> > > +++ b/doc/guides/rel_notes/release_20_11.rst
> > > @@ -543,6 +543,13 @@ API Changes
> > > +* **Changed ``rte_gso_segment`` in functional behavior and return value.**
> > > +
> > > +  * Don't save pkt to pkts_out[0] if it isn't GSOed in case of ret == 1.
> > > +  * Return 0 instead of 1 for the above case.
> > > +  * ``rte_gso_segment`` won't free pkt no matter whether it is GSOed, the
> > > +    application has responsibility to free it after call ``rte_gso_segment``.
> [...]
> > > --- a/lib/librte_gso/rte_gso.h
> > > +++ b/lib/librte_gso/rte_gso.h
> > > - * If the input packet is GSO'd, its mbuf refcnt reduces by 1. Therefore,
> > > - * when all GSO segments are freed, the input packet is freed automatically.
> > > + * If the input packet is GSO'd, all the indirect segments are attached to the
> > > + * input packet.
> > > + *
> > > + * rte_gso_segment() will not free the input packet no matter whether it is
> > > + * GSO'd or not, the application should free it after call rte_gso_segment().
> > >   *
> > >   * If the memory space in pkts_out or MBUF pools is insufficient, this
> > >   * function fails, and it returns (-1) * errno. Otherwise, GSO succeeds,
> > > @@ -109,6 +112,7 @@ struct rte_gso_ctx {
> > >   *
> > >   * @return
> > >   *  - The number of GSO segments filled in pkts_out on success.
> > > + *  - Return 0 if it needn't GSOed.
> > >   *  - Return -ENOMEM if run out of memory in MBUF pools.
> > >   *  - Return -EINVAL for invalid parameters.
> > >   */

Applied with formatting and english improvements, thanks.