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 1AE134654A for ; Thu, 10 Apr 2025 05:58:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9AC6240667; Thu, 10 Apr 2025 05:58:30 +0200 (CEST) Received: from mx0a-00196b01.pphosted.com (mx0b-00196b01.pphosted.com [67.231.157.166]) by mails.dpdk.org (Postfix) with ESMTP id B1DEE40288 for ; Thu, 10 Apr 2025 05:58:28 +0200 (CEST) Received: from pps.filterd (m0096262.ppops.net [127.0.0.1]) by mx0b-00196b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 539KErni014620; Wed, 9 Apr 2025 23:58:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netscout.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= netscout.com.09.24.2020; bh=VR0R9PHjzYy1fjNfRMwML0WpfyN3u4YGqRJN 5WKtBp8=; b=xV3CmlaPMc7yFKsV5jC2wtU7G1JsQFggkYCIaQNTGv7gq9DrPU4k jGPp9Fg2dw0yWI5xD4rlKyV6aJFhlDPxgmw55KuQf+pDZOFVxP+QG9vIMdS8LDLz fpceBqXpOCyFIQwI/aAPQOFBTseQBOZJzBcUwWD/HlYoBrdzd5ZWtgLYtTFaziFX oy3GO/plUykspNS1cPT+JELFMkuOT+fgaECzLC5/QEmeMwNX9Q54svd8qXMAwNMc 6f+lRVmRkXW8x5SBI7U1oRkABwB1zQUEIA6sGRsWVezY6QnXzHUA/qnPaRWUkoNN dXK6CWCOkTMs0N4yWuNKsKXWEEVjhrzBjQ== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by mx0b-00196b01.pphosted.com (PPS) with ESMTPS id 45u171dqv4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Apr 2025 23:58:27 -0400 (EDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Rwd9axn718PDkJf6mWU2NGX+v0zvwCEhnD/xjWJUZ2zrw50j0mecT1QWWZlO6n936FzLysr6DAycZilZYSePBacS7PPHVJzqk1CWHLDcvx9BfIBRA8Bay85oNCzFFEAvijwfRsMTA3g1xr4qZoM6U+OtdkapqaasEbE9+Zq8mavfb4jgH127nqJAy6pzKrYfFTADTfuBIEKr3YCqksxPKY2oO4uytApF6wKASKrRTzeDGbwQNWr8lUQaLd/58FR03BBhIfAUNRb9uD3++lWanPp6YjjGIilce1AKI2hXiyOcMXN0/u8iVHG07UuakjroT08aGYUfnzbn+EfGRfZ2TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VR0R9PHjzYy1fjNfRMwML0WpfyN3u4YGqRJN5WKtBp8=; b=jkq83cXWXGuvBc5bbmWxihZgTDI4yz6FFUuzDfHNG6SRJhsxwkMfaxncZEcVbZJ96nhDPgAgh6+dUxz6+KP6S87xvR2C380/1y52HZ7ajOPvodD93FR4SphXxcJ8bhJJsBeq4DwbJdtikiG3sKnN4M+HFno2MJ+TdqOTs4kcf3PTNGuF1R+L904wOaRF+9VKFLvrJm7TRlGTuPbwOnk0RVTzhq04nYi/v3hypFoQ65Ia+fNJR5Twbf/qkAxzZL4qycEhmcKlSxMAVUqPd4WJ7cVDz1Tu8bFXgRZNBt9loBzwjs/cv+H8wwD9SROahyuetDmZVUel3cSo/jTe25jJ+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=netscout.com; dmarc=pass action=none header.from=netscout.com; dkim=pass header.d=netscout.com; arc=none Received: from CH3PR01MB8470.prod.exchangelabs.com (2603:10b6:610:1a4::21) by SA1PR01MB8236.prod.exchangelabs.com (2603:10b6:806:38c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8606.31; Thu, 10 Apr 2025 03:58:24 +0000 Received: from CH3PR01MB8470.prod.exchangelabs.com ([fe80::80c4:7216:f070:e5fd]) by CH3PR01MB8470.prod.exchangelabs.com ([fe80::80c4:7216:f070:e5fd%5]) with mapi id 15.20.8606.029; Thu, 10 Apr 2025 03:58:24 +0000 From: "Lombardo, Ed" To: Stephen Hemminger CC: Dmitry Kozlyuk , "users@dpdk.org" Subject: RE: mbuf refcnt issue Thread-Topic: mbuf refcnt issue Thread-Index: AdulnN5IfTxeCHcXQsa3xaXr7ECZhQAFBrWAAGffZNAAOS6kYAAzcomAAAGN4hAAGKknAAALaIUgAAuwQwAAAPmcQA== Date: Thu, 10 Apr 2025 03:58:23 +0000 Message-ID: References: <20250408205341.68d37d0a@hermes.local> <20250409092418.70c5eb3d@hermes.local> <20250409202538.46a08ba8@hermes.local> In-Reply-To: <20250409202538.46a08ba8@hermes.local> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CH3PR01MB8470:EE_|SA1PR01MB8236:EE_ x-ms-office365-filtering-correlation-id: 7244bb05-93b5-48ab-1418-08dd77e3f0f6 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|376014|366016|38070700018; x-microsoft-antispam-message-info: =?us-ascii?Q?J8Be4TwrLsJDXAlFFfvDE4GQE5p3/R5XN4+eyts8TCcyCLZEyy/vutbslCdn?= =?us-ascii?Q?PSzu8/swNyVV8QYU93VhCPy0pycZFsfyYVk2/7cala+99qDemK5E76v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0e/+zcH788CvB0tQHmmye8Jf3En+x9E1AzG?= =?us-ascii?Q?cP5aBmOdD7fvoE2dEz041aK0bjQsyOc6K7BiILCQBxPr6ywnUoJRju067g8k?= =?us-ascii?Q?CjCC01tJ/dKc258R/A0hSBd80XxMHIqDR58uKRbHhNOJW8taWmF9cuEGs34Y?= =?us-ascii?Q?3MZxPwwgcD+eEh+bwLyRbRQ6erdrPkgxI99Tsup/LtKK7asPePcxIU/W1SNa?= =?us-ascii?Q?bMv6cQbIYisPjUMDjww+V3VhU80GuXyeadOgKeIIdfdbfpQXNvYLJD2kBn8W?= =?us-ascii?Q?oFvXQWVbmXWned1cy9OXeoBV7XmWePLT0+WLbweDISOZ7cYLLZ8kf9fw9uSF?= =?us-ascii?Q?vi3J7u99OX+FJw51LQH9tgg20eZTQl6jPPOKI02EhwLrXUFh7DhfcrXSLOs5?= =?us-ascii?Q?DFivttU2yeD9RzqdWP0Q6HsHk/uWRnD/H5+GwRrJmPG7HF5BLMu9Rx1GEma9?= =?us-ascii?Q?IeDr/YC1sAABYg6JgBkr42BFdi4rpWB0VSJRyW/YLNvKgSUJXQRU7Q=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH3PR01MB8470.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(366016)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?wrAN9eFzKxp9+ehC535nPEJZXBYhgQ2AbdlX96Y8hUgGyKFE1y+uGBTTa6Zg?= =?us-ascii?Q?TtS9mFXo7laUOLJX54gn+MnoPcBaZwaD2jDEm14OjJZ16/MGG/zG0nLVF7Bo?= =?us-ascii?Q?OOwu4zszqslbRbPxJPQonuB9XB+e8fG68Y+iAPMyF/1botFTFc6oING20zOl?= =?us-ascii?Q?fDUr1D7c25Y+rSQ+jhQ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?= =?us-ascii?Q?eiuPXRURsRoou+UmBIbcL4ikb2CNhq+Zj+e5FlzHtXVXKHVxv10nTLTvxl5n?= =?us-ascii?Q?OEnzsbrOR0ShZYExI6AXPLmqlNzgffMF2/8YfZJIMWut2TIqU08IreWBXp2n?= =?us-ascii?Q?HtJ6ve+gGHSnnWLNFOH/mOUDv9bZTCUbyb1soiKW/STS0pIKD65igg6/ewPu?= =?us-ascii?Q?VxkCnbExt+6tj6anTa/BuAO3KbCiFh+zJQIkr7fiwt2vmK+RNOozYRBYPAts?= =?us-ascii?Q?cdGhN9RRU1DQO5y1GAvkEsRwdVIfBMRrQK8PeZu6zLMoXv1+dUMcC/cpJIJH?= =?us-ascii?Q?507Q0kLD6RrXU098AF6w6op3vIPAK4xBoeVlMlFKpaqkL1oMDU0amY008zLt?= =?us-ascii?Q?aa9PCGBQjTmNX+6Vh7NnKFGW6EwGgk+3/HbdMUeMHWMxwsFD8mqZz63XPSoe?= =?us-ascii?Q?ZN5ltPRSzKIbAuUoJods4yoGPqg5hSF+7Bg8RaxWgo2YZBLJyXxMLXYLz7yt?= =?us-ascii?Q?O7S0eJ4lRhpstsaT228Y6a3uTxP/nXpMeyKA75kZ?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 9PCfWLaWZqZIXdx+A22VdcBKRSguloR3k1ns7zEFqdGCXj/t/iRnrjKsAAwVze39xwKGr/k5vQ3pGNPc9Lzud3uZl7ocW++rzAnW4Jo4ZR7osklv39J40gCsFJ9nSU0AUvzd0kanGoKFLerJAAy1QTlFXYHs2KvVEtPvzPRfJbTYARgDqG+PyL/7kapAmrt7OcV/iXMuRj+ME5K/akfc6HcuC7Te20emyE3UEApnSnnef+0yZEPfYgY1JxgWjT5K8wNee7hPr1s8njTMi9dP1lUzwwHiIJaQVb/suBXR2zzyCN1bxBKm2W5NDmeF8ehr80g/4B6arYVYBqSM8RYF7J4JSHl5QgSAASpC5RcUQdI4Vc7MGSSHFHj+sw0nyjcihs2n0+nOzlCkgo/Wp5pdkoymxl1RkMPCz1a9D1qPLMRaVSX9artzsSQNR1lNMSSwTKQ37pL8zm4LtYh3esCBJma56sTmqn6eozEYBIlDJNI3wWBspRDOMrknFk6NXnLpEyVHigbzuSm1Cp3Hz22rWH4HndjbSG1iUS45YcNoQkMgWbrQH2gQVy6oUtQnWWkYN5dszSNWU4g5MZl4FcDFWI6NNUDwVSqLg9z19GP1kqcdb+4qwOdq0kppxtZCUPdP X-OriginatorOrg: netscout.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CH3PR01MB8470.prod.exchangelabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7244bb05-93b5-48ab-1418-08dd77e3f0f6 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Apr 2025 03:58:24.0144 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 54f11205-d4aa-4809-bd36-0b542199c5b2 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: FxZocgBrKnEActF5rn8WgmyiRuF8E9U3K3g3Itjtck8Qi9XNinYWsoLs1nN0LTarDd1L3DG6KBEshZe8bkUnNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR01MB8236 X-Proofpoint-GUID: uZ46KcP6Ro6Dp5SE4q-UoX85y32Il-XM X-Authority-Analysis: v=2.4 cv=KfrSsRYD c=1 sm=1 tr=0 ts=67f741e3 cx=c_pps a=PdgAl9AEy1hEU2ikvxmBtw==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=kj9zAlcOel0A:10 a=XR8D0OoHHMoA:10 a=jZVsG21pAAAA:8 a=jQOgFn-ZAAAA:8 a=pGLkceISAAAA:8 a=8rWy6zfcAAAA:8 a=N2a8VRFkq3k6A3_EQTUA:9 a=CjuIK1q_8ugA:10 a=3Sh2lD0sZASs_lUdrUhf:22 a=mT82qxFQzDvLIExZS32s:22 a=YjdVzJdQTyZRADMV7wFX:22 cc=ntf X-Proofpoint-ORIG-GUID: uZ46KcP6Ro6Dp5SE4q-UoX85y32Il-XM X-Proofpoint-Spam-Details: rule=outbound_policy_notspam policy=outbound_policy score=0 priorityscore=1501 adultscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 clxscore=1015 bulkscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam authscore=0 authtc=n/a authcc=notification route=outbound adjust=0 reason=mlx scancount=1 engine=8.21.0-2502280000 definitions=main-2504100028 X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org Hi Stephen, I should mention that I added mbuf refcnt checks at all pipeline stages, an= d what caught my eye was the first stage of the pipeline the mbuf provided = by the rte_eth_rx_burst() I logged mbuf refcnt set to 2 when should be 1. = S,o something went bad after the event that triggered the error to cause th= is. The mbufs kept arriving so the mempool was making available the mbufs = for receive of packets from the NIC interface. So weird. I will try the patch your provided. -----Original Message----- From: Stephen Hemminger =20 Sent: Wednesday, April 9, 2025 11:26 PM To: Lombardo, Ed Cc: Dmitry Kozlyuk ; users@dpdk.org Subject: Re: mbuf refcnt issue External Email: This message originated outside of NETSCOUT. Do not click l= inks or open attachments unless you recognize the sender and know the conte= nt is safe. On Wed, 9 Apr 2025 23:22:50 +0000 "Lombardo, Ed" wrote: > Hi, > I just finished modifying and testing our application to just do transmit= of packets received on an NIC interface and let the rte_eth_tx_burst () fr= ee the mbuf and all works fine for both traffic types. This proves to me t= hat my implementation of processing the packets and queueing them to tx rin= g and transmit from the tx ring is not buggy, which I had carefully verifie= d in gdb early on. I still believe there is a problem with our application= with many threads that can do rte_pktmbuf_free() on the same mbuf. =20 >=20 > I added these lines in my driver source file: > #define RTE_LITRTE_MBUF_DEBUG 1 > #define RTE_LIBRTE_MEMPOOL_DEBUG 1 > #define RTE_ENABLE_ASSERT 1 >=20 > I don't see any asserts occur during my tx packet testing. >=20 > The dpdk header files show the Atomic ifdef checks=20 > rte_build_config.h:#define RTE_MBUF_REFCNT_ATOMIC > rte_mbuf_core.h: * or non-atomic) is controlled b= y the RTE_MBUF_REFCNT_ATOMIC flag. > rte_mbuf.h:#ifdef RTE_MBUF_REFCNT_ATOMIC rte_mbuf.h:#else /* !=20 > RTE_MBUF_REFCNT_ATOMIC */ rte_mbuf.h:#endif /* RTE_MBUF_REFCNT_ATOMIC=20 > */ >=20 > I verified in building our application with DPDK rte_mbuf.h header file t= hat the atomic functions for mbuf refcnt read/writes are turned ON. I adde= d junk characters, and the compiler spotted syntax errors. >=20 > So, I am back to the question as to why I get mbuf issue with multiple th= reads processing the same mbuf? >=20 > Any more suggestions. >=20 > Thanks, > Ed >=20 > -----Original Message----- > From: Stephen Hemminger > Sent: Wednesday, April 9, 2025 12:24 PM > To: Lombardo, Ed > Cc: Dmitry Kozlyuk ; users@dpdk.org > Subject: Re: mbuf refcnt issue >=20 > External Email: This message originated outside of NETSCOUT. Do not click= links or open attachments unless you recognize the sender and know the con= tent is safe. >=20 > On Wed, 9 Apr 2025 04:46:09 +0000 > "Lombardo, Ed" wrote: >=20 > > Hi Stephen, > > I am looking a the rte_mbuf.h file for rte_pktmbuf_free() and it is not= clear to me that it checks if the mbuf refcnt is 1 before decrementing it = and allowing the mbuf and segments (if any) to be returned to free pool. > >=20 > > Could my application issue be I have tx threads that transmit packets a= nd does rte_pktmbuf_free(), while one other thread will perform rte_pktmbuf= _free() on the same mbuf? I ensured I bump the mbuf refcnt to 2 before oth= er threads can process the same mbuf. > >=20 > > Thanks, > > Ed >=20 > It doesn't need to check refcnt there. The check is done later (since mbu= f can be multi segment). >=20 > rte_pktmbuf_free > -> rte_pktmbuf_free_seg > -> rte_pktmbuf_prefree_seg > =09 > static __rte_always_inline struct rte_mbuf * rte_pktmbuf_prefree_seg(stru= ct rte_mbuf *m) { > __rte_mbuf_sanity_check(m, 0); >=20 > if (likely(rte_mbuf_refcnt_read(m) =3D=3D 1)) { > normal fast path. breaks the chain. > } else if (__rte_mbuf_refcnt_update(m, -1) =3D=3D 0) { > refcnt > 1 logic >=20 > Note, the refcnt doesn't always go to zero when the mbuf is put back in t= he pool. > The refcnt for a freed mbuf (in the pool) doesn't matter, it is free, it = is dead. > The refcnt is reset to 1 when mbuf is extracted from the pool. >=20 >=20 >=20 You might find something by poisoning the mbuf when it is freed, so that an= y attempt to use the data would get junk. Also, add check at start of rte_p= ktmbuf_free_seg() to catch dup free. Something like this, but only compile tested. It will break some of the functional tests, because they tend to make bogus= dummy mbufs. diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h index 06ab7502a5..60= 88b34506 100644 --- a/lib/mbuf/rte_mbuf.h +++ b/lib/mbuf/rte_mbuf.h @@ -1423,10 +1423,11 @@ static inline int __rte_pktmbuf_pinned_extbuf_decre= f(struct rte_mbuf *m) static __rte_always_inline struct rte_mbuf * rte_pk= tmbuf_prefree_seg(struct rte_mbuf *m) { - __rte_mbuf_sanity_check(m, 0); =20 - if (likely(rte_mbuf_refcnt_read(m) =3D=3D 1)) { + __rte_mbuf_sanity_check(m, 0); =20 + unsigned int refcnt =3D rte_mbuf_refcnt_read(m); + if (likely(refcnt =3D=3D 1)) { if (!RTE_MBUF_DIRECT(m)) { rte_pktmbuf_detach(m); if (RTE_MBUF_HAS_EXTBUF(m) && @@ -1435,13 +1436,15 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) return NULL; } =20 + m->refcnt =3D 0; if (m->next !=3D NULL) m->next =3D NULL; if (m->nb_segs !=3D 1) m->nb_segs =3D 1; =20 return m; - + } else if (unlikely(refcnt =3D=3D 0 || refcnt >=3D UINT16_MAX - 1)) { + rte_panic("mbuf refcnt underflow %u\n", refcnt); } else if (__rte_mbuf_refcnt_update(m, -1) =3D=3D 0) { =20 if (!RTE_MBUF_DIRECT(m)) { @@ -1452,6 +1455,7 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) return NULL; } =20 + m->refcnt =3D 0; if (m->next !=3D NULL) m->next =3D NULL; if (m->nb_segs !=3D 1)