DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: dev <dev@dpdk.org>,
	shperetz@nvidia.com,
	"Viacheslav Ovsiienko" <viacheslavo@nvidia.com>,
	"Bruce Richardson" <bruce.richardson@intel.com>,
	"Morten Brørup" <mb@smartsharesystems.com>,
	"Aman Singh" <aman.deep.singh@intel.com>
Subject: Re: [PATCH v3 4/5] app/testpmd: add commands to dump mbuf history
Date: Wed, 1 Oct 2025 10:20:18 +0200	[thread overview]
Message-ID: <CAOaVG15nZ7NpHQuYnWtiit+U5HbwncEZEuUWA_ZaPnE1doHvpg@mail.gmail.com> (raw)
In-Reply-To: <20250930233828.3999565-5-thomas@monjalon.net>

[-- Attachment #1: Type: text/plain, Size: 12475 bytes --]

Most testpmd commands use spaces not underline as word separator.

On Wed, Oct 1, 2025, 01:39 Thomas Monjalon <thomas@monjalon.net> wrote:

> From: Shani Peretz <shperetz@nvidia.com>
>
> 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 mbuf pools:
> testpmd> dump_mbuf_history_all
>
> Dump the history of one mbuf pool:
> testpmd> dump_mbuf_history_single_mempool <mempool_name> [file_name]
>
> Dump the history of one mbuf:
> testpmd> dump_mbuf_history_single
>
> Signed-off-by: Shani Peretz <shperetz@nvidia.com>
> ---
>  app/test-pmd/cmdline.c | 246 ++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 245 insertions(+), 1 deletion(-)
>
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index 3731fba370..113db68f8c 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\n"
> +                       "    Dumps the mbuf history for all mempools\n\n"
> +
> +                       "dump_mbuf_history_single <mbuf_ptr>\n"
> +                       "    Dumps the history for a specific mbuf (use
> 0x<address> format)\n\n"
> +
> +                       "dump_mbuf_history_single_mempool <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"
>                 );
> @@ -9177,6 +9187,8 @@ static void cmd_dump_parsed(void *parsed_result,
>  #endif
>         else if (!strcmp(res->dump, "dump_log_types"))
>                 rte_log_dump(stdout);
> +       else if (!strcmp(res->dump, "dump_mbuf_history_all"))
> +               rte_mbuf_history_dump_all(stdout);
>  }
>
>  static cmdline_parse_token_string_t cmd_dump_dump =
> @@ -9198,7 +9210,8 @@ cmd_dump_init(void)
>  #ifndef RTE_EXEC_ENV_WINDOWS
>                 "dump_trace#"
>  #endif
> -               "dump_log_types";
> +               "dump_log_types#"
> +               "dump_mbuf_history";
>  }
>
>  static cmdline_parse_inst_t cmd_dump = {
> @@ -9260,6 +9273,232 @@ static cmdline_parse_inst_t cmd_dump_one = {
>         },
>  };
>
> +/* Dump mbuf history to file */
> +struct cmd_dump_mbuf_to_file_result {
> +       cmdline_fixed_string_t dump;
> +       cmdline_fixed_string_t file;
> +};
> +
> +static void cmd_dump_mbuf_to_file_parsed(void *parsed_result,
> +               struct cmdline *cl, __rte_unused void *data)
> +{
> +       struct cmd_dump_mbuf_to_file_result *res = parsed_result;
> +       FILE *file = stdout;
> +       char *file_name = res->file;
> +
> +       if (strcmp(res->dump, "dump_mbuf_history_all")) {
> +               cmdline_printf(cl, "Invalid dump type\n");
> +               return;
> +       }
> +
> +       if (file_name && strlen(file_name)) {
> +               file = fopen(file_name, "w");
> +               if (!file) {
> +                       rte_mbuf_history_dump_all(stdout);
> +                       return;
> +               }
> +       }
> +       rte_mbuf_history_dump_all(file);
> +       printf("Flow dump finished\n");
> +       if (file_name && strlen(file_name))
> +               fclose(file);
> +}
> +
> +static cmdline_parse_token_string_t cmd_dump_mbuf_to_file_dump =
> +       TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_to_file_result, dump,
> +                       "dump_mbuf_history_all");
> +
> +static cmdline_parse_token_string_t cmd_dump_mbuf_to_file_file =
> +       TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_to_file_result,
> file, NULL);
> +
> +static cmdline_parse_inst_t cmd_dump_mbuf_to_file = {
> +       .f = cmd_dump_mbuf_to_file_parsed,  /* function to call */
> +       .data = NULL,      /* 2nd arg of func */
> +       .help_str = "dump_mbuf_history_all <file_name>: Dump mbuf history
> to file",
> +       .tokens = {        /* token list, NULL terminated */
> +               (void *)&cmd_dump_mbuf_to_file_dump,
> +               (void *)&cmd_dump_mbuf_to_file_file,
> +               NULL,
> +       },
> +};
> +
> +/* Dump single mbuf history */
> +struct cmd_dump_mbuf_history_single_result {
> +       cmdline_fixed_string_t dump;
> +       cmdline_fixed_string_t mbuf_ptr;
> +};
> +
> +static void cmd_dump_mbuf_history_single_parsed(void *parsed_result,
> +               __rte_unused struct cmdline *cl, __rte_unused void *data)
> +{
> +       struct cmd_dump_mbuf_history_single_result *res = parsed_result;
> +       struct rte_mbuf *mbuf;
> +       uintptr_t mbuf_addr;
> +
> +       /* Parse the mbuf pointer from hex string */
> +       if (sscanf(res->mbuf_ptr, "0x%" SCNxPTR, &mbuf_addr) != 1) {
> +               printf("Invalid mbuf pointer format. Use 0x<address>\n");
> +               return;
> +       }
> +
> +       mbuf = (struct rte_mbuf *)mbuf_addr;
> +
> +       printf("Dumping history for mbuf at %p:\n", mbuf);
> +       rte_mbuf_history_dump(stdout, mbuf);
> +}
> +
> +static cmdline_parse_token_string_t cmd_dump_mbuf_history_single_dump =
> +       TOKEN_STRING_INITIALIZER(struct
> cmd_dump_mbuf_history_single_result, dump,
> +                       "dump_mbuf_history_single");
> +
> +static cmdline_parse_token_string_t cmd_dump_mbuf_history_single_ptr =
> +       TOKEN_STRING_INITIALIZER(struct
> cmd_dump_mbuf_history_single_result, mbuf_ptr,
> +                       NULL);
> +
> +static cmdline_parse_inst_t cmd_dump_mbuf_history_single = {
> +       .f = cmd_dump_mbuf_history_single_parsed,
> +       .data = NULL,
> +       .help_str = "dump_mbuf_history_single <mbuf_ptr>: Dump history for
> specific mbuf",
> +       .tokens = {
> +               (void *)&cmd_dump_mbuf_history_single_dump,
> +               (void *)&cmd_dump_mbuf_history_single_ptr,
> +               NULL,
> +       },
> +};
> +
> +/* Dump single mempool history */
> +struct cmd_dump_mbuf_history_single_mempool_result {
> +       cmdline_fixed_string_t dump;
> +       cmdline_fixed_string_t mempool_name;
> +};
> +
> +static void cmd_dump_mbuf_history_single_mempool_parsed(void
> *parsed_result,
> +               __rte_unused struct cmdline *cl, __rte_unused void *data)
> +{
> +       struct cmd_dump_mbuf_history_single_mempool_result *res =
> parsed_result;
> +       struct rte_mempool *mp;
> +
> +       mp = rte_mempool_lookup(res->mempool_name);
> +       if (mp == NULL) {
> +               printf("Mempool '%s' not found\n", res->mempool_name);
> +               return;
> +       }
> +
> +       printf("Dumping history for mempool '%s':\n", res->mempool_name);
> +
> +       rte_mbuf_history_dump_mempool(stdout, mp);
> +}
> +
> +static cmdline_parse_token_string_t
> cmd_dump_mbuf_history_single_mempool_dump =
> +       TOKEN_STRING_INITIALIZER(struct
> cmd_dump_mbuf_history_single_mempool_result,
> +                       dump, "dump_mbuf_history_single_mempool");
> +
> +static cmdline_parse_token_string_t
> cmd_dump_mbuf_history_single_mempool_name =
> +       TOKEN_STRING_INITIALIZER(struct
> cmd_dump_mbuf_history_single_mempool_result,
> +                       mempool_name, NULL);
> +
> +static cmdline_parse_inst_t cmd_dump_mbuf_history_single_mempool = {
> +       .f = cmd_dump_mbuf_history_single_mempool_parsed,
> +       .data = NULL,
> +       .help_str = "dump_mbuf_history_single_mempool <mempool_name>: Dump
> history for specific mempool",
> +       .tokens = {
> +               (void *)&cmd_dump_mbuf_history_single_mempool_dump,
> +               (void *)&cmd_dump_mbuf_history_single_mempool_name,
> +               NULL,
> +       },
> +};
> +
> +/* Dump single mempool history to file only */
> +struct cmd_dump_mbuf_history_single_mempool_to_file_result {
> +       cmdline_fixed_string_t dump;
> +       cmdline_fixed_string_t mempool_name;
> +       cmdline_fixed_string_t file;
> +};
> +
> +static void cmd_dump_mbuf_history_single_mempool_to_file_parsed(void
> *parsed_result,
> +               __rte_unused struct cmdline *cl, __rte_unused void *data)
> +{
> +       struct cmd_dump_mbuf_history_single_mempool_to_file_result *res =
> parsed_result;
> +       struct rte_mempool *mp;
> +       FILE *file = NULL;
> +       char *file_name = res->file;
> +
> +       mp = rte_mempool_lookup(res->mempool_name);
> +       if (mp == NULL) {
> +               printf("Mempool '%s' not found\n", res->mempool_name);
> +               return;
> +       }
> +
> +       if (file_name && strlen(file_name)) {
> +               file = fopen(file_name, "w");
> +               if (!file) {
> +                       printf("Failed to open file '%s'\n", file_name);
> +                       return;
> +               }
> +       } else {
> +               printf("File name required for this command\n");
> +               return;
> +       }
> +
> +       printf("Dumping history for mempool '%s' to file '%s'...\n",
> res->mempool_name, file_name);
> +       rte_mbuf_history_dump_mempool(file, mp);
> +       printf("Mempool history dump finished\n");
> +       fclose(file);
> +}
> +
> +static cmdline_parse_token_string_t
> cmd_dump_mbuf_history_single_mempool_to_file_dump =
> +       TOKEN_STRING_INITIALIZER(struct
> cmd_dump_mbuf_history_single_mempool_to_file_result,
> +                       dump, "dump_mbuf_history_single_mempool");
> +
> +static cmdline_parse_token_string_t
> cmd_dump_mbuf_history_single_mempool_to_file_name =
> +       TOKEN_STRING_INITIALIZER(struct
> cmd_dump_mbuf_history_single_mempool_to_file_result,
> +                       mempool_name, NULL);
> +
> +static cmdline_parse_token_string_t
> cmd_dump_mbuf_history_single_mempool_to_file_file =
> +       TOKEN_STRING_INITIALIZER(struct
> cmd_dump_mbuf_history_single_mempool_to_file_result,
> +                       file, NULL);
> +
> +static cmdline_parse_inst_t cmd_dump_mbuf_history_single_mempool_to_file
> = {
> +       .f = cmd_dump_mbuf_history_single_mempool_to_file_parsed,
> +       .data = NULL,
> +       .help_str = "dump_mbuf_history_single_mempool <mempool_name>
> <file_name>: Dump history for specific mempool to file",
> +       .tokens = {
> +               (void *)&cmd_dump_mbuf_history_single_mempool_to_file_dump,
> +               (void *)&cmd_dump_mbuf_history_single_mempool_to_file_name,
> +               (void *)&cmd_dump_mbuf_history_single_mempool_to_file_file,
> +               NULL,
> +       },
> +};
> +
> +/* Dump all mempools history */
> +struct cmd_dump_mbuf_history_all_result {
> +       cmdline_fixed_string_t dump;
> +};
> +
> +static void cmd_dump_mbuf_history_all_parsed(void *parsed_result,
> +               __rte_unused struct cmdline *cl, __rte_unused void *data)
> +{
> +       __rte_unused struct cmd_dump_mempool_history_all_result *res =
> parsed_result;
> +
> +       printf("Dumping history for all mempools:\n");
> +       rte_mbuf_history_dump_all(stdout);
> +}
> +
> +static cmdline_parse_token_string_t cmd_dump_mbuf_history_all_dump =
> +       TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_all_result,
> dump,
> +                       "dump_mbuf_history_all");
> +
> +static cmdline_parse_inst_t cmd_dump_mbuf_history_all = {
> +       .f = cmd_dump_mbuf_history_all_parsed,
> +       .data = NULL,
> +       .help_str = "dump_mbuf_history_all: Dump history for all mempools",
> +       .tokens = {
> +               (void *)&cmd_dump_mbuf_history_all_dump,
> +               NULL,
> +       },
> +};
> +
> +
>  /* *** Filters Control *** */
>
>  #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
> @@ -13999,6 +14238,11 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
>         &cmd_cleanup_txq_mbufs,
>         &cmd_dump,
>         &cmd_dump_one,
> +       &cmd_dump_mbuf_to_file,
> +       &cmd_dump_mbuf_history_single,
> +       &cmd_dump_mbuf_history_single_mempool,
> +       &cmd_dump_mbuf_history_single_mempool_to_file,
> +       &cmd_dump_mbuf_history_all,
>         &cmd_flow,
>         &cmd_show_port_meter_cap,
>         &cmd_add_port_meter_profile_srtcm,
> --
> 2.51.0
>
>

[-- Attachment #2: Type: text/html, Size: 15631 bytes --]

  reply	other threads:[~2025-10-01  8:20 UTC|newest]

Thread overview: 35+ 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-09-30 23:25   ` [PATCH v3 3/5] ethdev: mark mbufs in burst functions 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 [this message]
2025-09-30 23:25   ` [PATCH v3 5/5] usertools/mbuf: parse mbuf history dump Thomas Monjalon

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=CAOaVG15nZ7NpHQuYnWtiit+U5HbwncEZEuUWA_ZaPnE1doHvpg@mail.gmail.com \
    --to=stephen@networkplumber.org \
    --cc=aman.deep.singh@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=mb@smartsharesystems.com \
    --cc=shperetz@nvidia.com \
    --cc=thomas@monjalon.net \
    --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).