From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44BA9606A31A for ; Mon, 30 Nov 2026 20:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=iFcYn/nV Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 939CE4027B; Mon, 30 Nov 2026 21:52:29 +0100 (CET) Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by mails.dpdk.org (Postfix) with ESMTPS id 183BF40279 for ; Mon, 30 Nov 2026 21:52:29 +0100 (CET) Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-9214b9e4d74so60018496d6.1 for ; Mon, 30 Nov 2026 12:52:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796071948; x=1796676748; darn=dpdk.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=1o0bqAcC4m0BrHZ+pv7vHZvfoUjY9CWtJO2tpPAIzSQ=; b=iFcYn/nVcjTzX8QT0jwwZpbLdnsoo7N6UWd6oSqvlmJqaONsP37NzfxwPydQ4h0Lb0 k0uJiHNXKpJQRiLdvw8idu6WLsnja/Rx8n8kLzb7HdLfHcyDzQ4EeIYuduglmAoMR90T H9CLeIZYihoEuqdfjS6McnpLn0Z3Q1T81L2TFwR+yI3K6o+e2TCLCVgSZGs9g8/4N8eW W7uuKQ33GLNZeyc4UFbIJqccohcsAhxCcZCK3NVa4YJoYPbz7iv5Puu7MmFuYtwcHQKX FPEHRfw+Yrn2VvhvNCuzPwSgxTk8ooR1rVl08Ny17iRMzO6sdPiE+mGt8khiMJcgVtu9 oxAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796071948; x=1796676748; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=1o0bqAcC4m0BrHZ+pv7vHZvfoUjY9CWtJO2tpPAIzSQ=; b=UQF+4SYXIJTIMsPXgBBsVsO2wjWew5mVScohbI+ofu3osZrSAzxaOgaJfjEXDb8r3o PBWGAFZovf0anJuql9q7HpKIIaHxRd8H3vp+sskMP16x4ttM4JBKR2pmpjaPRk0BcYY4 RXLI6BPsh5/H02+EPvYVmYxGgOf/TC4Appaurz/nNTpDyK85BQUeQAKqPK/XHYmNhjU1 b6xFnFhR+u++wGC2FjCwW6vuPIJ5tuUN+jpeuitnlzJXlb3zV4uFzVH9ji26yBbht5nW Yvhk3C+MsxExftchH7xn46SXzdYRe6P5AaRYNq7gRT9KSGbElJZNHVsCU2SoQC6aRbUZ s0ag== X-Gm-Message-State: APuU4Z80TPG6pgWXNCoPt6QlHX3/M0MFaBNCFweb2DEOwuzHfULlQFsH 5r2Iq6EzEa9jDHqUDGxR6rsj+o1lEB+e9CVrpbhJst3NVj3GeDpiYyXo7gqJsrCF X-Gm-Gg: AZFdTZdBS6wrjjDxgnqBXNQ1NFWfZsJBMeY1rU8lDr+/ryxE5eGCqpp7VEVdp/TBS+R Rr25r8e5/LfL9TdB+fmZsZe1WOBZHQron6nHy0ANFUUcIFfYjLIL67D4ABce/w285DEQgTRAbxr gSB7LppZ5R2WnqGfKuITOGQq4drUmPxOrvVsecTaEMKNw5gnLUyr3ASd6JipjOZZjF9lnQQw08s 3+lP4T3mg1Nvq5BBj2Z8GJlebaAH5sJ6/gsRwKTiGM+hFYwOQUH2dxUgBqnHB6/K/wonPcayliN 8QhQOMpoC9sHqEs3+9xkDRCmNTxmNSjvnL+k5F9NXJyl9g0OmoTd6N5UxlhGimK7nP7gtHDxQCx fQYwrv5jrXb35A9eb2EP0myzoDyhXCjeiEEXIfd7ji85f4P8Luj67qqDcBqq3MQaFTWlkx2HFwU 9P/DP/4j3Xw3cPxngnONBi61+ZhN+n5x+JJdEkprBXZybjEfeCQFyw/SSuIVCdzglCsNdfmZFvg ewLOVGBtTBmi3pZY0pnxEReLpVbVD5EycR3GPAGbYCKnS71mg+uxPqSndzysXEPIDgZYkpSkHwy Cwyk2qscqs4CEWSnk/J6fiHZ0ByoHjjlvTNDlr9MlAdgM1f8O2VHo7HUVIsUhd7SdCdsxldZu10 9U+va9EWhiXYEOCl8of0j1XHh+LXZ7pfQC6oCEt/nLpuD58WqABZXjqdRgYl7ztO67XmROHEKaU 3Er1hZmU+WFVChN42Y9ZND X-Received: by 2002:a05:6214:458e:b0:91f:1fb1:850b with SMTP id 6a1803df08f44-9212e10f95dmr677149646d6.29.1796071947859; Mon, 30 Nov 2026 12:52:27 -0800 (PST) Received: from bos-lhvwah.bos01.corp.akamai.com (g2001-4878-8037-0700-526b-8dff-fef6-cfbf.deploy.static.akamaitechnologies.com. [2001:4878:8037:700:526b:8dff:fef6:cfbf]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-921349b3a0csm304029476d6.14.2026.11.30.12.52.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 12:52:26 -0800 (PST) From: Robert Sanford To: dev@dpdk.org Cc: andrew.rybchenko@oktetlabs.ru, mb@smartsharesystems.com, olivier.matz@6wind.com, thomas@monjalon.net, Robert Sanford Subject: [PATCH v5 0/3] mempool: fix races between list walk and create/free Date: Mon, 30 Nov 2026 15:51:49 -0500 Message-Id: <20261130205152.7107-1-rsanford2@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261112154342.1484709-1-rsanford2@gmail.com> References: <20261112154342.1484709-1-rsanford2@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Robert Sanford A thread walking the mempool list with rte_mempool_walk(), rte_mempool_lookup() or rte_mempool_list_dump() can crash while other threads create and free mempools. We hit this in production, in a process that walks the mempools while other threads create and free them. There are two races: - rte_mempool_free() unlinks and frees the list entry without the mempool list lock that the walkers hold, so a walker can reach a freed entry or mempool. Patch 1 takes the lock in rte_mempool_free(), as rte_mempool_create_empty() already does. A rte_mempool_walk() callback can therefore no longer free a mempool; this is documented. - A mempool is on the list before its store exists, but rte_mempool_dump() queries the mempool driver, which reads the store. So rte_mempool_list_dump() and the telemetry /mempool/info handler crash on such a mempool. Patch 2 adds rte_mempool_is_created(), makes them report the mempool without querying the driver until it returns true, and documents that rte_mempool_walk() callbacks must check it before querying the driver. Patch 3 adds a test to mempool_autotest. On x86 with 4 or 8 lcores, it crashed in all 20 runs without patch 1, without patch 2, or without both, and passed in all 20 runs with both patches. v5: - Patch 2: the commit log explains why rte_mempool_is_created() is public and added directly as stable API, as asked by Thomas Monjalon. The release note moved to 27.03. - Rebased on main (27.03). - Patches 1 and 3: unchanged. v4: - Patch 3, as suggested by Morten Brørup: the dump goes to "NUL" instead of "/dev/null" on Windows. Acked-by added. - Rebased on main. - Patches 1 and 2: unchanged. v3: - Patch 2, as suggested by Morten Brørup: the helper that tests RTE_MEMPOOL_F_POOL_CREATED is now the public function rte_mempool_is_created(), and the rte_mempool_walk() documentation refers to it instead of the flag. Release note added. Acked-by added. - Patch 3: the walk callback uses rte_mempool_is_created(). - Patch 1: unchanged. v2: - Patch 2 reworked as suggested by Morten Brørup: rte_mempool_walk() no longer skips mempools that are not populated yet. Instead, rte_mempool_dump() and the telemetry callback report them without querying the mempool driver, and the rte_mempool_walk() documentation asks callbacks to check RTE_MEMPOOL_F_POOL_CREATED. The flag is now set and tested with release/acquire atomics instead of plain accesses with fences. New title. - Patch 3: the walk callback dumps every mempool, and checks the flag before querying the driver. The test waits 100 us instead of 10 us before populating, so that it still finds unpopulated mempools reliably. - Patch 1: unchanged, Reviewed-by added. Robert Sanford (3): mempool: fix race between list walk and free mempool: fix dump of unpopulated pool test/mempool: add list walk race test app/test/test_mempool.c | 150 +++++++++++++++++++++++++ doc/guides/rel_notes/release_27_03.rst | 7 ++ lib/mempool/rte_mempool.c | 45 +++++++- lib/mempool/rte_mempool.h | 29 +++++ 4 files changed, 227 insertions(+), 4 deletions(-) -- 2.34.1