[RFC,v2,2/2] app/testpmd: support malloc and free tracking log

Message ID 1587110623-405-3-git-send-email-xuemingl@mellanox.com (mailing list archive)
State Deferred, archived
Delegated to: David Marchand
Headers
Series malloc: support malloc and free tracking log |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Xueming Li April 17, 2020, 8:03 a.m. UTC
  New CLI commands to manipulate malloc tracking log:

dump_malloc start <n>: start malloc tracking with number of buffers
dump_malloc dump <n>:  dump mmalloc tracking log with detail level
dump_malloc stop:      stop malloc tracking

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 app/test-pmd/cmdline.c                      | 60 ++++++++++++++++++++++++++++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++++++++
 2 files changed, 74 insertions(+), 1 deletion(-)
  

Comments

Iremonger, Bernard April 21, 2020, 1:41 p.m. UTC | #1
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Xueming Li
> Sent: Friday, April 17, 2020 9:04 AM
> To: Burakov, Anatoly <anatoly.burakov@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>; Stephen Hemminger
> <stephen@networkplumber.org>
> Cc: dev@dpdk.org; Asaf Penso <asafp@mellanox.com>
> Subject: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free
> tracking log
> 
> New CLI commands to manipulate malloc tracking log:
> 
> dump_malloc start <n>: start malloc tracking with number of buffers
> dump_malloc dump <n>:  dump mmalloc tracking log with detail level
> dump_malloc stop:      stop malloc tracking
> 
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
  
Somnath Kotur July 30, 2020, 3:10 p.m. UTC | #2
On Tue, Apr 21, 2020 at 7:11 PM Iremonger, Bernard
<bernard.iremonger@intel.com> wrote:
>
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Xueming Li
> > Sent: Friday, April 17, 2020 9:04 AM
> > To: Burakov, Anatoly <anatoly.burakov@intel.com>; Yigit, Ferruh
> > <ferruh.yigit@intel.com>; Stephen Hemminger
> > <stephen@networkplumber.org>
> > Cc: dev@dpdk.org; Asaf Penso <asafp@mellanox.com>
> > Subject: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free
> > tracking log
> >
> > New CLI commands to manipulate malloc tracking log:
> >
> > dump_malloc start <n>: start malloc tracking with number of buffers
> > dump_malloc dump <n>:  dump mmalloc tracking log with detail level
> > dump_malloc stop:      stop malloc tracking
> >
> > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
>
> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

Sorry if this has been answered already, but just wanted to know if
there is any reason this is not yet merged in ...could be a useful
tool to debug leaks in PMDs
Is there any other /better way to identify memory leaks now which is
why this is no longer under consideration ?

Thanks
som
  
Xueming Li July 30, 2020, 3:13 p.m. UTC | #3
Hi Som,

> -----Original Message-----
> From: Somnath Kotur <somnath.kotur@broadcom.com>
> Sent: Thursday, July 30, 2020 11:10 PM
> To: Iremonger, Bernard <bernard.iremonger@intel.com>
> Cc: Xueming(Steven) Li <xuemingl@mellanox.com>; Burakov, Anatoly
> <anatoly.burakov@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Stephen
> Hemminger <stephen@networkplumber.org>; dev@dpdk.org; Asaf Penso
> <asafp@mellanox.com>
> Subject: Re: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free
> tracking log
> 
> On Tue, Apr 21, 2020 at 7:11 PM Iremonger, Bernard
> <bernard.iremonger@intel.com> wrote:
> >
> > > -----Original Message-----
> > > From: dev <dev-bounces@dpdk.org> On Behalf Of Xueming Li
> > > Sent: Friday, April 17, 2020 9:04 AM
> > > To: Burakov, Anatoly <anatoly.burakov@intel.com>; Yigit, Ferruh
> > > <ferruh.yigit@intel.com>; Stephen Hemminger
> > > <stephen@networkplumber.org>
> > > Cc: dev@dpdk.org; Asaf Penso <asafp@mellanox.com>
> > > Subject: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and
> > > free tracking log
> > >
> > > New CLI commands to manipulate malloc tracking log:
> > >
> > > dump_malloc start <n>: start malloc tracking with number of buffers
> > > dump_malloc dump <n>:  dump mmalloc tracking log with detail level
> > > dump_malloc stop:      stop malloc tracking
> > >
> > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> >
> > Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> 
> Sorry if this has been answered already, but just wanted to know if there is any
> reason this is not yet merged in ...could be a useful tool to debug leaks in PMDs
> Is there any other /better way to identify memory leaks now which is why this
> is no longer under consideration ?

AFAIK, new tracking point system is introduced to record key event not only memory.
So this patchset no longer valid.
 
> 
> Thanks
> som
  
Somnath Kotur July 30, 2020, 3:30 p.m. UTC | #4
On Thu, Jul 30, 2020 at 8:43 PM Xueming(Steven) Li
<xuemingl@mellanox.com> wrote:
>
> Hi Som,
>
> > -----Original Message-----
> > From: Somnath Kotur <somnath.kotur@broadcom.com>
> > Sent: Thursday, July 30, 2020 11:10 PM
> > To: Iremonger, Bernard <bernard.iremonger@intel.com>
> > Cc: Xueming(Steven) Li <xuemingl@mellanox.com>; Burakov, Anatoly
> > <anatoly.burakov@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Stephen
> > Hemminger <stephen@networkplumber.org>; dev@dpdk.org; Asaf Penso
> > <asafp@mellanox.com>
> > Subject: Re: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free
> > tracking log
> >
> > On Tue, Apr 21, 2020 at 7:11 PM Iremonger, Bernard
> > <bernard.iremonger@intel.com> wrote:
> > >
> > > > -----Original Message-----
> > > > From: dev <dev-bounces@dpdk.org> On Behalf Of Xueming Li
> > > > Sent: Friday, April 17, 2020 9:04 AM
> > > > To: Burakov, Anatoly <anatoly.burakov@intel.com>; Yigit, Ferruh
> > > > <ferruh.yigit@intel.com>; Stephen Hemminger
> > > > <stephen@networkplumber.org>
> > > > Cc: dev@dpdk.org; Asaf Penso <asafp@mellanox.com>
> > > > Subject: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and
> > > > free tracking log
> > > >
> > > > New CLI commands to manipulate malloc tracking log:
> > > >
> > > > dump_malloc start <n>: start malloc tracking with number of buffers
> > > > dump_malloc dump <n>:  dump mmalloc tracking log with detail level
> > > > dump_malloc stop:      stop malloc tracking
> > > >
> > > > Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> > >
> > > Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
> >
> > Sorry if this has been answered already, but just wanted to know if there is any
> > reason this is not yet merged in ...could be a useful tool to debug leaks in PMDs
> > Is there any other /better way to identify memory leaks now which is why this
> > is no longer under consideration ?
>
> AFAIK, new tracking point system is introduced to record key event not only memory.
> So this patchset no longer valid.
Hmm sorry didn't get that ..did you mean tracing system ? Could you
please elaborate and provide any pointers on setting this up for
monitoring memory?
Any pointers would be greatly appreciated
>
> >
> > Thanks
> > som
>
>
  

Patch

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 <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,
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 <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
 ~~~~~~~~~~~~