[v3,20/33] eal/trace: add memzone tracepoints
diff mbox series

Message ID 20200329144342.1543749-21-jerinj@marvell.com
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • DPDK Trace support
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Jerin Jacob Kollanukkaran March 29, 2020, 2:43 p.m. UTC
From: Jerin Jacob <jerinj@marvell.com>

Add the following memzone related tracepoints.

rte_trace_lib_eal_memzone_reserve
rte_trace_lib_eal_memzone_lookup
rte_trace_lib_eal_memzone_free

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 lib/librte_eal/common/eal_common_memzone.c    |  9 +++++++
 .../common/eal_common_trace_points.c          | 10 +++++++
 lib/librte_eal/common/include/rte_trace_eal.h | 26 +++++++++++++++++++
 lib/librte_eal/rte_eal_version.map            |  3 +++
 4 files changed, 48 insertions(+)

Patch
diff mbox series

diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c
index 86f61369b..0f6556714 100644
--- a/lib/librte_eal/common/eal_common_memzone.c
+++ b/lib/librte_eal/common/eal_common_memzone.c
@@ -19,6 +19,7 @@ 
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_common.h>
+#include <rte_trace_eal.h>
 
 #include "malloc_heap.h"
 #include "malloc_elem.h"
@@ -201,6 +202,9 @@  rte_memzone_reserve_thread_safe(const char *name, size_t len, int socket_id,
 	mz = memzone_reserve_aligned_thread_unsafe(
 		name, len, socket_id, flags, align, bound);
 
+	rte_trace_lib_eal_memzone_reserve(name, len, socket_id, flags, align,
+					  bound, mz);
+
 	rte_rwlock_write_unlock(&mcfg->mlock);
 
 	return mz;
@@ -246,6 +250,7 @@  rte_memzone_reserve(const char *name, size_t len, int socket_id,
 int
 rte_memzone_free(const struct rte_memzone *mz)
 {
+	char name[RTE_MEMZONE_NAMESIZE];
 	struct rte_mem_config *mcfg;
 	struct rte_fbarray *arr;
 	struct rte_memzone *found_mz;
@@ -256,6 +261,7 @@  rte_memzone_free(const struct rte_memzone *mz)
 	if (mz == NULL)
 		return -EINVAL;
 
+	rte_strlcpy(name, mz->name, RTE_MEMZONE_NAMESIZE);
 	mcfg = rte_eal_get_configuration()->mem_config;
 	arr = &mcfg->memzones;
 
@@ -280,6 +286,8 @@  rte_memzone_free(const struct rte_memzone *mz)
 	if (addr != NULL)
 		rte_free(addr);
 
+	rte_trace_lib_eal_memzone_free(name, addr, ret);
+
 	return ret;
 }
 
@@ -300,6 +308,7 @@  rte_memzone_lookup(const char *name)
 
 	rte_rwlock_read_unlock(&mcfg->mlock);
 
+	rte_trace_lib_eal_memzone_lookup(name, memzone);
 	return memzone;
 }
 
diff --git a/lib/librte_eal/common/eal_common_trace_points.c b/lib/librte_eal/common/eal_common_trace_points.c
index dcae51bac..aeaeac061 100644
--- a/lib/librte_eal/common/eal_common_trace_points.c
+++ b/lib/librte_eal/common/eal_common_trace_points.c
@@ -31,6 +31,10 @@  RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_malloc);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_realloc);
 RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_mem_free);
 
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_reserve);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_lookup);
+RTE_TRACE_POINT_DEFINE(rte_trace_lib_eal_memzone_free);
+
 RTE_INIT(eal_trace_init)
 {
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_generic_void,
@@ -80,4 +84,10 @@  RTE_INIT(eal_trace_init)
 	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_mem_free,
 				 lib.eal.mem.free, INFO);
 
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_memzone_reserve,
+				 lib.eal.memzone.reserve, INFO);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_memzone_lookup,
+				 lib.eal.memzone.lookup, INFO);
+	RTE_TRACE_POINT_REGISTER(rte_trace_lib_eal_memzone_free,
+				 lib.eal.memzone.free, INFO);
 }
diff --git a/lib/librte_eal/common/include/rte_trace_eal.h b/lib/librte_eal/common/include/rte_trace_eal.h
index 597cf9ca3..abbaea5e0 100644
--- a/lib/librte_eal/common/include/rte_trace_eal.h
+++ b/lib/librte_eal/common/include/rte_trace_eal.h
@@ -166,6 +166,32 @@  RTE_TRACE_POINT(
 	rte_trace_ctf_ptr(ptr);
 )
 
+/* Memzone */
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_memzone_reserve,
+	RTE_TRACE_POINT_ARGS(const char *name, size_t len, int socket_id,
+			     unsigned int flags, unsigned int align,
+			     unsigned int bound, const void *mz),
+	rte_trace_ctf_string(name); rte_trace_ctf_long(len);
+	rte_trace_ctf_int(socket_id); rte_trace_ctf_u32(flags);
+	rte_trace_ctf_u32(align); rte_trace_ctf_u32(bound);
+	rte_trace_ctf_ptr(mz);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_memzone_lookup,
+	RTE_TRACE_POINT_ARGS(const char *name, const void *memzone),
+	rte_trace_ctf_string(name); rte_trace_ctf_ptr(memzone);
+)
+
+RTE_TRACE_POINT(
+	rte_trace_lib_eal_memzone_free,
+	RTE_TRACE_POINT_ARGS(const char *name, void *addr, int rc),
+	rte_trace_ctf_string(name); rte_trace_ctf_ptr(addr);
+	rte_trace_ctf_int(rc);
+)
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index 96c8e9099..5580b2962 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -388,4 +388,7 @@  EXPERIMENTAL {
 	__rte_trace_lib_eal_mem_malloc;
 	__rte_trace_lib_eal_mem_realloc;
 	__rte_trace_lib_eal_mem_free;
+	__rte_trace_lib_eal_memzone_reserve;
+	__rte_trace_lib_eal_memzone_lookup;
+	__rte_trace_lib_eal_memzone_free;
 };