trace: rework loop on trace points

Directly skip the block when a trace point does not match the user
criteria.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: Sunil Kumar Kori <skori@marvell.com>
This commit is contained in:
David Marchand 2022-09-22 16:50:39 +02:00
parent b980ced067
commit 3ee927d3e4

View File

@ -186,15 +186,18 @@ rte_trace_pattern(const char *pattern, bool enable)
int rc = 0, found = 0; int rc = 0, found = 0;
STAILQ_FOREACH(tp, &tp_list, next) { STAILQ_FOREACH(tp, &tp_list, next) {
if (fnmatch(pattern, tp->name, 0) == 0) { if (fnmatch(pattern, tp->name, 0) != 0)
if (enable) continue;
rc = rte_trace_point_enable(tp->handle);
else if (enable)
rc = rte_trace_point_disable(tp->handle); rc = rte_trace_point_enable(tp->handle);
found = 1; else
rc = rte_trace_point_disable(tp->handle);
if (rc < 0) {
found = 0;
break;
} }
if (rc < 0) found = 1;
return rc;
} }
return rc | found; return rc | found;
@ -211,17 +214,18 @@ rte_trace_regexp(const char *regex, bool enable)
return -EINVAL; return -EINVAL;
STAILQ_FOREACH(tp, &tp_list, next) { STAILQ_FOREACH(tp, &tp_list, next) {
if (regexec(&r, tp->name, 0, NULL, 0) == 0) { if (regexec(&r, tp->name, 0, NULL, 0) != 0)
if (enable) continue;
rc = rte_trace_point_enable(tp->handle);
else if (enable)
rc = rte_trace_point_disable(tp->handle); rc = rte_trace_point_enable(tp->handle);
found = 1; else
} rc = rte_trace_point_disable(tp->handle);
if (rc < 0) { if (rc < 0) {
found = 0; found = 0;
break; break;
} }
found = 1;
} }
regfree(&r); regfree(&r);