event: add scheduler_set RPC
Add RPC that allows to change scheduler at runtime. Change-Id: I008670f5e936bc25a0fbc923b826277d15343273 Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3958 Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
1b1e52cb47
commit
a2596f4dc2
@ -620,6 +620,46 @@ Example response:
|
||||
}
|
||||
~~~
|
||||
|
||||
## framework_set_scheduler {#rpc_framework_set_scheduler}
|
||||
|
||||
Select thread scheduler that will be activated.
|
||||
This feature is considered as experimental.
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Optional | Type | Description
|
||||
----------------------- | -------- | ----------- | -----------
|
||||
name | Required | string | Name of a scheduler
|
||||
|
||||
### Response
|
||||
|
||||
Completion status of the operation is returned as a boolean.
|
||||
|
||||
### Example
|
||||
|
||||
Example request:
|
||||
|
||||
~~~
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "framework_set_scheduler",
|
||||
"id": 1,
|
||||
"params": {
|
||||
"name": "static"
|
||||
}
|
||||
}
|
||||
~~~
|
||||
|
||||
Example response:
|
||||
|
||||
~~~
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": true
|
||||
}
|
||||
~~~
|
||||
|
||||
## thread_get_stats {#rpc_thread_get_stats}
|
||||
|
||||
Retrieve current statistics of all the threads.
|
||||
|
@ -433,6 +433,53 @@ rpc_framework_get_reactors(struct spdk_jsonrpc_request *request,
|
||||
|
||||
SPDK_RPC_REGISTER("framework_get_reactors", rpc_framework_get_reactors, SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_set_scheduler_ctx {
|
||||
char *name;
|
||||
};
|
||||
|
||||
static void
|
||||
free_rpc_framework_set_scheduler(struct rpc_set_scheduler_ctx *r)
|
||||
{
|
||||
free(r->name);
|
||||
}
|
||||
|
||||
static const struct spdk_json_object_decoder rpc_set_scheduler_decoders[] = {
|
||||
{"name", offsetof(struct rpc_set_scheduler_ctx, name), spdk_json_decode_string},
|
||||
};
|
||||
|
||||
static void
|
||||
rpc_framework_set_scheduler(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
struct rpc_set_scheduler_ctx req = {NULL};
|
||||
struct spdk_json_write_ctx *w;
|
||||
int ret;
|
||||
|
||||
ret = spdk_json_decode_object(params, rpc_set_scheduler_decoders,
|
||||
SPDK_COUNTOF(rpc_set_scheduler_decoders),
|
||||
&req);
|
||||
if (ret) {
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
"Invalid parameters");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = _spdk_scheduler_set(req.name);
|
||||
if (ret) {
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
|
||||
spdk_strerror(ret));
|
||||
goto end;
|
||||
}
|
||||
|
||||
w = spdk_jsonrpc_begin_result(request);
|
||||
spdk_json_write_bool(w, true);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
|
||||
end:
|
||||
free_rpc_framework_set_scheduler(&req);
|
||||
}
|
||||
SPDK_RPC_REGISTER("framework_set_scheduler", rpc_framework_set_scheduler, SPDK_RPC_STARTUP)
|
||||
|
||||
struct rpc_thread_set_cpumask_ctx {
|
||||
struct spdk_jsonrpc_request *request;
|
||||
struct spdk_cpuset cpumask;
|
||||
|
@ -157,6 +157,15 @@ if __name__ == "__main__":
|
||||
'framework_get_reactors', help='Display list of all reactors')
|
||||
p.set_defaults(func=framework_get_reactors)
|
||||
|
||||
def framework_set_scheduler(args):
|
||||
rpc.app.framework_set_scheduler(args.client,
|
||||
name=args.name)
|
||||
|
||||
p = subparsers.add_parser(
|
||||
'framework_set_scheduler', help='Select thread scheduler that will be activated (experimental)')
|
||||
p.add_argument('name', help="Name of a scheduler")
|
||||
p.set_defaults(func=framework_set_scheduler)
|
||||
|
||||
# bdev
|
||||
def bdev_set_options(args):
|
||||
rpc.bdev.bdev_set_options(args.client,
|
||||
|
@ -37,6 +37,18 @@ def framework_get_reactors(client):
|
||||
return client.call('framework_get_reactors')
|
||||
|
||||
|
||||
def framework_set_scheduler(client, name):
|
||||
"""Select threads scheduler that will be activated.
|
||||
|
||||
Args:
|
||||
name: Name of a scheduler
|
||||
Returns:
|
||||
True or False
|
||||
"""
|
||||
params = {'name': name}
|
||||
return client.call('framework_set_scheduler', params)
|
||||
|
||||
|
||||
def thread_get_stats(client):
|
||||
"""Query threads statistics.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user