From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: shperetz@nvidia.com, viacheslavo@nvidia.com,
bruce.richardson@intel.com, mb@smartsharesystems.com,
stephen@networkplumber.org,
Aman Singh <aman.deep.singh@intel.com>
Subject: [PATCH v6 6/7] app/testpmd: add commands to dump mbuf history
Date: Tue, 14 Oct 2025 14:33:39 +0200 [thread overview]
Message-ID: <20251014124046.1032293-7-thomas@monjalon.net> (raw)
In-Reply-To: <20251014124046.1032293-1-thomas@monjalon.net>
Dump the mbuf history to the console or to a file.
The dump will contain:
- Operation history for each mbuf
- Summary and statistics about all mbufs
Dump the history of all mbufs:
testpmd> dump mbuf history all [file]
Dump the history of one mbuf:
testpmd> dump mbuf history <mbuf_addr> [file]
Dump the history of one mbuf pool:
testpmd> dump mbuf pool history <mp_name> [file]
Signed-off-by: Shani Peretz <shperetz@nvidia.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
---
app/test-pmd/cmdline.c | 143 ++++++++++++++++++++
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 13 ++
2 files changed, 156 insertions(+)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 487a95cd16..cc35540115 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -40,6 +40,7 @@
#include <rte_gro.h>
#endif
#include <rte_mbuf_dyn.h>
+#include <rte_mbuf_history.h>
#include <rte_trace.h>
#include <cmdline_rdline.h>
@@ -296,6 +297,15 @@ static void cmd_help_long_parsed(void *parsed_result,
"dump log_types\n"
" Dumps the log level for all the dpdk modules\n\n"
+ "dump mbuf history all [file_name]\n"
+ " Dumps the mbuf history for all mempools\n\n"
+
+ "dump mbuf history <mbuf_addr> [file_name]\n"
+ " Dumps the history for a specific mbuf (use 0x<address> format)\n\n"
+
+ "dump mbuf pool history <mempool_name> [file_name]\n"
+ " Dumps the history for a specific mempool\n\n"
+
"show port (port_id) speed_lanes capabilities"
" Show speed lanes capabilities of a port.\n\n"
);
@@ -9243,6 +9253,135 @@ static cmdline_parse_inst_t cmd_dump_named = {
},
};
+struct cmd_dump_mbuf_history_result {
+ cmdline_fixed_string_t dump;
+ cmdline_fixed_string_t mbuf;
+ cmdline_fixed_string_t history;
+ cmdline_fixed_string_t obj;
+ cmdline_fixed_string_t name;
+ cmdline_fixed_string_t addr;
+ cmdline_fixed_string_t file;
+};
+static cmdline_parse_token_string_t cmd_dump_mbuf_history_dump =
+ TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, dump, "dump");
+static cmdline_parse_token_string_t cmd_dump_mbuf_history_mbuf =
+ TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, mbuf, "mbuf");
+static cmdline_parse_token_string_t cmd_dump_mbuf_history_history =
+ TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, history, "history");
+static cmdline_parse_token_string_t cmd_dump_mbuf_history_obj =
+ TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, NULL);
+static cmdline_parse_token_string_t cmd_dump_mbuf_history_pool =
+ TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, "pool");
+static cmdline_parse_token_string_t cmd_dump_mbuf_history_name =
+ TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, name, NULL);
+static cmdline_parse_token_string_t cmd_dump_mbuf_history_file =
+ TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, file, NULL);
+
+static void cmd_dump_mbuf_history_parsed(void *parsed_result,
+ struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_dump_mbuf_history_result *res = parsed_result;
+ FILE *out = stdout;
+
+ if (strcmp(res->file, "") != 0) {
+ out = fopen(res->file, "w");
+ if (out == NULL) {
+ cmdline_printf(cl,
+ "Failed to open file '%s'\n",
+ res->file);
+ return;
+ }
+ }
+
+ if (strcmp(res->obj, "all") == 0) {
+ rte_mbuf_history_dump_all(out);
+ if (out != stdout)
+ cmdline_printf(cl,
+ "Dump written in '%s'\n",
+ res->file);
+ } else if (strcmp(res->obj, "pool") == 0) {
+ struct rte_mempool *mp = rte_mempool_lookup(res->name);
+ if (mp == NULL) {
+ cmdline_printf(cl,
+ "Failed to find mempool '%s'\n",
+ res->name);
+ return;
+ }
+ rte_mbuf_history_dump_mempool(out, mp);
+ if (out != stdout)
+ cmdline_printf(cl,
+ "Dump for mempool '%s' written in '%s'\n",
+ res->name, res->file);
+ } else {
+ struct rte_mbuf *mbuf;
+ uintptr_t mbuf_addr;
+ if (sscanf(res->obj, "0x%" SCNxPTR, &mbuf_addr) != 1) {
+ cmdline_printf(cl,
+ "Invalid mbuf pointer format. Use 0x<address>\n");
+ return;
+ }
+ mbuf = (struct rte_mbuf *)mbuf_addr;
+ rte_mbuf_history_dump(out, mbuf);
+ if (out != stdout)
+ cmdline_printf(cl,
+ "Dump for mbuf '%p' written in '%s'\n",
+ mbuf, res->file);
+ }
+
+ if (out != stdout)
+ fclose(out);
+}
+
+static cmdline_parse_inst_t cmd_dump_mbuf_history_stdout = {
+ .f = cmd_dump_mbuf_history_parsed,
+ .help_str = "dump mbuf history all|<address>",
+ .tokens = {
+ (void *)&cmd_dump_mbuf_history_dump,
+ (void *)&cmd_dump_mbuf_history_mbuf,
+ (void *)&cmd_dump_mbuf_history_history,
+ (void *)&cmd_dump_mbuf_history_obj,
+ NULL,
+ },
+};
+static cmdline_parse_inst_t cmd_dump_mbuf_history_to_file = {
+ .f = cmd_dump_mbuf_history_parsed,
+ .help_str = "dump mbuf history all|<address> [file]",
+ .tokens = {
+ (void *)&cmd_dump_mbuf_history_dump,
+ (void *)&cmd_dump_mbuf_history_mbuf,
+ (void *)&cmd_dump_mbuf_history_history,
+ (void *)&cmd_dump_mbuf_history_obj,
+ (void *)&cmd_dump_mbuf_history_file,
+ NULL,
+ },
+};
+static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_stdout = {
+ .f = cmd_dump_mbuf_history_parsed,
+ .help_str = "dump mbuf pool history <name>",
+ .tokens = {
+ (void *)&cmd_dump_mbuf_history_dump,
+ (void *)&cmd_dump_mbuf_history_mbuf,
+ (void *)&cmd_dump_mbuf_history_pool,
+ (void *)&cmd_dump_mbuf_history_history,
+ (void *)&cmd_dump_mbuf_history_name,
+ NULL,
+ },
+};
+static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_to_file = {
+ .f = cmd_dump_mbuf_history_parsed,
+ .help_str = "dump mbuf pool history <name> [file]",
+ .tokens = {
+ (void *)&cmd_dump_mbuf_history_dump,
+ (void *)&cmd_dump_mbuf_history_mbuf,
+ (void *)&cmd_dump_mbuf_history_pool,
+ (void *)&cmd_dump_mbuf_history_history,
+ (void *)&cmd_dump_mbuf_history_name,
+ (void *)&cmd_dump_mbuf_history_file,
+ NULL,
+ },
+};
+
/* *** Filters Control *** */
#define IPV4_ADDR_TO_UINT(ip_addr, ip) \
@@ -13982,6 +14121,10 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
&cmd_cleanup_txq_mbufs,
&cmd_dump_simple,
&cmd_dump_named,
+ &cmd_dump_mbuf_history_stdout,
+ &cmd_dump_mbuf_history_to_file,
+ &cmd_dump_mbuf_pool_history_stdout,
+ &cmd_dump_mbuf_pool_history_to_file,
&cmd_flow,
&cmd_show_port_meter_cap,
&cmd_add_port_meter_profile_srtcm,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index e4bef31d06..f3b9a55fb2 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -633,6 +633,19 @@ Dumps the log level for all the dpdk modules::
testpmd> dump log_types
+dump mbuf history
+~~~~~~~~~~~~~~~~~
+
+The mbuf history is tracked
+if enabled at compilation with ``RTE_MBUF_HISTORY_DEBUG``.
+
+This tracking can be displayed or saved to a file
+for all mbufs or specific ones selected by pointer or mempool name::
+
+ testpmd> dump mbuf history all [file]
+ testpmd> dump mbuf history <mbuf_addr> [file]
+ testpmd> dump mbuf pool history <mp_name> [file]
+
show (raw_encap|raw_decap)
~~~~~~~~~~~~~~~~~~~~~~~~~~
--
2.51.0
next prev parent reply other threads:[~2025-10-14 12:41 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-16 7:29 [RFC PATCH 0/5] Introduce mempool object new debug capabilities Shani Peretz
2025-06-16 7:29 ` [RFC PATCH 1/5] mempool: record mempool objects operations history Shani Peretz
2025-06-16 7:29 ` [RFC PATCH 2/5] drivers: add mempool history compilation flag Shani Peretz
2025-06-16 7:29 ` [RFC PATCH 3/5] net/mlx5: mark an operation in mempool object's history Shani Peretz
2025-06-16 7:29 ` [RFC PATCH 4/5] app/testpmd: add testpmd command to dump mempool history Shani Peretz
2025-06-16 7:29 ` [RFC PATCH 5/5] usertool: add a script to parse mempool history dump Shani Peretz
2025-06-16 15:30 ` [RFC PATCH 0/5] Introduce mempool object new debug capabilities Stephen Hemminger
2025-06-19 12:57 ` Morten Brørup
2025-07-07 5:46 ` Shani Peretz
2025-07-07 5:45 ` Shani Peretz
2025-07-07 12:10 ` Morten Brørup
2025-07-19 14:39 ` Morten Brørup
2025-08-25 11:27 ` Slava Ovsiienko
2025-09-01 15:34 ` Morten Brørup
2025-09-16 15:12 ` [PATCH v2 0/4] add mbuf " Shani Peretz
2025-09-16 15:12 ` [PATCH v2 1/4] mbuf: record mbuf operations history Shani Peretz
2025-09-16 21:17 ` Stephen Hemminger
2025-09-16 21:33 ` Thomas Monjalon
2025-09-17 1:22 ` Morten Brørup
2025-09-17 14:46 ` Morten Brørup
2025-09-19 9:14 ` Shani Peretz
2025-09-16 15:12 ` [PATCH v2 2/4] net/mlx5: mark an operation in mbuf's history Shani Peretz
2025-09-16 21:14 ` Stephen Hemminger
2025-09-16 21:31 ` Thomas Monjalon
2025-09-17 15:04 ` Stephen Hemminger
2025-09-16 15:12 ` [PATCH v2 3/4] app/testpmd: add testpmd command to dump mbuf history Shani Peretz
2025-09-16 15:12 ` [PATCH v2 4/4] usertool: add a script to parse mbuf history dump Shani Peretz
2025-09-30 23:25 ` [PATCH v3 0/5] add mbuf debug capabilities Thomas Monjalon
2025-09-30 23:25 ` [PATCH v3 1/5] mbuf: move header include for logs Thomas Monjalon
2025-09-30 23:25 ` [PATCH v3 2/5] mbuf: record mbuf operations history Thomas Monjalon
2025-10-01 0:12 ` Thomas Monjalon
2025-10-02 7:37 ` Morten Brørup
2025-10-02 21:23 ` Thomas Monjalon
2025-10-13 18:39 ` Thomas Monjalon
2025-10-13 20:08 ` Morten Brørup
2025-10-13 21:07 ` Thomas Monjalon
2025-10-14 10:04 ` Morten Brørup
2025-09-30 23:25 ` [PATCH v3 3/5] ethdev: mark mbufs in burst functions Thomas Monjalon
2025-10-02 7:44 ` Morten Brørup
2025-10-13 15:32 ` Thomas Monjalon
2025-09-30 23:25 ` [PATCH v3 4/5] app/testpmd: add commands to dump mbuf history Thomas Monjalon
2025-10-01 8:20 ` Stephen Hemminger
2025-10-13 15:31 ` Thomas Monjalon
2025-09-30 23:25 ` [PATCH v3 5/5] usertools/mbuf: parse mbuf history dump Thomas Monjalon
2025-10-02 8:07 ` Robin Jarry
2025-10-13 21:16 ` [PATCH v4 0/7] add mbuf debug capabilities Thomas Monjalon
2025-10-13 21:16 ` [PATCH v4 1/7] doc: explain debug options in mbuf guide Thomas Monjalon
2025-10-13 21:16 ` [PATCH v4 2/7] mbuf: move header include for logs Thomas Monjalon
2025-10-13 21:16 ` [PATCH v4 3/7] mbuf: record mbuf operations history Thomas Monjalon
2025-10-13 21:16 ` [PATCH v4 4/7] ethdev: mark mbufs in burst functions Thomas Monjalon
2025-10-13 21:16 ` [PATCH v4 5/7] app/testpmd: use space separator in dump commands Thomas Monjalon
2025-10-13 21:16 ` [PATCH v4 6/7] app/testpmd: add commands to dump mbuf history Thomas Monjalon
2025-10-13 21:16 ` [PATCH v4 7/7] usertools/mbuf: parse mbuf history dump Thomas Monjalon
2025-10-14 6:58 ` [PATCH v5 0/7] add mbuf debug capabilities Thomas Monjalon
2025-10-14 6:58 ` [PATCH v5 1/7] doc: explain debug options in mbuf guide Thomas Monjalon
2025-10-14 6:58 ` [PATCH v5 2/7] mbuf: move header include for logs Thomas Monjalon
2025-10-14 8:47 ` Morten Brørup
2025-10-14 6:58 ` [PATCH v5 3/7] mbuf: record mbuf operations history Thomas Monjalon
2025-10-14 9:59 ` Morten Brørup
2025-10-14 12:03 ` Thomas Monjalon
2025-10-14 12:31 ` Thomas Monjalon
2025-10-14 6:58 ` [PATCH v5 4/7] ethdev: mark mbufs in burst functions Thomas Monjalon
2025-10-14 6:58 ` [PATCH v5 5/7] app/testpmd: use space separator in dump commands Thomas Monjalon
2025-10-14 6:58 ` [PATCH v5 6/7] app/testpmd: add commands to dump mbuf history Thomas Monjalon
2025-10-14 8:45 ` Morten Brørup
2025-10-14 9:43 ` Thomas Monjalon
2025-10-14 9:48 ` Bruce Richardson
2025-10-14 9:55 ` Thomas Monjalon
2025-10-14 6:58 ` [PATCH v5 7/7] usertools/mbuf: parse mbuf history dump Thomas Monjalon
2025-10-14 12:33 ` [PATCH v6 0/7] add mbuf debug capabilities Thomas Monjalon
2025-10-14 12:33 ` [PATCH v6 1/7] doc: explain debug options in mbuf guide Thomas Monjalon
2025-10-14 12:33 ` [PATCH v6 2/7] mbuf: move header include for logs Thomas Monjalon
2025-10-14 12:33 ` [PATCH v6 3/7] mbuf: record mbuf operations history Thomas Monjalon
2025-10-14 12:33 ` [PATCH v6 4/7] ethdev: mark mbufs in burst functions Thomas Monjalon
2025-10-14 12:33 ` [PATCH v6 5/7] app/testpmd: use space separator in dump commands Thomas Monjalon
2025-10-14 12:33 ` Thomas Monjalon [this message]
2025-10-14 12:33 ` [PATCH v6 7/7] usertools/mbuf: parse mbuf history dump Thomas Monjalon
2025-10-14 14:03 ` Robin Jarry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251014124046.1032293-7-thomas@monjalon.net \
--to=thomas@monjalon.net \
--cc=aman.deep.singh@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.com \
--cc=shperetz@nvidia.com \
--cc=stephen@networkplumber.org \
--cc=viacheslavo@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).