[v2,3/3] mbuf: standardize library debug flag
Checks
Commit Message
Use standardized debug macro RTE_DEBUG_MBUF instead of
RTE_LIBRTE_MBUF_DEBUG for wrapping sanity checks.
Add runtime control of running sanity checks basing on
rte_log_can_log() function.
To run mbuf sanity checks all following conditions must occur:
1) RTE_DEBUG_MBUF - must be defined, this can be done by enabling meson
rte_debug option or defining CFLAGS="-DRTE_DEBUG_MBUF"
2) global log level must be set to RTE_LOG_DEBUG
3) mbuf library logtype log level (lib.mbuf) must be set to RTE_LOG_DEBUG
Tests and documentation were also updated.
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
---
app/test/test_mbuf.c | 3 ++-
config/common_base | 1 -
doc/guides/prog_guide/mbuf_lib.rst | 2 +-
lib/librte_mbuf/rte_mbuf.h | 12 ++++++++----
4 files changed, 11 insertions(+), 7 deletions(-)
Comments
On Wed, Apr 22, 2020 at 11:45:55PM +0200, Lukasz Wojciechowski wrote:
> Use standardized debug macro RTE_DEBUG_MBUF instead of
> RTE_LIBRTE_MBUF_DEBUG for wrapping sanity checks.
>
> Add runtime control of running sanity checks basing on
> rte_log_can_log() function.
>
> To run mbuf sanity checks all following conditions must occur:
> 1) RTE_DEBUG_MBUF - must be defined, this can be done by enabling meson
> rte_debug option or defining CFLAGS="-DRTE_DEBUG_MBUF"
> 2) global log level must be set to RTE_LOG_DEBUG
> 3) mbuf library logtype log level (lib.mbuf) must be set to RTE_LOG_DEBUG
>
> Tests and documentation were also updated.
>
> Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
> ---
> app/test/test_mbuf.c | 3 ++-
> config/common_base | 1 -
> doc/guides/prog_guide/mbuf_lib.rst | 2 +-
> lib/librte_mbuf/rte_mbuf.h | 12 ++++++++----
> 4 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c
> index 8200b4f71..b7b956659 100644
> --- a/app/test/test_mbuf.c
> +++ b/app/test/test_mbuf.c
> @@ -994,7 +994,8 @@ test_pktmbuf_free_segment(struct rte_mempool *pktmbuf_pool)
> /*
> * Stress test for rte_mbuf atomic refcnt.
> * Implies that RTE_MBUF_REFCNT_ATOMIC is defined.
> - * For more efficiency, recommended to run with RTE_LIBRTE_MBUF_DEBUG defined.
> + * For more efficiency, recommended to run with RTE_DEBUG_MBUF defined
> + * or using rte_debug meson build option.
> */
>
> #ifdef RTE_MBUF_REFCNT_ATOMIC
> diff --git a/config/common_base b/config/common_base
> index 38c5ada26..80fa3281f 100644
> --- a/config/common_base
> +++ b/config/common_base
> @@ -859,7 +859,6 @@ CONFIG_RTE_LIBRTE_OCTEONTX2_MEMPOOL=y
> # Compile librte_mbuf
> #
> CONFIG_RTE_LIBRTE_MBUF=y
> -CONFIG_RTE_LIBRTE_MBUF_DEBUG=n
This provides no "standard" way to enable the debug options with make,
right? I think that is perhaps a step too far. Two options I see:
* Rather than dropping this flag, it could be converted inside the mbuf
library (maybe the makefile) to the new version
* Replace this macro with CONFIG_RTE_DEBUG_MBUF
What do you think?
/Bruce
W dniu 26.06.2020 o 19:00, Bruce Richardson pisze:
> On Wed, Apr 22, 2020 at 11:45:55PM +0200, Lukasz Wojciechowski wrote:
>> Use standardized debug macro RTE_DEBUG_MBUF instead of
>> RTE_LIBRTE_MBUF_DEBUG for wrapping sanity checks.
>>
>> Add runtime control of running sanity checks basing on
>> rte_log_can_log() function.
>>
>> To run mbuf sanity checks all following conditions must occur:
>> 1) RTE_DEBUG_MBUF - must be defined, this can be done by enabling meson
>> rte_debug option or defining CFLAGS="-DRTE_DEBUG_MBUF"
>> 2) global log level must be set to RTE_LOG_DEBUG
>> 3) mbuf library logtype log level (lib.mbuf) must be set to RTE_LOG_DEBUG
>>
>> Tests and documentation were also updated.
>>
>> Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
>> ---
>> app/test/test_mbuf.c | 3 ++-
>> config/common_base | 1 -
>> doc/guides/prog_guide/mbuf_lib.rst | 2 +-
>> lib/librte_mbuf/rte_mbuf.h | 12 ++++++++----
>> 4 files changed, 11 insertions(+), 7 deletions(-)
>>
>> diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c
>> index 8200b4f71..b7b956659 100644
>> --- a/app/test/test_mbuf.c
>> +++ b/app/test/test_mbuf.c
>> @@ -994,7 +994,8 @@ test_pktmbuf_free_segment(struct rte_mempool *pktmbuf_pool)
>> /*
>> * Stress test for rte_mbuf atomic refcnt.
>> * Implies that RTE_MBUF_REFCNT_ATOMIC is defined.
>> - * For more efficiency, recommended to run with RTE_LIBRTE_MBUF_DEBUG defined.
>> + * For more efficiency, recommended to run with RTE_DEBUG_MBUF defined
>> + * or using rte_debug meson build option.
>> */
>>
>> #ifdef RTE_MBUF_REFCNT_ATOMIC
>> diff --git a/config/common_base b/config/common_base
>> index 38c5ada26..80fa3281f 100644
>> --- a/config/common_base
>> +++ b/config/common_base
>> @@ -859,7 +859,6 @@ CONFIG_RTE_LIBRTE_OCTEONTX2_MEMPOOL=y
>> # Compile librte_mbuf
>> #
>> CONFIG_RTE_LIBRTE_MBUF=y
>> -CONFIG_RTE_LIBRTE_MBUF_DEBUG=n
> This provides no "standard" way to enable the debug options with make,
> right? I think that is perhaps a step too far. Two options I see:
> * Rather than dropping this flag, it could be converted inside the mbuf
> library (maybe the makefile) to the new version
> * Replace this macro with CONFIG_RTE_DEBUG_MBUF
>
> What do you think?
I prefer the second option because we want to standardize the names - so
let it be only one flag with proper name. Using conversion would be a
bit messy as probably final user will be able to achieve the same effect
using either old or new flag.
Change applied in v3.
> /Bruce
>
>
@@ -994,7 +994,8 @@ test_pktmbuf_free_segment(struct rte_mempool *pktmbuf_pool)
/*
* Stress test for rte_mbuf atomic refcnt.
* Implies that RTE_MBUF_REFCNT_ATOMIC is defined.
- * For more efficiency, recommended to run with RTE_LIBRTE_MBUF_DEBUG defined.
+ * For more efficiency, recommended to run with RTE_DEBUG_MBUF defined
+ * or using rte_debug meson build option.
*/
#ifdef RTE_MBUF_REFCNT_ATOMIC
@@ -859,7 +859,6 @@ CONFIG_RTE_LIBRTE_OCTEONTX2_MEMPOOL=y
# Compile librte_mbuf
#
CONFIG_RTE_LIBRTE_MBUF=y
-CONFIG_RTE_LIBRTE_MBUF_DEBUG=n
CONFIG_RTE_MBUF_DEFAULT_MEMPOOL_OPS="ring_mp_mc"
CONFIG_RTE_MBUF_REFCNT_ATOMIC=y
CONFIG_RTE_PKTMBUF_HEADROOM=128
@@ -243,7 +243,7 @@ can be found in several of the sample applications, for example, the IPv4 Multic
Debug
-----
-In debug mode (CONFIG_RTE_MBUF_DEBUG is enabled),
+In debug mode (RTE_DEBUG_MBUF is enabled, e.g. by using "rte_debug" option during meson build),
the functions of the mbuf library perform sanity checks before any operation (such as, buffer corruption, bad type, and so on).
Use Cases
@@ -35,6 +35,7 @@
#include <rte_compat.h>
#include <rte_common.h>
#include <rte_config.h>
+#include <rte_log.h>
#include <rte_mempool.h>
#include <rte_memory.h>
#include <rte_atomic.h>
@@ -341,17 +342,20 @@ rte_pktmbuf_priv_flags(struct rte_mempool *mp)
#define RTE_MBUF_HAS_PINNED_EXTBUF(mb) \
(rte_pktmbuf_priv_flags(mb->pool) & RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF)
-#ifdef RTE_LIBRTE_MBUF_DEBUG
+#ifdef RTE_DEBUG_MBUF
/** check mbuf type in debug mode */
-#define __rte_mbuf_sanity_check(m, is_h) rte_mbuf_sanity_check(m, is_h)
+#define __rte_mbuf_sanity_check(m, is_h) do { \
+ if (rte_log_can_log(RTE_LOGTYPE_MBUF, RTE_LOG_DEBUG)) \
+ rte_mbuf_sanity_check(m, is_h); \
+} while (0)
-#else /* RTE_LIBRTE_MBUF_DEBUG */
+#else /* RTE_DEBUG_MBUF */
/** check mbuf type in debug mode */
#define __rte_mbuf_sanity_check(m, is_h) do { } while (0)
-#endif /* RTE_LIBRTE_MBUF_DEBUG */
+#endif /* RTE_DEBUG_MBUF */
#ifdef RTE_MBUF_REFCNT_ATOMIC