Skip to content

Commit

Permalink
Added Struct filter to mm_print_memory_usage() fn
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinites committed Feb 16, 2020
1 parent bf79134 commit ef32ed0
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
9 changes: 8 additions & 1 deletion LinuxMemoryManager/mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ mm_print_vm_page_details(vm_page_t *vm_page, uint32_t i){
}

void
mm_print_memory_usage(){
mm_print_memory_usage(char *struct_name){

uint32_t i = 0;
vm_page_t *vm_page = NULL;
Expand All @@ -538,6 +538,13 @@ mm_print_memory_usage(){

ITERATE_PAGE_FAMILIES_BEGIN(first_vm_page_family, vm_page_family_curr){

if(struct_name){
if(strncmp(struct_name, vm_page_family_curr->struct_name,
strlen(vm_page_family_curr->struct_name))){
continue;
}
}

number_of_struct_families++;

printf(ANSI_COLOR_GREEN "vm_page_family : %s, struct size = %u\n"
Expand Down
2 changes: 1 addition & 1 deletion LinuxMemoryManager/uapi_mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void
xfree(void *app_ptr);

/*Printing Functions*/
void mm_print_memory_usage();
void mm_print_memory_usage(char *struct_name);
void mm_print_block_usage();

/*Initialization Functions*/
Expand Down
2 changes: 2 additions & 0 deletions spfcmdcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,6 @@
#define CMDCODE_CONFIG_NODE_TILFA_ENABLE 113 /*config node <node-name> source-packet-routing use-post-convergence-paths*/
#define CMDCODE_DEBUG_TRACEOPTIONS_TILFA 114 /*config debug set trace tilfa*/
#define CMDCODE_DEBUG_SHOW_MEMORY_USAGE 115 /*debug show mem-usage*/
#define CMDCODE_DEBUG_SHOW_MEMORY_USAGE_DETAIL 116 /*debug show mem-usage detail*/

#endif /* __SPFCMDCODES__H */
35 changes: 33 additions & 2 deletions spfdcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,27 @@ validate_metric_value(char *value_passed){
static int
display_mem_usage(param_t *param, ser_buff_t *tlv_buf,
op_mode enable_or_disable){

tlv_struct_t *tlv = NULL;
char *struct_name = NULL;
int cmdcode = EXTRACT_CMD_CODE(tlv_buf);

TLV_LOOP_BEGIN(tlv_buf, tlv){

mm_print_memory_usage();
mm_print_block_usage();
if(strncmp(tlv->leaf_id, "struct-name", strlen("struct-name")) == 0)
struct_name = tlv->value;
} TLV_LOOP_END;

switch(cmdcode){
case CMDCODE_DEBUG_SHOW_MEMORY_USAGE:
mm_print_block_usage();
break;
case CMDCODE_DEBUG_SHOW_MEMORY_USAGE_DETAIL:
mm_print_memory_usage(struct_name);
break;
default:
;
}
}

static int
Expand Down Expand Up @@ -2021,6 +2039,19 @@ spf_init_dcm(){
init_param(&mem_usage, CMD, "mem-usage", display_mem_usage, 0, INVALID, 0, "Memory Usage");
libcli_register_param(debug_show, &mem_usage);
set_param_cmd_code(&mem_usage, CMDCODE_DEBUG_SHOW_MEMORY_USAGE);
{
/*debug show mem-usage detail*/
static param_t detail;
init_param(&detail, CMD, "detail", display_mem_usage, 0, INVALID, 0, "Memory Usage Detail");
libcli_register_param(&mem_usage, &detail);
set_param_cmd_code(&detail, CMDCODE_DEBUG_SHOW_MEMORY_USAGE_DETAIL);
{
static param_t struct_name;
init_param(&struct_name, LEAF, 0, display_mem_usage, 0, STRING, "struct-name", "Structure Name Filter");
libcli_register_param(&detail, &struct_name);
set_param_cmd_code(&struct_name, CMDCODE_DEBUG_SHOW_MEMORY_USAGE_DETAIL);
}
}
}
/*debug show log-status*/
{
Expand Down
4 changes: 2 additions & 2 deletions testapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ main(int argc, char **argv){
//instance = tilfa_topo_one_hop_test();
//instance = tilfa_topo_p_q_distance_1();
//instance = tilfa_topo_page_408_node_protection();
//instance = tilfa_topo_2_adj_segment_example();
instance = tilfa_ecmp_topology();
instance = tilfa_topo_2_adj_segment_example();
//instance = tilfa_ecmp_topology();
start_shell();
return 0;
}

0 comments on commit ef32ed0

Please sign in to comment.