From 402321cfca9b9f954ab960ddacc1c436b5b51869 Mon Sep 17 00:00:00 2001 From: Jerin Jacob Date: Thu, 23 Apr 2020 00:33:36 +0530 Subject: [PATCH] trace: add memzone tracepoints Add the following memzone related tracepoints. - rte_eal_trace_memzone_reserve() - rte_eal_trace_memzone_lookup() - rte_eal_trace_memzone_free() Signed-off-by: Jerin Jacob Acked-by: David Marchand --- lib/librte_eal/common/eal_common_memzone.c | 8 +++++ .../common/eal_common_trace_points.c | 11 +++++++ lib/librte_eal/include/rte_eal_trace.h | 30 +++++++++++++++++++ lib/librte_eal/rte_eal_version.map | 3 ++ 4 files changed, 52 insertions(+) diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c index 86f61369b3..7c21aa921e 100644 --- a/lib/librte_eal/common/eal_common_memzone.c +++ b/lib/librte_eal/common/eal_common_memzone.c @@ -19,6 +19,7 @@ #include #include #include +#include #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_eal_trace_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,7 @@ rte_memzone_free(const struct rte_memzone *mz) if (addr != NULL) rte_free(addr); + rte_eal_trace_memzone_free(name, addr, ret); return ret; } @@ -300,6 +307,7 @@ rte_memzone_lookup(const char *name) rte_rwlock_read_unlock(&mcfg->mlock); + rte_eal_trace_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 f61285ee47..e76a66df46 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_eal_trace_mem_malloc); RTE_TRACE_POINT_DEFINE(rte_eal_trace_mem_realloc); RTE_TRACE_POINT_DEFINE(rte_eal_trace_mem_free); +RTE_TRACE_POINT_DEFINE(rte_eal_trace_memzone_reserve); +RTE_TRACE_POINT_DEFINE(rte_eal_trace_memzone_lookup); +RTE_TRACE_POINT_DEFINE(rte_eal_trace_memzone_free); + RTE_INIT(eal_trace_init) { RTE_TRACE_POINT_REGISTER(rte_eal_trace_generic_void, @@ -79,4 +83,11 @@ RTE_INIT(eal_trace_init) lib.eal.mem.realloc); RTE_TRACE_POINT_REGISTER(rte_eal_trace_mem_free, lib.eal.mem.free); + + RTE_TRACE_POINT_REGISTER(rte_eal_trace_memzone_reserve, + lib.eal.memzone.reserve); + RTE_TRACE_POINT_REGISTER(rte_eal_trace_memzone_lookup, + lib.eal.memzone.lookup); + RTE_TRACE_POINT_REGISTER(rte_eal_trace_memzone_free, + lib.eal.memzone.free); } diff --git a/lib/librte_eal/include/rte_eal_trace.h b/lib/librte_eal/include/rte_eal_trace.h index ebf750c6d0..d39989395d 100644 --- a/lib/librte_eal/include/rte_eal_trace.h +++ b/lib/librte_eal/include/rte_eal_trace.h @@ -175,6 +175,36 @@ RTE_TRACE_POINT( rte_trace_point_emit_ptr(ptr); ) +/* Memzone */ +RTE_TRACE_POINT( + rte_eal_trace_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_point_emit_string(name); + rte_trace_point_emit_long(len); + rte_trace_point_emit_int(socket_id); + rte_trace_point_emit_u32(flags); + rte_trace_point_emit_u32(align); + rte_trace_point_emit_u32(bound); + rte_trace_point_emit_ptr(mz); +) + +RTE_TRACE_POINT( + rte_eal_trace_memzone_lookup, + RTE_TRACE_POINT_ARGS(const char *name, const void *memzone), + rte_trace_point_emit_string(name); + rte_trace_point_emit_ptr(memzone); +) + +RTE_TRACE_POINT( + rte_eal_trace_memzone_free, + RTE_TRACE_POINT_ARGS(const char *name, void *addr, int rc), + rte_trace_point_emit_string(name); + rte_trace_point_emit_ptr(addr); + rte_trace_point_emit_int(rc); +) + #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 470cff5dca..edec61a9dd 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -359,6 +359,9 @@ EXPERIMENTAL { __rte_eal_trace_mem_malloc; __rte_eal_trace_mem_realloc; __rte_eal_trace_mem_zmalloc; + __rte_eal_trace_memzone_free; + __rte_eal_trace_memzone_lookup; + __rte_eal_trace_memzone_reserve; __rte_trace_mem_per_thread_alloc; __rte_trace_point_emit_field; __rte_trace_point_register; -- 2.20.1