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 ED7A5A0548; Tue, 11 Oct 2022 16:49:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DC5F542DE1; Tue, 11 Oct 2022 16:49:44 +0200 (CEST) Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by mails.dpdk.org (Postfix) with ESMTP id EB7F842B7D for ; Tue, 11 Oct 2022 16:49:42 +0200 (CEST) Received: by mail-qk1-f177.google.com with SMTP id 8so1140673qka.1 for ; Tue, 11 Oct 2022 07:49:42 -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=mG2xRuE46SCGKhAyjaN5Q+dU8Dy0BKZX8w9DG7dz+/s=; b=QjUKn6+OOrinbODMGOXb8/q8htvFwdR333A2ng5bmuDEAqmxqQVhTxvIciyvOIcEkM omHLKGNULk3Q3rAcOLKmA9uKU44sa+6d+6QhmZ69PewfJZFvfCG1KqmKb7SMQ3JUsSzs j0B+7pnxkIw6wtNe+u+4hWKI6FTbkDUqGPVk6O2N9B5P7Qw9NATC+fhThuQgZL47Y1c4 9NKg1FJqQzBCbLiYQUTonsVYb+0/C9LGDzdskZHjkxp8Yayw+r0UGVnP9gWZ3GbEIBbt lP+LAN6xioVGdfKLWq8SRcinsItNRLgD3ayZFHBUetOGXZTuQEuId2FcykfHjVjq5tx9 yshQ== 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=mG2xRuE46SCGKhAyjaN5Q+dU8Dy0BKZX8w9DG7dz+/s=; b=3FPwBn7FTpoV1ZVuAvMKsG+ieHjpZ0Ls6EsWUiFt22xvkMCrB9RzLim+xdCZVTVYOI +GqSTRFNxru+Rz+3ONoUQ7M23eGWnTRWM4L7VeRiwgmtRwdp+o4m7lmvYgTihfXSQ7Ai sX/lcIW1cTQvQuMuujbfHMKS3GUzDWyjv5ehBARbo/SZK4UkpnL8HjsLl/SneuMTqeuU p/RGdG1mCXQOrX36Khh88D6g7J7DggFnSMmMWlRWI64ThcOsCEpeXwaBAazGMlCdE3B6 vgPCOKQPCdLIPzQOK2Dc+FxABnae7OdUSuV4QQLyeZqRrVwnw66kVpCxjpj3pxiZtAxk 2/Yg== X-Gm-Message-State: ACrzQf0MnlLw6YyPcUfOxDqVfIBn0aoU75GZzR0+TZtBjP12UghuF6/1 hS89iBNMNdVznn7FA1keespqPaTxyFH4G78zxRQ= X-Google-Smtp-Source: AMsMyM7AN/mQFkBI4wWzNFQam27SS2Mes6bBKKHrEECcYQq74LJo8DCpt54Xf6h9zJV5UV2FmaBG6HghsqrdfmlMSw8= X-Received: by 2002:a05:620a:2b90:b0:6ce:30a5:b716 with SMTP id dz16-20020a05620a2b9000b006ce30a5b716mr17328169qkb.494.1665499782315; Tue, 11 Oct 2022 07:49:42 -0700 (PDT) MIME-Version: 1.0 References: <20220921120359.2201131-1-david.marchand@redhat.com> <20220921120359.2201131-8-david.marchand@redhat.com> In-Reply-To: <20220921120359.2201131-8-david.marchand@redhat.com> From: Jerin Jacob Date: Tue, 11 Oct 2022 20:19:16 +0530 Message-ID: Subject: Re: [PATCH 7/8] trace: remove limitation on trace point name To: David Marchand Cc: dev@dpdk.org, Jerin Jacob , Sunil Kumar Kori 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 Wed, Sep 21, 2022 at 5:35 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 the constant string in the binary and simply point at it. I am not sure about this. If we compile with -Os (optimized for space) compiler may decide to use stack instead of rodata. If so, we will have segfaults with specific compiler or compiler build options. Thoughts? > 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 >