Commit a10d0ce7 authored by Maciej Wawryk's avatar Maciej Wawryk Committed by Jim Harris
Browse files

RPC: rename context_switch_monitor to framework_monitor_context_switch

parent fb3918a0
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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.

@@ -115,7 +115,7 @@ Example request:
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "context_switch_monitor",
  "method": "framework_monitor_context_switch",
  "params": {
    "enabled": false
  }
@@ -277,7 +277,7 @@ Example response:
    "bdev_get_iostat",
    "get_subsystem_config",
    "get_subsystems",
    "context_switch_monitor",
    "framework_monitor_context_switch",
    "spdk_kill_instance",
    "ioat_scan_copy_engine",
    "bdev_virtio_attach_controller",
+2 −2
Original line number Diff line number Diff line
@@ -296,14 +296,14 @@ void spdk_event_call(struct spdk_event *event);
 *
 * \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 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
}
+6 −6
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ static struct spdk_reactor *g_reactors;
static struct spdk_cpuset *g_reactor_core_mask;
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;

@@ -301,19 +301,19 @@ get_rusage(struct spdk_reactor *reactor)
}

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
	 * strictly thread safe. However, we're toggling between true and
	 * false here, and if a thread sees the value update later than it
	 * should, it's no big deal. */
	g_context_switch_monitor_enabled = enable;
	g_framework_monitor_context_switch_enabled = enable;
}

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
@@ -369,7 +369,7 @@ _spdk_reactor_run(void *arg)
			break;
		}

		if (g_context_switch_monitor_enabled) {
		if (g_framework_monitor_context_switch_enabled) {
			if ((last_rusage + CONTEXT_SWITCH_MONITOR_PERIOD) < now) {
				get_rusage(reactor);
				last_rusage = now;
+13 −11
Original line number Diff line number Diff line
@@ -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)


struct rpc_context_switch_monitor {
struct rpc_framework_monitor_context_switch {
	bool enabled;
};

static const struct spdk_json_object_decoder rpc_context_switch_monitor_decoders[] = {
	{"enabled", offsetof(struct rpc_context_switch_monitor, enabled), spdk_json_decode_bool},
static const struct spdk_json_object_decoder rpc_framework_monitor_context_switch_decoders[] = {
	{"enabled", offsetof(struct rpc_framework_monitor_context_switch, enabled), spdk_json_decode_bool},
};

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)
{
	struct rpc_context_switch_monitor req = {};
	struct rpc_framework_monitor_context_switch req = {};
	struct spdk_json_write_ctx *w;

	if (params != NULL) {
		if (spdk_json_decode_object(params, rpc_context_switch_monitor_decoders,
					    SPDK_COUNTOF(rpc_context_switch_monitor_decoders),
		if (spdk_json_decode_object(params, rpc_framework_monitor_context_switch_decoders,
					    SPDK_COUNTOF(rpc_framework_monitor_context_switch_decoders),
					    &req)) {
			SPDK_DEBUGLOG(SPDK_LOG_REACTOR, "spdk_json_decode_object failed\n");
			spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
			return;
		}

		spdk_reactor_enable_context_switch_monitor(req.enabled);
		spdk_reactor_enable_framework_monitor_context_switch(req.enabled);
	}

	w = spdk_jsonrpc_begin_result(request);
	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_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 spdk_jsonrpc_request *request;
+6 −5
Original line number Diff line number Diff line
@@ -120,19 +120,20 @@ if __name__ == "__main__":
    p.add_argument('sig_name', help='signal will be sent to server.')
    p.set_defaults(func=spdk_kill_instance)

    def context_switch_monitor(args):
    def framework_monitor_context_switch(args):
        enabled = None
        if args.enable:
            enabled = True
        if args.disable:
            enabled = False
        print_dict(rpc.app.context_switch_monitor(args.client,
        print_dict(rpc.app.framework_monitor_context_switch(args.client,
                                                            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('-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
    def bdev_set_options(args):
Loading