spdk_top: add rpc for scheduler and governor
Added rpc to get name and period of currently set spdk scheduler and name of currently set spdk governor. Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com> Change-Id: I5562a81a7f9e4879bd48a765c9467f70b43f73ab Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5917 Community-CI: Broadcom CI Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Maciej Szwed <maciej.szwed@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
8f7d9ec2f4
commit
abf52d7d7f
@ -727,6 +727,48 @@ Example response:
|
||||
}
|
||||
~~~
|
||||
|
||||
### framework_get_scheduler {#rpc_framework_get_scheduler}
|
||||
|
||||
Retrieve currently set scheduler name and period, along with current governor name.
|
||||
|
||||
### Parameters
|
||||
|
||||
This method has no parameters.
|
||||
|
||||
### Response
|
||||
|
||||
Name | Description
|
||||
------------------------| -----------
|
||||
scheduler_name | Current scheduler name
|
||||
scheduler_period | Currently set scheduler period in microseconds
|
||||
governor_name | Governor name
|
||||
|
||||
### Example
|
||||
|
||||
Example request:
|
||||
|
||||
~~~
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "framework_set_scheduler",
|
||||
"id": 1,
|
||||
}
|
||||
~~~
|
||||
|
||||
Example response:
|
||||
|
||||
~~~
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": {
|
||||
"scheduler name": "static",
|
||||
"scheduler period": 2800000000,
|
||||
"governor name": "default"
|
||||
}
|
||||
}
|
||||
~~~
|
||||
|
||||
## thread_get_stats {#rpc_thread_get_stats}
|
||||
|
||||
Retrieve current statistics of all the threads.
|
||||
|
@ -253,6 +253,12 @@ void _spdk_governor_list_add(struct spdk_governor *governor);
|
||||
*/
|
||||
int _spdk_governor_set(char *name);
|
||||
|
||||
/**
|
||||
* Get currently set governor.
|
||||
*
|
||||
*/
|
||||
struct spdk_governor *_spdk_governor_get(void);
|
||||
|
||||
/**
|
||||
* Macro used to register new cores governor.
|
||||
*/
|
||||
@ -320,6 +326,12 @@ void _spdk_scheduler_list_add(struct spdk_scheduler *scheduler);
|
||||
*/
|
||||
int _spdk_scheduler_set(char *name);
|
||||
|
||||
/**
|
||||
* Get currently set scheduler.
|
||||
*
|
||||
*/
|
||||
struct spdk_scheduler *_spdk_scheduler_get(void);
|
||||
|
||||
/**
|
||||
* Change current scheduling period.
|
||||
*
|
||||
@ -327,6 +339,11 @@ int _spdk_scheduler_set(char *name);
|
||||
*/
|
||||
void _spdk_scheduler_period_set(uint64_t period);
|
||||
|
||||
/**
|
||||
* Get period of currently set scheduler.
|
||||
*/
|
||||
uint64_t _spdk_scheduler_period_get(void);
|
||||
|
||||
/*
|
||||
* Macro used to register new reactor balancer.
|
||||
*/
|
||||
|
@ -480,6 +480,31 @@ end:
|
||||
}
|
||||
SPDK_RPC_REGISTER("framework_set_scheduler", rpc_framework_set_scheduler, SPDK_RPC_STARTUP)
|
||||
|
||||
static void
|
||||
rpc_framework_get_scheduler(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
struct spdk_json_write_ctx *w;
|
||||
struct spdk_scheduler *scheduler = _spdk_scheduler_get();
|
||||
uint64_t scheduler_period = _spdk_scheduler_period_get();
|
||||
struct spdk_governor *governor = _spdk_governor_get();
|
||||
|
||||
if (params) {
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
"'rpc_get_scheduler' requires no arguments");
|
||||
return;
|
||||
}
|
||||
|
||||
w = spdk_jsonrpc_begin_result(request);
|
||||
spdk_json_write_object_begin(w);
|
||||
spdk_json_write_named_string(w, "scheduler name", scheduler->name);
|
||||
spdk_json_write_named_uint64(w, "scheduler period", scheduler_period);
|
||||
spdk_json_write_named_string(w, "governor name", governor->name);
|
||||
spdk_json_write_object_end(w);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
SPDK_RPC_REGISTER("framework_get_scheduler", rpc_framework_get_scheduler, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_thread_set_cpumask_ctx {
|
||||
struct spdk_jsonrpc_request *request;
|
||||
struct spdk_cpuset cpumask;
|
||||
|
@ -132,6 +132,19 @@ _spdk_scheduler_set(char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct spdk_scheduler *
|
||||
_spdk_scheduler_get(void)
|
||||
{
|
||||
return g_scheduler;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
_spdk_scheduler_period_get(void)
|
||||
{
|
||||
/* Convert from ticks to microseconds */
|
||||
return (g_scheduler_period * SPDK_SEC_TO_USEC / spdk_get_ticks_hz());
|
||||
}
|
||||
|
||||
void
|
||||
_spdk_scheduler_period_set(uint64_t period)
|
||||
{
|
||||
@ -1250,6 +1263,12 @@ _spdk_governor_set(char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct spdk_governor *
|
||||
_spdk_governor_get(void)
|
||||
{
|
||||
return &g_governor;
|
||||
}
|
||||
|
||||
void
|
||||
_spdk_governor_list_add(struct spdk_governor *governor)
|
||||
{
|
||||
|
@ -168,6 +168,13 @@ if __name__ == "__main__":
|
||||
p.add_argument('-p', '--period', help="Scheduler period in microseconds", type=int)
|
||||
p.set_defaults(func=framework_set_scheduler)
|
||||
|
||||
def framework_get_scheduler(args):
|
||||
print_dict(rpc.app.framework_get_scheduler(args.client))
|
||||
|
||||
p = subparsers.add_parser(
|
||||
'framework_get_scheduler', help='Display currently set scheduler and its properties.')
|
||||
p.set_defaults(func=framework_get_scheduler)
|
||||
|
||||
# bdev
|
||||
def bdev_set_options(args):
|
||||
rpc.bdev.bdev_set_options(args.client,
|
||||
|
@ -52,6 +52,15 @@ def framework_set_scheduler(client, name, period=None):
|
||||
return client.call('framework_set_scheduler', params)
|
||||
|
||||
|
||||
def framework_get_scheduler(client):
|
||||
"""Query currently set scheduler.
|
||||
|
||||
Returns:
|
||||
Name, period (in microseconds) of currently set scheduler and name of curently set governor.
|
||||
"""
|
||||
return client.call('framework_get_scheduler')
|
||||
|
||||
|
||||
def thread_get_stats(client):
|
||||
"""Query threads statistics.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user