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 9E183A04B1 for ; Thu, 5 Nov 2020 01:16:03 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 550812C2E; Thu, 5 Nov 2020 01:16:02 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 592332C2E; Thu, 5 Nov 2020 01:16:00 +0100 (CET) IronPort-SDR: lFuabVTy0rC/YtQgKJ02rVImiT5+XLEf0IYBphnQSRrQC4pNq7pDeVi24UXjhhew/YYKs32RjH EL7dg7OMvZXw== X-IronPort-AV: E=McAfee;i="6000,8403,9795"; a="156294130" X-IronPort-AV: E=Sophos;i="5.77,451,1596524400"; d="scan'208";a="156294130" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2020 16:15:56 -0800 IronPort-SDR: 2+5VeIk0EZTmnJa2noVvzi/UR3vq1j52R8HQzRorcORWcG6U9Pm/00KmdRTDFHTMrQq4GAWk2R 1kVfsNgL+FPA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,451,1596524400"; d="scan'208";a="306612153" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga007.fm.intel.com with ESMTP; 04 Nov 2020 16:15:53 -0800 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 4 Nov 2020 16:15:51 -0800 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 4 Nov 2020 16:15:50 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx603.amr.corp.intel.com (10.18.126.83) 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, 4 Nov 2020 16:15:50 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.108) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Wed, 4 Nov 2020 16:15:50 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DSsz08AkcPeDlVdV//Fxx/v3xVgB8HUaKyR40K6lKeohAhy1zwLgugBzUOAjg7gksfTFuDnWhOEhWZ9r4WvlUNjimf2PAHYaLfLdpbo5VZFV5nmhDpfz779x9o90Ob1BdtbG5sqgKPhVVYiyqPe2B5+8cgV8o+ZCRHiKZSrKznWjUiEEnVLqoZ9HVveoH/iMRVcSrKOBWJeMel4nyq0hd/hjBB92mEgxNxPp5c9TTlGiIbPJMuFMBkJQDp2C7R+qaCUlvbm2FMZ3zouixcxkddyECbG8C88UkSl9U1u2YFku4vK1kpvuVkLB9sbHabBZgfLv4SF2Z79TOHCPXxUeKA== 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=MugFQwi171HLhOFpdHJ2fs8AhAQy4X86MHQ2YIAeGtk=; b=eipZyD6VeW2wx0TdWR+EgjkK8vE9DoDyOQmQWwmBilREmYuLPGMnAoDqa/kzqlLGangGJWKOPB+uEmzYm5T9EHVDj3LbqWID8HgPHcJeMHiPbz2Em3ropSR7V+UThkRlBY0m0sugp8qEKiKIa+dWgQzWZdKec+pmFXmEFu7cHrFVLW1CktYd42j7LZZB7GI5aqHRYBJmxc3h66AgemUw53GTA70C4PeS/jprO9UCVdZsKXSUBIuu30OoYt9XY7N0+Yd/8i9CrCpLktiBn9ws2o/PxsjR+0MO+xPwpDo17mUGiEJ2lEjWVFPzWe3U5elfYHQKA/GoJmNnipmrtA/8rQ== 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=MugFQwi171HLhOFpdHJ2fs8AhAQy4X86MHQ2YIAeGtk=; b=a42XB3XAk8CiQzAroBDN7gFqGoyfqZpLOzx09BA8UT0uC21NXMubkMwxUbg6tIcOk2XSbw0Yf11ciuvjZyY8Wlu4EnRhjRQaKwH4lqGHKOxqGonYmvNXRPbbmNsj2C6+DDfFpaf2bEQTrfQaOGkIkvHCJajH0wiTeKuRiOttOdo= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by BYAPR11MB2903.namprd11.prod.outlook.com (2603:10b6:a03:89::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.29; Thu, 5 Nov 2020 00:15:49 +0000 Received: from BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f5a4:3f6b:ade3:296b]) by BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f5a4:3f6b:ade3:296b%3]) with mapi id 15.20.3499.032; Thu, 5 Nov 2020 00:15:49 +0000 From: "Ananyev, Konstantin" To: Olivier Matz , "dev@dpdk.org" CC: "stable@dpdk.org" Thread-Topic: [PATCH] mbuf: fix reset on mbuf free Thread-Index: AQHWssw9/Ru+bbJv2UmxCtlz1ORQn6m4ql1g Date: Thu, 5 Nov 2020 00:15:49 +0000 Message-ID: References: <20201104170007.8026-1-olivier.matz@6wind.com> In-Reply-To: <20201104170007.8026-1-olivier.matz@6wind.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: 6wind.com; dkim=none (message not signed) header.d=none;6wind.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: 6306032a-8d90-4431-6bee-08d8811ff34d x-ms-traffictypediagnostic: BYAPR11MB2903: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: UCcPcPJpGRBQl6NQalF++2LX6AqGQso7Bp0jU9hoAUng2scz31hPL81tYOxH10q+OFIJf4CcDTxMggrpsJt/+eSc7bKM2IFge1OOPmlaHZ1CBd++cwspOTqttI4UVUGbZ5AePwvDiMYXyrOVkvHXAc+fW6A4ubZiC59zmtAE0PfCg5Brpfb/QNlwEjOAS/Y7La8yLBN/F6h931ybHOxijCk4b3gtod35tEHWHebHvDtcGCLuv0WH9kK+lpLBriohr2/3vbW2ex33ER9cf2BXb05HU9V795NaAZT5PDQbJedpBwXJ3x74n3nayy1HeOTL1Q9PawupCDJnJ5Xfdgn3KQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB3301.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(396003)(366004)(346002)(39860400002)(8676002)(66946007)(64756008)(66446008)(66476007)(66556008)(52536014)(83380400001)(6506007)(76116006)(2906002)(316002)(4326008)(9686003)(55016002)(8936002)(86362001)(5660300002)(71200400001)(33656002)(186003)(7696005)(478600001)(110136005)(26005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: KEc01NE5Ah27qF5LYFZo5qJx28dgiDOfifdd3tAuGEv6J+q+cFvBCx2yLjzUqhBTYcRvqPf596ZfZlExTxGHud5eCjUXicVeqxoK35HlUgt7uYNF5SAzQ8ogqAVy9OoELdCiD9S33kiUcfRtrgu/YTpkPIorgdVft+U74EoSElJkdRu823j26ubM+/XH2GXR8lAG/jHor3vOeFH5M0fX02x6mJjoPJeleUzcdybiT3BBpV+Edmw8/1Q2rN0hm7UtnjoZ2jeiQ372RFkR89hy9sZvzTkCh1tn8DS8ykNb+tvC0DyBWhJVthRZ/8t3SaTkrcrrPcZdSruz1DsqkNGJ/LO2WbA1O0Q39EcIHO6GptDBk5miMEbWh4K47CZcpSBNX8O+KhvN5udc7P8Lqov/39kJAm81xVp7aKSYobK0Mm8bFsrUg9CzSev53eOC2zU1jjDhdOEcUrXE5OJQmlxLIVj6Vh01SHjEGQJToPUviKYvRDV1Vwe9qk3vbKal4S3HVktlGbaNeZSDN59QnDlCoyTGDLTP36bzv455R9bMSDSixI9RuM7gqQd2IzgZc66s+zS2cs2xw/lazebuTS1HOlVSnTHYuSMIRn9W56sQvMOMh4SWqQIP7hko4OKiqtlgttVgM1sE2yWHfvHKLqxVHA== x-ms-exchange-transport-forked: True 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: BYAPR11MB3301.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6306032a-8d90-4431-6bee-08d8811ff34d X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Nov 2020 00:15:49.7332 (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: rotiFBplc1mU19yKgW1RftiJbCuyYffvzHZ5sirltw2ojqp956exrbML3O/6KRv4MnfojsLsKZuDftk/UuZxlWfrViq+QUN3UTHFHcmdJJE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2903 X-OriginatorOrg: intel.com Subject: Re: [dpdk-stable] [PATCH] mbuf: fix reset on mbuf free X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi Olivier, =20 > m->nb_seg must be reset on mbuf free whatever the value of m->next, > because it can happen that m->nb_seg is !=3D 1. For instance in this > case: >=20 > m1 =3D rte_pktmbuf_alloc(mp); > rte_pktmbuf_append(m1, 500); > m2 =3D rte_pktmbuf_alloc(mp); > rte_pktmbuf_append(m2, 500); > rte_pktmbuf_chain(m1, m2); > m0 =3D rte_pktmbuf_alloc(mp); > rte_pktmbuf_append(m0, 500); > rte_pktmbuf_chain(m0, m1); >=20 > As rte_pktmbuf_chain() does not reset nb_seg in the initial m1 > segment (this is not required), after this code the mbuf chain > have 3 segments: > - m0: next=3Dm1, nb_seg=3D3 > - m1: next=3Dm2, nb_seg=3D2 > - m2: next=3DNULL, nb_seg=3D1 >=20 > Freeing this mbuf chain will not restore nb_seg=3D1 in the second > segment.=20 Hmm, not sure why is that? You are talking about freeing m1, right? rte_pktmbuf_prefree_seg(struct rte_mbuf *m) { ... if (m->next !=3D NULL) { m->next =3D NULL; m->nb_segs =3D 1; } m1->next !=3D NULL, so it will enter the if() block, and will reset both next and nb_segs. What I am missing here?=20 Thinking in more generic way, that change: - if (m->next !=3D NULL) { - m->next =3D NULL; - m->nb_segs =3D 1; - } + m->next =3D NULL; + m->nb_segs =3D 1; Assumes that it is ok to have an mbuf with nb_seg > 1 and next =3D=3D NULL. Which seems wrong to me. Konstantin >This is expected that mbufs stored in pool have their > nb_seg field set to 1. >=20 > Fixes: 8f094a9ac5d7 ("mbuf: set mbuf fields while in pool") > Cc: stable@dpdk.org >=20 > Signed-off-by: Olivier Matz > --- > lib/librte_mbuf/rte_mbuf.c | 6 ++---- > lib/librte_mbuf/rte_mbuf.h | 12 ++++-------- > 2 files changed, 6 insertions(+), 12 deletions(-) >=20 > diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c > index 8a456e5e64..e632071c23 100644 > --- a/lib/librte_mbuf/rte_mbuf.c > +++ b/lib/librte_mbuf/rte_mbuf.c > @@ -129,10 +129,8 @@ rte_pktmbuf_free_pinned_extmem(void *addr, void *opa= que) >=20 > rte_mbuf_ext_refcnt_set(m->shinfo, 1); > m->ol_flags =3D EXT_ATTACHED_MBUF; > - if (m->next !=3D NULL) { > - m->next =3D NULL; > - m->nb_segs =3D 1; > - } > + m->next =3D NULL; > + m->nb_segs =3D 1; > rte_mbuf_raw_free(m); > } >=20 > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > index a1414ed7cd..ef5800c8ef 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -1329,10 +1329,8 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) > return NULL; > } >=20 > - if (m->next !=3D NULL) { > - m->next =3D NULL; > - m->nb_segs =3D 1; > - } > + m->next =3D NULL; > + m->nb_segs =3D 1; >=20 > return m; >=20 > @@ -1346,10 +1344,8 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) > return NULL; > } >=20 > - if (m->next !=3D NULL) { > - m->next =3D NULL; > - m->nb_segs =3D 1; > - } > + m->next =3D NULL; > + m->nb_segs =3D 1; > rte_mbuf_refcnt_set(m, 1); >=20 > return m; > -- > 2.25.1