From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C5FF6A0540; Wed, 21 Sep 2022 14:05:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B225042B8A; Wed, 21 Sep 2022 14:04:39 +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 46C5242B84 for ; Wed, 21 Sep 2022 14:04:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663761877; 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=APiQ7r9rK6oTOi5jGf2Wcwcwe/KM5rXMPTl3UOA/hvk=; b=KiP/pNdYK1e6m5a8XjNqSo97eO++1JR+4IHMcXonww1x1zXmhQRy66FHdJwtwtjfM57+tP EvYkFDxcXp+GBFapgCZw8n0zJ37ExHn/tJW7Eb6U36Z18FzVp0VMDvbkd051yX8UZkt0Q8 ot1ec8SHbMH8SjVXZaTmvKJzn2hOeAU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-30-1m0k4Wq2NJmNiCM5sD_1PQ-1; Wed, 21 Sep 2022 08:04:34 -0400 X-MC-Unique: 1m0k4Wq2NJmNiCM5sD_1PQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 354C780280C; Wed, 21 Sep 2022 12:04:34 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DAC1111F3DB; Wed, 21 Sep 2022 12:04:33 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Jerin Jacob , Sunil Kumar Kori Subject: [PATCH 7/8] trace: remove limitation on trace point name Date: Wed, 21 Sep 2022 14:03:58 +0200 Message-Id: <20220921120359.2201131-8-david.marchand@redhat.com> In-Reply-To: <20220921120359.2201131-1-david.marchand@redhat.com> References: <20220921120359.2201131-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 The name of a trace point is provided as a constant string via the RTE_TRACE_POINT_REGISTER macro. We can rely on the constant string in the binary and simply point at it. There is then no need for a (fixed size) copy. Signed-off-by: David Marchand --- lib/eal/common/eal_common_trace.c | 10 +++------- lib/eal/common/eal_common_trace_utils.c | 2 +- lib/eal/common/eal_trace.h | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c index 5280aa7d62..a2c5a72735 100644 --- a/lib/eal/common/eal_common_trace.c +++ b/lib/eal/common/eal_common_trace.c @@ -231,7 +231,7 @@ rte_trace_point_lookup(const char *name) return NULL; STAILQ_FOREACH(tp, &tp_list, next) - if (strncmp(tp->name, name, TRACE_POINT_NAME_SIZE) == 0) + if (strcmp(tp->name, name) == 0) return tp->handle; return NULL; @@ -488,10 +488,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name, } /* Initialize the trace point */ - if (rte_strscpy(tp->name, name, TRACE_POINT_NAME_SIZE) < 0) { - trace_err("name is too long"); - goto free; - } + tp->name = name; /* Copy the accumulated fields description and clear it for the next * trace point. @@ -513,8 +510,7 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name, /* All Good !!! */ return 0; -free: - free(tp); + fail: if (trace.register_errno == 0) trace.register_errno = rte_errno; diff --git a/lib/eal/common/eal_common_trace_utils.c b/lib/eal/common/eal_common_trace_utils.c index 6340caabbf..9b5a41ca12 100644 --- a/lib/eal/common/eal_common_trace_utils.c +++ b/lib/eal/common/eal_common_trace_utils.c @@ -42,7 +42,7 @@ trace_entry_compare(const char *name) int count = 0; STAILQ_FOREACH(tp, tp_list, next) { - if (strncmp(tp->name, name, TRACE_POINT_NAME_SIZE) == 0) + if (strcmp(tp->name, name) == 0) count++; if (count > 1) { trace_err("found duplicate entry %s", name); diff --git a/lib/eal/common/eal_trace.h b/lib/eal/common/eal_trace.h index 72a5a461ae..26a18a2c48 100644 --- a/lib/eal/common/eal_trace.h +++ b/lib/eal/common/eal_trace.h @@ -24,14 +24,13 @@ #define TRACE_PREFIX_LEN 12 #define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN) -#define TRACE_POINT_NAME_SIZE 64 #define TRACE_CTF_MAGIC 0xC1FC1FC1 #define TRACE_MAX_ARGS 32 struct trace_point { STAILQ_ENTRY(trace_point) next; rte_trace_point_t *handle; - char name[TRACE_POINT_NAME_SIZE]; + const char *name; char *ctf_field; }; -- 2.37.3