[v2,1/3] config: introduce global rte debug flag

Message ID 20200422214555.11837-2-l.wojciechow@partner.samsung.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series introduce global debug flag |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS

Commit Message

Lukasz Wojciechowski April 22, 2020, 9:45 p.m. UTC
  A new boolean meson build flag is introduced with this patch: rte_debug.
To enable this option add -Drte_debug=true to the meson configure command.

By enabling this flag the globaly defined macro RTE_DEBUG becomes
defined. It should be used for enabling debug code in all dpdk project
components. Using this flag allows to make additional checks or tests
and provide additional logs even in performance sensitive parts of code.

The flag is disabled by default.

Additionally for all enabled to be built libraries
a RTE_DEBUG_{library name} is defined and assigned a value 1.
This standardize names of library specific debug macros. Those can
be used also without rte_debug option by using CFLAGS="-D..." build
parameter.

Code put inside RTE_DEBUG* #ifdef sections should be also put inside
if (rte_log_can_log(...)) condition to allow run-time filtering of
sanity checks, validations, logs and dumps when using rte_debug option.

Libraries will be adjusted to the change in separate patches.

Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
---
 config/meson.build | 4 ++++
 lib/meson.build    | 4 ++++
 meson_options.txt  | 2 ++
 3 files changed, 10 insertions(+)
  

Comments

Bruce Richardson June 26, 2020, 4:56 p.m. UTC | #1
On Wed, Apr 22, 2020 at 11:45:53PM +0200, Lukasz Wojciechowski wrote:
> A new boolean meson build flag is introduced with this patch: rte_debug.
> To enable this option add -Drte_debug=true to the meson configure command.
> 
> By enabling this flag the globaly defined macro RTE_DEBUG becomes
> defined. It should be used for enabling debug code in all dpdk project
> components. Using this flag allows to make additional checks or tests
> and provide additional logs even in performance sensitive parts of code.
> 
> The flag is disabled by default.
> 
> Additionally for all enabled to be built libraries
> a RTE_DEBUG_{library name} is defined and assigned a value 1.
> This standardize names of library specific debug macros. Those can
> be used also without rte_debug option by using CFLAGS="-D..." build
> parameter.
> 
> Code put inside RTE_DEBUG* #ifdef sections should be also put inside
> if (rte_log_can_log(...)) condition to allow run-time filtering of
> sanity checks, validations, logs and dumps when using rte_debug option.
> 
> Libraries will be adjusted to the change in separate patches.
> 
> Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
> Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>

The drivers are missing debug flag options, which probably need to be
defined as <driver_type>_<driver_name> e.g. RTE_DEBUG_NET_I40E,
RTE_DEBUG_EVENT_SW, etc.

However, this is definitely a good start.

Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  
Andrew Rybchenko June 28, 2020, 8:40 a.m. UTC | #2
On 6/26/20 7:56 PM, Bruce Richardson wrote:
> On Wed, Apr 22, 2020 at 11:45:53PM +0200, Lukasz Wojciechowski wrote:
>> A new boolean meson build flag is introduced with this patch: rte_debug.
>> To enable this option add -Drte_debug=true to the meson configure command.
>>
>> By enabling this flag the globaly defined macro RTE_DEBUG becomes
>> defined. It should be used for enabling debug code in all dpdk project
>> components. Using this flag allows to make additional checks or tests
>> and provide additional logs even in performance sensitive parts of code.
>>
>> The flag is disabled by default.
>>
>> Additionally for all enabled to be built libraries
>> a RTE_DEBUG_{library name} is defined and assigned a value 1.
>> This standardize names of library specific debug macros. Those can
>> be used also without rte_debug option by using CFLAGS="-D..." build
>> parameter.
>>
>> Code put inside RTE_DEBUG* #ifdef sections should be also put inside
>> if (rte_log_can_log(...)) condition to allow run-time filtering of
>> sanity checks, validations, logs and dumps when using rte_debug option.
>>
>> Libraries will be adjusted to the change in separate patches.
>>
>> Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
>> Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
> 
> The drivers are missing debug flag options, which probably need to be
> defined as <driver_type>_<driver_name> e.g. RTE_DEBUG_NET_I40E,
> RTE_DEBUG_EVENT_SW, etc.
> 
> However, this is definitely a good start.
> 
> Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 

Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
  
