Use global debug flag RTE_DEBUG instead of RTE_LIBRTE_MEMPOOL_DEBUG. The old define is completely removed from source code and config. Documentation was also updated.
Signed-off-by: Lukasz Wojciechowski <l.wojciec...@partner.samsung.com> --- config/common_base | 1 - doc/guides/prog_guide/mempool_lib.rst | 7 ++++--- lib/librte_mempool/rte_mempool.c | 16 ++++++++-------- lib/librte_mempool/rte_mempool.h | 20 ++++++++++---------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/config/common_base b/config/common_base index c24086789..b975a1feb 100644 --- a/config/common_base +++ b/config/common_base @@ -828,7 +828,6 @@ CONFIG_RTE_LIBRTE_STACK=y # CONFIG_RTE_LIBRTE_MEMPOOL=y CONFIG_RTE_MEMPOOL_CACHE_MAX_SIZE=512 -CONFIG_RTE_LIBRTE_MEMPOOL_DEBUG=n # # Compile Mempool drivers diff --git a/doc/guides/prog_guide/mempool_lib.rst b/doc/guides/prog_guide/mempool_lib.rst index f8b430d65..b8104163e 100644 --- a/doc/guides/prog_guide/mempool_lib.rst +++ b/doc/guides/prog_guide/mempool_lib.rst @@ -17,14 +17,15 @@ This library is used by the :ref:`Mbuf Library <Mbuf_Library>`. Cookies ------- -In debug mode (CONFIG_RTE_LIBRTE_MEMPOOL_DEBUG is enabled), cookies are added at the beginning and end of allocated blocks. +In debug mode (RTE_DEBUG is enabled), cookies are added at the beginning and end of allocated blocks. The allocated objects then contain overwrite protection fields to help debugging buffer overflows. +The RTE_DEBUG flag can be enabled using meson "debug" option. Stats ----- -In debug mode (CONFIG_RTE_LIBRTE_MEMPOOL_DEBUG is enabled), -statistics about get from/put in the pool are stored in the mempool structure. +In debug mode (RTE_DEBUG is enabled), statistics about get from/put in the pool +are stored in the mempool structure. Statistics are per-lcore to avoid concurrent access to statistics counters. Memory Alignment Constraints on x86 architecture diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 712c839a0..7772895cc 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -164,7 +164,7 @@ mempool_add_elem(struct rte_mempool *mp, __rte_unused void *opaque, STAILQ_INSERT_TAIL(&mp->elt_list, hdr, next); mp->populated_size++; -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE2; tlr = __mempool_get_trailer(obj); tlr->cookie = RTE_MEMPOOL_TRAILER_COOKIE; @@ -219,7 +219,7 @@ rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags, sz->header_size = RTE_ALIGN_CEIL(sz->header_size, RTE_MEMPOOL_ALIGN); -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG sz->trailer_size = sizeof(struct rte_mempool_objtlr); #else sz->trailer_size = 0; @@ -806,7 +806,7 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, RTE_CACHE_LINE_MASK) != 0); RTE_BUILD_BUG_ON((sizeof(struct rte_mempool_cache) & RTE_CACHE_LINE_MASK) != 0); -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG RTE_BUILD_BUG_ON((sizeof(struct rte_mempool_debug_stats) & RTE_CACHE_LINE_MASK) != 0); RTE_BUILD_BUG_ON((offsetof(struct rte_mempool, stats) & @@ -1033,7 +1033,7 @@ rte_mempool_dump_cache(FILE *f, const struct rte_mempool *mp) void rte_mempool_check_cookies(const struct rte_mempool *mp, void * const *obj_table_const, unsigned n, int free) { -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG struct rte_mempool_objhdr *hdr; struct rte_mempool_objtlr *tlr; uint64_t cookie; @@ -1102,7 +1102,7 @@ void rte_mempool_contig_blocks_check_cookies(const struct rte_mempool *mp, void * const *first_obj_table_const, unsigned int n, int free) { -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG struct rte_mempool_info info; const size_t total_elt_sz = mp->header_size + mp->elt_size + mp->trailer_size; @@ -1128,7 +1128,7 @@ rte_mempool_contig_blocks_check_cookies(const struct rte_mempool *mp, #endif } -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG static void mempool_obj_audit(struct rte_mempool *mp, __rte_unused void *opaque, void *obj, __rte_unused unsigned idx) @@ -1192,7 +1192,7 @@ rte_mempool_audit(struct rte_mempool *mp) void rte_mempool_dump(FILE *f, struct rte_mempool *mp) { -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG struct rte_mempool_info info; struct rte_mempool_debug_stats sum; unsigned lcore_id; @@ -1234,7 +1234,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp) fprintf(f, " common_pool_count=%u\n", common_count); /* sum and dump statistics */ -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG rte_mempool_ops_get_info(mp, &info); memset(&sum, 0, sizeof(sum)); for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index c90cf3146..dd16c1146 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -59,7 +59,7 @@ extern "C" { #define RTE_MEMPOOL_HEADER_COOKIE2 0xf2eef2eedadd2e55ULL /**< Header cookie. */ #define RTE_MEMPOOL_TRAILER_COOKIE 0xadd2e55badbadbadULL /**< Trailer cookie.*/ -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG /** * A structure that stores the mempool statistics (per-lcore). */ @@ -141,7 +141,7 @@ struct rte_mempool_objhdr { rte_iova_t iova; /**< IO address of the object. */ phys_addr_t physaddr; /**< deprecated - Physical address of the object. */ }; -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG uint64_t cookie; /**< Debug cookie. */ #endif }; @@ -151,7 +151,7 @@ struct rte_mempool_objhdr { */ STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr); -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG /** * Mempool object trailer structure @@ -254,7 +254,7 @@ struct rte_mempool { uint32_t nb_mem_chunks; /**< Number of memory chunks */ struct rte_mempool_memhdr_list mem_list; /**< List of memory chunks */ -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG /** Per-lcore statistics. */ struct rte_mempool_debug_stats stats[RTE_MAX_LCORE]; #endif @@ -279,7 +279,7 @@ struct rte_mempool { * @param n * Number to add to the object-oriented statistics. */ -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG #define __MEMPOOL_STAT_ADD(mp, name, n) do { \ unsigned __lcore_id = rte_lcore_id(); \ if (__lcore_id < RTE_MAX_LCORE) { \ @@ -357,12 +357,12 @@ static inline struct rte_mempool_objtlr *__mempool_get_trailer(void *obj) void rte_mempool_check_cookies(const struct rte_mempool *mp, void * const *obj_table_const, unsigned n, int free); -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG #define __mempool_check_cookies(mp, obj_table_const, n, free) \ rte_mempool_check_cookies(mp, obj_table_const, n, free) #else #define __mempool_check_cookies(mp, obj_table_const, n, free) do {} while(0) -#endif /* RTE_LIBRTE_MEMPOOL_DEBUG */ +#endif /* RTE_DEBUG */ /** * @warning @@ -385,7 +385,7 @@ void rte_mempool_check_cookies(const struct rte_mempool *mp, void rte_mempool_contig_blocks_check_cookies(const struct rte_mempool *mp, void * const *first_obj_table_const, unsigned int n, int free); -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG #define __mempool_contig_blocks_check_cookies(mp, first_obj_table_const, n, \ free) \ rte_mempool_contig_blocks_check_cookies(mp, first_obj_table_const, n, \ @@ -394,7 +394,7 @@ void rte_mempool_contig_blocks_check_cookies(const struct rte_mempool *mp, #define __mempool_contig_blocks_check_cookies(mp, first_obj_table_const, n, \ free) \ do {} while (0) -#endif /* RTE_LIBRTE_MEMPOOL_DEBUG */ +#endif /* RTE_DEBUG */ #define RTE_MEMPOOL_OPS_NAMESIZE 32 /**< Max length of ops struct name. */ @@ -1337,7 +1337,7 @@ __mempool_generic_put(struct rte_mempool *mp, void * const *obj_table, ring_enqueue: /* push remaining objects in ring */ -#ifdef RTE_LIBRTE_MEMPOOL_DEBUG +#ifdef RTE_DEBUG if (rte_mempool_ops_enqueue_bulk(mp, obj_table, n) < 0) rte_panic("cannot put objects in mempool\n"); #else -- 2.17.1