Skip to content

Commit

Permalink
patch: dpdk eal memory debug patch for dpdk-stable-18.11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ywc689 committed Jan 29, 2021
1 parent fbc7390 commit 379584a
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions patch/dpdk-stable-18.11.2/0006-enable-dpdk-eal-memory-debug.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
From 19652889ed74b09aba6f22dfa96b19c009a7309a Mon Sep 17 00:00:00 2001
From: ywc <ywc689@163.com>
Date: Mon, 25 Jan 2021 10:27:52 +0800
Subject: [PATCH] enable dpdk eal memory debug

---
config/common_base | 2 +-
lib/librte_eal/common/include/rte_malloc.h | 15 +++++++++++++++
lib/librte_eal/common/rte_malloc.c | 4 ++++
3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/config/common_base b/config/common_base
index d12ae98..765ae2e 100644
--- a/config/common_base
+++ b/config/common_base
@@ -94,7 +94,7 @@ CONFIG_RTE_EAL_IGB_UIO=n
CONFIG_RTE_EAL_VFIO=n
CONFIG_RTE_MAX_VFIO_GROUPS=64
CONFIG_RTE_MAX_VFIO_CONTAINERS=64
-CONFIG_RTE_MALLOC_DEBUG=n
+CONFIG_RTE_MALLOC_DEBUG=y
CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=n
CONFIG_RTE_USE_LIBBSD=n

diff --git a/lib/librte_eal/common/include/rte_malloc.h b/lib/librte_eal/common/include/rte_malloc.h
index e0be13c..f3bcdc6 100644
--- a/lib/librte_eal/common/include/rte_malloc.h
+++ b/lib/librte_eal/common/include/rte_malloc.h
@@ -214,6 +214,21 @@ struct rte_malloc_socket_stats {
rte_calloc_socket(const char *type, size_t num, size_t size, unsigned align, int socket);

/**
+ * Check the header/tailer cookies of memory pointed to by the provided pointer.
+ *
+ * This pointer must have been returned by a previous call to
+ * rte_malloc(), rte_zmalloc(), rte_calloc() or rte_realloc().
+ *
+ * @param ptr
+ * The pointer to memory to be checked.
+ * @return
+ * - true if the header/tailer cookies are OK.
+ * - Otherwise, false.
+ */
+int
+rte_memmory_ok(void *ptr);
+
+/**
* Frees the memory space pointed to by the provided pointer.
*
* This pointer must have been returned by a previous call to
diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c
index 47c2bec..1fab27c 100644
--- a/lib/librte_eal/common/rte_malloc.c
+++ b/lib/librte_eal/common/rte_malloc.c
@@ -26,6 +26,10 @@
#include "malloc_heap.h"
#include "eal_memalloc.h"

+int rte_memmory_ok(void *addr)
+{
+ return malloc_elem_cookies_ok(RTE_PTR_SUB(addr, MALLOC_ELEM_HEADER_LEN));
+}

/* Free the memory space back to heap */
void rte_free(void *addr)
--
1.8.3.1

0 comments on commit 379584a

Please sign in to comment.