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