trace_rpc.c: add support for enabling individual traces
Add support to enable individual traces through rpc commands and modify jsonrpc.md to describe the changes. Change-Id: I3664fc28f1c25a76eade4cff0a0ab1870172f8de Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10518 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
f8bf3cb462
commit
def5e10a31
@ -949,6 +949,87 @@ Example response:
|
|||||||
}
|
}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
### trace_set_tpoint_mask {#rpc_trace_set_tpoint_mask}
|
||||||
|
|
||||||
|
Enable tracepoint mask on a specific tpoint group. For example "bdev" for bdev trace group,
|
||||||
|
and 0x1 to enable the first tracepoint inside the group (BDEV_IO_START). This command will not
|
||||||
|
disable already active tracepoints or those not specified in the mask. For a full description
|
||||||
|
of all available trace groups, see
|
||||||
|
[tracepoint documentation](https://spdk.io/doc/nvmf_tgt_tracepoints.html).
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
Name | Optional | Type | Description
|
||||||
|
----------------------- | -------- | ----------- | -----------
|
||||||
|
name | Required | string | bdev, nvmf_rdma, nvmf_tcp, blobfs, scsi, iscsi_conn, ftl
|
||||||
|
tpoint_mask | Required | number | mask to enable tracepoints inside a group
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
Example request:
|
||||||
|
|
||||||
|
~~~json
|
||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "trace_set_tpoint_mask",
|
||||||
|
"id": 1,
|
||||||
|
"params": {
|
||||||
|
"name": "bdev",
|
||||||
|
"tpoint_mask": 0x1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Example response:
|
||||||
|
|
||||||
|
~~~json
|
||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": 1,
|
||||||
|
"result": true
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
### trace_clear_tpoint_mask {#rpc_trace_clear_tpoint_mask}
|
||||||
|
|
||||||
|
Disable tracepoint mask on a specific tpoint group. For example "bdev" for bdev trace group,
|
||||||
|
and 0x1 to disable the first tracepoint inside the group (BDEV_IO_START). For a full description
|
||||||
|
of all available trace groups, see
|
||||||
|
[tracepoint documentation](https://spdk.io/doc/nvmf_tgt_tracepoints.html).
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
Name | Optional | Type | Description
|
||||||
|
----------------------- | -------- | ----------- | -----------
|
||||||
|
name | Required | string | bdev, nvmf_rdma, nvmf_tcp, blobfs, scsi, iscsi_conn, ftl
|
||||||
|
tpoint_mask | Required | number | mask to diesable tracepoints inside a group
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
Example request:
|
||||||
|
|
||||||
|
~~~json
|
||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "trace_clear_tpoint_mask",
|
||||||
|
"id": 1,
|
||||||
|
"params": {
|
||||||
|
"name": "bdev",
|
||||||
|
"tpoint_mask": 0x1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Example response:
|
||||||
|
|
||||||
|
~~~json
|
||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": 1,
|
||||||
|
"result": true
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
### trace_get_tpoint_group_mask {#rpc_trace_get_tpoint_group_mask}
|
### trace_get_tpoint_group_mask {#rpc_trace_get_tpoint_group_mask}
|
||||||
|
|
||||||
Display mask info for every group.
|
Display mask info for every group.
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
struct rpc_tpoint_group {
|
struct rpc_tpoint_group {
|
||||||
char *name;
|
char *name;
|
||||||
|
uint64_t tpoint_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -46,6 +47,85 @@ free_rpc_tpoint_group(struct rpc_tpoint_group *p)
|
|||||||
free(p->name);
|
free(p->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct spdk_json_object_decoder rpc_tpoint_mask_decoders[] = {
|
||||||
|
{"name", offsetof(struct rpc_tpoint_group, name), spdk_json_decode_string},
|
||||||
|
{"tpoint_mask", offsetof(struct rpc_tpoint_group, tpoint_mask), spdk_json_decode_uint64, true},
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
rpc_trace_set_tpoint_mask(struct spdk_jsonrpc_request *request,
|
||||||
|
const struct spdk_json_val *params)
|
||||||
|
{
|
||||||
|
struct rpc_tpoint_group req = {};
|
||||||
|
uint64_t tpoint_group_mask = 0;
|
||||||
|
|
||||||
|
if (spdk_json_decode_object(params, rpc_tpoint_mask_decoders,
|
||||||
|
SPDK_COUNTOF(rpc_tpoint_mask_decoders), &req)) {
|
||||||
|
SPDK_DEBUGLOG(trace, "spdk_json_decode_object failed\n");
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.name == NULL) {
|
||||||
|
SPDK_DEBUGLOG(trace, "flag was NULL\n");
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
tpoint_group_mask = spdk_trace_create_tpoint_group_mask(req.name);
|
||||||
|
if (tpoint_group_mask == 0) {
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_trace_set_tpoints(spdk_u64log2(tpoint_group_mask), req.tpoint_mask);
|
||||||
|
|
||||||
|
free_rpc_tpoint_group(&req);
|
||||||
|
|
||||||
|
spdk_jsonrpc_send_bool_response(request, true);
|
||||||
|
return;
|
||||||
|
|
||||||
|
invalid:
|
||||||
|
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||||
|
free_rpc_tpoint_group(&req);
|
||||||
|
}
|
||||||
|
SPDK_RPC_REGISTER("trace_set_tpoint_mask", rpc_trace_set_tpoint_mask,
|
||||||
|
SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
|
||||||
|
|
||||||
|
static void
|
||||||
|
rpc_trace_clear_tpoint_mask(struct spdk_jsonrpc_request *request,
|
||||||
|
const struct spdk_json_val *params)
|
||||||
|
{
|
||||||
|
struct rpc_tpoint_group req = {};
|
||||||
|
uint64_t tpoint_group_mask = 0;
|
||||||
|
|
||||||
|
if (spdk_json_decode_object(params, rpc_tpoint_mask_decoders,
|
||||||
|
SPDK_COUNTOF(rpc_tpoint_mask_decoders), &req)) {
|
||||||
|
SPDK_DEBUGLOG(trace, "spdk_json_decode_object failed\n");
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.name == NULL) {
|
||||||
|
SPDK_DEBUGLOG(trace, "flag was NULL\n");
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
tpoint_group_mask = spdk_trace_create_tpoint_group_mask(req.name);
|
||||||
|
if (tpoint_group_mask == 0) {
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_trace_clear_tpoints(spdk_u64log2(tpoint_group_mask), req.tpoint_mask);
|
||||||
|
|
||||||
|
free_rpc_tpoint_group(&req);
|
||||||
|
|
||||||
|
spdk_jsonrpc_send_bool_response(request, true);
|
||||||
|
return;
|
||||||
|
|
||||||
|
invalid:
|
||||||
|
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
|
||||||
|
free_rpc_tpoint_group(&req);
|
||||||
|
}
|
||||||
|
SPDK_RPC_REGISTER("trace_clear_tpoint_mask", rpc_trace_clear_tpoint_mask,
|
||||||
|
SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
|
||||||
|
|
||||||
static const struct spdk_json_object_decoder rpc_tpoint_group_decoders[] = {
|
static const struct spdk_json_object_decoder rpc_tpoint_group_decoders[] = {
|
||||||
{"name", offsetof(struct rpc_tpoint_group, name), spdk_json_decode_string},
|
{"name", offsetof(struct rpc_tpoint_group, name), spdk_json_decode_string},
|
||||||
};
|
};
|
||||||
|
@ -1563,6 +1563,34 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
|||||||
(for example "bdev" for bdev trace group, "all" for all trace groups).""")
|
(for example "bdev" for bdev trace group, "all" for all trace groups).""")
|
||||||
p.set_defaults(func=trace_disable_tpoint_group)
|
p.set_defaults(func=trace_disable_tpoint_group)
|
||||||
|
|
||||||
|
def trace_set_tpoint_mask(args):
|
||||||
|
rpc.trace.trace_set_tpoint_mask(args.client, name=args.name, tpoint_mask=args.tpoint_mask)
|
||||||
|
|
||||||
|
p = subparsers.add_parser('trace_set_tpoint_mask',
|
||||||
|
help='enable tracepoint mask on a specific tpoint group')
|
||||||
|
p.add_argument(
|
||||||
|
'name', help="""trace group name we want to enable in tpoint_group_mask.
|
||||||
|
(for example "bdev" for bdev trace group)""")
|
||||||
|
p.add_argument(
|
||||||
|
'tpoint_mask', help="""tracepoints to be enabled inside a given trace group.
|
||||||
|
(for example value of "0x3" will enable only the first two tpoints in this group)""",
|
||||||
|
type=lambda m: int(m, 16))
|
||||||
|
p.set_defaults(func=trace_set_tpoint_mask)
|
||||||
|
|
||||||
|
def trace_clear_tpoint_mask(args):
|
||||||
|
rpc.trace.trace_clear_tpoint_mask(args.client, name=args.name, tpoint_mask=args.tpoint_mask)
|
||||||
|
|
||||||
|
p = subparsers.add_parser('trace_clear_tpoint_mask',
|
||||||
|
help='disable tracepoint mask on a specific tpoint group')
|
||||||
|
p.add_argument(
|
||||||
|
'name', help="""trace group name we want to disable in tpoint_group_mask.
|
||||||
|
(for example "bdev" for bdev trace group)""")
|
||||||
|
p.add_argument(
|
||||||
|
'tpoint_mask', help="""tracepoints to be disabled inside a given trace group.
|
||||||
|
(for example value of "0x3" will disable the first two tpoints in this group)""",
|
||||||
|
type=lambda m: int(m, 16))
|
||||||
|
p.set_defaults(func=trace_clear_tpoint_mask)
|
||||||
|
|
||||||
def trace_get_tpoint_group_mask(args):
|
def trace_get_tpoint_group_mask(args):
|
||||||
print_dict(rpc.trace.trace_get_tpoint_group_mask(args.client))
|
print_dict(rpc.trace.trace_get_tpoint_group_mask(args.client))
|
||||||
|
|
||||||
|
@ -23,6 +23,30 @@ def trace_disable_tpoint_group(client, name):
|
|||||||
return client.call('trace_disable_tpoint_group', params)
|
return client.call('trace_disable_tpoint_group', params)
|
||||||
|
|
||||||
|
|
||||||
|
def trace_set_tpoint_mask(client, name, tpoint_mask):
|
||||||
|
"""Enable tracepoint mask on a specific tpoint group.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
name: trace group name we want to enable in tpoint_group_mask. (for example "bdev").
|
||||||
|
tpoint_mask: tracepoints to be enabled inside decleared group
|
||||||
|
(for example "0x3" to enable first two tpoints).
|
||||||
|
"""
|
||||||
|
params = {'name': name, 'tpoint_mask': tpoint_mask}
|
||||||
|
return client.call('trace_set_tpoint_mask', params)
|
||||||
|
|
||||||
|
|
||||||
|
def trace_clear_tpoint_mask(client, name, tpoint_mask):
|
||||||
|
"""Disable tracepoint mask on a specific tpoint group.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
name: trace group name we want to disable in tpoint_group_mask. (for example "bdev").
|
||||||
|
tpoint_mask: tracepoints to be disabled inside decleared group
|
||||||
|
(for example "0x3" to disable first two tpoints).
|
||||||
|
"""
|
||||||
|
params = {'name': name, 'tpoint_mask': tpoint_mask}
|
||||||
|
return client.call('trace_clear_tpoint_mask', params)
|
||||||
|
|
||||||
|
|
||||||
@deprecated_alias('get_tpoint_group_mask')
|
@deprecated_alias('get_tpoint_group_mask')
|
||||||
def trace_get_tpoint_group_mask(client):
|
def trace_get_tpoint_group_mask(client):
|
||||||
"""Get trace point group mask
|
"""Get trace point group mask
|
||||||
|
Loading…
Reference in New Issue
Block a user