[PATCH v6 1/6] eal: trace: add trace point emit for blob
Morten Brørup
mb at smartsharesystems.com
Fri Jan 20 11:11:49 CET 2023
> From: Ankur Dwivedi [mailto:adwivedi at marvell.com]
> Sent: Friday, 20 January 2023 09.41
>
> Adds a trace point emit function for capturing a blob. The blob
> captures the length passed by the application followed by the array.
>
> 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.
>
> This patch also adds test case for emit blob tracepoint function.
>
> Signed-off-by: Ankur Dwivedi <adwivedi at marvell.com>
> ---
[...]
> +/** 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 = RTE_PTR_ADD(mem, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
> } while (0)
>
> +#define rte_trace_point_emit_blob(in, len) \
> +do { \
> + if (unlikely(in == NULL)) \
> + return; \
> + if (len > RTE_TRACE_BLOB_LEN_MAX) \
> + len = RTE_TRACE_BLOB_LEN_MAX; \
> + __rte_trace_point_emit(len, uint8_t); \
> + memcpy(mem, in, len); \
> + mem = RTE_PTR_ADD(mem, len); \
> + memset(mem, 0, RTE_TRACE_BLOB_LEN_MAX - len); \
> + mem = 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 = 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
>
> #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)
> +
>
> #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)
>
> +#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ørup <mb at smartsharesystems.com>
More information about the dev
mailing list