]> git.droids-corp.org - dpdk.git/commitdiff
trace: implement registration payload
authorJerin Jacob <jerinj@marvell.com>
Wed, 22 Apr 2020 19:03:29 +0000 (00:33 +0530)
committerDavid Marchand <david.marchand@redhat.com>
Thu, 23 Apr 2020 13:39:33 +0000 (15:39 +0200)
The trace function payloads such as rte_trace_point_emit_* have
dual functions. The first to emit the payload for the registration
function and the second one to act as trace memory emitters.

When it is used as registration payload, it will do the following to
fulfill the registration job.
- Find out the size of the event,
- Generate metadata field string using __rte_trace_point_emit_field().

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Acked-by: David Marchand <david.marchand@redhat.com>
lib/librte_eal/common/eal_common_trace.c
lib/librte_eal/include/rte_trace_point.h
lib/librte_eal/include/rte_trace_point_register.h
lib/librte_eal/rte_eal_version.map

index e82bb9e30f2726a2ee066c8ab98d7a189dcec146..da269debeb52cf7b0426b7d1ab0dd079132b2dc5 100644 (file)
@@ -378,6 +378,25 @@ trace_mem_per_thread_free(void)
        rte_spinlock_unlock(&trace->lock);
 }
 
+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;
+       int rc;
+
+       size = RTE_MAX(0, TRACE_CTF_FIELD_SIZE - 1 - count);
+       RTE_PER_LCORE(trace_point_sz) += sz;
+       rc = snprintf(RTE_PTR_ADD(field, count), size, "%s %s;", datatype, in);
+       if (rc <= 0 || (size_t)rc >= size) {
+               RTE_PER_LCORE(trace_point_sz) = 0;
+               trace_crit("CTF field is too long");
+               return;
+       }
+       RTE_PER_LCORE(ctf_count) += rc;
+}
+
 int
 __rte_trace_point_register(rte_trace_point_t *handle, const char *name,
                void (*register_fn)(void))
index fc3d9c4f5d466831b0d7eaa09102ecc1cb63834c..34dcba3a632f28e6cc6aaed1064a5d2f05cd2151 100644 (file)
@@ -236,6 +236,25 @@ __rte_trace_point_fp_is_enabled(void)
 __rte_experimental
 void __rte_trace_mem_per_thread_alloc(void);
 
+/**
+ * @internal
+ *
+ * Helper function to emit field.
+ *
+ * @param sz
+ *   The tracepoint size.
+ * @param field
+ *   The name of the trace event.
+ * @param type
+ *   The datatype of the trace event as string.
+ * @return
+ *   - 0: Success.
+ *   - <0: Failure.
+ */
+__rte_experimental
+void __rte_trace_point_emit_field(size_t sz, const char *field,
+       const char *type);
+
 /**
  * @internal
  *
index 6c5872a3e6b6346d6d00477f630d8bf19550ede0..4e2306f1af1337cdd83db9891f1e559a81ddf2eb 100644 (file)
@@ -17,4 +17,24 @@ RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz);
        __rte_trace_point_register(&__##trace, RTE_STR(name), \
                (void (*)(void)) trace)
 
+#define __rte_trace_point_emit_header_generic(t) \
+       RTE_PER_LCORE(trace_point_sz) = __RTE_TRACE_EVENT_HEADER_SZ
+
+#define __rte_trace_point_emit_header_fp(t) \
+       __rte_trace_point_emit_header_generic(t)
+
+#define __rte_trace_point_emit(in, type) \
+do { \
+       RTE_BUILD_BUG_ON(sizeof(type) != sizeof(typeof(in))); \
+       __rte_trace_point_emit_field(sizeof(type), RTE_STR(in), \
+               RTE_STR(type)); \
+} while (0)
+
+#define rte_trace_point_emit_string(in) \
+do { \
+       RTE_SET_USED(in); \
+       __rte_trace_point_emit_field(__RTE_TRACE_EMIT_STRING_LEN_MAX, \
+               RTE_STR(in)"[32]", "string_bounded_t"); \
+} while (0)
+
 #endif /* _RTE_TRACE_POINT_REGISTER_H_ */
index b4b3a92e5c24b41101fa3eca1d660f15c783cb47..8b51c8a5b11d626b121cc9b2143497e6ee2dd1bc 100644 (file)
@@ -338,6 +338,7 @@ EXPERIMENTAL {
 
        # added in 20.05
        __rte_trace_mem_per_thread_alloc;
+       __rte_trace_point_emit_field;
        __rte_trace_point_register;
        per_lcore_trace_mem;
        per_lcore_trace_point_sz;