From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7165443688; Wed, 6 Dec 2023 11:55:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F3FC4402CF; Wed, 6 Dec 2023 11:55:33 +0100 (CET) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id DDEEB402C6 for ; Wed, 6 Dec 2023 11:55:31 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id A808A206C2; Wed, 6 Dec 2023 11:55:29 +0100 (CET) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [dpdk-dev] [PATCH v6 2/5] mbuf: detach mbuf with pinned externalbuffer X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Wed, 6 Dec 2023 11:55:26 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F096@smartserver.smartshare.dk> In-Reply-To: <1579547786-7650-3-git-send-email-viacheslavo@mellanox.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [dpdk-dev] [PATCH v6 2/5] mbuf: detach mbuf with pinned externalbuffer Thread-Index: AdXPxjBAOoSWFyLKRd2JHkcePmwZC4iw1kAQ References: <20191118094938.192850-1-shahafs@mellanox.com> <1579547786-7650-1-git-send-email-viacheslavo@mellanox.com> <1579547786-7650-3-git-send-email-viacheslavo@mellanox.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Viacheslav Ovsiienko" , , "Shahaf Shuler" Cc: "Matan Azrad" , , , "Olivier Matz" , "Stephen Hemminger" , "Thomas Monjalon" , "Konstantin Ananyev" , "Feifei Wang" , , "Ruifeng Wang" , X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Triggered by another discussion, I have identified a potential bug = related to this patch. > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Viacheslav > Ovsiienko > Sent: Monday, 20 January 2020 20.16 >=20 > Update detach routine to check the mbuf pool type. > Introduce the special internal version of detach routine to handle > the special case of pinned external bufferon mbuf freeing. >=20 > Signed-off-by: Shahaf Shuler > Signed-off-by: Viacheslav Ovsiienko > Acked-by: Olivier Matz > --- [...] > @@ -1201,8 +1278,13 @@ static inline void rte_pktmbuf_detach(struct > rte_mbuf *m) >=20 > if (likely(rte_mbuf_refcnt_read(m) =3D=3D 1)) { >=20 > - if (!RTE_MBUF_DIRECT(m)) > - rte_pktmbuf_detach(m); > + if (!RTE_MBUF_DIRECT(m)) { > + if (!RTE_MBUF_HAS_EXTBUF(m) || > + !RTE_MBUF_HAS_PINNED_EXTBUF(m)) > + rte_pktmbuf_detach(m); > + else if (__rte_pktmbuf_pinned_extbuf_decref(m)) > + return NULL; When NULL is returned here, m->refcnt is still 1. > + } >=20 > if (m->next !=3D NULL) { > m->next =3D NULL; > @@ -1213,8 +1295,13 @@ static inline void rte_pktmbuf_detach(struct > rte_mbuf *m) >=20 > } else if (__rte_mbuf_refcnt_update(m, -1) =3D=3D 0) { >=20 > - if (!RTE_MBUF_DIRECT(m)) > - rte_pktmbuf_detach(m); > + if (!RTE_MBUF_DIRECT(m)) { > + if (!RTE_MBUF_HAS_EXTBUF(m) || > + !RTE_MBUF_HAS_PINNED_EXTBUF(m)) > + rte_pktmbuf_detach(m); > + else if (__rte_pktmbuf_pinned_extbuf_decref(m)) > + return NULL; When NULL is returned here, m->refcnt has been decremented to 0. I don't know which is correct, but I suppose m->refcnt should end up = with the same value in both cases? > + } >=20 > if (m->next !=3D NULL) { > m->next =3D NULL; > -- > 1.8.3.1 >=20