From 78d7ce3c901800fad6e2b759ca4c4bb3586a914b Mon Sep 17 00:00:00 2001 From: Andreas Economides Date: Thu, 22 Jul 2021 10:55:30 +0000 Subject: [PATCH] spdk_top: fix sorting when total data is displayed Even when g_interval_data was false, all three sorting functions would still use interval data. Signed-off-by: Andreas Economides Change-Id: I4650fd0bd8581e13a79cdf1dc972fdcada86afc4 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8959 Reviewed-by: Tomasz Zawadzki Reviewed-by: Ben Walker Reviewed-by: Krzysztof Karas Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot --- app/spdk_top/spdk_top.c | 48 ++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/app/spdk_top/spdk_top.c b/app/spdk_top/spdk_top.c index 00d55b659..f53dd5fba 100644 --- a/app/spdk_top/spdk_top.c +++ b/app/spdk_top/spdk_top.c @@ -583,12 +583,22 @@ sort_threads(const void *p1, const void *p2) count2 = thread_info2.paused_pollers_count; break; case 5: /* Sort by idle time */ - count1 = thread_info1.idle - thread_info1.last_idle; - count2 = thread_info2.idle - thread_info2.last_idle; + if (g_interval_data) { + count1 = thread_info1.idle - thread_info1.last_idle; + count2 = thread_info2.idle - thread_info2.last_idle; + } else { + count1 = thread_info1.idle; + count2 = thread_info2.idle; + } break; case 6: /* Sort by busy time */ - count1 = thread_info1.busy - thread_info1.last_busy; - count2 = thread_info2.busy - thread_info2.last_busy; + if (g_interval_data) { + count1 = thread_info1.busy - thread_info1.last_busy; + count2 = thread_info2.busy - thread_info2.last_busy; + } else { + count1 = thread_info1.busy; + count2 = thread_info2.busy; + } break; default: return 0; @@ -753,7 +763,6 @@ sort_pollers(const void *p1, const void *p2, void *arg) const struct rpc_poller_info *poller2 = (struct rpc_poller_info *)p2; enum sort_type sorting = *(enum sort_type *)arg; uint64_t count1, count2; - uint64_t last_run_counter; if (sorting == BY_NAME) { /* Sorting by name requested explicitly */ @@ -768,10 +777,13 @@ sort_pollers(const void *p1, const void *p2, void *arg) case 2: /* Sort by thread */ return strcmp(poller1->thread_name, poller2->thread_name); case 3: /* Sort by run counter */ - last_run_counter = get_last_run_counter(poller1->name, poller1->thread_id); - count1 = poller1->run_count - last_run_counter; - last_run_counter = get_last_run_counter(poller2->name, poller2->thread_id); - count2 = poller2->run_count - last_run_counter; + if (g_interval_data) { + count1 = poller1->run_count - get_last_run_counter(poller1->name, poller1->thread_id); + count2 = poller2->run_count - get_last_run_counter(poller2->name, poller2->thread_id); + } else { + count1 = poller1->run_count; + count2 = poller2->run_count; + } break; case 4: /* Sort by period */ count1 = poller1->period_ticks; @@ -868,12 +880,22 @@ sort_cores(const void *p1, const void *p2) count2 = core_info2.pollers_count; break; case 3: /* Sort by idle time */ - count1 = core_info1.last_idle - core_info1.idle; - count2 = core_info1.last_idle - core_info2.idle; + if (g_interval_data) { + count1 = core_info1.last_idle - core_info1.idle; + count2 = core_info2.last_idle - core_info2.idle; + } else { + count1 = core_info1.idle; + count2 = core_info2.idle; + } break; case 4: /* Sort by busy time */ - count1 = core_info1.last_busy - core_info1.busy; - count2 = core_info1.last_busy - core_info2.busy; + if (g_interval_data) { + count1 = core_info1.last_busy - core_info1.busy; + count2 = core_info2.last_busy - core_info2.busy; + } else { + count1 = core_info1.busy; + count2 = core_info2.busy; + } break; default: return 0;