From 49bc3005f528cfcdfa4eac98e3d328a4f7843a9d Mon Sep 17 00:00:00 2001 From: Krzysztof Karas Date: Wed, 19 May 2021 12:25:08 +0200 Subject: [PATCH] spdk_top: move store_last_run_counter() function Moves store_last_run_counter() function to allow next patch to call it earlier in the code, inside get_data() function. Signed-off-by: Krzysztof Karas Change-Id: I1e37080ec86309bbf33442fa12cbe9dc575cc864 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7950 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Tomasz Zawadzki Reviewed-by: Paul Luse Reviewed-by: Aleksey Marchuk --- app/spdk_top/spdk_top.c | 48 ++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/app/spdk_top/spdk_top.c b/app/spdk_top/spdk_top.c index 969d02844..1235e8c7e 100644 --- a/app/spdk_top/spdk_top.c +++ b/app/spdk_top/spdk_top.c @@ -592,6 +592,30 @@ sort_threads(const void *p1, const void *p2) } } +static void +store_last_run_counter(const char *poller_name, uint64_t thread_id, uint64_t last_run_counter) +{ + struct run_counter_history *history; + + TAILQ_FOREACH(history, &g_run_counter_history, link) { + if (!strcmp(history->poller_name, poller_name) && history->thread_id == thread_id) { + history->last_run_counter = last_run_counter; + return; + } + } + + history = calloc(1, sizeof(*history)); + if (history == NULL) { + fprintf(stderr, "Unable to allocate a history object in store_last_run_counter.\n"); + return; + } + history->poller_name = strdup(poller_name); + history->thread_id = thread_id; + history->last_run_counter = last_run_counter; + + TAILQ_INSERT_TAIL(&g_run_counter_history, history, link); +} + static int get_data(void) { @@ -995,30 +1019,6 @@ get_last_run_counter(const char *poller_name, uint64_t thread_id) return NULL; } -static void -store_last_run_counter(const char *poller_name, uint64_t thread_id, uint64_t last_run_counter) -{ - struct run_counter_history *history; - - TAILQ_FOREACH(history, &g_run_counter_history, link) { - if (!strcmp(history->poller_name, poller_name) && history->thread_id == thread_id) { - history->last_run_counter = last_run_counter; - return; - } - } - - history = calloc(1, sizeof(*history)); - if (history == NULL) { - fprintf(stderr, "Unable to allocate a history object in store_last_run_counter.\n"); - return; - } - history->poller_name = strdup(poller_name); - history->thread_id = thread_id; - history->last_run_counter = last_run_counter; - - TAILQ_INSERT_TAIL(&g_run_counter_history, history, link); -} - enum sort_type { BY_NAME, USE_GLOBAL,