@@ -9554,6 +9554,8 @@ struct cmd_rm_mirror_rule_result {
struct cmd_dump_result {
cmdline_fixed_string_t dump;
+ cmdline_fixed_string_t cmd;
+ uint32_t val;
};
static void
@@ -9628,6 +9630,16 @@ static void cmd_dump_parsed(void *parsed_result,
dump_socket_mem(stdout);
else if (!strcmp(res->dump, "dump_memzone"))
rte_memzone_dump(stdout);
+ else if (!strcmp(res->dump, "dump_malloc")) {
+ if (!strcmp(res->cmd, "start")) {
+ if (rte_malloc_log_init(res->val))
+ fprintf(stdout, "Failed to start logging\n");
+ } else if (!strcmp(res->cmd, "dump")) {
+ rte_malloc_log_dump(stdout, res->val);
+ } else if (!strcmp(res->cmd, "stop")) {
+ rte_malloc_log_stop();
+ }
+ }
else if (!strcmp(res->dump, "dump_struct_sizes"))
dump_struct_sizes();
else if (!strcmp(res->dump, "dump_ring"))
@@ -9650,7 +9662,50 @@ static void cmd_dump_parsed(void *parsed_result,
"dump_mempool#"
"dump_devargs#"
"dump_log_types");
-
+cmdline_parse_token_string_t cmd_dump_malloc =
+ TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
+ "dump_malloc");
+cmdline_parse_token_string_t cmd_dump_malloc_cmd_start =
+ TOKEN_STRING_INITIALIZER(struct cmd_dump_result, cmd,
+ "start");
+cmdline_parse_token_string_t cmd_dump_malloc_cmd_dump =
+ TOKEN_STRING_INITIALIZER(struct cmd_dump_result, cmd,
+ "dump");
+cmdline_parse_token_string_t cmd_dump_malloc_cmd_stop =
+ TOKEN_STRING_INITIALIZER(struct cmd_dump_result, cmd,
+ "stop");
+cmdline_parse_token_num_t cmd_dump_val =
+ TOKEN_NUM_INITIALIZER(struct cmd_dump_result, val, UINT32);
+
+cmdline_parse_inst_t cmd_dump_malloc_start = {
+ .f = cmd_dump_parsed, /* function to call */
+ .help_str = "Start rte_malloc tracking log with <count> buffer entries",
+ .tokens = { /* token list, NULL terminated */
+ (void *)&cmd_dump_malloc,
+ (void *)&cmd_dump_malloc_cmd_start,
+ (void *)&cmd_dump_val,
+ NULL,
+ },
+};
+cmdline_parse_inst_t cmd_dump_malloc_dump = {
+ .f = cmd_dump_parsed, /* function to call */
+ .help_str = "Dump rte_malloc tracking log with <level>, 0:summary, 1:leaks, 2: all",
+ .tokens = { /* token list, NULL terminated */
+ (void *)&cmd_dump_malloc,
+ (void *)&cmd_dump_malloc_cmd_dump,
+ (void *)&cmd_dump_val,
+ NULL,
+ },
+};
+cmdline_parse_inst_t cmd_dump_malloc_stop = {
+ .f = cmd_dump_parsed, /* function to call */
+ .help_str = "Stop rte_malloc tracking log",
+ .tokens = { /* token list, NULL terminated */
+ (void *)&cmd_dump_malloc,
+ (void *)&cmd_dump_malloc_cmd_stop,
+ NULL,
+ },
+};
cmdline_parse_inst_t cmd_dump = {
.f = cmd_dump_parsed, /* function to call */
.data = NULL, /* 2nd arg of func */
@@ -19505,6 +19560,9 @@ struct cmd_showport_macs_result {
(cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
(cmdline_parse_inst_t *)&cmd_dump,
+ (cmdline_parse_inst_t *)&cmd_dump_malloc_start,
+ (cmdline_parse_inst_t *)&cmd_dump_malloc_dump,
+ (cmdline_parse_inst_t *)&cmd_dump_malloc_stop,
(cmdline_parse_inst_t *)&cmd_dump_one,
(cmdline_parse_inst_t *)&cmd_ethertype_filter,
(cmdline_parse_inst_t *)&cmd_syn_filter,
@@ -567,6 +567,21 @@ Dumps the statistics of all or specific memory pool::
testpmd> dump_mempool [mempool_name]
+dump malloc
+~~~~~~~~~~~~
+
+Start rte_malloc and rte_free tracking with number of buffers::
+
+ testpmd> dump_malloc start <count>
+
+Dump tracking result with different level, 0:summary, 1:leaks, 2: all::
+
+ testpmd> dump_malloc dump <level>
+
+Stop tracking::
+
+ testpmd> dump_malloc stop
+
dump devargs
~~~~~~~~~~~~