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 <andreas.economides@nutanix.com>
Change-Id: I4650fd0bd8581e13a79cdf1dc972fdcada86afc4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8959
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Andreas Economides 2021-07-22 10:55:30 +00:00 committed by Jim Harris
parent a746dd6e60
commit 78d7ce3c90

View File

@ -583,12 +583,22 @@ sort_threads(const void *p1, const void *p2)
count2 = thread_info2.paused_pollers_count; count2 = thread_info2.paused_pollers_count;
break; break;
case 5: /* Sort by idle time */ case 5: /* Sort by idle time */
count1 = thread_info1.idle - thread_info1.last_idle; if (g_interval_data) {
count2 = thread_info2.idle - thread_info2.last_idle; 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; break;
case 6: /* Sort by busy time */ case 6: /* Sort by busy time */
count1 = thread_info1.busy - thread_info1.last_busy; if (g_interval_data) {
count2 = thread_info2.busy - thread_info2.last_busy; 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; break;
default: default:
return 0; 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; const struct rpc_poller_info *poller2 = (struct rpc_poller_info *)p2;
enum sort_type sorting = *(enum sort_type *)arg; enum sort_type sorting = *(enum sort_type *)arg;
uint64_t count1, count2; uint64_t count1, count2;
uint64_t last_run_counter;
if (sorting == BY_NAME) { if (sorting == BY_NAME) {
/* Sorting by name requested explicitly */ /* Sorting by name requested explicitly */
@ -768,10 +777,13 @@ sort_pollers(const void *p1, const void *p2, void *arg)
case 2: /* Sort by thread */ case 2: /* Sort by thread */
return strcmp(poller1->thread_name, poller2->thread_name); return strcmp(poller1->thread_name, poller2->thread_name);
case 3: /* Sort by run counter */ case 3: /* Sort by run counter */
last_run_counter = get_last_run_counter(poller1->name, poller1->thread_id); if (g_interval_data) {
count1 = poller1->run_count - last_run_counter; count1 = poller1->run_count - get_last_run_counter(poller1->name, poller1->thread_id);
last_run_counter = get_last_run_counter(poller2->name, poller2->thread_id); count2 = poller2->run_count - get_last_run_counter(poller2->name, poller2->thread_id);
count2 = poller2->run_count - last_run_counter; } else {
count1 = poller1->run_count;
count2 = poller2->run_count;
}
break; break;
case 4: /* Sort by period */ case 4: /* Sort by period */
count1 = poller1->period_ticks; count1 = poller1->period_ticks;
@ -868,12 +880,22 @@ sort_cores(const void *p1, const void *p2)
count2 = core_info2.pollers_count; count2 = core_info2.pollers_count;
break; break;
case 3: /* Sort by idle time */ case 3: /* Sort by idle time */
count1 = core_info1.last_idle - core_info1.idle; if (g_interval_data) {
count2 = core_info1.last_idle - core_info2.idle; 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; break;
case 4: /* Sort by busy time */ case 4: /* Sort by busy time */
count1 = core_info1.last_busy - core_info1.busy; if (g_interval_data) {
count2 = core_info1.last_busy - core_info2.busy; 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; break;
default: default:
return 0; return 0;