spdk_top: add data structures and functions for scheduler and governor

Added data structure to hold scheduler name,
scheduler period and governor name.
Implemented functions to get data from rpc and free memory after use.

Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Change-Id: I83108e29b9b80415c276d3592cb78ec3eaf9aeb9
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5944
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Maciej Szwed <maciej.szwed@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Krzysztof Karas 2021-01-15 17:14:16 +01:00 committed by Jim Harris
parent 635d0cbe75
commit 07e3c34f79

View File

@ -268,9 +268,16 @@ struct rpc_core_info {
struct rpc_core_threads threads;
};
struct rpc_scheduler {
char *scheduler_name;
uint64_t scheduler_period;
char *governor_name;
};
struct rpc_thread_info g_threads_info[RPC_MAX_THREADS];
struct rpc_poller_info g_pollers_info[RPC_MAX_POLLERS];
struct rpc_core_info g_cores_info[RPC_MAX_CORES];
struct rpc_scheduler g_scheduler_info;
static void
init_str_len(void)
@ -553,6 +560,18 @@ end:
return rc;
}
static void
free_rpc_scheduler(struct rpc_scheduler *req)
{
free(req->scheduler_name);
free(req->governor_name);
}
static const struct spdk_json_object_decoder rpc_scheduler_decoders[] = {
{"scheduler_name", offsetof(struct rpc_scheduler, scheduler_name), spdk_json_decode_string},
{"scheduler_period", offsetof(struct rpc_scheduler, scheduler_period), spdk_json_decode_uint64},
};
static int
rpc_send_req(char *rpc_name, struct spdk_jsonrpc_client_response **resp)
{
@ -1079,6 +1098,35 @@ end:
return rc;
}
static int
get_scheduler_data(void)
{
struct spdk_jsonrpc_client_response *json_resp = NULL;
struct rpc_scheduler scheduler_info;
int rc = 0;
rc = rpc_send_req("framework_get_scheduler", &json_resp);
if (rc) {
return rc;
}
memset(&scheduler_info, 0, sizeof(scheduler_info));
if (spdk_json_decode_object(json_resp->result, rpc_scheduler_decoders,
SPDK_COUNTOF(rpc_scheduler_decoders), &scheduler_info)) {
rc = -EINVAL;
} else {
pthread_mutex_lock(&g_thread_lock);
free_rpc_scheduler(&g_scheduler_info);
memcpy(&g_scheduler_info, &scheduler_info, sizeof(struct rpc_scheduler));
pthread_mutex_unlock(&g_thread_lock);
}
spdk_jsonrpc_client_free_response(json_resp);
return rc;
}
enum str_alignment {
ALIGN_LEFT,
ALIGN_RIGHT,
@ -2632,6 +2680,10 @@ data_thread_routine(void *arg)
if (rc) {
print_bottom_message("ERROR occurred while getting pollers data");
}
rc = get_scheduler_data();
if (rc) {
print_bottom_message("ERROR occurred while getting scheduler data");
}
usleep(g_sleep_time * SPDK_SEC_TO_USEC);
}
@ -2881,6 +2933,7 @@ show_stats(pthread_t *data_thread)
free_rpc_threads_stats(&g_threads_info[i]);
}
free_rpc_core_info(g_cores_info, g_last_cores_count);
free_rpc_scheduler(&g_scheduler_info);
}
static void