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 6E21F4242B; Fri, 20 Jan 2023 11:11:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2567D40150; Fri, 20 Jan 2023 11:11:54 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 6FED2400D5 for ; Fri, 20 Jan 2023 11:11:52 +0100 (CET) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH v6 1/6] eal: trace: add trace point emit for blob Date: Fri, 20 Jan 2023 11:11:49 +0100 X-MimeOLE: Produced By Microsoft Exchange V6.5 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D8769B@smartserver.smartshare.dk> In-Reply-To: <20230120084059.2926575-2-adwivedi@marvell.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH v6 1/6] eal: trace: add trace point emit for blob Thread-Index: Adksqx2BAMUB72+yRkSEXE5C+5wjFgACileg References: <20230112112140.807233-1-adwivedi@marvell.com> <20230120084059.2926575-1-adwivedi@marvell.com> <20230120084059.2926575-2-adwivedi@marvell.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Ankur Dwivedi" , Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 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 > From: Ankur Dwivedi [mailto:adwivedi@marvell.com] > Sent: Friday, 20 January 2023 09.41 >=20 > Adds a trace point emit function for capturing a blob. The blob > captures the length passed by the application followed by the array. >=20 > The maximum blob bytes which can be captured is bounded by > RTE_TRACE_BLOB_LEN_MAX macro. The value for max blob length macro is > 64 bytes. If the length is less than 64 the remaining trailing bytes > are set to zero. >=20 > This patch also adds test case for emit blob tracepoint function. >=20 > Signed-off-by: Ankur Dwivedi > --- [...] > +/** Macro to define maximum emit length of blob. */ > +#define RTE_TRACE_BLOB_LEN_MAX 64 > + > /** > * Enable recording events of the given tracepoint in the trace > buffer. > * > @@ -374,12 +387,31 @@ do { \ > mem =3D RTE_PTR_ADD(mem, __RTE_TRACE_EMIT_STRING_LEN_MAX); \ > } while (0) >=20 > +#define rte_trace_point_emit_blob(in, len) \ > +do { \ > + if (unlikely(in =3D=3D NULL)) \ > + return; \ > + if (len > RTE_TRACE_BLOB_LEN_MAX) \ > + len =3D RTE_TRACE_BLOB_LEN_MAX; \ > + __rte_trace_point_emit(len, uint8_t); \ > + memcpy(mem, in, len); \ > + mem =3D RTE_PTR_ADD(mem, len); \ > + memset(mem, 0, RTE_TRACE_BLOB_LEN_MAX - len); \ > + mem =3D RTE_PTR_ADD(mem, RTE_TRACE_BLOB_LEN_MAX - len); \ Alternatively (just a suggestion): memcpy(mem, in, len); \ memset(RTE_PTR_ADD(mem, len), 0, RTE_TRACE_BLOB_LEN_MAX - len); \ mem =3D RTE_PTR_ADD(mem, RTE_TRACE_BLOB_LEN_MAX); \ (If memset() is annotated to inform the compiler that the mem pointer is = constant, the compiler should generate exactly the same code.) > +} while (0) > + > #else >=20 > #define __rte_trace_point_emit_header_generic(t) RTE_SET_USED(t) > #define __rte_trace_point_emit_header_fp(t) RTE_SET_USED(t) > #define __rte_trace_point_emit(in, type) RTE_SET_USED(in) > #define rte_trace_point_emit_string(in) RTE_SET_USED(in) > +#define rte_trace_point_emit_blob(in, len) \ > +do { \ > + RTE_SET_USED(in); \ > + RTE_SET_USED(len); \ > +} while (0) > + >=20 > #endif /* ALLOW_EXPERIMENTAL_API */ > #endif /* _RTE_TRACE_POINT_REGISTER_H_ */ > diff --git a/lib/eal/include/rte_trace_point_register.h > b/lib/eal/include/rte_trace_point_register.h > index a32f4d731b..7efbac8a72 100644 > --- a/lib/eal/include/rte_trace_point_register.h > +++ b/lib/eal/include/rte_trace_point_register.h > @@ -47,6 +47,15 @@ do { \ > RTE_STR(in)"[32]", "string_bounded_t"); \ > } while (0) >=20 > +#define rte_trace_point_emit_blob(in, len) \ > +do { \ > + RTE_SET_USED(in); \ > + __rte_trace_point_emit(len, uint8_t); \ > + __rte_trace_point_emit_field(RTE_TRACE_BLOB_LEN_MAX, \ > + RTE_STR(in)"["RTE_STR(RTE_TRACE_BLOB_LEN_MAX)"]", \ > + RTE_STR(uint8_t)); \ > +} while (0) I guess the variable sized trace entry couldn't be implemented. Anyway, this BLOB implementation is still very useful! Acked-by: Morten Br=F8rup