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 1C7E4606A31A for ; Mon, 30 Nov 2026 20:52:51 +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=wmaJWbls Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 73AF04064F; Mon, 30 Nov 2026 21:52:36 +0100 (CET) Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by mails.dpdk.org (Postfix) with ESMTPS id E3C31402B4 for ; Mon, 30 Nov 2026 21:52:34 +0100 (CET) Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-55d360ca878so95265191cf.2 for ; Mon, 30 Nov 2026 12:52:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796071954; x=1796676754; 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=v2nr0irbPLtwUqwFIwCL8edIha6ZZ1dUc5Xabiv97Is=; b=wmaJWblsdiKOfncfTzfVgjnL5vNEB3eWNLMQgy1qdy6CnD9uwbHQ/Ekg0PRrZkpz6m iPm0FhmoF/bOTN1H8gBchYk028eurtr37wpD4Qwm8oiFuXtaXQBhz2nDk6rhHwgMScRV GB3LxohG4320sIBcXH9v0snEjJOc54ySXLTlVLNpJVmht3H0ED76kG/8tSP6slBEuQ1N +ljfKhpATq17XJ9PWKCA0gZ+oJbn+KO+AdFSD2mlR9iRaCO2Sh/qKSnGkN0nbeMG+O7f RcQ0LFHrJJXOcdfQJ9gucY0k/wFciSaO5WEfqi+xCoEqZN6MQyhI3ljym3Eesad4nEha ttlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796071954; x=1796676754; 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=v2nr0irbPLtwUqwFIwCL8edIha6ZZ1dUc5Xabiv97Is=; b=KCSIC+ZKAbHskBixrBHK1Xq/p8QF7MOaC74OmQCMDccRInTLH2G6QDYzEaNV9d0rsI p7mflsPliMyK5zDgi/DcRopLPU7P4/Bw8kJrthvN+PvStMLY0xd3IT4l4RuUNd40Su6e 6NJOqaf9+uF0RPGmtRNfuzsRajKaexl/xS9iZUWD3PHmnTAmFwYwFQAar3fNfPaV8tCP SzU1QTiwROiiRva2lPm6KbXDexkdCGvsavrIv2UpwvlwvDuMIdV54dG8x68ULmuIMrl5 6V9Quo9eNjRl6uS8HezT96Kt7jV6paWteaclindkKbWwwJdS4HjP//J9ksbcWKDszJ3g 9D8A== X-Gm-Message-State: APuU4Z+NmZ4NckEpVGftTJSkeDsVuPxlB3C1bYfxlaB3WwmuARZX6Q96 6DMzDOXW+IFxyjGxV8+zYl7fJQKAzhFtLGBGyv4p+c1ae9mEjH0MMtr/fb44L5hO X-Gm-Gg: AZFdTZfouXC7wdZs38RMYPPnami2Uhqy+fSu4sjaOL4iXKJOfaZHATQ56kXbtGUyFtP jSWtB1xIZLP8+7LlxLLRyEYQ8WjAvPET8Lt7kveqlpSRrJ1+0XFQNq4LgGqttsbYimra4Ipeuvd qDKysvCUU1xo0dhjbrvEoSGajoWmoE6Jiwe0A+GZFIUOaTX/BZHLzQS9SZWmSIPMepF92RMI9Hw Cdt9ze9/eGY5ilvLJgYTsVLOP+GPI1dvOmGRwpP68MEAPHHfd2T8uMgexg5whwy/eE7f0kSbwRD 7ctdp+BbQYhhSiaOZkFydkbfH0YTwPZ4IEid6gqiVRlADkXOZ03/3XTbjGGCTJrAajm/K4mV9cK xAWl6OIsZrfisIwDFvqOlpjOcK+noxujpX5NOgA50vI4qkW9AasUG15YCn1K9FuITrhgXb0wMPj IiYPLa2p5x3TjlzPWmoPltlNTpljxPZ7qqh8k6I/c+OeSKbfqCN6YDvdOM73PdgV0sEIZlgobT7 86YnILq6jiaS8Gev5YQdmC7aOmKGUQN3kMd+tZCrygURdZ0rzh1qkX62FCFCcCPOr2jgZJ6Ath1 VxOUKdgnfqGe6LzIMkuDZMWEu70UaSoZ8LKKKk7uBwicyY4U4C/+PYDxbCi9+1//GvB+NMpsnAf lNWyiKK5+drsu4lOniLG/fIlGN7iFLA6nu+lhgDJ11ZexvDHCOshwg2n2bVuKsrmSpHNrmGxZla Q= X-Received: by 2002:a05:622a:14d1:b0:55d:3350:d262 with SMTP id d75a77b69052e-55d76af1864mr648829461cf.52.1796071953766; Mon, 30 Nov 2026 12:52:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 12:52:32 -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 3/3] test/mempool: add list walk race test Date: Mon, 30 Nov 2026 15:51:52 -0500 Message-Id: <20261130205152.7107-4-rsanford2@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261130205152.7107-1-rsanford2@gmail.com> References: <20261112154342.1484709-1-rsanford2@gmail.com> <20261130205152.7107-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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,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 Walk, look up and dump the mempool list on some lcores while other lcores create and free mempools, in two phases of 500 ms. In the first phase, mempools are created and freed as fast as possible. In the second phase, every other mempool is created empty and populated after a short delay, so that the walkers also find mempools that are not populated yet. In that phase, the walk callback also dumps each mempool, and it checks rte_mempool_is_created() before querying the mempool driver, as documented for rte_mempool_walk(). Without either of the two previous patches, the test crashes. It needs at least 3 lcores and is skipped otherwise. It adds about one second to mempool_autotest. Signed-off-by: Robert Sanford Acked-by: Morten Brørup --- app/test/test_mempool.c | 150 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c index 0a4d794346..0edb691b56 100644 --- a/app/test/test_mempool.c +++ b/app/test/test_mempool.c @@ -839,6 +839,152 @@ test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void) #pragma pop_macro("RTE_TEST_TRACE_FAILURE") +/* + * Walk, look up and dump the mempool list on some lcores while other lcores + * create and free mempools. In the first phase the creators free mempools as + * fast as possible. In the second phase every other mempool is created empty + * and populated after a short delay, so that the walkers also find mempools + * that are not populated yet, and dump them. + */ +#define LIST_RACE_PHASE_MS 500 +#define LIST_RACE_NB_OBJ 63 +#define LIST_RACE_ELT_SIZE 64 + +#ifndef RTE_EXEC_ENV_WINDOWS +#define LIST_RACE_DUMP_FILE "/dev/null" +#else +#define LIST_RACE_DUMP_FILE "NUL" +#endif + +static RTE_ATOMIC(uint32_t) list_race_stop; +static int list_race_populate_later; +static FILE *list_race_dump; + +static int +test_mempool_list_race_create(__rte_unused void *arg) +{ + char name[RTE_MEMPOOL_NAMESIZE]; + struct rte_mempool *mp; + int populate_later = 0; + + snprintf(name, sizeof(name), "test_list_race_%u", rte_lcore_id()); + while (rte_atomic_load_explicit(&list_race_stop, + rte_memory_order_relaxed) == 0) { + if (populate_later) { + mp = rte_mempool_create_empty(name, LIST_RACE_NB_OBJ, + LIST_RACE_ELT_SIZE, 0, 0, SOCKET_ID_ANY, 0); + if (mp == NULL) + RET_ERR(); + rte_delay_us(100); + if (rte_mempool_set_ops_byname(mp, + rte_mbuf_best_mempool_ops(), NULL) < 0 || + rte_mempool_populate_default(mp) < 0) { + rte_mempool_free(mp); + RET_ERR(); + } + } else { + mp = rte_mempool_create(name, LIST_RACE_NB_OBJ, + LIST_RACE_ELT_SIZE, 0, 0, NULL, NULL, NULL, NULL, + SOCKET_ID_ANY, 0); + if (mp == NULL) + RET_ERR(); + } + rte_mempool_free(mp); + if (list_race_populate_later) + populate_later = !populate_later; + } + return 0; +} + +static void +test_mempool_list_race_walk_cb(struct rte_mempool *mp, void *arg) +{ + unsigned int *count = arg; + + /* rte_mempool_dump() must handle mempools that are not populated yet */ + if (list_race_dump != NULL) + rte_mempool_dump(list_race_dump, mp); + + /* as documented for rte_mempool_walk(), check this first */ + if (!rte_mempool_is_created(mp)) + return; + /* access the store */ + *count += mp->size + rte_mempool_avail_count(mp); +} + +static int +test_mempool_list_race_walk(__rte_unused void *arg) +{ + unsigned int count = 0; + + while (rte_atomic_load_explicit(&list_race_stop, + rte_memory_order_relaxed) == 0) { + rte_mempool_walk(test_mempool_list_race_walk_cb, &count); + if (rte_mempool_lookup("test_list_race_none") != NULL) + RET_ERR(); + if (list_race_dump != NULL) + rte_mempool_list_dump(list_race_dump); + } + return 0; +} + +static int +test_mempool_list_race_phase(int populate_later, FILE *dump) +{ + unsigned int nb_creators = (rte_lcore_count() - 1) / 2; + unsigned int lcore_id, i = 0; + int ret = 0; + + list_race_populate_later = populate_later; + list_race_dump = dump; + rte_atomic_store_explicit(&list_race_stop, 0, rte_memory_order_relaxed); + RTE_LCORE_FOREACH_WORKER(lcore_id) { + lcore_function_t *func = i++ < nb_creators ? + test_mempool_list_race_create : + test_mempool_list_race_walk; + + if (rte_eal_remote_launch(func, NULL, lcore_id) != 0) + ret = -1; + } + + rte_delay_ms(LIST_RACE_PHASE_MS); + rte_atomic_store_explicit(&list_race_stop, 1, rte_memory_order_relaxed); + + RTE_LCORE_FOREACH_WORKER(lcore_id) { + if (rte_eal_wait_lcore(lcore_id) < 0) + ret = -1; + } + return ret; +} + +static int +test_mempool_list_race(void) +{ + FILE *f; + int ret; + + if (rte_lcore_count() < 3) { + printf("%s skipped: needs at least 3 lcores\n", __func__); + return 0; + } + + /* mempools freed while the list is walked */ + ret = test_mempool_list_race_phase(0, NULL); + if (ret != 0) { + LOG_ERR(); + return ret; + } + + /* mempools not populated yet while the list is walked and dumped */ + f = fopen(LIST_RACE_DUMP_FILE, "w"); + ret = test_mempool_list_race_phase(1, f); + if (f != NULL) + fclose(f); + if (ret != 0) + LOG_ERR(); + return ret; +} + static int test_mempool(void) { @@ -1105,6 +1251,10 @@ test_mempool(void) if (test_mempool_flag_non_io_unset_when_populated_with_valid_iova() < 0) GOTO_ERR(ret, err); + /* test walking the mempool list while mempools are created and freed */ + if (test_mempool_list_race() < 0) + GOTO_ERR(ret, err); + rte_mempool_list_dump(stdout); ret = 0; -- 2.34.1