lib/trace: add trace_get_info RPC
Add rpc method trace_get_info to show name of shared memory file, list of the available trace point groups and mask of the available trace points for each group. Fixes #2747 Signed-off-by: Xinrui Mao <xinrui.mao@intel.com> Change-Id: I2098283bed454dc46644fd2ca1b9568ab2aea81b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15426 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
c680e3a05b
commit
cd4ac9c792
@ -58,6 +58,11 @@ Added spdk_rpc_set_allowlist to restrict allowed RPCs to the specified list.
|
|||||||
Promoted the application to example to match similar programs: fio_plugin and perf.
|
Promoted the application to example to match similar programs: fio_plugin and perf.
|
||||||
It can now be found inside `examples/bdev/bdevperf`.
|
It can now be found inside `examples/bdev/bdevperf`.
|
||||||
|
|
||||||
|
### trace
|
||||||
|
|
||||||
|
New `trace_get_info` RPC was added to get name of shared memory file, list of the
|
||||||
|
available trace point groups and mask of the available trace points for each group.
|
||||||
|
|
||||||
### util
|
### util
|
||||||
|
|
||||||
New API `spdk_fd_group_get_epoll_event` that returns the epoll(7) event that
|
New API `spdk_fd_group_get_epoll_event` that returns the epoll(7) event that
|
||||||
|
@ -1173,6 +1173,76 @@ Example response:
|
|||||||
}
|
}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
### trace_get_info {#rpc_trace_get_info}
|
||||||
|
|
||||||
|
Get name of shared memory file, list of the available trace point groups
|
||||||
|
and mask of the available trace points for each group
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
No parameters required
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
Example request:
|
||||||
|
|
||||||
|
~~~json
|
||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "trace_get_info",
|
||||||
|
"id": 1
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Example response:
|
||||||
|
|
||||||
|
~~~json
|
||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": 1,
|
||||||
|
"result": {
|
||||||
|
"tpoint_shm_path": "/dev/shm/spdk_tgt_trace.pid3071944",
|
||||||
|
"tpoint_group_mask": "0x8",
|
||||||
|
"iscsi_conn": {
|
||||||
|
"mask": "0x2",
|
||||||
|
"tpoint_mask": "0x0"
|
||||||
|
},
|
||||||
|
"scsi": {
|
||||||
|
"mask": "0x4",
|
||||||
|
"tpoint_mask": "0x0"
|
||||||
|
},
|
||||||
|
"bdev": {
|
||||||
|
"mask": "0x8",
|
||||||
|
"tpoint_mask": "0xffffffffffffffff"
|
||||||
|
},
|
||||||
|
"nvmf_tcp": {
|
||||||
|
"mask": "0x20",
|
||||||
|
"tpoint_mask": "0x0"
|
||||||
|
},
|
||||||
|
"blobfs": {
|
||||||
|
"mask": "0x80",
|
||||||
|
"tpoint_mask": "0x0"
|
||||||
|
},
|
||||||
|
"thread": {
|
||||||
|
"mask": "0x400",
|
||||||
|
"tpoint_mask": "0x0"
|
||||||
|
},
|
||||||
|
"nvme_pcie": {
|
||||||
|
"mask": "0x800",
|
||||||
|
"tpoint_mask": "0x0"
|
||||||
|
},
|
||||||
|
"nvme_tcp": {
|
||||||
|
"mask": "0x2000",
|
||||||
|
"tpoint_mask": "0x0"
|
||||||
|
},
|
||||||
|
"bdev_nvme": {
|
||||||
|
"mask": "0x4000",
|
||||||
|
"tpoint_mask": "0x0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
### log_set_print_level {#rpc_log_set_print_level}
|
### log_set_print_level {#rpc_log_set_print_level}
|
||||||
|
|
||||||
Set the current level at which output will additionally be
|
Set the current level at which output will additionally be
|
||||||
|
@ -7,7 +7,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
|
|||||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||||
|
|
||||||
SO_VER := 7
|
SO_VER := 7
|
||||||
SO_MINOR := 0
|
SO_MINOR := 1
|
||||||
|
|
||||||
C_SRCS = trace.c trace_flags.c trace_rpc.c
|
C_SRCS = trace.c trace_flags.c trace_rpc.c
|
||||||
LIBNAME = trace
|
LIBNAME = trace
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "spdk/log.h"
|
#include "spdk/log.h"
|
||||||
#include "spdk/cpuset.h"
|
#include "spdk/cpuset.h"
|
||||||
#include "spdk/likely.h"
|
#include "spdk/likely.h"
|
||||||
|
#include "trace_internal.h"
|
||||||
|
|
||||||
static int g_trace_fd = -1;
|
static int g_trace_fd = -1;
|
||||||
static char g_shm_name[64];
|
static char g_shm_name[64];
|
||||||
@ -271,3 +272,9 @@ spdk_trace_cleanup(void)
|
|||||||
shm_unlink(g_shm_name);
|
shm_unlink(g_shm_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
trace_get_shm_name(void)
|
||||||
|
{
|
||||||
|
return g_shm_name;
|
||||||
|
}
|
||||||
|
14
lib/trace/trace_internal.h
Normal file
14
lib/trace/trace_internal.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
* Copyright (C) 2022 Intel Corporation.
|
||||||
|
* All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __TRACE_INTERNAL_H__
|
||||||
|
#define __TRACE_INTERNAL_H__
|
||||||
|
|
||||||
|
#include "spdk/trace.h"
|
||||||
|
|
||||||
|
/* Get shared memory file name. */
|
||||||
|
const char *trace_get_shm_name(void);
|
||||||
|
|
||||||
|
#endif
|
@ -7,6 +7,7 @@
|
|||||||
#include "spdk/util.h"
|
#include "spdk/util.h"
|
||||||
#include "spdk/trace.h"
|
#include "spdk/trace.h"
|
||||||
#include "spdk/log.h"
|
#include "spdk/log.h"
|
||||||
|
#include "trace_internal.h"
|
||||||
|
|
||||||
struct rpc_tpoint_group {
|
struct rpc_tpoint_group {
|
||||||
char *name;
|
char *name;
|
||||||
@ -211,3 +212,52 @@ rpc_trace_get_tpoint_group_mask(struct spdk_jsonrpc_request *request,
|
|||||||
}
|
}
|
||||||
SPDK_RPC_REGISTER("trace_get_tpoint_group_mask", rpc_trace_get_tpoint_group_mask,
|
SPDK_RPC_REGISTER("trace_get_tpoint_group_mask", rpc_trace_get_tpoint_group_mask,
|
||||||
SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
|
SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
|
||||||
|
|
||||||
|
static void
|
||||||
|
rpc_trace_get_info(struct spdk_jsonrpc_request *request,
|
||||||
|
const struct spdk_json_val *params)
|
||||||
|
{
|
||||||
|
char shm_path[128];
|
||||||
|
uint64_t tpoint_group_mask;
|
||||||
|
uint64_t tpoint_mask;
|
||||||
|
char tpoint_mask_str[20];
|
||||||
|
char mask_str[20];
|
||||||
|
struct spdk_json_write_ctx *w;
|
||||||
|
struct spdk_trace_register_fn *register_fn;
|
||||||
|
|
||||||
|
if (params != NULL) {
|
||||||
|
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||||
|
"trace_get_info requires no parameters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(shm_path, sizeof(shm_path), "/dev/shm%s", trace_get_shm_name());
|
||||||
|
tpoint_group_mask = spdk_trace_get_tpoint_group_mask();
|
||||||
|
|
||||||
|
w = spdk_jsonrpc_begin_result(request);
|
||||||
|
spdk_json_write_object_begin(w);
|
||||||
|
spdk_json_write_named_string(w, "tpoint_shm_path", shm_path);
|
||||||
|
|
||||||
|
snprintf(mask_str, sizeof(mask_str), "0x%" PRIx64, tpoint_group_mask);
|
||||||
|
spdk_json_write_named_string(w, "tpoint_group_mask", mask_str);
|
||||||
|
|
||||||
|
register_fn = spdk_trace_get_first_register_fn();
|
||||||
|
while (register_fn) {
|
||||||
|
|
||||||
|
tpoint_mask = spdk_trace_get_tpoint_mask(register_fn->tgroup_id);
|
||||||
|
|
||||||
|
spdk_json_write_named_object_begin(w, register_fn->name);
|
||||||
|
snprintf(mask_str, sizeof(mask_str), "0x%lx", (1UL << register_fn->tgroup_id));
|
||||||
|
spdk_json_write_named_string(w, "mask", mask_str);
|
||||||
|
snprintf(tpoint_mask_str, sizeof(tpoint_mask_str), "0x%lx", tpoint_mask);
|
||||||
|
spdk_json_write_named_string(w, "tpoint_mask", tpoint_mask_str);
|
||||||
|
spdk_json_write_object_end(w);
|
||||||
|
|
||||||
|
register_fn = spdk_trace_get_next_register_fn(register_fn);
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_json_write_object_end(w);
|
||||||
|
spdk_jsonrpc_end_result(request, w);
|
||||||
|
}
|
||||||
|
SPDK_RPC_REGISTER("trace_get_info", rpc_trace_get_info,
|
||||||
|
SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
|
||||||
|
@ -53,3 +53,12 @@ def trace_get_tpoint_group_mask(client):
|
|||||||
List of trace point group mask
|
List of trace point group mask
|
||||||
"""
|
"""
|
||||||
return client.call('trace_get_tpoint_group_mask')
|
return client.call('trace_get_tpoint_group_mask')
|
||||||
|
|
||||||
|
|
||||||
|
def trace_get_info(client):
|
||||||
|
"""Get name of shared memory file and list of the available trace point groups
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Name of shared memory file and list of the available trace point groups
|
||||||
|
"""
|
||||||
|
return client.call('trace_get_info')
|
||||||
|
@ -1803,6 +1803,13 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
|||||||
p = subparsers.add_parser('trace_get_tpoint_group_mask', help='get trace point group mask')
|
p = subparsers.add_parser('trace_get_tpoint_group_mask', help='get trace point group mask')
|
||||||
p.set_defaults(func=trace_get_tpoint_group_mask)
|
p.set_defaults(func=trace_get_tpoint_group_mask)
|
||||||
|
|
||||||
|
def trace_get_info(args):
|
||||||
|
print_dict(rpc.trace.trace_get_info(args.client))
|
||||||
|
|
||||||
|
p = subparsers.add_parser('trace_get_info',
|
||||||
|
help='get name of shared memory file and list of the available trace point groups')
|
||||||
|
p.set_defaults(func=trace_get_info)
|
||||||
|
|
||||||
# log
|
# log
|
||||||
def log_set_flag(args):
|
def log_set_flag(args):
|
||||||
rpc.log.log_set_flag(args.client, flag=args.flag)
|
rpc.log.log_set_flag(args.client, flag=args.flag)
|
||||||
|
@ -40,7 +40,18 @@ function rpc_plugins() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$SPDK_BIN_DIR/spdk_tgt &
|
function rpc_trace_cmd_test() {
|
||||||
|
local info
|
||||||
|
|
||||||
|
info=$($rpc trace_get_info)
|
||||||
|
[ "$(jq length <<< "$info")" -gt 2 ]
|
||||||
|
[ "$(jq 'has("tpoint_group_mask")' <<< "$info")" = "true" ]
|
||||||
|
[ "$(jq 'has("tpoint_shm_path")' <<< "$info")" = "true" ]
|
||||||
|
[ "$(jq 'has("bdev")' <<< "$info")" = "true" ]
|
||||||
|
[ "$(jq -r .bdev.tpoint_mask <<< "$info")" != "0x0" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
$SPDK_BIN_DIR/spdk_tgt -e bdev &
|
||||||
spdk_pid=$!
|
spdk_pid=$!
|
||||||
trap 'killprocess $spdk_pid; exit 1' SIGINT SIGTERM EXIT
|
trap 'killprocess $spdk_pid; exit 1' SIGINT SIGTERM EXIT
|
||||||
waitforlisten $spdk_pid
|
waitforlisten $spdk_pid
|
||||||
@ -51,6 +62,7 @@ export PYTHONPATH=$PYTHONPATH:$testdir
|
|||||||
rpc=rpc_cmd
|
rpc=rpc_cmd
|
||||||
run_test "rpc_integrity" rpc_integrity
|
run_test "rpc_integrity" rpc_integrity
|
||||||
run_test "rpc_plugins" rpc_plugins
|
run_test "rpc_plugins" rpc_plugins
|
||||||
|
run_test "rpc_trace_cmd_test" rpc_trace_cmd_test
|
||||||
# same integrity test, but with rpc_cmd() instead
|
# same integrity test, but with rpc_cmd() instead
|
||||||
rpc="rpc_cmd"
|
rpc="rpc_cmd"
|
||||||
run_test "rpc_daemon_integrity" rpc_integrity
|
run_test "rpc_daemon_integrity" rpc_integrity
|
||||||
|
Loading…
Reference in New Issue
Block a user