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 578D1A0560; Tue, 18 Oct 2022 15:36:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0DAF440395; Tue, 18 Oct 2022 15:36:38 +0200 (CEST) Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) by mails.dpdk.org (Postfix) with ESMTP id 4A4784021D for ; Tue, 18 Oct 2022 15:36:37 +0200 (CEST) Received: by mail-qv1-f54.google.com with SMTP id f14so9287599qvo.3 for ; Tue, 18 Oct 2022 06:36:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=gKHpM0tFSEeb37vmO8kLmXhegjPwnRs8mwDgtk9Y+Fc=; b=d0/jXR8cDYHLQ5jA2aV2bEJDB953ZI/SvLZzWFZcnb36KuqvagFfoKqWxwC1tOWRQv 1odlG2zpZxqyuIb/I/+upsu/o59uxakcJb9fvXax9R0Ii0QfAE6su2WZ5BHMzy5UzGAJ TPO2J43fTaq4W+CLinkFQW7gbc62I8NP8Q0MyXPu0UY8QC/csKmVd/WzOxrG4cl1UXKY CZLpma5pcAYc/ZKQsvyjJERYPeRMHq0xM87efHbfLr/hnvptJySMb1f4B5LQ+D24SnvT SoI1Oq3RUvBi2F/awzwbEHTmFTH1etj6tmNuYNXVzDaMgeYtQr4jfKn8idzorHQfXe2g DadA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gKHpM0tFSEeb37vmO8kLmXhegjPwnRs8mwDgtk9Y+Fc=; b=UmTToji0QYqxgHAjDSvPHA5Q/mLbp1pP9rlwQtoGQAkhwO6EVb1M7ptJj/MGK1UlEv hH9QUz8KVmT09dQ3ZoexVj5XA88q3Bqkh4s9WpzCmzvixKX7rMxhjAGg+FcAYim5wi+Q YBXFzETAc0eLJhN0NoMdqLvymnlyGBR6+r0D6GtKvbT7O7GVkzss+uHGeck0l+JkAVFF ydURXP88m5rTB8mLrMxue245ybSTlIErpAEjOdKFPQ7c6373rSvVMq5GH1p2ECYNjLDN B3VSQkcHS9/aYyvhr9kAHwxPKi8Svg61FymQmBt1vpjln/qgtLLfhOV+DHyHvVJMdG4a gHUQ== X-Gm-Message-State: ACrzQf3OKHlEeLfbhjqfFJopoVgF4vrjYDVHMdT99AQegH9iAokLLJv0 n8uKQ8r+CfU0ogeqKOt64VIQEjwr/3oPGfh7ldEgJ6uvbGJP3g== X-Google-Smtp-Source: AMsMyM4ET7P6LWCy4//g1+HRN6TyTkUNDkeiCXQ2RJCpqH1TPA3THZUKH34w/abtbuM2Cx9SdTsUyqKLtGY/4vhDT+U= X-Received: by 2002:a0c:b256:0:b0:4b1:9f77:91da with SMTP id k22-20020a0cb256000000b004b19f7791damr2378092qve.84.1666100196540; Tue, 18 Oct 2022 06:36:36 -0700 (PDT) MIME-Version: 1.0 References: <20220921120359.2201131-1-david.marchand@redhat.com> <20221018132654.3760561-1-david.marchand@redhat.com> <20221018132654.3760561-9-david.marchand@redhat.com> In-Reply-To: <20221018132654.3760561-9-david.marchand@redhat.com> From: Jerin Jacob Date: Tue, 18 Oct 2022 19:06:10 +0530 Message-ID: Subject: Re: [PATCH v4 08/11] trace: remove limitation on trace point name To: David Marchand Cc: dev@dpdk.org, jerinj@marvell.com, skori@marvell.com Content-Type: text/plain; charset="UTF-8" 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 On Tue, Oct 18, 2022 at 6:58 PM David Marchand wrote: > > The name of a trace point is provided as a constant string via the > RTE_TRACE_POINT_REGISTER macro. > We can rely on an explicit 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 Acked-by: Jerin Jacob > --- > Changes since v2: > - stored trace point name in a static variable to make sure the string > is put in .data, > > --- > lib/eal/common/eal_common_trace.c | 10 +++------- > lib/eal/common/eal_common_trace_utils.c | 2 +- > lib/eal/common/eal_trace.h | 3 +-- > lib/eal/include/rte_trace_point_register.h | 3 ++- > 4 files changed, 7 insertions(+), 11 deletions(-) > > diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c > index ec168e37b3..5caaac8e59 100644 > --- a/lib/eal/common/eal_common_trace.c > +++ b/lib/eal/common/eal_common_trace.c > @@ -235,7 +235,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; > @@ -492,10 +492,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. > @@ -517,8 +514,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 7bf1c05e12..72108d36a6 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; > }; > > diff --git a/lib/eal/include/rte_trace_point_register.h b/lib/eal/include/rte_trace_point_register.h > index 2e61439940..a32f4d731b 100644 > --- a/lib/eal/include/rte_trace_point_register.h > +++ b/lib/eal/include/rte_trace_point_register.h > @@ -20,9 +20,10 @@ RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz); > > #define RTE_TRACE_POINT_REGISTER(trace, name) \ > rte_trace_point_t __attribute__((section("__rte_trace_point"))) __##trace; \ > +static const char __##trace##_name[] = RTE_STR(name); \ > RTE_INIT(trace##_init) \ > { \ > - __rte_trace_point_register(&__##trace, RTE_STR(name), \ > + __rte_trace_point_register(&__##trace, __##trace##_name, \ > (void (*)(void)) trace); \ > } > > -- > 2.37.3 >