RPC: rename context_switch_monitor to framework_monitor_context_switch

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I6de7bf824b5f57e535168afaafca55f4c758fc94
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468667
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Maciej Wawryk 2019-09-18 10:12:48 +02:00 committed by Jim Harris
parent fb3918a0ca
commit a10d0ce79c
6 changed files with 33 additions and 29 deletions

View File

@ -91,7 +91,7 @@ Example response:
} }
~~~ ~~~
## context_switch_monitor {#rpc_context_switch_monitor} ## framework_monitor_context_switch {#rpc_framework_monitor_context_switch}
Query, enable, or disable the context switch monitoring functionality. Query, enable, or disable the context switch monitoring functionality.
@ -115,7 +115,7 @@ Example request:
{ {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"id": 1, "id": 1,
"method": "context_switch_monitor", "method": "framework_monitor_context_switch",
"params": { "params": {
"enabled": false "enabled": false
} }
@ -277,7 +277,7 @@ Example response:
"bdev_get_iostat", "bdev_get_iostat",
"get_subsystem_config", "get_subsystem_config",
"get_subsystems", "get_subsystems",
"context_switch_monitor", "framework_monitor_context_switch",
"spdk_kill_instance", "spdk_kill_instance",
"ioat_scan_copy_engine", "ioat_scan_copy_engine",
"bdev_virtio_attach_controller", "bdev_virtio_attach_controller",

View File

@ -296,14 +296,14 @@ void spdk_event_call(struct spdk_event *event);
* *
* \param enabled True to enable, false to disable. * \param enabled True to enable, false to disable.
*/ */
void spdk_reactor_enable_context_switch_monitor(bool enabled); void spdk_reactor_enable_framework_monitor_context_switch(bool enabled);
/** /**
* Return whether context switch monitoring is enabled. * Return whether context switch monitoring is enabled.
* *
* \return true if enabled or false otherwise. * \return true if enabled or false otherwise.
*/ */
bool spdk_reactor_context_switch_monitor_enabled(void); bool spdk_reactor_framework_monitor_context_switch_enabled(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -87,7 +87,7 @@ static struct spdk_reactor *g_reactors;
static struct spdk_cpuset *g_reactor_core_mask; static struct spdk_cpuset *g_reactor_core_mask;
static enum spdk_reactor_state g_reactor_state = SPDK_REACTOR_STATE_INVALID; static enum spdk_reactor_state g_reactor_state = SPDK_REACTOR_STATE_INVALID;
static bool g_context_switch_monitor_enabled = true; static bool g_framework_monitor_context_switch_enabled = true;
static struct spdk_mempool *g_spdk_event_mempool = NULL; static struct spdk_mempool *g_spdk_event_mempool = NULL;
@ -301,19 +301,19 @@ get_rusage(struct spdk_reactor *reactor)
} }
void void
spdk_reactor_enable_context_switch_monitor(bool enable) spdk_reactor_enable_framework_monitor_context_switch(bool enable)
{ {
/* This global is being read by multiple threads, so this isn't /* This global is being read by multiple threads, so this isn't
* strictly thread safe. However, we're toggling between true and * strictly thread safe. However, we're toggling between true and
* false here, and if a thread sees the value update later than it * false here, and if a thread sees the value update later than it
* should, it's no big deal. */ * should, it's no big deal. */
g_context_switch_monitor_enabled = enable; g_framework_monitor_context_switch_enabled = enable;
} }
bool bool
spdk_reactor_context_switch_monitor_enabled(void) spdk_reactor_framework_monitor_context_switch_enabled(void)
{ {
return g_context_switch_monitor_enabled; return g_framework_monitor_context_switch_enabled;
} }
static void static void
@ -369,7 +369,7 @@ _spdk_reactor_run(void *arg)
break; break;
} }
if (g_context_switch_monitor_enabled) { if (g_framework_monitor_context_switch_enabled) {
if ((last_rusage + CONTEXT_SWITCH_MONITOR_PERIOD) < now) { if ((last_rusage + CONTEXT_SWITCH_MONITOR_PERIOD) < now) {
get_rusage(reactor); get_rusage(reactor);
last_rusage = now; last_rusage = now;

View File

@ -112,43 +112,45 @@ SPDK_RPC_REGISTER("spdk_kill_instance", spdk_rpc_spdk_kill_instance, SPDK_RPC_RU
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(spdk_kill_instance, kill_instance) SPDK_RPC_REGISTER_ALIAS_DEPRECATED(spdk_kill_instance, kill_instance)
struct rpc_context_switch_monitor { struct rpc_framework_monitor_context_switch {
bool enabled; bool enabled;
}; };
static const struct spdk_json_object_decoder rpc_context_switch_monitor_decoders[] = { static const struct spdk_json_object_decoder rpc_framework_monitor_context_switch_decoders[] = {
{"enabled", offsetof(struct rpc_context_switch_monitor, enabled), spdk_json_decode_bool}, {"enabled", offsetof(struct rpc_framework_monitor_context_switch, enabled), spdk_json_decode_bool},
}; };
static void static void
spdk_rpc_context_switch_monitor(struct spdk_jsonrpc_request *request, spdk_rpc_framework_monitor_context_switch(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params) const struct spdk_json_val *params)
{ {
struct rpc_context_switch_monitor req = {}; struct rpc_framework_monitor_context_switch req = {};
struct spdk_json_write_ctx *w; struct spdk_json_write_ctx *w;
if (params != NULL) { if (params != NULL) {
if (spdk_json_decode_object(params, rpc_context_switch_monitor_decoders, if (spdk_json_decode_object(params, rpc_framework_monitor_context_switch_decoders,
SPDK_COUNTOF(rpc_context_switch_monitor_decoders), SPDK_COUNTOF(rpc_framework_monitor_context_switch_decoders),
&req)) { &req)) {
SPDK_DEBUGLOG(SPDK_LOG_REACTOR, "spdk_json_decode_object failed\n"); SPDK_DEBUGLOG(SPDK_LOG_REACTOR, "spdk_json_decode_object failed\n");
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters"); spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
return; return;
} }
spdk_reactor_enable_context_switch_monitor(req.enabled); spdk_reactor_enable_framework_monitor_context_switch(req.enabled);
} }
w = spdk_jsonrpc_begin_result(request); w = spdk_jsonrpc_begin_result(request);
spdk_json_write_object_begin(w); spdk_json_write_object_begin(w);
spdk_json_write_named_bool(w, "enabled", spdk_reactor_context_switch_monitor_enabled()); spdk_json_write_named_bool(w, "enabled", spdk_reactor_framework_monitor_context_switch_enabled());
spdk_json_write_object_end(w); spdk_json_write_object_end(w);
spdk_jsonrpc_end_result(request, w); spdk_jsonrpc_end_result(request, w);
} }
SPDK_RPC_REGISTER("context_switch_monitor", spdk_rpc_context_switch_monitor, SPDK_RPC_RUNTIME) SPDK_RPC_REGISTER("framework_monitor_context_switch", spdk_rpc_framework_monitor_context_switch,
SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(framework_monitor_context_switch, context_switch_monitor)
struct rpc_thread_get_stats_ctx { struct rpc_thread_get_stats_ctx {
struct spdk_jsonrpc_request *request; struct spdk_jsonrpc_request *request;

View File

@ -120,19 +120,20 @@ if __name__ == "__main__":
p.add_argument('sig_name', help='signal will be sent to server.') p.add_argument('sig_name', help='signal will be sent to server.')
p.set_defaults(func=spdk_kill_instance) p.set_defaults(func=spdk_kill_instance)
def context_switch_monitor(args): def framework_monitor_context_switch(args):
enabled = None enabled = None
if args.enable: if args.enable:
enabled = True enabled = True
if args.disable: if args.disable:
enabled = False enabled = False
print_dict(rpc.app.context_switch_monitor(args.client, print_dict(rpc.app.framework_monitor_context_switch(args.client,
enabled=enabled)) enabled=enabled))
p = subparsers.add_parser('context_switch_monitor', help='Control whether the context switch monitor is enabled') p = subparsers.add_parser('framework_monitor_context_switch', aliases=['context_switch_monitor'],
help='Control whether the context switch monitor is enabled')
p.add_argument('-e', '--enable', action='store_true', help='Enable context switch monitoring') p.add_argument('-e', '--enable', action='store_true', help='Enable context switch monitoring')
p.add_argument('-d', '--disable', action='store_true', help='Disable context switch monitoring') p.add_argument('-d', '--disable', action='store_true', help='Disable context switch monitoring')
p.set_defaults(func=context_switch_monitor) p.set_defaults(func=framework_monitor_context_switch)
# bdev # bdev
def bdev_set_options(args): def bdev_set_options(args):

View File

@ -12,7 +12,8 @@ def spdk_kill_instance(client, sig_name):
return client.call('spdk_kill_instance', params) return client.call('spdk_kill_instance', params)
def context_switch_monitor(client, enabled=None): @deprecated_alias('context_switch_monitor')
def framework_monitor_context_switch(client, enabled=None):
"""Query or set state of context switch monitoring. """Query or set state of context switch monitoring.
Args: Args:
@ -24,7 +25,7 @@ def context_switch_monitor(client, enabled=None):
params = {} params = {}
if enabled is not None: if enabled is not None:
params['enabled'] = enabled params['enabled'] = enabled
return client.call('context_switch_monitor', params) return client.call('framework_monitor_context_switch', params)
def thread_get_stats(client): def thread_get_stats(client):