diff options
author | Damjan Marion <damarion@cisco.com> | 2020-09-16 21:15:44 +0200 |
---|---|---|
committer | Damjan Marion <damarion@cisco.com> | 2020-09-16 21:19:51 +0200 |
commit | 57d1ec00a953620ff59242db07c369843bb16820 (patch) | |
tree | 7badde39e261f24c7a69221a87843a9acf030413 /src/vlib | |
parent | 33ce5e568f8b4fb1254bf5ee32865e9443c0185a (diff) |
vppinfra: introduce clib_mem_main
To hold more data later...
Type: improvement
Change-Id: I4006d22dcacd788988c4907f2c263fd4e4a9d398
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib')
-rw-r--r-- | src/vlib/cli.c | 24 | ||||
-rw-r--r-- | src/vlib/threads.c | 7 |
2 files changed, 17 insertions, 14 deletions
diff --git a/src/vlib/cli.c b/src/vlib/cli.c index 2697c0ae083..2bdc98c71ca 100644 --- a/src/vlib/cli.c +++ b/src/vlib/cli.c @@ -739,6 +739,7 @@ static clib_error_t * show_memory_usage (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { + clib_mem_main_t *mm = &clib_mem_main; int verbose __attribute__ ((unused)) = 0; int api_segment = 0, stats_segment = 0, main_heap = 0, numa_heaps = 0; clib_error_t *error; @@ -826,7 +827,7 @@ show_memory_usage (vlib_main_t * vm, ({ struct dlmallinfo mi; void *mspace; - mspace = clib_per_cpu_mheaps[index]; + mspace = mm->per_cpu_mheaps[index]; mi = mspace_mallinfo (mspace); vlib_cli_output (vm, "%sThread %d %s\n", index ? "\n":"", index, @@ -835,7 +836,7 @@ show_memory_usage (vlib_main_t * vm, pointer_to_uword (mspace_least_addr(mspace)), mi.arena); vlib_cli_output (vm, " %U\n", format_mheap, - clib_per_cpu_mheaps[index], + mm->per_cpu_mheaps[index], verbose); index++; })); @@ -849,17 +850,17 @@ show_memory_usage (vlib_main_t * vm, struct dlmallinfo mi; void *mspace; - for (i = 0; i < ARRAY_LEN (clib_per_numa_mheaps); i++) + for (i = 0; i < ARRAY_LEN (mm->per_numa_mheaps); i++) { - if (clib_per_numa_mheaps[i] == 0) + if (mm->per_numa_mheaps[i] == 0) continue; - if (clib_per_numa_mheaps[i] == clib_per_cpu_mheaps[i]) + if (mm->per_numa_mheaps[i] == mm->per_cpu_mheaps[i]) { vlib_cli_output (vm, "Numa %d uses the main heap...", i); continue; } was_enabled = clib_mem_trace_enable_disable (0); - mspace = clib_per_numa_mheaps[i]; + mspace = mm->per_numa_mheaps[i]; mi = mspace_mallinfo (mspace); vlib_cli_output (vm, "Numa %d:", i); @@ -867,7 +868,7 @@ show_memory_usage (vlib_main_t * vm, pointer_to_uword (mspace_least_addr (mspace)), mi.arena); vlib_cli_output (vm, " %U\n", format_mheap, - clib_per_numa_mheaps[index], verbose); + mm->per_numa_mheaps[index], verbose); } } } @@ -921,6 +922,7 @@ enable_disable_memory_trace (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { + clib_mem_main_t *mm = &clib_mem_main; unformat_input_t _line_input, *line_input = &_line_input; int enable = 1; int api_segment = 0; @@ -1003,15 +1005,15 @@ enable_disable_memory_trace (vlib_main_t * vm, if (numa_id != ~0) { - if (numa_id >= ARRAY_LEN (clib_per_numa_mheaps)) + if (numa_id >= ARRAY_LEN (mm->per_numa_mheaps)) return clib_error_return (0, "Numa %d out of range", numa_id); - if (clib_per_numa_mheaps[numa_id] == 0) + if (mm->per_numa_mheaps[numa_id] == 0) return clib_error_return (0, "Numa %d heap not active", numa_id); - if (clib_per_numa_mheaps[numa_id] == clib_mem_get_heap ()) + if (mm->per_numa_mheaps[numa_id] == clib_mem_get_heap ()) return clib_error_return (0, "Numa %d uses the main heap...", numa_id); - current_traced_heap = clib_per_numa_mheaps[numa_id]; + current_traced_heap = mm->per_numa_mheaps[numa_id]; oldheap = clib_mem_set_heap (current_traced_heap); clib_mem_trace (1); clib_mem_set_heap (oldheap); diff --git a/src/vlib/threads.c b/src/vlib/threads.c index d5096c8cd18..c2ac4a1b389 100644 --- a/src/vlib/threads.c +++ b/src/vlib/threads.c @@ -626,6 +626,7 @@ vlib_get_thread_core_numa (vlib_worker_thread_t * w, unsigned cpu_id) static clib_error_t * vlib_launch_thread_int (void *fp, vlib_worker_thread_t * w, unsigned cpu_id) { + clib_mem_main_t *mm = &clib_mem_main; vlib_thread_main_t *tm = &vlib_thread_main; void *(*fp_arg) (void *) = fp; void *numa_heap; @@ -634,19 +635,19 @@ vlib_launch_thread_int (void *fp, vlib_worker_thread_t * w, unsigned cpu_id) vlib_get_thread_core_numa (w, cpu_id); /* Set up NUMA-bound heap if indicated */ - if (clib_per_numa_mheaps[w->numa_id] == 0) + if (mm->per_numa_mheaps[w->numa_id] == 0) { /* If the user requested a NUMA heap, create it... */ if (tm->numa_heap_size) { numa_heap = clib_mem_init_thread_safe_numa (0 /* DIY */ , tm->numa_heap_size, w->numa_id); - clib_per_numa_mheaps[w->numa_id] = numa_heap; + mm->per_numa_mheaps[w->numa_id] = numa_heap; } else { /* Or, use the main heap */ - clib_per_numa_mheaps[w->numa_id] = w->thread_mheap; + mm->per_numa_mheaps[w->numa_id] = w->thread_mheap; } } |