From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 52FF8A0597; Wed, 8 Apr 2020 06:05:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 229C61BFC6; Wed, 8 Apr 2020 06:05:10 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 5BBA22BF4 for ; Wed, 8 Apr 2020 06:05:05 +0200 (CEST) From: Xueming Li To: Anatoly Burakov , Ferruh Yigit Cc: dev@dpdk.org, Asaf Penso Date: Wed, 8 Apr 2020 04:04:54 +0000 Message-Id: <1586318694-31358-3-git-send-email-xuemingl@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1586318694-31358-1-git-send-email-xuemingl@mellanox.com> References: <1586318694-31358-1-git-send-email-xuemingl@mellanox.com> In-Reply-To: <1585900482-5234-2-git-send-email-xuemingl@mellanox.com> References: <1585900482-5234-2-git-send-email-xuemingl@mellanox.com> Subject: [dpdk-dev] [PATCH v1 2/2] app/testpmd: support malloc and free tracking log X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" New CLI commands to manipulate malloc tracking log: dump_malloc start : start malloc tracking with number of buffers dump_malloc dump : dump mmalloc tracking log with detail level dump_malloc stop: stop malloc tracking Signed-off-by: Xueming Li --- app/test-pmd/cmdline.c | 60 ++++++++++++++++++++++++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 863b567..0490823 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -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 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 , 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, diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index dcee5de..1c55f23 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -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 + +Dump tracking result with different level, 0:summary, 1:leaks, 2: all:: + + testpmd> dump_malloc dump + +Stop tracking:: + + testpmd> dump_malloc stop + dump devargs ~~~~~~~~~~~~ -- 1.8.3.1