Commit dde60dba authored by Krishna Kanth Reddy's avatar Krishna Kanth Reddy Committed by Jim Harris
Browse files

lib/event: add framework_get_governor RPC



Implemented a new RPC 'framework_get_governor' to fetch the
details of Power Governor, env and the frequencies available,
frequency set to the CPU cores.

Change-Id: I2fa7f884f1253188c002ea4816dd80f88b623098
Signed-off-by: default avatarKrishna Kanth Reddy <krish.reddy@samsung.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23640


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent a4f71f8f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -26,6 +26,11 @@ The `framework_get_reactors` RPC method supports getting pid and tid.

`spdk_get_tid` is added to get the tid of the current thread.

### scheduler

Added `framework_get_governor` RPC to retrieve the power governor name,
power env and the frequencies available, frequency set to the cpu cores.

## v24.05

### accel
+51 −0
Original line number Diff line number Diff line
@@ -817,6 +817,57 @@ Example response:
}
~~~

### framework_get_governor {#rpc_framework_get_governor}

Retrieve current governor name, power env, frequencies available and frequency set to the cpu cores.

#### Parameters

This method has no parameters.

#### Response

Displays the current governor name, power env, frequencies available and frequency set to the cpu cores.

#### Example

Example request:

~~~json
{
  "jsonrpc": "2.0",
  "method": "framework_get_governor",
  "id": 1,
}
~~~

Example response:

~~~json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "governor_name": "dpdk_governor"
    "module_specific": {
      "env": "amd-pstate"
    }
    "cores": [
      {
        "lcore_id": 0,
        "available_frequencies": [
          4951000,
          4948000,
          4748000,
          4744000
        ],
        "current_frequency": 4744000
      }
    ]
  }
}
~~~

### framework_enable_cpumask_locks

Enable CPU core lock files to block multiple SPDK applications from running on the same cpumask.
+56 −0
Original line number Diff line number Diff line
@@ -554,6 +554,62 @@ rpc_framework_get_scheduler(struct spdk_jsonrpc_request *request,
}
SPDK_RPC_REGISTER("framework_get_scheduler", rpc_framework_get_scheduler, SPDK_RPC_RUNTIME)

static void
rpc_framework_get_governor(struct spdk_jsonrpc_request *request,
			   const struct spdk_json_val *params)
{
	struct spdk_json_write_ctx *w;
	struct spdk_governor *governor = spdk_governor_get();

	if (params) {
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
						 "'rpc_get_governor' requires no arguments");
		return;
	}

	w = spdk_jsonrpc_begin_result(request);
	spdk_json_write_object_begin(w);

	if (governor != NULL) {
		uint32_t core, index, num;
		uint32_t freqs[SPDK_MAX_LCORE_FREQS];

		spdk_json_write_named_string(w, "governor_name", governor->name);

		spdk_json_write_named_object_begin(w, "module_specific");

		governor->dump_info_json(w);

		spdk_json_write_object_end(w);

		spdk_json_write_named_array_begin(w, "cores");

		SPDK_ENV_FOREACH_CORE(core) {
			spdk_json_write_object_begin(w);
			spdk_json_write_named_uint32(w, "lcore_id", core);

			memset(freqs, 0, SPDK_MAX_LCORE_FREQS * sizeof(uint32_t));

			num = governor->get_core_avail_freqs(core, freqs, SPDK_MAX_LCORE_FREQS);

			spdk_json_write_named_array_begin(w, "available_frequencies");
			for (index = 0; index < num; index++) {
				spdk_json_write_uint32(w, freqs[index]);
			}
			spdk_json_write_array_end(w);

			spdk_json_write_named_uint32(w, "current_frequency", governor->get_core_curr_freq(core));
			spdk_json_write_object_end(w);
		}

		spdk_json_write_array_end(w);
	}

	spdk_json_write_object_end(w);
	spdk_jsonrpc_end_result(request, w);
}
SPDK_RPC_REGISTER("framework_get_governor", rpc_framework_get_governor, SPDK_RPC_RUNTIME)

struct rpc_thread_set_cpumask_ctx {
	struct spdk_jsonrpc_request *request;
	struct spdk_cpuset cpumask;
+9 −0
Original line number Diff line number Diff line
@@ -68,6 +68,15 @@ def framework_get_scheduler(client):
    return client.call('framework_get_scheduler')


def framework_get_governor(client):
    """Query current governor data.

    Returns:
        Name of currently set governor, available frequencies and currently set frequency of the CPU cores.
    """
    return client.call('framework_get_governor')


def thread_get_stats(client):
    """Query threads statistics.

+7 −0
Original line number Diff line number Diff line
@@ -187,6 +187,13 @@ if __name__ == "__main__":
        'framework_get_scheduler', help='Display currently set scheduler and its properties.')
    p.set_defaults(func=framework_get_scheduler)

    def framework_get_governor(args):
        print_dict(rpc.app.framework_get_governor(args.client))

    p = subparsers.add_parser(
        'framework_get_governor', help='Display currently set governor and the available, set CPU frequencies.')
    p.set_defaults(func=framework_get_governor)

    def framework_disable_cpumask_locks(args):
        rpc.framework_disable_cpumask_locks(args.client)