Lukasz Wojciechowski July 9, 2020, 1:51 p.m. UTC | #3
W dniu 26.06.2020 o 18:56, Bruce Richardson pisze:
> On Wed, Apr 22, 2020 at 11:45:53PM +0200, Lukasz Wojciechowski wrote:
>> A new boolean meson build flag is introduced with this patch: rte_debug.
>> To enable this option add -Drte_debug=true to the meson configure command.
>>
>> By enabling this flag the globaly defined macro RTE_DEBUG becomes
>> defined. It should be used for enabling debug code in all dpdk project
>> components. Using this flag allows to make additional checks or tests
>> and provide additional logs even in performance sensitive parts of code.
>>
>> The flag is disabled by default.
>>
>> Additionally for all enabled to be built libraries
>> a RTE_DEBUG_{library name} is defined and assigned a value 1.
>> This standardize names of library specific debug macros. Those can
>> be used also without rte_debug option by using CFLAGS="-D..." build
>> parameter.
>>
>> Code put inside RTE_DEBUG* #ifdef sections should be also put inside
>> if (rte_log_can_log(...)) condition to allow run-time filtering of
>> sanity checks, validations, logs and dumps when using rte_debug option.
>>
>> Libraries will be adjusted to the change in separate patches.
>>
>> Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
>> Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
> The drivers are missing debug flag options, which probably need to be
> defined as <driver_type>_<driver_name> e.g. RTE_DEBUG_NET_I40E,
> RTE_DEBUG_EVENT_SW, etc.
I added also flags for drivers constructed as you suggested (see v3).
It might however be a bit tricky to differentiate library debug flags 
form drivers, e.g.
RTE_DEBUG_MEMPOOL (library) vs RTE_DEBUG_MEMPOOL_DPAA (driver).

If there is a need the macro names can be changed by adding _LIB_ or _DRV_.
What do you think?
> However, this is definitely a good start.
>
> Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
>
  
Bruce Richardson July 9, 2020, 2:09 p.m. UTC | #4
On Thu, Jul 09, 2020 at 03:51:25PM +0200, Lukasz Wojciechowski wrote:
> 
> W dniu 26.06.2020 o 18:56, Bruce Richardson pisze:
> > On Wed, Apr 22, 2020 at 11:45:53PM +0200, Lukasz Wojciechowski wrote:
> >> A new boolean meson build flag is introduced with this patch: rte_debug.
> >> To enable this option add -Drte_debug=true to the meson configure command.
> >>
> >> By enabling this flag the globaly defined macro RTE_DEBUG becomes
> >> defined. It should be used for enabling debug code in all dpdk project
> >> components. Using this flag allows to make additional checks or tests
> >> and provide additional logs even in performance sensitive parts of code.
> >>
> >> The flag is disabled by default.
> >>
> >> Additionally for all enabled to be built libraries
> >> a RTE_DEBUG_{library name} is defined and assigned a value 1.
> >> This standardize names of library specific debug macros. Those can
> >> be used also without rte_debug option by using CFLAGS="-D..." build
> >> parameter.
> >>
> >> Code put inside RTE_DEBUG* #ifdef sections should be also put inside
> >> if (rte_log_can_log(...)) condition to allow run-time filtering of
> >> sanity checks, validations, logs and dumps when using rte_debug option.
> >>
> >> Libraries will be adjusted to the change in separate patches.
> >>
> >> Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
> >> Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
> > The drivers are missing debug flag options, which probably need to be
> > defined as <driver_type>_<driver_name> e.g. RTE_DEBUG_NET_I40E,
> > RTE_DEBUG_EVENT_SW, etc.
> I added also flags for drivers constructed as you suggested (see v3).
> It might however be a bit tricky to differentiate library debug flags 
> form drivers, e.g.
> RTE_DEBUG_MEMPOOL (library) vs RTE_DEBUG_MEMPOOL_DPAA (driver).
> 
> If there is a need the macro names can be changed by adding _LIB_ or _DRV_.
> What do you think?

I don't think DRV is needed for the drivers, though perhaps LIB (or RTE) could
be added for the libs. I actually think that mempool is the only case where
we might have any confusion, for other device classes the library names
tend to have "dev" on the end, e.g. cryptodev, rawdev etc.

So overall, I'd suggest it's not a problem, but if you want modify the lib
one.

/Bruce
  
