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 A2836A04B7; Wed, 14 Oct 2020 14:05:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C71061DC8B; Wed, 14 Oct 2020 14:05:52 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id D7FDE1DA28 for ; Wed, 14 Oct 2020 14:05:49 +0200 (CEST) IronPort-SDR: 3uLFCB81ZYhF7i1OLsihDJE+8DwVNjjotVT/ftdHTUk6/0K+NywBLS6KRRWoDBPpIbzXU01+kp nXPIvykUq31w== X-IronPort-AV: E=McAfee;i="6000,8403,9773"; a="153922354" X-IronPort-AV: E=Sophos;i="5.77,374,1596524400"; d="scan'208";a="153922354" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2020 05:05:48 -0700 IronPort-SDR: tY+ihcRNyLIcblnUGL/2MHgj+47v6shCEVE1qRrOji7q2+uWcR6u8mP0jo2r6hsGOFwI8GR6oJ vBMO1gBlc7jg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,374,1596524400"; d="scan'208";a="346492073" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga008.jf.intel.com with ESMTP; 14 Oct 2020 05:05:48 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 14 Oct 2020 05:05:48 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 14 Oct 2020 05:05:47 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 14 Oct 2020 05:05:47 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.106) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Wed, 14 Oct 2020 05:05:47 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F02KsjmUovFbR8FXAcBjwakZ8NLugMGCviubIRbX/sl8aODK01D5BvrPggANq62xyIRdPnRv+fo3ZF0IwVbWD7kjeKbFvI+y3imIVANG97Dgmgh27Tirevv5HKrFKu83jYlC1TZuch96t3yjEYCWH2lkhf51GdTrGMACL7GkhIuxiYu4HZB8Xqj1jdq3JRg/I4jNlalSo3zJCPCVK7zTriQ6QQJcv9lhyVFJwrPz4eej66C3z7qp+A0tNloqQOTuJGhEFfBzMYvRNffAChdivrwldN8Uneuepe6nFaCB5ykaZ1/QBYyjs1fqHbL0V1FhyO2JUskF1yJO3Vsy3uhHsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g3bmJHtwtYs53wyBLQGT1Vl6WHG/HPb5Cie422aaXp8=; b=dR6VqKcehU4vq+NqmOmt1uzZ/RNu4axuSsvuJ0MQoZow8qPdhZljMK25xa0VTRCjIsnFSse6SoMCnqB/dkkqiNkiI2tQKiPEw1Ai2vPwsFnr/cDOTSLcyYmlN9i7WjUjt/pVIeRi9FCgPnxLDALWoQN8Wd+5KCcLv8aQB3jxEKyotdIC4s6SNdcY8SD/GuquhpEI8ZwayOG0lMpUh3fdpnG5EmRpYP7YmOkeek0+dwUUxOqfqK+v4oYXrxN0+e52oLD2FfI1o/3ToMXmBHAk7woNz79h0weqtklBYRtCmo3fOVZos55sN8dZ+/EISubPiuX7B8Q9KLgzktbzNpZnQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g3bmJHtwtYs53wyBLQGT1Vl6WHG/HPb5Cie422aaXp8=; b=zHzqdV44kSa5PmdlIS8oN9EHpbKssdF3+OwAwcxxbQ53ZQVuDPY7XXLT5OlDReC0yN7Q+TLSrMzg4TtLJ6X2tbn50Y6dbquzM8PtTMyohdgIjLCXodNIF7acJvkkAt+sRhmNuCbvrv3CpHxkpgbagyAM4ibDclRFREE77HAW6Ns= Received: from SN6PR11MB3310.namprd11.prod.outlook.com (2603:10b6:805:b9::13) by SN6PR11MB2766.namprd11.prod.outlook.com (2603:10b6:805:53::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Wed, 14 Oct 2020 12:05:45 +0000 Received: from SN6PR11MB3310.namprd11.prod.outlook.com ([fe80::ed1d:ff6d:e1e2:6d07]) by SN6PR11MB3310.namprd11.prod.outlook.com ([fe80::ed1d:ff6d:e1e2:6d07%2]) with mapi id 15.20.3455.030; Wed, 14 Oct 2020 12:05:45 +0000 From: "Ananyev, Konstantin" To: yang_y_yi , "Hu, Jiayu" CC: "dev@dpdk.org" , "olivier.matz@6wind.com" , "thomas@monjalon.net" , "yangyi01@inspur.com" Thread-Topic: Re:RE: [PATCH] gso: fix free issue of mbuf gso segments attach to Thread-Index: AQHWnrL85KBHJVyvm02xWITKaS0ypKmVJ4OAgACCzBCAAKMIAIAAIGYAgACLbLA= Date: Wed, 14 Oct 2020 12:05:44 +0000 Message-ID: References: <20201010031020.349516-1-yang_y_yi@163.com> <43f71e6c9d2f4d5ba3ab56a921c5912d@intel.com> <6167423037704e3382f85275be79de30@intel.com> <9239b2e.2116.17525095531.Coremail.yang_y_yi@163.com> In-Reply-To: <9239b2e.2116.17525095531.Coremail.yang_y_yi@163.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: 163.com; dkim=none (message not signed) header.d=none;163.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [46.7.39.127] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4b4b398d-08e4-49d0-5d09-08d870397b03 x-ms-traffictypediagnostic: SN6PR11MB2766: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2399; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pyX4bGDOTSAfYA7/TvBB+wWiS0pWmgUy2uG0VThGFBj3Hu0xwOpTksmBZ/d+IFkcstQKE3F/4y/8LhGqlkvjWaVgmoEktzzFCZFHW6hL0PCG4dIzzg80TyXNMqLf/FbEp9d+RikE2/UmkHphCrd1FyKWbhKvkeYfe41axLYTh6c67UJNvwwSYM5a40g0uMGRuXXBpsBHgDxhw4PELlDJuNd/VFl5l4eb7woQI3tCK8Q1ca6BnaeSM3Yui5H3n781w9ftYeQ/cU+uxMr4ak9B/jYSqzcaJPAV2TIFD/+mlH1wmfVvkp/SJqI6jkzECfA/mStKZwQukVUbfnpDbSC9Sw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3310.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(136003)(376002)(346002)(39860400002)(5660300002)(33656002)(66946007)(7696005)(26005)(186003)(2906002)(71200400001)(9686003)(4001150100001)(53546011)(478600001)(110136005)(316002)(6506007)(54906003)(8676002)(55016002)(8936002)(66446008)(66556008)(76116006)(4326008)(66476007)(64756008)(83380400001)(52536014)(86362001)(6636002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: 1OfBZPDi1ZL3MjA312G2ERB0i2SHL9qpA8WhMb4QScuLiTWtmP5GCWW0X4KYv62vVFM+WRWskLtto4VW+4zx87ldoYbBitSC+q53xwy9+jiVMCxcrm0/yCnqwOTjOoG9ksRByKP6Vw6vQ/wraLxEZPuH2nutgrz7RjF6DXCjphgU0uu8bV/1WOhNa3WBPhpIxrkQap60QrriOJTt+1B58j1m8rm2QpkVQY91gC8sUkjJShVq2PdLQBoQ90UFHZIwLj0KQbHMAAouGH0LUGZRya07t1V44Kbz8nzX7jUnhG09FaBtWFQkx36FQnm/eZWwmbo7Jy61F+5pLHfz1Onj47RgYW3FPw384v+siSCRjSaf1JrXNdLtqi1qkeceZrGNDvLJua+Dx4bxi+jnV8Uvr0DKRaos3x0plrn4VQTMjiZ1av0NnuvBqtpOuwyLdaglnWqngD1kn96xmZKjDyVjZKM9DD6ruXTTOXClSKYmGloUaBQAIRy+U4glTQDAkCb/67wPSTH6tvjzk1oCFswlifrEYvfy4dTz3iR+m7ea22oBdKJxdpjxUTCTq82fPhpgtlwmK3mwZGaldhTwA9+HfmUuvmq/wMbuDJkKBeyXGPUiKrHUgUPWQYXpbpLxca2ULp31Ld2HP0PWv/dr1AVe2g== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB3310.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b4b398d-08e4-49d0-5d09-08d870397b03 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Oct 2020 12:05:45.1320 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: c+zTh13i3MlbTpJrtQi1Afrizf4kR3R9OaeUtIVfeOyfCMyJndTLLjdW9ahLnPPy4mcbGjotn1DR09+JdLoqEK5ocVrNDziBJtSW75H5eu0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB2766 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH] 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > From: yang_y_yi > Sent: Wednesday, October 14, 2020 3:56 AM > To: Hu, Jiayu > Cc: Ananyev, Konstantin ; dev@dpdk.org; oli= vier.matz@6wind.com; thomas@monjalon.net; > yangyi01@inspur.com > Subject: Re:RE: [PATCH] gso: fix free issue of mbuf gso segments attach t= o >=20 > I think it isn't a good idea to free it in rte_gso_segment, maybe applica= tion will continue to use this pkt for other purpose, rte_gso_segment > can't make decision for application without any notice, it is better to r= eturn this decision right backt to application. >=20 I think, if user wants to keep original packet, he can always call rte_pktm= buf_refcnt_update(pkt, 1) just before calling gso function. Also, as I remember in some cases it is not safe to do free() for input pac= ket (as pkt_out[] can contain input pkt itself). Would it also be user responsi= bility to determine such situations? P.S. Please don't reply on the top. =20 Konstantin =20 >=20 >=20 >=20 >=20 > At 2020-10-14 09:00:12, "Hu, Jiayu" wrote: > > > > > >> -----Original Message----- > >> From: Ananyev, Konstantin > >> Sent: Tuesday, October 13, 2020 11:39 PM > >> To: Hu, Jiayu ; mailto:yang_y_yi@163.com; m= ailto:dev@dpdk.org > >> Cc: mailto:mark.b.kavanagh@intel.com; mailto:olivier.matz@6wind.com; > >> mailto:thomas@monjalon.net; mailto:yangyi01@inspur.com > >> Subject: RE: [PATCH] gso: fix free issue of mbuf gso segments attach t= o > >> > >> > >> > > 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 > >> > > --- > >> > > 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_li= b.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 DP= DK > >> > > 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 explicitl= y 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-creat= ed > >> > > 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 =3D pkt; > >> > > -while (pkt_seg) { > >> > > -rte_mbuf_refcnt_update(pkt_seg, -1); > >> > > -pkt_seg =3D pkt_seg->next; > >> > > -} > >> > > -} else if (ret < 0) { > >> > > +if (ret < 0) { > >> > > /* Revert the ol_flags in the event of failure. */ > >> > > pkt->ol_flags =3D ol_flags; > >> > > } > >> > > -- > >> > > 1.8.3.1 > >> > > >> >=20 >