From patchwork Wed Oct 28 21:02:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 82680 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 13BB1A04B5; Wed, 28 Oct 2020 22:03:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 44F635A62; Wed, 28 Oct 2020 22:03:11 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by dpdk.org (Postfix) with ESMTP id BBDC45947 for ; Wed, 28 Oct 2020 22:03:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603918985; 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=u3xwK1gPvqlINEPzQCq4tPiTBMPQqBsmWioN+eJKiYo=; b=M0XNZ6fQgrVbM/bQFIQmRtyICOfRkU9+oks2oC+rl0s7hl3WyfC4VkuUm+0MkakZRIOl/2 HYYKmnS6KVR0lQfeaXxpG8oKpGQLI1Jf/hTTajtMfKwMnUQ+uR9EdjlD1qegyOFXddRzPc R5NAGzIPmR3k5KKb6abUR7N9L+r+hb0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-r4DfvC5xPkOLPuK80MOPyw-1; Wed, 28 Oct 2020 17:03:01 -0400 X-MC-Unique: r4DfvC5xPkOLPuK80MOPyw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4B4F5876E3C; Wed, 28 Oct 2020 21:03:00 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.192.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FDD355766; Wed, 28 Oct 2020 21:02:58 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: jerinj@marvell.com, skori@marvell.com Date: Wed, 28 Oct 2020 22:02:46 +0100 Message-Id: <20201028210249.9021-2-david.marchand@redhat.com> In-Reply-To: <20201028210249.9021-1-david.marchand@redhat.com> References: <20201023080058.13335-1-david.marchand@redhat.com> <20201028210249.9021-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH v2 1/4] trace: fixup CTF event description at registration X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" CTF event description is currently built by appending all fields in a single string at trace point registration. When dumping the metadata, this string is split again and inspected to fixup reserved keywords and special tokens like "." or "->". Move this fixup per field at trace point registration time so that there is no need for inspecting / string parsing when dumping metadata. Use dynamic allocations to remove an artificial size limit on the CTF event description manipulations. Signed-off-by: David Marchand Acked-by: Sunil Kumar Kori --- lib/librte_eal/common/eal_common_trace.c | 5 + lib/librte_eal/common/eal_common_trace_ctf.c | 159 +++++-------------- lib/librte_eal/common/eal_trace.h | 1 + 3 files changed, 46 insertions(+), 119 deletions(-) diff --git a/lib/librte_eal/common/eal_common_trace.c b/lib/librte_eal/common/eal_common_trace.c index b6da5537fe..80b458edb6 100644 --- a/lib/librte_eal/common/eal_common_trace.c +++ b/lib/librte_eal/common/eal_common_trace.c @@ -432,11 +432,16 @@ __rte_trace_point_emit_field(size_t sz, const char *in, const char *datatype) char *field = RTE_PER_LCORE(ctf_field); int count = RTE_PER_LCORE(ctf_count); size_t size; + char *fixup; int rc; size = RTE_MAX(0, TRACE_CTF_FIELD_SIZE - 1 - count); RTE_PER_LCORE(trace_point_sz) += sz; + fixup = trace_metadata_fixup_field(in); + if (fixup != NULL) + in = fixup; rc = snprintf(RTE_PTR_ADD(field, count), size, "%s %s;", datatype, in); + free(fixup); if (rc <= 0 || (size_t)rc >= size) { RTE_PER_LCORE(trace_point_sz) = 0; trace_crit("CTF field is too long"); diff --git a/lib/librte_eal/common/eal_common_trace_ctf.c b/lib/librte_eal/common/eal_common_trace_ctf.c index 9dc91df0fb..174cdac1b0 100644 --- a/lib/librte_eal/common/eal_common_trace_ctf.c +++ b/lib/librte_eal/common/eal_common_trace_ctf.c @@ -220,131 +220,12 @@ meta_stream_emit(char **meta, int *offset) return meta_copy(meta, offset, str, rc); } -static void -string_fixed_replace(char *input, const char *search, const char *replace) -{ - char *found; - size_t len; - - found = strstr(input, search); - if (found == NULL) - return; - - if (strlen(found) != strlen(search)) - return; - - len = strlen(replace); - memcpy(found, replace, len); - found[len] = '\0'; -} - -static void -ctf_fixup_align(char *str) -{ - string_fixed_replace(str, "align", "_align"); -} - -static void -ctf_fixup_arrow_deref(char *str) -{ - const char *replace = "_"; - const char *search = "->"; - char *found; - size_t len; - - found = strstr(str, search); - if (found == NULL) - return; - - do { - memcpy(found, replace, strlen(replace)); - len = strlen(found + 2); - memcpy(found + 1, found + 2, len); - found[len + 1] = '\0'; - found = strstr(str, search); - } while (found != NULL); -} - -static void -ctf_fixup_dot_deref(char *str) -{ - const char *replace = "_"; - const char *search = "."; - char *found; - size_t len; - - found = strstr(str, search); - if (found == NULL) - return; - - len = strlen(replace); - do { - memcpy(found, replace, len); - found = strstr(str, search); - } while (found != NULL); -} - -static void -ctf_fixup_event(char *str) -{ - string_fixed_replace(str, "event", "_event"); -} - -static int -ctf_fixup_keyword(char *str) -{ - char dup_str[TRACE_CTF_FIELD_SIZE]; - char input[TRACE_CTF_FIELD_SIZE]; - const char *delim = ";"; - char *from; - int len; - - if (str == NULL) - return 0; - - len = strlen(str); - if (len >= TRACE_CTF_FIELD_SIZE) { - trace_err("ctf_field reached its maximum limit"); - return -EMSGSIZE; - } - - /* Create duplicate string */ - strcpy(dup_str, str); - - len = 0; - from = strtok(dup_str, delim); - while (from != NULL) { - strcpy(input, from); - ctf_fixup_align(input); - ctf_fixup_dot_deref(input); - ctf_fixup_arrow_deref(input); - ctf_fixup_event(input); - - strcpy(&input[strlen(input)], delim); - if ((len + strlen(input)) >= TRACE_CTF_FIELD_SIZE) { - trace_err("ctf_field reached its maximum limit"); - return -EMSGSIZE; - } - - strcpy(str + len, input); - len += strlen(input); - from = strtok(NULL, delim); - } - - return 0; -} - static int meta_event_emit(char **meta, int *offset, struct trace_point *tp) { char *str = NULL; int rc; - /* Fixup ctf field string in case it using reserved ctf keywords */ - rc = ctf_fixup_keyword(tp->ctf_field); - if (rc) - return rc; - rc = metadata_printf(&str, "event {\n" " id = %d;\n" @@ -491,3 +372,43 @@ rte_trace_metadata_dump(FILE *f) rc = fprintf(f, "%s", ctf_meta); return rc < 0 ? rc : 0; } + +char *trace_metadata_fixup_field(const char *field) +{ + const char *ctf_reserved_words[] = { + "align", + "event", + }; + unsigned int i; + char *out; + char *p; + + /* reserved keywords */ + for (i = 0; i < RTE_DIM(ctf_reserved_words); i++) { + if (strcmp(field, ctf_reserved_words[i]) != 0) + continue; + if (asprintf(&out, "_%s", ctf_reserved_words[i]) == -1) + out = NULL; + return out; + } + + /* nothing to replace, return early */ + if (strstr(field, ".") == NULL && strstr(field, "->") == NULL) + return NULL; + + out = strdup(field); + if (out == NULL) + return NULL; + p = out; + while ((p = strstr(p, ".")) != NULL) { + p[0] = '_'; + p++; + } + p = out; + while ((p = strstr(p, "->")) != NULL) { + p[0] = '_'; + p++; + memmove(p, p + 1, strlen(p)); + } + return out; +} diff --git a/lib/librte_eal/common/eal_trace.h b/lib/librte_eal/common/eal_trace.h index 438c2b73f6..8a3f6c5359 100644 --- a/lib/librte_eal/common/eal_trace.h +++ b/lib/librte_eal/common/eal_trace.h @@ -104,6 +104,7 @@ bool trace_has_duplicate_entry(void); void trace_uuid_generate(void); int trace_metadata_create(void); void trace_metadata_destroy(void); +char *trace_metadata_fixup_field(const char *field); int trace_mkdir(void); int trace_epoch_time_save(void); void trace_mem_free(void); From patchwork Wed Oct 28 21:02:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 82681 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3B81BA04B5; Wed, 28 Oct 2020 22:03:40 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DB0D55AB3; Wed, 28 Oct 2020 22:03:12 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by dpdk.org (Postfix) with ESMTP id 57C25594B for ; Wed, 28 Oct 2020 22:03:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603918984; 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=iEA170tC74h4ZGaYI3K6/+EuxEXF1B+HZo4Oa7Z3uNc=; b=M8Z4/YyciuahMIyJMI+VZJ7TXSa0ehktgHhAQ+ML1S2WdElbzSrfFaiJCnTW0YHq1mNWyl 0qtfGuXulmnsQoZw2Rkec277uzFGrCnwtX6Fdz5LoRVBS0lXg9W1RGeoi0ZvU37aAOWGqM jLh1ARPusaJWw7PX3z+YKg8cAG1hOHY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-GlbHcUf5OZG4lJNQfJ8Gqw-1; Wed, 28 Oct 2020 17:03:03 -0400 X-MC-Unique: GlbHcUf5OZG4lJNQfJ8Gqw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E04E01882FAA; Wed, 28 Oct 2020 21:03:01 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.192.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id D850855766; Wed, 28 Oct 2020 21:03:00 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: jerinj@marvell.com, skori@marvell.com Date: Wed, 28 Oct 2020 22:02:47 +0100 Message-Id: <20201028210249.9021-3-david.marchand@redhat.com> In-Reply-To: <20201028210249.9021-1-david.marchand@redhat.com> References: <20201023080058.13335-1-david.marchand@redhat.com> <20201028210249.9021-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH v2 2/4] trace: remove size limit on CTF event description X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Rework registration so that it uses dynamic allocations and has no size limit. Signed-off-by: David Marchand Reviewed-by: Jerin Jacob Acked-by: Sunil Kumar Kori --- lib/librte_eal/common/eal_common_trace.c | 39 +++++++++----------- lib/librte_eal/common/eal_common_trace_ctf.c | 3 +- lib/librte_eal/common/eal_trace.h | 3 +- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/lib/librte_eal/common/eal_common_trace.c b/lib/librte_eal/common/eal_common_trace.c index 80b458edb6..bc031ca719 100644 --- a/lib/librte_eal/common/eal_common_trace.c +++ b/lib/librte_eal/common/eal_common_trace.c @@ -17,8 +17,7 @@ RTE_DEFINE_PER_LCORE(volatile int, trace_point_sz); RTE_DEFINE_PER_LCORE(void *, trace_mem); -static RTE_DEFINE_PER_LCORE(char, ctf_field[TRACE_CTF_FIELD_SIZE]); -static RTE_DEFINE_PER_LCORE(int, ctf_count); +static RTE_DEFINE_PER_LCORE(char *, ctf_field); static struct trace_point_head tp_list = STAILQ_HEAD_INITIALIZER(tp_list); static struct trace trace = { .args = STAILQ_HEAD_INITIALIZER(trace.args), }; @@ -429,32 +428,33 @@ trace_mem_free(void) void __rte_trace_point_emit_field(size_t sz, const char *in, const char *datatype) { - char *field = RTE_PER_LCORE(ctf_field); - int count = RTE_PER_LCORE(ctf_count); - size_t size; + char *field; char *fixup; int rc; - size = RTE_MAX(0, TRACE_CTF_FIELD_SIZE - 1 - count); - RTE_PER_LCORE(trace_point_sz) += sz; fixup = trace_metadata_fixup_field(in); if (fixup != NULL) in = fixup; - rc = snprintf(RTE_PTR_ADD(field, count), size, "%s %s;", datatype, in); + rc = asprintf(&field, "%s%s %s;", + RTE_PER_LCORE(ctf_field) != NULL ? + RTE_PER_LCORE(ctf_field) : "", + datatype, in); + free(RTE_PER_LCORE(ctf_field)); free(fixup); - if (rc <= 0 || (size_t)rc >= size) { + if (rc == -1) { RTE_PER_LCORE(trace_point_sz) = 0; - trace_crit("CTF field is too long"); + RTE_PER_LCORE(ctf_field) = NULL; + trace_crit("could not allocate CTF field"); return; } - RTE_PER_LCORE(ctf_count) += rc; + RTE_PER_LCORE(trace_point_sz) += sz; + RTE_PER_LCORE(ctf_field) = field; } int __rte_trace_point_register(rte_trace_point_t *handle, const char *name, void (*register_fn)(void)) { - char *field = RTE_PER_LCORE(ctf_field); struct trace_point *tp; uint16_t sz; @@ -467,7 +467,6 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name, /* Check the size of the trace point object */ RTE_PER_LCORE(trace_point_sz) = 0; - RTE_PER_LCORE(ctf_count) = 0; register_fn(); if (RTE_PER_LCORE(trace_point_sz) == 0) { trace_err("missing rte_trace_emit_header() in register fn"); @@ -505,15 +504,11 @@ __rte_trace_point_register(rte_trace_point_t *handle, const char *name, goto free; } - /* Copy the field data for future use */ - if (rte_strscpy(tp->ctf_field, field, TRACE_CTF_FIELD_SIZE) < 0) { - trace_err("CTF field size is too long"); - rte_errno = E2BIG; - goto free; - } - - /* Clear field memory for the next event */ - memset(field, 0, TRACE_CTF_FIELD_SIZE); + /* Copy the accumulated fields description and clear it for the next + * trace point. + */ + tp->ctf_field = RTE_PER_LCORE(ctf_field); + RTE_PER_LCORE(ctf_field) = NULL; /* Form the trace handle */ *handle = sz; diff --git a/lib/librte_eal/common/eal_common_trace_ctf.c b/lib/librte_eal/common/eal_common_trace_ctf.c index 174cdac1b0..ac1f64d04b 100644 --- a/lib/librte_eal/common/eal_common_trace_ctf.c +++ b/lib/librte_eal/common/eal_common_trace_ctf.c @@ -233,7 +233,8 @@ meta_event_emit(char **meta, int *offset, struct trace_point *tp) " fields := struct {\n" " %s\n" " };\n" - "};\n\n", trace_id_get(tp->handle), tp->name, tp->ctf_field); + "};\n\n", trace_id_get(tp->handle), tp->name, + tp->ctf_field != NULL ? tp->ctf_field : ""); return meta_copy(meta, offset, str, rc); } diff --git a/lib/librte_eal/common/eal_trace.h b/lib/librte_eal/common/eal_trace.h index 8a3f6c5359..06751eb23a 100644 --- a/lib/librte_eal/common/eal_trace.h +++ b/lib/librte_eal/common/eal_trace.h @@ -24,7 +24,6 @@ #define TRACE_PREFIX_LEN 12 #define TRACE_DIR_STR_LEN (sizeof("YYYY-mm-dd-AM-HH-MM-SS") + TRACE_PREFIX_LEN) -#define TRACE_CTF_FIELD_SIZE 448 #define TRACE_POINT_NAME_SIZE 64 #define TRACE_CTF_MAGIC 0xC1FC1FC1 #define TRACE_MAX_ARGS 32 @@ -33,7 +32,7 @@ struct trace_point { STAILQ_ENTRY(trace_point) next; rte_trace_point_t *handle; char name[TRACE_POINT_NAME_SIZE]; - char ctf_field[TRACE_CTF_FIELD_SIZE]; + char *ctf_field; }; enum trace_area_e { From patchwork Wed Oct 28 21:02:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 82682 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 14BB1A04B5; Wed, 28 Oct 2020 22:04:01 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5142F5F18; Wed, 28 Oct 2020 22:03:14 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by dpdk.org (Postfix) with ESMTP id 193ED5A51 for ; Wed, 28 Oct 2020 22:03:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603918987; 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=VWAs9eXau3WN1I8xOrgrp2BtJIHTk/VhkHybusOzW2M=; b=K0j0Oil/kg+UhrGl3H+d08C0JIAuv5XgSYPedODZ2XlbPk/dsJt2+Cx54HEAlW/AdXRi5z 8ugG8sZOesgjnTaxztsacc12edY3sNly7RV/3jVcS/3CCIilENZBa5SZOvbD/ZARZszA8K yG7tvLYsvkJN4h8AfobrlzNTX7qA44k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-567-ga-va9gbN2qCKsotOZDUcw-1; Wed, 28 Oct 2020 17:03:05 -0400 X-MC-Unique: ga-va9gbN2qCKsotOZDUcw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6EB5464162; Wed, 28 Oct 2020 21:03:03 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.192.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6885A6266E; Wed, 28 Oct 2020 21:03:02 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: jerinj@marvell.com, skori@marvell.com Date: Wed, 28 Oct 2020 22:02:48 +0100 Message-Id: <20201028210249.9021-4-david.marchand@redhat.com> In-Reply-To: <20201028210249.9021-1-david.marchand@redhat.com> References: <20201023080058.13335-1-david.marchand@redhat.com> <20201028210249.9021-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH v2 3/4] trace: fix metadata dump X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The ctf metadata is written to the metadata file without any check for length, so this string must be null terminated. Fixes: f1a099f5b1f1 ("trace: create CTF TDSL metadata in memory") Signed-off-by: David Marchand Acked-by: Sunil Kumar Kori --- lib/librte_eal/common/eal_common_trace_ctf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_trace_ctf.c b/lib/librte_eal/common/eal_common_trace_ctf.c index ac1f64d04b..22615c4e73 100644 --- a/lib/librte_eal/common/eal_common_trace_ctf.c +++ b/lib/librte_eal/common/eal_common_trace_ctf.c @@ -37,11 +37,12 @@ meta_copy(char **meta, int *offset, char *str, int rc) if (rc < 0) return rc; - ptr = realloc(ptr, count + rc); + ptr = realloc(ptr, count + rc + 1); if (ptr == NULL) goto free_str; memcpy(RTE_PTR_ADD(ptr, count), str, rc); + ptr[count + rc] = '\0'; count += rc; free(str); From patchwork Wed Oct 28 21:02:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 82683 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CD869A04B5; Wed, 28 Oct 2020 22:04:20 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B58EA6938; Wed, 28 Oct 2020 22:03:22 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by dpdk.org (Postfix) with ESMTP id 68F845AA7 for ; Wed, 28 Oct 2020 22:03:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603918990; 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=1XL2UeU4iIu0gNED6mxl6y2w/O0ZMiY1H6BvB8rkX40=; b=df6pCiWa6CfVjuekQm0tPeKTVHOfs+iTKSDo4+BpkFyNJrnOaWsVOynHCJyhuBGgwu6ZX8 K8EUqdRCjdT4cR4JL8QNks9m7ruKy6olmPYV7+Nlvry19mXSZ9BMQJ0Il/PsFbGLtzUobN vOlOGiqPFDmx3ExySl2/28pf3oXyUFI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-39-jLSpts70OLWleMHVi3znaQ-1; Wed, 28 Oct 2020 17:03:06 -0400 X-MC-Unique: jLSpts70OLWleMHVi3znaQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0124E8797F6; Wed, 28 Oct 2020 21:03:05 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.192.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED09E55781; Wed, 28 Oct 2020 21:03:03 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: jerinj@marvell.com, skori@marvell.com Date: Wed, 28 Oct 2020 22:02:49 +0100 Message-Id: <20201028210249.9021-5-david.marchand@redhat.com> In-Reply-To: <20201028210249.9021-1-david.marchand@redhat.com> References: <20201023080058.13335-1-david.marchand@redhat.com> <20201028210249.9021-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH v2 4/4] trace: make CTF metadata prettier X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This is simply a cosmetic change. Before: event { id = 17; name = "lib.eal.alarm.set"; fields := struct { uint64_t us;uintptr_t cb_fn;uintptr_t cb_arg;int32_t rc; }; }; After: event { id = 17; name = "lib.eal.alarm.set"; fields := struct { uint64_t us; uintptr_t cb_fn; uintptr_t cb_arg; int32_t rc; }; }; Signed-off-by: David Marchand Acked-by: Sunil Kumar Kori --- lib/librte_eal/common/eal_common_trace.c | 2 +- lib/librte_eal/common/eal_common_trace_ctf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/eal_common_trace.c b/lib/librte_eal/common/eal_common_trace.c index bc031ca719..24e27387b1 100644 --- a/lib/librte_eal/common/eal_common_trace.c +++ b/lib/librte_eal/common/eal_common_trace.c @@ -435,7 +435,7 @@ __rte_trace_point_emit_field(size_t sz, const char *in, const char *datatype) fixup = trace_metadata_fixup_field(in); if (fixup != NULL) in = fixup; - rc = asprintf(&field, "%s%s %s;", + rc = asprintf(&field, "%s %s %s;\n", RTE_PER_LCORE(ctf_field) != NULL ? RTE_PER_LCORE(ctf_field) : "", datatype, in); diff --git a/lib/librte_eal/common/eal_common_trace_ctf.c b/lib/librte_eal/common/eal_common_trace_ctf.c index 22615c4e73..33e419aac7 100644 --- a/lib/librte_eal/common/eal_common_trace_ctf.c +++ b/lib/librte_eal/common/eal_common_trace_ctf.c @@ -232,7 +232,7 @@ meta_event_emit(char **meta, int *offset, struct trace_point *tp) " id = %d;\n" " name = \"%s\";\n" " fields := struct {\n" - " %s\n" + "%s" " };\n" "};\n\n", trace_id_get(tp->handle), tp->name, tp->ctf_field != NULL ? tp->ctf_field : "");