DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sunil Kumar Kori <skori@marvell.com>
To: David Marchand <david.marchand@redhat.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>
Subject: Re: [dpdk-dev] [EXT] [PATCH v2 2/4] trace: remove size limit on CTF event description
Date: Thu, 29 Oct 2020 08:41:08 +0000	[thread overview]
Message-ID: <CY4PR18MB1622AC182F098150777CFB35B4140@CY4PR18MB1622.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20201028210249.9021-3-david.marchand@redhat.com>

>-----Original Message-----
>From: David Marchand <david.marchand@redhat.com>
>Sent: Thursday, October 29, 2020 2:33 AM
>To: dev@dpdk.org
>Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Sunil Kumar Kori
><skori@marvell.com>
>Subject: [EXT] [PATCH v2 2/4] trace: remove size limit on CTF event description
>
>External Email
>
>----------------------------------------------------------------------
>Rework registration so that it uses dynamic allocations and has no size limit.
>
>Signed-off-by: David Marchand <david.marchand@redhat.com>
>Reviewed-by: Jerin Jacob <jerinj@marvell.com>
>---
> 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;

Although patch looks okay but I have one that how "tp->ctf_field" is populated because during
registration time RTE_PER_LCORE(ctf_field) will be NULL. So "tp->ctf_field" will always be 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 {
>--
>2.23.0


  reply	other threads:[~2020-10-29  8:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23  8:00 [dpdk-dev] [PATCH 0/3] Rework CTF event description storage David Marchand
2020-10-23  8:00 ` [dpdk-dev] [PATCH 1/3] trace: fixup CTF event description at registration David Marchand
2020-10-23  8:00 ` [dpdk-dev] [PATCH 2/3] trace: remove size limit on CTF event description David Marchand
2020-10-28  9:06   ` Jerin Jacob
2020-10-23  8:00 ` [dpdk-dev] [PATCH 3/3] trace: make CTF metadata prettier David Marchand
2020-10-27 19:43 ` [dpdk-dev] [PATCH 0/3] Rework CTF event description storage David Marchand
2020-10-28  8:52   ` Jerin Jacob
2020-10-28 13:09     ` David Marchand
2020-10-28 15:17       ` David Marchand
2020-10-28 15:59         ` David Marchand
2020-10-28 21:02 ` [dpdk-dev] [PATCH v2 0/4] " David Marchand
2020-10-28 21:02   ` [dpdk-dev] [PATCH v2 1/4] trace: fixup CTF event description at registration David Marchand
2020-10-29  8:35     ` [dpdk-dev] [EXT] " Sunil Kumar Kori
2020-10-28 21:02   ` [dpdk-dev] [PATCH v2 2/4] trace: remove size limit on CTF event description David Marchand
2020-10-29  8:41     ` Sunil Kumar Kori [this message]
2020-10-29  8:51       ` [dpdk-dev] [EXT] " David Marchand
2020-10-29  9:36         ` Sunil Kumar Kori
2020-10-29 10:02           ` David Marchand
2020-10-29 10:31             ` Sunil Kumar Kori
2020-10-28 21:02   ` [dpdk-dev] [PATCH v2 3/4] trace: fix metadata dump David Marchand
2020-10-29  8:36     ` [dpdk-dev] [EXT] " Sunil Kumar Kori
2020-10-28 21:02   ` [dpdk-dev] [PATCH v2 4/4] trace: make CTF metadata prettier David Marchand
2020-10-29  8:37     ` [dpdk-dev] [EXT] " Sunil Kumar Kori
2020-10-29 21:50   ` [dpdk-dev] [PATCH v2 0/4] Rework CTF event description storage David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CY4PR18MB1622AC182F098150777CFB35B4140@CY4PR18MB1622.namprd18.prod.outlook.com \
    --to=skori@marvell.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).