trace: disable trace by set num-trace-entries=0
Previously, trace file is always created in shared memory. Adding disabling trace in order to avoid trace file's creation if user doesn't require trace. Also returning error if trace is disabled but trace rpc is call to enable or diable trace group Change-Id: Ic9ea781a8a1edd530d0a5921b0dc774356ae4d48 Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5195 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
ddba8440c0
commit
e4e218d898
@ -477,13 +477,16 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_msg_fn start_fn,
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable and ignore trace setup if setting num_entries
|
||||
* to be 0.
|
||||
*
|
||||
* Note the call to app_setup_trace() is located here
|
||||
* ahead of app_setup_signal_handlers().
|
||||
* That's because there is not an easy/direct clean
|
||||
* way of unwinding alloc'd resources that can occur
|
||||
* in app_setup_signal_handlers().
|
||||
*/
|
||||
if (app_setup_trace(opts) != 0) {
|
||||
if (opts->num_entries != 0 && app_setup_trace(opts) != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -577,7 +580,7 @@ usage(void (*app_usage)(void))
|
||||
printf(" --huge-dir <path> use a specific hugetlbfs mount to reserve memory from\n");
|
||||
printf(" --iova-mode <pa/va> set IOVA mode ('pa' for IOVA_PA and 'va' for IOVA_VA)\n");
|
||||
printf(" --base-virtaddr <addr> the base virtual address for DPDK (default: 0x200000000000)\n");
|
||||
printf(" --num-trace-entries <num> number of trace entries for each core, must be power of 2. (default %d)\n",
|
||||
printf(" --num-trace-entries <num> number of trace entries for each core, must be power of 2, setting 0 to disable trace (default %d)\n",
|
||||
SPDK_APP_DEFAULT_NUM_TRACE_ENTRIES);
|
||||
spdk_log_usage(stdout, "-L");
|
||||
spdk_trace_mask_usage(stdout, "-e");
|
||||
@ -797,13 +800,13 @@ spdk_app_parse_args(int argc, char **argv, struct spdk_app_opts *opts,
|
||||
break;
|
||||
case NUM_TRACE_ENTRIES_OPT_IDX:
|
||||
tmp = spdk_strtoll(optarg, 0);
|
||||
if (tmp <= 0) {
|
||||
if (tmp < 0) {
|
||||
SPDK_ERRLOG("Invalid num-trace-entries %s\n", optarg);
|
||||
usage(app_usage);
|
||||
goto out;
|
||||
}
|
||||
opts->num_entries = (uint64_t)tmp;
|
||||
if (opts->num_entries & (opts->num_entries - 1)) {
|
||||
if (opts->num_entries > 0 && opts->num_entries & (opts->num_entries - 1)) {
|
||||
SPDK_ERRLOG("num-trace-entries must be power of 2\n");
|
||||
usage(app_usage);
|
||||
goto out;
|
||||
|
@ -50,12 +50,21 @@ spdk_trace_get_tpoint_mask(uint32_t group_id)
|
||||
return 0ULL;
|
||||
}
|
||||
|
||||
if (g_trace_flags == NULL) {
|
||||
return 0ULL;
|
||||
}
|
||||
|
||||
return g_trace_flags->tpoint_mask[group_id];
|
||||
}
|
||||
|
||||
void
|
||||
spdk_trace_set_tpoints(uint32_t group_id, uint64_t tpoint_mask)
|
||||
{
|
||||
if (g_trace_flags == NULL) {
|
||||
SPDK_ERRLOG("trace is not initialized\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (group_id >= SPDK_TRACE_MAX_GROUP_ID) {
|
||||
SPDK_ERRLOG("invalid group ID %d\n", group_id);
|
||||
return;
|
||||
@ -67,6 +76,11 @@ spdk_trace_set_tpoints(uint32_t group_id, uint64_t tpoint_mask)
|
||||
void
|
||||
spdk_trace_clear_tpoints(uint32_t group_id, uint64_t tpoint_mask)
|
||||
{
|
||||
if (g_trace_flags == NULL) {
|
||||
SPDK_ERRLOG("trace is not initialized\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (group_id >= SPDK_TRACE_MAX_GROUP_ID) {
|
||||
SPDK_ERRLOG("invalid group ID %d\n", group_id);
|
||||
return;
|
||||
@ -95,6 +109,11 @@ spdk_trace_set_tpoint_group_mask(uint64_t tpoint_group_mask)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (g_trace_flags == NULL) {
|
||||
SPDK_ERRLOG("trace is not initialized\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < SPDK_TRACE_MAX_GROUP_ID; i++) {
|
||||
if (tpoint_group_mask & (1ULL << i)) {
|
||||
spdk_trace_set_tpoints(i, -1ULL);
|
||||
@ -107,6 +126,11 @@ spdk_trace_clear_tpoint_group_mask(uint64_t tpoint_group_mask)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (g_trace_flags == NULL) {
|
||||
SPDK_ERRLOG("trace is not initialized\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < SPDK_TRACE_MAX_GROUP_ID; i++) {
|
||||
if (tpoint_group_mask & (1ULL << i)) {
|
||||
spdk_trace_clear_tpoints(i, -1ULL);
|
||||
@ -161,6 +185,10 @@ spdk_trace_enable_tpoint_group(const char *group_name)
|
||||
{
|
||||
uint64_t tpoint_group_mask = 0;
|
||||
|
||||
if (g_trace_flags == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
tpoint_group_mask = trace_create_tpoint_group_mask(group_name);
|
||||
if (tpoint_group_mask == 0) {
|
||||
return -1;
|
||||
@ -175,6 +203,10 @@ spdk_trace_disable_tpoint_group(const char *group_name)
|
||||
{
|
||||
uint64_t tpoint_group_mask = 0;
|
||||
|
||||
if (g_trace_flags == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
tpoint_group_mask = trace_create_tpoint_group_mask(group_name);
|
||||
if (tpoint_group_mask == 0) {
|
||||
return -1;
|
||||
@ -208,6 +240,11 @@ spdk_trace_register_owner(uint8_t type, char id_prefix)
|
||||
|
||||
assert(type != OWNER_NONE);
|
||||
|
||||
if (g_trace_flags == NULL) {
|
||||
SPDK_ERRLOG("trace is not initialized\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* 'owner' has 256 entries and since 'type' is a uint8_t, it
|
||||
* can't overrun the array.
|
||||
*/
|
||||
@ -225,6 +262,11 @@ spdk_trace_register_object(uint8_t type, char id_prefix)
|
||||
|
||||
assert(type != OBJECT_NONE);
|
||||
|
||||
if (g_trace_flags == NULL) {
|
||||
SPDK_ERRLOG("trace is not initialized\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* 'object' has 256 entries and since 'type' is a uint8_t, it
|
||||
* can't overrun the array.
|
||||
*/
|
||||
@ -245,6 +287,11 @@ spdk_trace_register_description(const char *name, uint16_t tpoint_id, uint8_t ow
|
||||
assert(tpoint_id != 0);
|
||||
assert(tpoint_id < SPDK_TRACE_MAX_TPOINT_ID);
|
||||
|
||||
if (g_trace_flags == NULL) {
|
||||
SPDK_ERRLOG("trace is not initialized\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strnlen(name, sizeof(tpoint->name)) == sizeof(tpoint->name)) {
|
||||
SPDK_ERRLOG("name (%s) too long\n", name);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user