From patchwork Tue Oct 4 09:44:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 117287 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0ABEEA0543; Tue, 4 Oct 2022 11:44:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B5E814281C; Tue, 4 Oct 2022 11:44:52 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id BC4B5427F4 for ; Tue, 4 Oct 2022 11:44:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664876690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/OPQBU45cZGmJVOaeRSuwPpY+zVjPtfHDve0Cw8Cpow=; b=KvsK3Na6mnuqeTlKJJim3+kHQBBmXMM6aud8b5gL4YiedyTrrVSFD9xALNN14/uRktVEdq rX9gcTZkElMHdRdM0gHt1kHonimtdqui5Jil/1kIcfoL9dNFiWV1ie5WBGMiH2t+/WaNwI TLSdxYtFy5Ve7eKmkVHF9gW5sWywerg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-586-fvMa_bwxNoSe0yR8r6tABQ-1; Tue, 04 Oct 2022 05:44:48 -0400 X-MC-Unique: fvMa_bwxNoSe0yR8r6tABQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D000E3C0F665; Tue, 4 Oct 2022 09:44:47 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id E55DA23177; Tue, 4 Oct 2022 09:44:46 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: skori@mavell.com, jerinj@marvell.com, Sunil Kumar Kori Subject: [PATCH v2 4/9] trace: rework loop on trace points Date: Tue, 4 Oct 2022 11:44:13 +0200 Message-Id: <20221004094418.196544-5-david.marchand@redhat.com> In-Reply-To: <20221004094418.196544-1-david.marchand@redhat.com> References: <20220921120359.2201131-1-david.marchand@redhat.com> <20221004094418.196544-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Directly skip the block when a trace point does not match the user criteria. Signed-off-by: David Marchand Acked-by: Jerin Jacob Acked-by: Sunil Kumar Kori --- lib/eal/common/eal_common_trace.c | 34 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c index 1db11e3e14..6b8660c318 100644 --- a/lib/eal/common/eal_common_trace.c +++ b/lib/eal/common/eal_common_trace.c @@ -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);