From e9af400888051fd474217214d2925097933314ec Mon Sep 17 00:00:00 2001 From: Krzysztof Karas Date: Fri, 21 May 2021 08:39:15 +0200 Subject: [PATCH] spdk_top: change where g_last_pollers_count is set The goal of this patch is to set g_last_pollers_count earlier than it was originally done to allocate less memory for pollers array in refresh_pollers_tab(), which is done in the next patch. Signed-off-by: Krzysztof Karas Change-Id: Id403af9b1c510abd7b6a1ac1742076590b1b37d7 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7992 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- app/spdk_top/spdk_top.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/spdk_top/spdk_top.c b/app/spdk_top/spdk_top.c index 93ba2e1a1..0b5217eed 100644 --- a/app/spdk_top/spdk_top.c +++ b/app/spdk_top/spdk_top.c @@ -627,6 +627,7 @@ get_data(void) struct rpc_pollers *pollers; struct rpc_poller_info *poller; uint64_t i, j, k; + uint64_t pollers_count = 0; int rc = 0; rc = rpc_send_req("thread_get_stats", &json_resp); @@ -670,17 +671,23 @@ get_data(void) poller = &pollers->pollers[j]; store_last_run_counter(poller->name, poller->thread_id, poller->run_count); } + pollers_count += pollers->pollers_count; + pollers = &g_pollers_stats.pollers_threads.threads[i].timed_pollers; for (j = 0; j < pollers->pollers_count; j++) { poller = &pollers->pollers[j]; store_last_run_counter(poller->name, poller->thread_id, poller->run_count); } + pollers_count += pollers->pollers_count; + pollers = &g_pollers_stats.pollers_threads.threads[i].paused_pollers; for (j = 0; j < pollers->pollers_count; j++) { poller = &pollers->pollers[j]; store_last_run_counter(poller->name, poller->thread_id, poller->run_count); } + pollers_count += pollers->pollers_count; } + g_last_pollers_count = pollers_count; /* Free old pollers values before allocating memory for new ones */ free_rpc_pollers_stats(&g_pollers_stats); @@ -1191,8 +1198,6 @@ refresh_pollers_tab(uint8_t current_page) } } - g_last_pollers_count = count; - /* We need to run store_last_run_counter() again, so the easiest way is to call this function * again with changed g_last_page value */ g_last_page = 0xF;