Lukasz Wojciechowski July 9, 2020, 2:13 p.m. UTC | #5
W dniu 09.07.2020 o 16:09, Bruce Richardson pisze:
> On Thu, Jul 09, 2020 at 03:51:25PM +0200, Lukasz Wojciechowski wrote:
>> W dniu 26.06.2020 o 18:56, Bruce Richardson pisze:
>>> On Wed, Apr 22, 2020 at 11:45:53PM +0200, Lukasz Wojciechowski wrote:
>>>> A new boolean meson build flag is introduced with this patch: rte_debug.
>>>> To enable this option add -Drte_debug=true to the meson configure command.
>>>>
>>>> By enabling this flag the globaly defined macro RTE_DEBUG becomes
>>>> defined. It should be used for enabling debug code in all dpdk project
>>>> components. Using this flag allows to make additional checks or tests
>>>> and provide additional logs even in performance sensitive parts of code.
>>>>
>>>> The flag is disabled by default.
>>>>
>>>> Additionally for all enabled to be built libraries
>>>> a RTE_DEBUG_{library name} is defined and assigned a value 1.
>>>> This standardize names of library specific debug macros. Those can
>>>> be used also without rte_debug option by using CFLAGS="-D..." build
>>>> parameter.
>>>>
>>>> Code put inside RTE_DEBUG* #ifdef sections should be also put inside
>>>> if (rte_log_can_log(...)) condition to allow run-time filtering of
>>>> sanity checks, validations, logs and dumps when using rte_debug option.
>>>>
>>>> Libraries will be adjusted to the change in separate patches.
>>>>
>>>> Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
>>>> Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
>>> The drivers are missing debug flag options, which probably need to be
>>> defined as <driver_type>_<driver_name> e.g. RTE_DEBUG_NET_I40E,
>>> RTE_DEBUG_EVENT_SW, etc.
>> I added also flags for drivers constructed as you suggested (see v3).
>> It might however be a bit tricky to differentiate library debug flags
>> form drivers, e.g.
>> RTE_DEBUG_MEMPOOL (library) vs RTE_DEBUG_MEMPOOL_DPAA (driver).
>>
>> If there is a need the macro names can be changed by adding _LIB_ or _DRV_.
>> What do you think?
> I don't think DRV is needed for the drivers, though perhaps LIB (or RTE) could
> be added for the libs. I actually think that mempool is the only case where
> we might have any confusion, for other device classes the library names
> tend to have "dev" on the end, e.g. cryptodev, rawdev etc.
maybe also with net
>
> So overall, I'd suggest it's not a problem, but if you want modify the lib
> one.

If it's not a problem, I'll leave it as it is for now.

>
> /Bruce
>
  

Patch

diff --git a/config/meson.build b/config/meson.build
index 224d29e1c..5ab510009 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -183,6 +183,10 @@  endif
 # add -include rte_config to cflags
 add_project_arguments('-include', 'rte_config.h', language: 'c')
 
+if get_option('rte_debug')
+	dpdk_conf.set('RTE_DEBUG', 1)
+endif
+
 # enable extra warnings and disable any unwanted warnings
 warning_flags = [
 	# -Wall is added by meson by default, so add -Wextra only
diff --git a/lib/meson.build b/lib/meson.build
index 63c17ee75..8e0abca1e 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -88,6 +88,10 @@  foreach l:libraries
 		dpdk_conf.set('RTE_LIBRTE_' + name.to_upper(), 1)
 		install_headers(headers)
 
+		if get_option('rte_debug')
+			dpdk_conf.set('RTE_DEBUG_' + name.to_upper(), 1)
+		endif
+
 		libname = 'rte_' + name
 		includes += include_directories(dir_name)
 
diff --git a/meson_options.txt b/meson_options.txt
index 9e4923a4f..a14f0efdb 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -30,6 +30,8 @@  option('max_lcores', type: 'integer', value: 128,
 	description: 'maximum number of cores/threads supported by EAL')
 option('max_numa_nodes', type: 'integer', value: 4,
 	description: 'maximum number of NUMA nodes supported by EAL')
+option('rte_debug', type: 'boolean', value: false,
+	description: 'build with additional sanity checks, validations and logs')
 option('tests', type: 'boolean', value: true,
 	description: 'build unit tests')
 option('use_hpet', type: 'boolean', value: false,