malloc: add malloc and free log function
DPDK uses second level memory allocation management, this makes regular memory profiler tool not applicant. This patch trys to provide a lightweight malloc and free logging, then show leaked memory entries based on logs.
This tool only target to malloc and free tracking, for memzone used by ring and mempool, "dump_memzone" in testpmd list them.
There will be another example that enable and dump tracking as secondary process.
This tool came from Mellanox internal Hackathon, thanks Shahaf Shuler <[email protected]> who provided the idea.
Xueming Li (1):
malloc: add malloc and free log function
app/test-pmd/cmdline.c | 61 ++++++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 +++ lib/librte_eal/common/eal_memcfg.h | 18 ++++ lib/librte_eal/common/include/rte_malloc.h | 30 +++++- lib/librte_eal/common/malloc_elem.h | 4 +- lib/librte_eal/common/rte_malloc.c | 154 +++++++++++++++++++++++++++- lib/librte_eal/rte_eal_version.map | 2 + 7 files changed, 280 insertions(+), 4 deletions(-)
Signature · 1 line
1.8.3.1
RFC 1/1 malloc: add malloc and free log function
This patch introduces new feature to track rte_malloc leakage by logging malloc and free function.
--- app/test-pmd/cmdline.c | 61 ++++++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 +++ lib/librte_eal/common/eal_memcfg.h | 18 ++++ lib/librte_eal/common/include/rte_malloc.h | 30 +++++- lib/librte_eal/common/malloc_elem.h | 4 +- lib/librte_eal/common/rte_malloc.c | 154 +++++++++++++++++++++++++++- lib/librte_eal/rte_eal_version.map | 2 + 7 files changed, 280 insertions(+), 4 deletions(-)
app/test-pmd/cmdline.c +60 -1
@@ -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
@@ -9576,6 +9578,16 @@ static void cmd_dump_parsed(void *parsed_result,rte_dump_physmem_layout (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_init (0 ); + } + } else if (!strcmp(res->dump, "dump_struct_sizes"))dump_struct_sizes (); else if (!strcmp(res->dump, "dump_ring"))
@@ -9595,9 +9607,53 @@ static void cmd_dump_parsed(void *parsed_result,"dump_struct_sizes#" "dump_ring#" "dump_mempool#" +"dump_malloc#" "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 */
@@ -19452,6 +19508,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,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +15 -0
@@ -561,6 +561,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 ~~~~~~~~~~~~
lib/librte_eal/common/eal_memcfg.h +18 -0
@@ -15,6 +15,20 @@#include "malloc_heap.h" /** +* Memory allocation and free tracking log +*/ +struct rte_malloc_log { +int socket; +void *addr; +size_t size;/* requested size */ +size_t real_size; +size_t align; +int8_t free;/* allocate or free. */ +int8_t alloc_free;/* alloc and free both tracked. */ +char name[64 ];/* name may come from stack, copy. */ +}; + +/** * Memory configuration shared across multiple processes. */ struct rte_mem_config {
@@ -73,6 +87,10 @@ struct rte_mem_config {/**< TSC rate */ uint8_t dma_maskbits;/**< Keeps the more restricted dma mask. */ + +struct rte_malloc_log *malloc_logs;/**< Log entries. */ +int malloc_log_max;/**< Max number of logs to write. */ +int malloc_log_index;/**< Next log index to write to. */ };/* update internal config from shared mem config */
lib/librte_eal/common/include/rte_malloc.h +29 -1
@@ -508,7 +508,35 @@ struct rte_malloc_socket_stats {* to dump all objects. */ void -rte_malloc_dump_stats (FILE *f,const char *type); +rte_malloc_dump_stats (FILE *out,const char *type); + +/** +* Initialize malloc tracking log buffer. +* +* @param count +* Max count of tracking log entries, 0 to stop tracking +* @return +* 0 on success, negative errno otherwise +*/ +__rte_experimental +int +rte_malloc_log_init (int count); + + +/** +* Dump malloc tracking log to output. +* +* @param out +* output file handle +* @param detail +* detail level of output +* 0: summary +* 1: potential leaks - allocated without free +* -1: all entries +*/ +__rte_experimental +void +rte_malloc_log_dump (FILE *out,int detail);/** * Dump contents of all malloc heaps to a file.
lib/librte_eal/common/malloc_elem.h +3 -1
@@ -27,7 +27,9 @@ struct malloc_elem {LIST_ENTRY (malloc_elem) free_list;/**< list of free elements in heap */ struct rte_memseg_list *msl; -volatile enum elem_state state; + volatile uint32_t state:2; + volatile uint32_t log:1; /* Element logged. */ + volatile uint32_t log_index:29; /* Element log index. */uint32_t pad;size_t size;struct malloc_elem *orig_elem;
lib/librte_eal/common/rte_malloc.c +153 -1
183 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map +2 -0
@@ -338,4 +338,6 @@ EXPERIMENTAL { # added in 20.05 rte_log_can_log; + rte_malloc_log_init; + rte_malloc_log_dump; };
Signature · 1 line
1.8.3.1
Quoted 2 lines · Xueming Li
This patch introduces new feature to track
rte_mallocleakage by logging malloc and free function.
Hi,
Thanks for the patch.
A general comment - i would avoid mixing testpmd code with adding a new API to malloc. I understand this is an RFC so it's OK for now, but by the time V1 comes i think it is better to add malloc API as a separate patch.
Quoted 27 lines
Signed-off-by Xueming Li <[email protected]>--- app/test-pmd/cmdline.c | 61 ++++++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 +++ lib/librte_eal/common/eal_memcfg.h | 18 ++++ lib/librte_eal/common/include/rte_malloc.h | 30 +++++- lib/librte_eal/common/malloc_elem.h | 4 +- lib/librte_eal/common/rte_malloc.c | 154 +++++++++++++++++++++++++++- lib/librte_eal/rte_eal_version.map | 2 + 7 files changed, 280 insertions(+), 4 deletions(-)app/test-pmd/cmdline.c +2
-0@@ -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@@ -9576,6 +9578,16 @@ static void cmd_dump_parsed(void *parsed_result,rte_dump_physmem_layout (stdout);
app/test-pmd/cmdline.c static void cmd_dump_parsed(void *parsed_result, · line 9588
Quoted 10 lines
app/test-pmd/cmdline.c +8
-0else 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_init (0 );
This looks odd and confusing. I think an explicit "stop" API is needed here, even though technically you could get away with just one API.
Quoted 101 lines
app/test-pmd/cmdline.c +50
-1+ } + }else if (!strcmp (res->dump,"dump_struct_sizes" ))dump_struct_sizes ();else if (!strcmp (res->dump,"dump_ring" ))@@ -9595,9 +9607,53 @@ static void cmd_dump_parsed(void *parsed_result,"dump_struct_sizes#" "dump_ring#" "dump_mempool#" +"dump_malloc#" "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 */ @@ -19452,6 +19508,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,doc/guides/testpmd_app_ug/testpmd_funcs.rst +15
-0@@ -561,6 +561,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 ~~~~~~~~~~~~lib/librte_eal/common/eal_memcfg.h +0
-0
lib/librte_eal/common/eal_memcfg.h line 24
Quoted 10 lines
lib/librte_eal/common/eal_memcfg.h +7
-0@@ -15,6 +15,20 @@#include "malloc_heap.h" /** +* Memory allocation and free tracking log +*/ +struct rte_malloc_log { +int socket; +void *addr; +size_t size;/* requested size */ +size_t real_size;
I'm not sure of the terminology here. If you're referring to outer element size and pad, then you should really use the same terms here as in the other malloc code. No need to introduce new ones.
lib/librte_eal/common/eal_memcfg.h line 27
Quoted 3 lines
lib/librte_eal/common/eal_memcfg.h +3
-0+size_t align; +int8_t free;/* allocate or free. */ +int8_t alloc_free;/* alloc and free both tracked. */
Why not just store a flag? E.g.
#define RTE_MALLOC_LOG_ALLOC (1 << 0)
#define RTE_MALLOC_LOG_FREE (1 << 1)log->flags |= RTE_MALLOC_LOG_ALLOC;
Also, i don't see you handling rte_realloc() anywhere. While it could cause deallocation/new allocation, it can also resize existing allocated memory.
Quoted 8 lines
lib/librte_eal/common/eal_memcfg.h +4
-0+char name[64 ];/* name may come from stack, copy. */ +}; + +/** * Memory configuration shared across multiple processes. */ struct rte_mem_config {
lib/librte_eal/common/eal_memcfg.h struct rte_mem_config { · line 93
Quoted 7 lines
lib/librte_eal/common/eal_memcfg.h +4
-0@@ -73,6 +87,10 @@ struct rte_mem_config {/**< TSC rate */ uint8_t dma_maskbits;/**< Keeps the more restricted dma mask. */ + +struct rte_malloc_log *malloc_logs;/**< Log entries. */ +int malloc_log_max;/**< Max number of logs to write. */ +int malloc_log_index;/**< Next log index to write to. */
I'm not 100% sure of this approach. I understand why you're doing it, but i have this nagging thought that there probably is a better way :D
Quoted 107 lines
lib/librte_eal/common/eal_memcfg.h +0
-0};/* update internal config from shared mem config */ lib/librte_eal/common/include/rte_malloc.h +29
-1@@ -508,7 +508,35 @@ struct rte_malloc_socket_stats {* to dump all objects. */ void -rte_malloc_dump_stats (FILE *f,const char *type); +rte_malloc_dump_stats (FILE *out,const char *type); + +/** +* Initialize malloc tracking log buffer. +* +* @param count +* Max count of tracking log entries, 0 to stop tracking +* @return +* 0 on success, negative errno otherwise +*/ +__rte_experimental +int +rte_malloc_log_init (int count); + + +/** +* Dump malloc tracking log to output. +* +* @param out +* output file handle +* @param detail +* detail level of output +* 0: summary +* 1: potential leaks - allocated without free +* -1: all entries +*/ +__rte_experimental +void +rte_malloc_log_dump (FILE *out,int detail);/** * Dump contents of all malloc heaps to a file. lib/librte_eal/common/malloc_elem.h +3
-1@@ -27,7 +27,9 @@ struct malloc_elem {LIST_ENTRY (malloc_elem) free_list;/**< list of free elements in heap */ struct rte_memseg_list *msl; -volatile enum elem_state state; + volatile uint32_t state:2; + volatile uint32_t log:1; /* Element logged. */ + volatile uint32_t log_index:29; /* Element log index. */uint32_t pad;size_t size;struct malloc_elem *orig_elem;lib/librte_eal/common/rte_malloc.c +33
-0@@ -6,6 +6,7 @@#include <stddef.h> #include <stdio.h> #include <string.h> +#include <assert.h> #include <sys/queue.h> #include <rte_errno.h> @@ -29,10 +30,154 @@#include "eal_private.h" +/* +* Track and log memory allocation information. +*/ +static void +rte_malloc_log (const char *type,size_t size,unsigned int align, +void *addr) +{ +struct rte_malloc_log *log; +struct malloc_elem *elem =malloc_elem_from_data (addr); +struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; + +if (!addr || !elem || !mcfg->malloc_log_max || + mcfg->malloc_log_max == mcfg->malloc_log_index) +return ; + + log = &mcfg->malloc_logs[mcfg->malloc_log_index]; +if (type) +strncpy (log->name, type,sizeof (log->name) -1 ); + log->size = size; + log->real_size = elem->size; + align = align ? align :1 ; + log->align =RTE_CACHE_LINE_ROUNDUP (align); + log->addr = addr; + log->socket = elem->heap->socket_id; + elem->log =1 ; + elem->log_index = mcfg->malloc_log_index++; +} + +/* +* track and log memory free +*/ +static void
lib/librte_eal/common/rte_malloc.c line 74
Quoted 10 lines
lib/librte_eal/common/rte_malloc.c +10
-0+rte_free_log(void *addr) +{ +struct rte_malloc_log *alloc_log; +struct rte_malloc_log *log; +struct malloc_elem *elem =malloc_elem_from_data (addr); +struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; + +if (!addr || !elem || !mcfg->malloc_log_max || + mcfg->malloc_log_max == mcfg->malloc_log_index) +return ;
This would still succeed when addr is invalid, because you don't do all of the checks that malloc_heap_free() does (you don't chec malloc cookies and ELEM_BUSY).
Quoted 15 lines
lib/librte_eal/common/rte_malloc.c +15
-0+ log = &mcfg->malloc_logs[mcfg->malloc_log_index++]; + log->addr = addr; + log->free =1 ; + log->real_size = elem->size; +if (elem->log) { + alloc_log = &mcfg->malloc_logs[elem->log_index]; +strncpy (log->name, alloc_log->name,sizeof (log->name)); + log->size = alloc_log->size; + log->align = alloc_log->align; + log->socket = alloc_log->socket; + log->alloc_free =1 ; + alloc_log->alloc_free =1 ; + } +} +
lib/librte_eal/common/rte_malloc.c line 99
Quoted 10 lines
lib/librte_eal/common/rte_malloc.c +10
-0+/* +* Initialize malloc tracking with max count of log entries +*/ +int +rte_malloc_log_init (int count) +{ +struct malloc_elem *elem; +int i; +struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; +struct rte_malloc_log *log;
Since your malloc elements can only hold 29 bit indices, you should check the count against that value.
Quoted 9 lines
lib/librte_eal/common/rte_malloc.c +9
-0+ +if (mcfg->malloc_log_max) { +/* release all logs. */ +for (i =0 ; i < mcfg->malloc_log_index; i++) { + log = &mcfg->malloc_logs[i]; +/* clear log info from malloc elem. */ +if (log->free || log->alloc_free) +continue ; + elem =malloc_elem_from_data (log->addr);
lib/librte_eal/common/rte_malloc.c line 118
Quoted 10 lines
lib/librte_eal/common/rte_malloc.c +10
-0+if (elem) { + elem->log =0 ; + elem->log_index =0 ; + } + } +rte_free (mcfg->malloc_logs); + mcfg->malloc_logs =NULL ; + mcfg->malloc_log_max =0 ; + mcfg->malloc_log_index =0 ; + }
I don't think immediately deallocating everything on a log_init call is a good idea. That's why you need stop() API :)
Quoted 101 lines
lib/librte_eal/common/rte_malloc.c +66
-1+if (count) { +/* allocate logs. */ + mcfg->malloc_logs =rte_calloc ("malloc_logs" , count, +sizeof (*log),0 ); +if (!mcfg->malloc_logs) +return -ENOMEM ; + mcfg->malloc_log_max = count; + } +return 0 ; +} + +/* +* Dump malloc tracking +*/ +void +rte_malloc_log_dump (FILE *out,int detail) +{ +struct rte_malloc_log *log; +int i; +int n_alloc_free =0 ; +int n_alloc =0 ; +int n_free_alloc =0 ; +int n_free =0 ; +struct rte_mem_config *mcfg =rte_eal_get_configuration ()->mem_config; + +if (!mcfg->malloc_log_max || !mcfg->malloc_logs) { +fprintf (out,"warning: malloc tracking log not enabled\n" ); +return ; + } +if (detail) +fprintf (out,"Socket Action Paired Address Size Align Mgmt Total Type\n" ); +for (i =0 ; i < mcfg->malloc_log_index; i++) { + log = &mcfg->malloc_logs[i]; +if (detail ==2 || + (detail ==1 && !log->alloc_free && !log->free)) +fprintf (out,"%6d %6s %6s %18p %7lu %5lu %4d %7lu %s\n" , + log->socket, + log->free ?"free" :"alloc" , + log->alloc_free ?"y" :"n" , + log->addr, log->size, log->align, +MALLOC_ELEM_OVERHEAD , + log->real_size, + log->name); +if (log->free) { + n_free++; +if (log->alloc_free) + n_free_alloc++; + }else { + n_alloc++; +if (log->alloc_free) + n_alloc_free++; + } + } +fprintf (out,"Total rte_malloc: %d/%d, rte_free:%d/%d\n" , + n_alloc_free, n_alloc, n_free_alloc, n_free); +} +/* Free the memory space back to heap */ void rte_free (void *addr) {if (addr ==NULL )return ; +rte_free_log (addr);if (malloc_heap_free (malloc_elem_from_data (addr)) <0 )RTE_LOG (ERR ,EAL ,"Error: Invalid memory\n" ); }@@ -44,6 +189,8 @@ void rte_free(void *addr) rte_malloc_socket(const char *type, size_t size, unsigned int align, int socket_arg) { + void *ret; +/* return NULL if size is 0 or alignment is not power-of-2 */ if (size ==0 || (align && !rte_is_power_of_2 (align)))return NULL ;@@ -57,8 +204,13 @@ void rte_free(void *addr) !rte_eal_has_hugepages()) socket_arg =SOCKET_ID_ANY ; -return malloc_heap_alloc (type, size, socket_arg,0 , + ret =malloc_heap_alloc (type, size, socket_arg,0 , align ==0 ?1 : align,0 , false); + +if (ret) +rte_malloc_log (type, size, align ==0 ?1 : align, ret); + +return ret; }/* lib/librte_eal/rte_eal_version.map +2
-0@@ -338,4 +338,6 @@ EXPERIMENTAL { # added in 20.05 rte_log_can_log; + rte_malloc_log_init; + rte_malloc_log_dump; };
Signature · 2 lines
Thanks, Anatoly
cover malloc: support malloc and free tracking log
In reply to Xueming LiDPDK uses second level memory allocation management, this makes regular memory profiler tool not applicant. This patch trys to provide a lightweight malloc and free logging, then show leaked memory entries based on logs.
This tool only target to malloc and free tracking, for memzone used by ring and mempool, "dump_memzone" in testpmd list them.
There will be another example that enable and dump tracking as secondary process.
This tool came from Mellanox internal Hackathon, thanks Shahaf Shuler <[email protected]> who provided the idea.
V0: initial version
V1: log rte_realloc function
rename log size to req_size, real_size to size(total) log padding and include padding in total size rename log "free" field to "type", alloc_free to "paired" rename malloc_log_index to malloc_log_count split testpmd part into separate patch
add rte_malloc_log_stop() function
add log entry number check
change log dump detail level from (-1,0,1) to (0,1,2)
Xueming Li (2):
malloc: support malloc and free tracking log app/testpmd: support malloc and free tracking log
app/test-pmd/cmdline.c | 60 ++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++ lib/librte_eal/common/eal_memcfg.h | 26 +++ lib/librte_eal/common/malloc_elem.h | 6 +- lib/librte_eal/common/rte_malloc.c | 259 +++++++++++++++++++++++++++- lib/librte_eal/include/rte_malloc.h | 39 ++++- lib/librte_eal/rte_eal_version.map | 3 + 7 files changed, 399 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/2 malloc: support malloc and free tracking log
This patch introduces new feature to track rte_malloc leakage by logging malloc and free.
--- lib/librte_eal/common/eal_memcfg.h | 26 ++++ lib/librte_eal/common/malloc_elem.h | 6 +- lib/librte_eal/common/rte_malloc.c | 259 +++++++++++++++++++++++++++++++++++- lib/librte_eal/include/rte_malloc.h | 39 +++++- lib/librte_eal/rte_eal_version.map | 3 + 5 files changed, 325 insertions(+), 8 deletions(-)
lib/librte_eal/common/eal_memcfg.h +26 -0
@@ -14,6 +14,28 @@#include "malloc_heap.h" + +enum rte_malloc_log_type { + rte_malloc_log_malloc, + rte_malloc_log_realloc, + rte_malloc_log_free, +}; + +/** +* Memory allocation and free tracking log +*/ +struct rte_malloc_log { +int socket; +void *addr; +size_t req_size;/* requested size */ +size_t size;/* outer element and pad */ +size_t align; +uint32_t pad; +uint32_t type:2 ;/* log entry type. */ +uint32_t paired:1 ;/* allocation and free both tracked. */ +char name[64 ];/* name may come from stack, copy. */ +}; +/** * Memory configuration shared across multiple processes. */
@@ -73,6 +95,10 @@ struct rte_mem_config {/**< TSC rate */ uint8_t dma_maskbits;/**< Keeps the more restricted dma mask. */ + +struct rte_malloc_log *malloc_logs;/**< Log entries. */ +int malloc_log_max;/**< Max number of logs to write. */ +int malloc_log_count;/**< count of logs written. */ };/* update internal config from shared mem config */
lib/librte_eal/common/malloc_elem.h +5 -1
@@ -9,6 +9,8 @@#define MIN_DATA_SIZE (RTE_CACHE_LINE_SIZE) +#define MALLOC_TRACKING_MAX (1 << 29) +/* dummy definition of struct so we can use pointers to it in malloc_elem struct */ struct malloc_heap ;
@@ -27,7 +29,9 @@ struct malloc_elem {LIST_ENTRY (malloc_elem) free_list;/**< list of free elements in heap */ struct rte_memseg_list *msl; -volatile enum elem_state state; + volatile uint32_t state:2; + volatile uint32_t log:1; /* Element logged. */ + volatile uint32_t log_index:29; /* Element log index. */uint32_t pad;size_t size;struct malloc_elem *orig_elem;
lib/librte_eal/common/rte_malloc.c +253 -6
304 lines not on this page · raw message
lib/librte_eal/include/rte_malloc.h +38 -1
@@ -508,7 +508,44 @@ struct rte_malloc_socket_stats {* to dump all objects. */ void -rte_malloc_dump_stats (FILE *f,const char *type); +rte_malloc_dump_stats (FILE *out,const char *type); + +/** +* Initialize malloc tracking log buffer. +* +* @param count +* Max count of tracking log entries, range (1 : 1 << 29) +* @return +* 0 on success, negative errno otherwise +*/ +__rte_experimental +int +rte_malloc_log_init (uint32_t count); + +/** +* Stop malloc tracking log. +* +* @return +* 0 on success, negative errno otherwise +*/ +__rte_experimental +int +rte_malloc_log_stop (void ); + +/** +* Dump malloc tracking log to output. +* +* @param out +* output file handle +* @param detail +* detail level of output +* 0: summary +* 1: potential leaks - allocated without free +* 2: all entries +*/ +__rte_experimental +void +rte_malloc_log_dump (FILE *out,uint32_t detail);/** * Dump contents of all malloc heaps to a file.
lib/librte_eal/rte_eal_version.map +3 -0
@@ -338,4 +338,7 @@ EXPERIMENTAL { # added in 20.05 rte_log_can_log; + rte_malloc_log_init; + rte_malloc_log_dump; + rte_malloc_log_stop; };
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v1 1/2] malloc: support malloc and free tracking log
lib/librte_eal/common/rte_malloc.c line 208
Quoted 5 lines · On Wed, 8 Apr 2020 04:04:53 +0000 Xueming Li <[email protected]> wrote:
int n_alloc_free = 0;lib/librte_eal/common/rte_malloc.c +4
-0+int n_alloc =0 ; +int n_free_alloc =0 ; +int n_free =0 ; +size_t alloc_leak =0 ;
All statistics should be unsigned, size_t or uint64_t to avoid any wraparound issues.
Re: [dpdk-dev] [PATCH v1 1/2] malloc: support malloc and free tracking log
In reply to Xueming Lilib/librte_eal/rte_eal_version.map EXPERIMENTAL { · line 344
Quoted 13 lines · On Wed, 8 Apr 2020 04:04:53 +0000 Xueming Li <[email protected]> wrote:
* Dump contents of all malloc heaps to a file.
lib/librte_eal/rte_eal_version.map +3
-0@@ -338,4 +338,7 @@ EXPERIMENTAL { # added in 20.05 rte_log_can_log; + rte_malloc_log_init; + rte_malloc_log_dump; + rte_malloc_log_stop; };
Looks like other entries were indented with tabs and you used spaces?
Re: [dpdk-dev] [PATCH v1 1/2] malloc: support malloc and free tracking log
Thanks for your suggestion, will include them in next version.
Quoted 28 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, April 8, 2020 1:12 PM
To: Xueming(Steven) Li <[email protected]>
Cc: Anatoly Burakov <[email protected]>; Ferruh Yigit <[email protected]>; [email protected]; Asaf Penso <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1 1/2] malloc: support malloc and free tracking logReview
Quoted 2 lines · On Wed, 8 Apr 2020 04:04:53 +0000 Xueming Li <[email protected]> wrote:
* Dump contents of all malloc heaps to a file.
(quoted diff) +0
-0b/lib/librte_eal/rte_eal_version.map
lib/librte_eal/rte_eal_version.map EXPERIMENTAL { · line 344
Quoted 11 lines
index f9ede5b..25c4b13 100644
lib/librte_eal/rte_eal_version.map +3
-0@@ -338,4 +338,7 @@ EXPERIMENTAL { # added in 20.05 rte_log_can_log; + rte_malloc_log_init; + rte_malloc_log_dump; + rte_malloc_log_stop; };Looks like other entries were indented with tabs and you used spaces?
PATCH 2/2 app/testpmd: support malloc and free tracking log
In reply to Xueming LiNew 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 leveldump_malloc stop: stop malloc tracking
--- app/test-pmd/cmdline.c | 60 ++++++++++++++++++++++++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++++++++ 2 files changed, 74 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +59 -1
@@ -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,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +15 -0
@@ -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 ~~~~~~~~~~~~
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [PATCH v1 2/2] app/testpmd: support malloc and free tracking log
Quoted 9 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xueming Li
Sent: Wednesday, April 8, 2020 5:05 AM
To: Burakov, Anatoly <[email protected]>; Yigit, Ferruh <[email protected]>
Cc: [email protected]; Asaf Penso <[email protected]>
Subject: [dpdk-dev] [PATCH v1 2/2] app/testpmd: support malloc and free tracking log
Quoted 7 lines
New CLI commands to manipulate malloc tracking log:
dump_mallocstart <n>: start malloc tracking with number of buffersdump_mallocdump <n>: dump mmalloc tracking log with detail leveldump_mallocstop: stop malloc trackingSigned-off-by Xueming Li <[email protected]>
v2 cover malloc: support malloc and free tracking log
In reply to Xueming LiDPDK uses second level memory allocation management, this makes regular memory profiler tool not applicant. This patch trys to provide a lightweight malloc and free logging, then show leaked memory entries based on logs.
This tool only target to malloc and free tracking, for memzone used by ring and mempool, "dump_memzone" in testpmd list them.
There will be another example that enable and dump tracking as secondary process.
This tool came from Mellanox internal Hackathon, thanks Shahaf Shuler <[email protected]> who provided the idea.
V0: initial version
V1: log rte_realloc function
rename log size to req_size, real_size to size(total) log padding and include padding in total size rename log "free" field to "type", alloc_free to "paired" rename malloc_log_index to malloc_log_count split testpmd part into separate patch
add rte_malloc_log_stop() function
add log entry number check
change log dump detail level from (-1,0,1) to (0,1,2)
V2: fix map file indent
change type of counter variables to unsigned fix CI error
Xueming Li (2):
malloc: support malloc and free tracking log app/testpmd: support malloc and free tracking log
app/test-pmd/cmdline.c | 60 ++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++ lib/librte_eal/common/eal_memcfg.h | 26 +++ lib/librte_eal/common/malloc_elem.h | 6 +- lib/librte_eal/common/rte_malloc.c | 261 +++++++++++++++++++++++++++- lib/librte_eal/include/rte_malloc.h | 39 ++++- lib/librte_eal/rte_eal_version.map | 3 + 7 files changed, 401 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.3.1
RFC v2 1/2 malloc: support malloc and free tracking log
This patch introduces new feature to track rte_malloc leakage by logging malloc and free.
--- lib/librte_eal/common/eal_memcfg.h | 26 ++++ lib/librte_eal/common/malloc_elem.h | 6 +- lib/librte_eal/common/rte_malloc.c | 261 +++++++++++++++++++++++++++++++++++- lib/librte_eal/include/rte_malloc.h | 39 +++++- lib/librte_eal/rte_eal_version.map | 3 + 5 files changed, 327 insertions(+), 8 deletions(-)
lib/librte_eal/common/eal_memcfg.h +26 -0
@@ -14,6 +14,28 @@#include "malloc_heap.h" + +enum rte_malloc_log_type { + rte_malloc_log_malloc, + rte_malloc_log_realloc, + rte_malloc_log_free, +}; + +/** +* Memory allocation and free tracking log +*/ +struct rte_malloc_log { +int socket; +void *addr; +size_t req_size;/* requested size */ +size_t size;/* outer element and pad */ +size_t align; +uint32_t pad; +uint32_t type:2 ;/* log entry type. */ +uint32_t paired:1 ;/* allocation and free both tracked. */ +char name[64 ];/* name may come from stack, copy. */ +}; +/** * Memory configuration shared across multiple processes. */
@@ -73,6 +95,10 @@ struct rte_mem_config {/**< TSC rate */ uint8_t dma_maskbits;/**< Keeps the more restricted dma mask. */ + +struct rte_malloc_log *malloc_logs;/**< Log entries. */ +int malloc_log_max;/**< Max number of logs to write. */ +int malloc_log_count;/**< count of logs written. */ };/* update internal config from shared mem config */
lib/librte_eal/common/malloc_elem.h +5 -1
@@ -9,6 +9,8 @@#define MIN_DATA_SIZE (RTE_CACHE_LINE_SIZE) +#define MALLOC_TRACKING_MAX (1 << 29) +/* dummy definition of struct so we can use pointers to it in malloc_elem struct */ struct malloc_heap ;
@@ -27,7 +29,9 @@ struct malloc_elem {LIST_ENTRY (malloc_elem) free_list;/**< list of free elements in heap */ struct rte_memseg_list *msl; -volatile enum elem_state state; + volatile uint32_t state:2; + volatile uint32_t log:1; /* Element logged. */ + volatile uint32_t log_index:29; /* Element log index. */uint32_t pad;size_t size;struct malloc_elem *orig_elem;
lib/librte_eal/common/rte_malloc.c +255 -6
306 lines not on this page · raw message
lib/librte_eal/include/rte_malloc.h +38 -1
@@ -508,7 +508,44 @@ struct rte_malloc_socket_stats {* to dump all objects. */ void -rte_malloc_dump_stats (FILE *f,const char *type); +rte_malloc_dump_stats (FILE *out,const char *type); + +/** +* Initialize malloc tracking log buffer. +* +* @param count +* Max count of tracking log entries, range (1 : 1 << 29) +* @return +* 0 on success, negative errno otherwise +*/ +__rte_experimental +int +rte_malloc_log_init (uint32_t count); + +/** +* Stop malloc tracking log. +* +* @return +* 0 on success, negative errno otherwise +*/ +__rte_experimental +int +rte_malloc_log_stop (void ); + +/** +* Dump malloc tracking log to output. +* +* @param out +* output file handle +* @param detail +* detail level of output +* 0: summary +* 1: potential leaks - allocated without free +* 2: all entries +*/ +__rte_experimental +void +rte_malloc_log_dump (FILE *out,uint32_t detail);/** * Dump contents of all malloc heaps to a file.
lib/librte_eal/rte_eal_version.map +3 -0
@@ -338,4 +338,7 @@ EXPERIMENTAL { # added in 20.05 rte_log_can_log; + rte_malloc_log_init; + rte_malloc_log_dump; + rte_malloc_log_stop; };
Signature · 1 line
1.8.3.1
RFC v2 2/2 app/testpmd: support malloc and free tracking log
In reply to Xueming LiNew 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 leveldump_malloc stop: stop malloc tracking
--- app/test-pmd/cmdline.c | 60 ++++++++++++++++++++++++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++++++++ 2 files changed, 74 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +59 -1
@@ -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,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +15 -0
@@ -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 ~~~~~~~~~~~~
Signature · 1 line
1.8.3.1
Re: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free tracking log
Quoted 10 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xueming Li
Sent: Friday, April 17, 2020 9:04 AM
To: Burakov, Anatoly <[email protected]>; Yigit, Ferruh <[email protected]>; Stephen Hemminger <[email protected]>
Cc: [email protected]; Asaf Penso <[email protected]>
Subject: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free tracking log
Quoted 7 lines
New CLI commands to manipulate malloc tracking log:
dump_mallocstart <n>: start malloc tracking with number of buffersdump_mallocdump <n>: dump mmalloc tracking log with detail leveldump_mallocstop: stop malloc trackingSigned-off-by Xueming Li <[email protected]>
Re: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free tracking log
Quoted 13 lines · Bernard
Quoted 13 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xueming Li
Sent: Friday, April 17, 2020 9:04 AM
To: Burakov, Anatoly <[email protected]>; Yigit, Ferruh <[email protected]>; Stephen Hemminger <[email protected]>
Cc: [email protected]; Asaf Penso <[email protected]>
Subject: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free tracking logNew CLI commands to manipulate malloc tracking log:
Quoted 7 lines
Quoted 5 lines
dump_mallocstart <n>: start malloc tracking with number of buffersdump_mallocdump <n>: dump mmalloc tracking log with detail leveldump_mallocstop: stop malloc trackingSigned-off-by Xueming Li <[email protected]>
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
Re: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free tracking log
Hi Som,
Quoted 30 lines
-----Original Message-----
From: Somnath Kotur <[email protected]>
Sent: Thursday, July 30, 2020 11:10 PM
To: Iremonger, Bernard <[email protected]>
Cc: Xueming(Steven) Li <[email protected]>; Burakov, Anatoly <[email protected]>; Yigit, Ferruh <[email protected]>; Stephen Hemminger <[email protected]>; [email protected]; Asaf Penso <[email protected]>
Subject: Re: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free tracking logQuoted 17 lines · Bernard
Quoted 17 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xueming Li
Sent: Friday, April 17, 2020 9:04 AM
To: Burakov, Anatoly <[email protected]>; Yigit, Ferruh <[email protected]>; Stephen Hemminger <[email protected]>
Cc: [email protected]; Asaf Penso <[email protected]>
Subject: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free tracking logNew CLI commands to manipulate malloc tracking log:
dump_mallocstart <n>: start malloc tracking with number of buffersdump_mallocdump <n>: dump mmalloc tracking log with detail leveldump_mallocstop: stop malloc tracking
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Xueming Li <[email protected]>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.
Quoted 3 lines
Thanks
som
Re: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free tracking log
Quoted 37 lines · Xueming(Steven) Li
Hi Som,
Quoted 34 lines
-----Original Message-----
From: Somnath Kotur <[email protected]>
Sent: Thursday, July 30, 2020 11:10 PM
To: Iremonger, Bernard <[email protected]>
Cc: Xueming(Steven) Li <[email protected]>; Burakov, Anatoly <[email protected]>; Yigit, Ferruh <[email protected]>; Stephen Hemminger <[email protected]>; [email protected]; Asaf Penso <[email protected]>
Subject: Re: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free tracking logQuoted 20 lines · Bernard
Quoted 11 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Xueming Li
Sent: Friday, April 17, 2020 9:04 AM
To: Burakov, Anatoly <[email protected]>; Yigit, Ferruh <[email protected]>; Stephen Hemminger <[email protected]>
Cc: [email protected]; Asaf Penso <[email protected]>
Subject: [dpdk-dev] [RFC v2 2/2] app/testpmd: support malloc and free tracking logQuoted 7 lines
New CLI commands to manipulate malloc tracking log:
dump_mallocstart <n>: start malloc tracking with number of buffersdump_mallocdump <n>: dump mmalloc tracking log with detail leveldump_mallocstop: stop malloc trackingSigned-off-by Xueming Li <[email protected]>
Quoted 7 lines
Quoted 4 lines
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
Quoted 6 lines
Quoted 4 lines
Thanks
som