Add the following memory-related tracepoints.
- rte_eal_trace_mem_zmalloc()
- rte_eal_trace_mem_malloc()
- rte_eal_trace_mem_realloc()
- rte_eal_trace_mem_free()
rte_malloc() and rte_free() has been used in the trace implementation,
in order to avoid tracing implementation specific events, added
an internal no trace version rte_malloc() and rte_free().
Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Acked-by: David Marchand <david.marchand@redhat.com>
}
/* First attempt from huge page */
- header = rte_malloc(NULL, trace_mem_sz(trace->buff_len), 8);
+ header = eal_malloc_no_trace(NULL, trace_mem_sz(trace->buff_len), 8);
if (header) {
trace->lcore_meta[count].area = TRACE_AREA_HUGEPAGE;
goto found;
for (count = 0; count < trace->nb_trace_mem_list; count++) {
mem = trace->lcore_meta[count].mem;
if (trace->lcore_meta[count].area == TRACE_AREA_HUGEPAGE)
- rte_free(mem);
+ eal_free_no_trace(mem);
else if (trace->lcore_meta[count].area == TRACE_AREA_HEAP)
free(mem);
}
RTE_TRACE_POINT_DEFINE(rte_eal_trace_alarm_set);
RTE_TRACE_POINT_DEFINE(rte_eal_trace_alarm_cancel);
+RTE_TRACE_POINT_DEFINE(rte_eal_trace_mem_zmalloc);
+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_INIT(eal_trace_init)
{
RTE_TRACE_POINT_REGISTER(rte_eal_trace_generic_void,
lib.eal.alarm.set);
RTE_TRACE_POINT_REGISTER(rte_eal_trace_alarm_cancel,
lib.eal.alarm.cancel);
+
+ RTE_TRACE_POINT_REGISTER(rte_eal_trace_mem_zmalloc,
+ lib.eal.mem.zmalloc);
+ RTE_TRACE_POINT_REGISTER(rte_eal_trace_mem_malloc,
+ lib.eal.mem.malloc);
+ RTE_TRACE_POINT_REGISTER(rte_eal_trace_mem_realloc,
+ lib.eal.mem.realloc);
+ RTE_TRACE_POINT_REGISTER(rte_eal_trace_mem_free,
+ lib.eal.mem.free);
}
uint64_t
eal_get_baseaddr(void);
+void *
+eal_malloc_no_trace(const char *type, size_t size, unsigned int align);
+
+void eal_free_no_trace(void *addr);
+
#endif /* _EAL_PRIVATE_H_ */
#include <rte_lcore.h>
#include <rte_common.h>
#include <rte_spinlock.h>
+#include <rte_eal_trace.h>
#include <rte_malloc.h>
#include "malloc_elem.h"
/* Free the memory space back to heap */
-void rte_free(void *addr)
+static void
+mem_free(void *addr, const bool trace_ena)
{
+ if (trace_ena)
+ rte_eal_trace_mem_free(addr);
+
if (addr == NULL) return;
if (malloc_heap_free(malloc_elem_from_data(addr)) < 0)
RTE_LOG(ERR, EAL, "Error: Invalid memory\n");
}
-/*
- * Allocate memory on specified heap.
- */
-void *
-rte_malloc_socket(const char *type, size_t size, unsigned int align,
- int socket_arg)
+void
+rte_free(void *addr)
{
+ return mem_free(addr, true);
+}
+
+void
+eal_free_no_trace(void *addr)
+{
+ return mem_free(addr, false);
+}
+
+static void *
+malloc_socket(const char *type, size_t size, unsigned int align,
+ int socket_arg, const bool trace_ena)
+{
+ void *ptr;
+
/* return NULL if size is 0 or alignment is not power-of-2 */
if (size == 0 || (align && !rte_is_power_of_2(align)))
return NULL;
!rte_eal_has_hugepages())
socket_arg = SOCKET_ID_ANY;
- return malloc_heap_alloc(type, size, socket_arg, 0,
+ ptr = malloc_heap_alloc(type, size, socket_arg, 0,
align == 0 ? 1 : align, 0, false);
+
+ if (trace_ena)
+ rte_eal_trace_mem_malloc(type, size, align, socket_arg, ptr);
+ return ptr;
+}
+
+/*
+ * Allocate memory on specified heap.
+ */
+void *
+rte_malloc_socket(const char *type, size_t size, unsigned int align,
+ int socket_arg)
+{
+ return malloc_socket(type, size, align, socket_arg, true);
+}
+
+void *
+eal_malloc_no_trace(const char *type, size_t size, unsigned int align)
+{
+ return malloc_socket(type, size, align, SOCKET_ID_ANY, false);
}
/*
if (ptr != NULL)
memset(ptr, 0, size);
#endif
+
+ rte_eal_trace_mem_zmalloc(type, size, align, socket, ptr);
return ptr;
}
if ((socket == SOCKET_ID_ANY ||
(unsigned int)socket == elem->heap->socket_id) &&
RTE_PTR_ALIGN(ptr, align) == ptr &&
- malloc_heap_resize(elem, size) == 0)
+ malloc_heap_resize(elem, size) == 0) {
+ rte_eal_trace_mem_realloc(size, align, socket, ptr);
return ptr;
+ }
/* either requested socket id doesn't match, alignment is off
* or we have no room to expand,
rte_memcpy(new_ptr, ptr, old_size < size ? old_size : size);
rte_free(ptr);
+ rte_eal_trace_mem_realloc(size, align, socket, new_ptr);
return new_ptr;
}
rte_trace_point_emit_int(count);
)
+/* Memory */
+RTE_TRACE_POINT(
+ rte_eal_trace_mem_zmalloc,
+ RTE_TRACE_POINT_ARGS(const char *type, size_t size, unsigned int align,
+ int socket, void *ptr),
+ rte_trace_point_emit_string(type);
+ rte_trace_point_emit_long(size);
+ rte_trace_point_emit_u32(align);
+ rte_trace_point_emit_int(socket);
+ rte_trace_point_emit_ptr(ptr);
+)
+
+RTE_TRACE_POINT(
+ rte_eal_trace_mem_malloc,
+ RTE_TRACE_POINT_ARGS(const char *type, size_t size, unsigned int align,
+ int socket, void *ptr),
+ rte_trace_point_emit_string(type);
+ rte_trace_point_emit_long(size);
+ rte_trace_point_emit_u32(align);
+ rte_trace_point_emit_int(socket);
+ rte_trace_point_emit_ptr(ptr);
+)
+
+RTE_TRACE_POINT(
+ rte_eal_trace_mem_realloc,
+ RTE_TRACE_POINT_ARGS(size_t size, unsigned int align, int socket,
+ void *ptr),
+ rte_trace_point_emit_long(size);
+ rte_trace_point_emit_u32(align);
+ rte_trace_point_emit_int(socket);
+ rte_trace_point_emit_ptr(ptr);
+)
+
+RTE_TRACE_POINT(
+ rte_eal_trace_mem_free,
+ RTE_TRACE_POINT_ARGS(void *ptr),
+ rte_trace_point_emit_ptr(ptr);
+)
+
#ifdef __cplusplus
}
#endif
__rte_eal_trace_generic_u64;
__rte_eal_trace_generic_u8;
__rte_eal_trace_generic_void;
+ __rte_eal_trace_mem_free;
+ __rte_eal_trace_mem_malloc;
+ __rte_eal_trace_mem_realloc;
+ __rte_eal_trace_mem_zmalloc;
__rte_trace_mem_per_thread_alloc;
__rte_trace_point_emit_field;
__rte_trace_point_register;