event: always fail if invalid tpoint mask is specified

There were a few error cases that weren't caught
as errors, meaning the "invalid tpoint mask" string
wouldn't be printed.

But also change it so that when an invalid tpoint mask
is specified, it fails spdk_app_start and causes the
application to exit, rather than just silently
stopping processing of the tpoint group mask string.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I567a4eee740559914e089dca7d7c3865ed9ce35b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13986
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jacek Kalwas <jacek.kalwas@intel.com>
This commit is contained in:
Jim Harris 2022-08-11 04:13:35 +00:00
parent a68a12a478
commit e1eee2ebac

View File

@ -343,6 +343,7 @@ app_setup_trace(struct spdk_app_opts *opts)
uint64_t tpoint_group_mask, tpoint_mask = -1ULL; uint64_t tpoint_group_mask, tpoint_mask = -1ULL;
char *end = NULL, *tpoint_group_mask_str, *tpoint_group_str = NULL; char *end = NULL, *tpoint_group_mask_str, *tpoint_group_str = NULL;
char *tp_g_str, *tpoint_group, *tpoints; char *tp_g_str, *tpoint_group, *tpoints;
bool error_found = false;
uint64_t group_id; uint64_t group_id;
if (opts->shm_id >= 0) { if (opts->shm_id >= 0) {
@ -379,6 +380,7 @@ app_setup_trace(struct spdk_app_opts *opts)
if (*end != '\0' || errno) { if (*end != '\0' || errno) {
tpoint_group_mask = spdk_trace_create_tpoint_group_mask(tpoint_group); tpoint_group_mask = spdk_trace_create_tpoint_group_mask(tpoint_group);
if (tpoint_group_mask == 0) { if (tpoint_group_mask == 0) {
error_found = true;
break; break;
} }
} }
@ -388,12 +390,14 @@ app_setup_trace(struct spdk_app_opts *opts)
if (!spdk_u64_is_pow2(tpoint_group_mask)) { if (!spdk_u64_is_pow2(tpoint_group_mask)) {
SPDK_ERRLOG("Tpoint group mask: %s contains multiple tpoint groups.\n", tpoint_group); SPDK_ERRLOG("Tpoint group mask: %s contains multiple tpoint groups.\n", tpoint_group);
SPDK_ERRLOG("This is not supported, to prevent from activating tpoints by mistake.\n"); SPDK_ERRLOG("This is not supported, to prevent from activating tpoints by mistake.\n");
error_found = true;
break; break;
} }
errno = 0; errno = 0;
tpoint_mask = strtoull(tpoints, &end, 16); tpoint_mask = strtoull(tpoints, &end, 16);
if (*end != '\0' || errno) { if (*end != '\0' || errno) {
error_found = true;
break; break;
} }
} else { } else {
@ -402,6 +406,7 @@ app_setup_trace(struct spdk_app_opts *opts)
if (*end != '\0' || errno) { if (*end != '\0' || errno) {
tpoint_group_mask = spdk_trace_create_tpoint_group_mask(tpoint_group_str); tpoint_group_mask = spdk_trace_create_tpoint_group_mask(tpoint_group_str);
if (tpoint_group_mask == 0) { if (tpoint_group_mask == 0) {
error_found = true;
break; break;
} }
} }
@ -415,8 +420,9 @@ app_setup_trace(struct spdk_app_opts *opts)
} }
} }
if (tpoint_group_str != NULL) { if (error_found) {
SPDK_ERRLOG("invalid tpoint mask %s\n", opts->tpoint_group_mask); SPDK_ERRLOG("invalid tpoint mask %s\n", opts->tpoint_group_mask);
return -1;
} else { } else {
SPDK_NOTICELOG("Tracepoint Group Mask %s specified.\n", opts->tpoint_group_mask); SPDK_NOTICELOG("Tracepoint Group Mask %s specified.\n", opts->tpoint_group_mask);
SPDK_NOTICELOG("Use 'spdk_trace -s %s %s %d' to capture a snapshot of events at runtime.\n", SPDK_NOTICELOG("Use 'spdk_trace -s %s %s %d' to capture a snapshot of events at runtime.\n",