eal: add error check for core options
PATCH 1/1 eal: add error check for core options
Error information on the current core usage list,mask and map were incomplete. Added states to differentiate core usage and to inform user.
--- doc/guides/testpmd_app_ug/run_app.rst | 4 ++++ lib/librte_eal/common/eal_common_options.c | 33 +++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-)
doc/guides/testpmd_app_ug/run_app.rst +4 -0
@@ -62,6 +62,10 @@ See the DPDK Getting Started Guides for more information on these options. The grouping ``()`` can be omitted for single element group. The ``@`` can be omitted if cpus and lcores have the same value. +.. Note:: + When ``--lcores`` is in use, the options ``-l`` and ``-c`` cannot be used. + + * ``--master-lcore ID`` Core ID that is used as master.
lib/librte_eal/common/eal_common_options.c +30 -3
@@ -57,6 +57,9 @@#include "eal_filesystem.h" #define BITS_PER_HEX 4 +#define LCORE_OPT_LST 1 +#define LCORE_OPT_MSK 2 +#define LCORE_OPT_MAP 3const char eal_short_options[] =
@@ -1028,7 +1031,15 @@ eal_parse_common_option(int opt, const char *optarg,RTE_LOG (ERR ,EAL ,"invalid coremask\n" );return -1 ; } - core_parsed =1 ; + +if (core_parsed) { +RTE_LOG (ERR ,EAL ,"Core Mask Option is ignored, because core (%s) is set!\n" , + (core_parsed ==LCORE_OPT_LST )?"LIST" : + (core_parsed ==LCORE_OPT_MAP )?"MAP" :"Unknown" ); +return -1 ; + } + + core_parsed =LCORE_OPT_MSK ;break ;/* corelist */ case 'l' :
@@ -1036,7 +1047,15 @@ eal_parse_common_option(int opt, const char *optarg,RTE_LOG (ERR ,EAL ,"invalid core list\n" );return -1 ; } - core_parsed =1 ; + +if (core_parsed) { +RTE_LOG (ERR ,EAL ,"Core List Option is ignored, because core (%s) is set!\n" , + (core_parsed ==LCORE_OPT_MSK )?"LIST" : + (core_parsed ==LCORE_OPT_MAP )?"MAP" :"Unknown" ); +return -1 ; + } + + core_parsed =LCORE_OPT_LST ;break ;/* service coremask */ case 's' :
@@ -1156,7 +1175,15 @@ eal_parse_common_option(int opt, const char *optarg, OPT_LCORES "\n");return -1 ; } - core_parsed =1 ; + +if (core_parsed) { +RTE_LOG (ERR ,EAL ,"Core Map Option is ignored, because core (%s) is set!\n" , + (core_parsed ==LCORE_OPT_LST )?"LIST" : + (core_parsed ==LCORE_OPT_MSK )?"MASK" :"Unknown" ); +return -1 ; + } + + core_parsed =LCORE_OPT_MAP ;break ;/* don't know what to do, leave this to caller */
Signature · 1 line
2.9.5
Quoted 4 lines · Marko Kovacevic
Error information on the current core usage list,mask and map were incomplete. Added states to differentiate core usage and to inform user.
Nitpicking, but line width on commit message is a little on the short side...
Quoted 37 lines
Signed-off-by Marko Kovacevic <[email protected]>--- doc/guides/testpmd_app_ug/run_app.rst | 4 ++++ lib/librte_eal/common/eal_common_options.c | 33 +++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-)doc/guides/testpmd_app_ug/run_app.rst +4
-0@@ -62,6 +62,10 @@ See the DPDK Getting Started Guides for more information on these options. The grouping ``()`` can be omitted for single element group. The ``@`` can be omitted if cpus and lcores have the same value. +.. Note:: + When ``--lcores`` is in use, the options ``-l`` and ``-c`` cannot be used. + + * ``--master-lcore ID`` Core ID that is used as master.lib/librte_eal/common/eal_common_options.c +3
-0@@ -57,6 +57,9 @@#include "eal_filesystem.h" #define BITS_PER_HEX 4 +#define LCORE_OPT_LST 1 +#define LCORE_OPT_MSK 2 +#define LCORE_OPT_MAP 3const char eal_short_options[] =
lib/librte_eal/common/eal_common_options.c eal_parse_common_option(int opt, const char *optarg, · line 1038
Quoted 9 lines
lib/librte_eal/common/eal_common_options.c +5
-1@@ -1028,7 +1031,15 @@ eal_parse_common_option(int opt, const char *optarg,RTE_LOG (ERR ,EAL ,"invalid coremask\n" );return -1 ; } - core_parsed =1 ; + +if (core_parsed) { +RTE_LOG (ERR ,EAL ,"Core Mask Option is ignored, because core (%s) is set!\n" , + (core_parsed ==LCORE_OPT_LST )?"LIST" : + (core_parsed ==LCORE_OPT_MAP )?"MAP" :"Unknown" );
i think "LIST" and "MAP" are terribly undescriptive. It would be better to put the respective cmdline arguments ("-l" or "-c") there instead. Same applies to other cases.
Otherwise,
Quoted 42 lines
lib/librte_eal/common/eal_common_options.c +22
-2+return -1 ; + } + + core_parsed =LCORE_OPT_MSK ;break ;/* corelist */ case 'l' :@@ -1036,7 +1047,15 @@ eal_parse_common_option(int opt, const char *optarg,RTE_LOG (ERR ,EAL ,"invalid core list\n" );return -1 ; } - core_parsed =1 ; + +if (core_parsed) { +RTE_LOG (ERR ,EAL ,"Core List Option is ignored, because core (%s) is set!\n" , + (core_parsed ==LCORE_OPT_MSK )?"LIST" : + (core_parsed ==LCORE_OPT_MAP )?"MAP" :"Unknown" ); +return -1 ; + } + + core_parsed =LCORE_OPT_LST ;break ;/* service coremask */ case 's' :@@ -1156,7 +1175,15 @@ eal_parse_common_option(int opt, const char *optarg, OPT_LCORES "\n");return -1 ; } - core_parsed =1 ; + +if (core_parsed) { +RTE_LOG (ERR ,EAL ,"Core Map Option is ignored, because core (%s) is set!\n" , + (core_parsed ==LCORE_OPT_LST )?"LIST" : + (core_parsed ==LCORE_OPT_MSK )?"MASK" :"Unknown" ); +return -1 ; + } + + core_parsed =LCORE_OPT_MAP ;break ;/* don't know what to do, leave this to caller */
Signature · 2 lines
Thanks, Anatoly
PATCH v2 1/1 eal: add error check for core options
In reply to Marko KovacevicError information on the current core usage list,mask and map were incomplete. Added states to differentiate core usage and to inform user.
---
V2:
- Cleaned up the logging for error cases - Anatoly
--- doc/guides/testpmd_app_ug/run_app.rst | 4 ++++ lib/librte_eal/common/eal_common_options.c | 33 +++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-)
doc/guides/testpmd_app_ug/run_app.rst +4 -0
@@ -62,6 +62,10 @@ See the DPDK Getting Started Guides for more information on these options. The grouping ``()`` can be omitted for single element group. The ``@`` can be omitted if cpus and lcores have the same value. +.. Note:: + When ``--lcores`` is in use, the options ``-l`` and ``-c`` cannot be used. + + * ``--master-lcore ID`` Core ID that is used as master.
lib/librte_eal/common/eal_common_options.c +30 -3
@@ -57,6 +57,9 @@#include "eal_filesystem.h" #define BITS_PER_HEX 4 +#define LCORE_OPT_LST 1 +#define LCORE_OPT_MSK 2 +#define LCORE_OPT_MAP 3const char eal_short_options[] =
@@ -1028,7 +1031,15 @@ eal_parse_common_option(int opt, const char *optarg,RTE_LOG (ERR ,EAL ,"invalid coremask\n" );return -1 ; } - core_parsed =1 ; + +if (core_parsed) { +RTE_LOG (ERR ,EAL ,"Option -c is ignored, because (%s) is set!\n" , + (core_parsed ==LCORE_OPT_LST )?"-l" : + (core_parsed ==LCORE_OPT_MAP )?"--lcore" :"Unknown" ); +return -1 ; + } + + core_parsed =LCORE_OPT_MSK ;break ;/* corelist */ case 'l' :
@@ -1036,7 +1047,15 @@ eal_parse_common_option(int opt, const char *optarg,RTE_LOG (ERR ,EAL ,"invalid core list\n" );return -1 ; } - core_parsed =1 ; + +if (core_parsed) { +RTE_LOG (ERR ,EAL ,"Option -l is ignored, because (%s) is set!\n" , + (core_parsed ==LCORE_OPT_MSK )?"-c" : + (core_parsed ==LCORE_OPT_MAP )?"--lcore" :"Unknown" ); +return -1 ; + } + + core_parsed =LCORE_OPT_LST ;break ;/* service coremask */ case 's' :
@@ -1156,7 +1175,15 @@ eal_parse_common_option(int opt, const char *optarg, OPT_LCORES "\n");return -1 ; } - core_parsed =1 ; + +if (core_parsed) { +RTE_LOG (ERR ,EAL ,"Option --lcore is ignored, because (%s) is set!\n" , + (core_parsed ==LCORE_OPT_LST )?"-l" : + (core_parsed ==LCORE_OPT_MSK )?"-c" :"Unknown" ); +return -1 ; + } + + core_parsed =LCORE_OPT_MAP ;break ;/* don't know what to do, leave this to caller */
Signature · 1 line
2.9.5
Quoted 8 lines · Marko Kovacevic
Error information on the current core usage list,mask and map were incomplete. Added states to differentiate core usage and to inform user.
Signed-off-by Marko Kovacevic <[email protected]>---
Should've kept my Reviewed-by tag, but no harm done.
Signature · 2 lines
Thanks, Anatoly
PATCH v3 1/1 eal: add error check for core options
In reply to Marko KovacevicError information on current core usage list, mask or map were incomplete. Added states to differentiate core usage and to inform user.
---
V3:
- Changed to reflect the coding guidelines - Bruce
- update the documentation for better clarity - Bruce
- Added back the reviewer information - Anatoly
V2:
- Cleaned up the logging for error cases - Anatoly
--- doc/guides/testpmd_app_ug/run_app.rst | 4 ++++ lib/librte_eal/common/eal_common_options.c | 36 +++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-)
doc/guides/testpmd_app_ug/run_app.rst +4 -0
@@ -62,6 +62,10 @@ See the DPDK Getting Started Guides for more information on these options. The grouping ``()`` can be omitted for single element group. The ``@`` can be omitted if cpus and lcores have the same value. +.. Note:: + At a given instance only one core option ``--lcores``, ``-l`` or ``-c`` can be used. + + * ``--master-lcore ID`` Core ID that is used as master.
lib/librte_eal/common/eal_common_options.c +33 -3
@@ -57,6 +57,9 @@#include "eal_filesystem.h" #define BITS_PER_HEX 4 +#define LCORE_OPT_LST 1 +#define LCORE_OPT_MSK 2 +#define LCORE_OPT_MAP 3const char eal_short_options[] =
@@ -1028,7 +1031,16 @@ eal_parse_common_option(int opt, const char *optarg,RTE_LOG (ERR ,EAL ,"invalid coremask\n" );return -1 ; } - core_parsed =1 ; + +if (core_parsed) { +RTE_LOG (ERR ,EAL ,"Option -c is ignored, because (%s) is set!\n" , + (core_parsed ==LCORE_OPT_LST ) ?"-l" : + (core_parsed ==LCORE_OPT_MAP ) ?"--lcore" : +"-c" ); +return -1 ; + } + + core_parsed =LCORE_OPT_MSK ;break ;/* corelist */ case 'l' :
@@ -1036,7 +1048,16 @@ eal_parse_common_option(int opt, const char *optarg,RTE_LOG (ERR ,EAL ,"invalid core list\n" );return -1 ; } - core_parsed =1 ; + +if (core_parsed) { +RTE_LOG (ERR ,EAL ,"Option -l is ignored, because (%s) is set!\n" , + (core_parsed ==LCORE_OPT_MSK ) ?"-c" : + (core_parsed ==LCORE_OPT_MAP ) ?"--lcore" : +"-l" ); +return -1 ; + } + + core_parsed =LCORE_OPT_LST ;break ;/* service coremask */ case 's' :
@@ -1156,7 +1177,16 @@ eal_parse_common_option(int opt, const char *optarg, OPT_LCORES "\n");return -1 ; } - core_parsed =1 ; + +if (core_parsed) { +RTE_LOG (ERR ,EAL ,"Option --lcore is ignored, because (%s) is set!\n" , + (core_parsed ==LCORE_OPT_LST ) ?"-l" : + (core_parsed ==LCORE_OPT_MSK ) ?"-c" : +"--lcore" ); +return -1 ; + } + + core_parsed =LCORE_OPT_MAP ;break ;/* don't know what to do, leave this to caller */
Signature · 1 line
2.9.5
Quoted 6 lines · Marko Kovacevic
Error information on current core usage list, mask or map were incomplete. Added states to differentiate core usage and to inform user.
Signed-off-by Marko Kovacevic <[email protected]>Reviewed-by Anatoly Burakov <[email protected]>
This is fine as-is - one comment below for future consideration.
Quoted 45 lines
---
V3:
- Changed to reflect the coding guidelines - Bruce
- update the documentation for better clarity - Bruce
- Added back the reviewer information - AnatolyV2:
- Cleaned up the logging for error cases - Anatoly--- doc/guides/testpmd_app_ug/run_app.rst | 4 ++++ lib/librte_eal/common/eal_common_options.c | 36 +++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-)doc/guides/testpmd_app_ug/run_app.rst +4
-0@@ -62,6 +62,10 @@ See the DPDK Getting Started Guides for more information on these options. The grouping ``()`` can be omitted for single element group. The ``@`` can be omitted if cpus and lcores have the same value. +.. Note:: + At a given instance only one core option ``--lcores``, ``-l`` or ``-c`` can be used. + + * ``--master-lcore ID`` Core ID that is used as master.lib/librte_eal/common/eal_common_options.c +3
-0@@ -57,6 +57,9 @@#include "eal_filesystem.h" #define BITS_PER_HEX 4 +#define LCORE_OPT_LST 1 +#define LCORE_OPT_MSK 2 +#define LCORE_OPT_MAP 3const char eal_short_options[] =
lib/librte_eal/common/eal_common_options.c eal_parse_common_option(int opt, const char *optarg, · line 1039
Quoted 10 lines
lib/librte_eal/common/eal_common_options.c +6
-1@@ -1028,7 +1031,16 @@ eal_parse_common_option(int opt, const char *optarg,RTE_LOG (ERR ,EAL ,"invalid coremask\n" );return -1 ; } - core_parsed =1 ; + +if (core_parsed) { +RTE_LOG (ERR ,EAL ,"Option -c is ignored, because (%s) is set!\n" , + (core_parsed ==LCORE_OPT_LST ) ?"-l" : + (core_parsed ==LCORE_OPT_MAP ) ?"--lcore" : +"-c" );
This block is repeated in slightly different forms 3 times. It should probably be replaced using a function or macro to return the appropriate string based on core_parsed value.
Thanks,
/Bruce
Thomas Monjalon
Applied02/02/2018 16:33, Bruce Richardson:
Quoted 8 lines · Marko Kovacevic
Quoted 6 lines
Error information on current core usage list, mask or map were incomplete. Added states to differentiate core usage and to inform user.
Signed-off-by Marko Kovacevic <[email protected]>Reviewed-by Anatoly Burakov <[email protected]>Acked-by Bruce Richardson <[email protected]>
Applied, thanks
Quoted 5 lines
Quoted 2 lines
+.. Note::
+ At a given instance only one core option ``--lcores``, ``-l`` or ``-c`` can beused.
Review
Quoted 2 lines
(quoted diff) +2
-0+ +
Hi Marko,
I always found the n different way to specify cores perplexing. I always suspected they were mutually exclusive but that was far from clear from the docs and it never was important enough to me to try out the various options. Taking the time to add clear documentation makes everyone's work more efficient and less frustrating.
So thank you and keep up the good work :)
Billy.
Quoted 87 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Bruce Richardson
Sent: Friday, February 2, 2018 3:33 PM
To: Kovacevic, Marko <[email protected]>
Cc: [email protected]; Burakov, Anatoly <[email protected]>; Varghese, Vipin <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v3] eal: add error check for core optionsQuoted 6 lines · Marko Kovacevic
Error information on current core usage list, mask or map were incomplete. Added states to differentiate core usage and to inform user.
Signed-off-by Marko Kovacevic <[email protected]>Reviewed-by Anatoly Burakov <[email protected]>Acked-by Bruce Richardson <[email protected]>This is fine as-is - one comment below for future consideration.
doc/guides/testpmd_app_ug/run_app.rst See the DPDK Getting Started Guides for more
Quoted 22 lines
---
V3:
- Changed to reflect the coding guidelines - Bruce
- update the documentation for better clarity - Bruce
- Added back the reviewer information - AnatolyV2:
- Cleaned up the logging for error cases - Anatoly--- doc/guides/testpmd_app_ug/run_app.rst | 4 ++++ lib/librte_eal/common/eal_common_options.c | 36 +++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-)doc/guides/testpmd_app_ug/run_app.rst +0
-0@@ -62,6 +62,10 @@ See the DPDK Getting Started Guides for moreinformation on these options.
doc/guides/testpmd_app_ug/run_app.rst See the DPDK Getting Started Guides for more information on these options.
Quoted 5 lines
doc/guides/testpmd_app_ug/run_app.rst +2
-0The grouping ``()`` can be omitted for single element group. The ``@`` can be omitted if cpus and lcores have the same value. +.. Note:: + At a given instance only one core option ``--lcores``, ``-l`` or ``-c`` can beused.
lib/librte_eal/common/eal_common_options.c eal_parse_common_option(int opt, const char
Quoted 21 lines
doc/guides/testpmd_app_ug/run_app.rst +2
-0+ + * ``--master-lcore ID`` Core ID that is used as master.lib/librte_eal/common/eal_common_options.c +3
-0@@ -57,6 +57,9 @@#include "eal_filesystem.h" #define BITS_PER_HEX 4 +#define LCORE_OPT_LST 1 +#define LCORE_OPT_MSK 2 +#define LCORE_OPT_MAP 3const char eal_short_options[] =@@ -1028,7 +1031,16 @@ eal_parse_common_option(int opt, const char*optarg,
lib/librte_eal/common/eal_common_options.c eal_parse_common_option(int opt, const char *optarg,
Quoted 7 lines
lib/librte_eal/common/eal_common_options.c +3
-1RTE_LOG (ERR ,EAL ,"invalid coremask\n" );return -1 ; } - core_parsed =1 ; + +if (core_parsed) { + RTE_LOG(ERR, EAL, "Option -c is ignored, because (%s)is set!\n",
lib/librte_eal/common/eal_common_options.c eal_parse_common_option(int opt, const char *optarg, · line 1039
Quoted 3 lines
lib/librte_eal/common/eal_common_options.c +3
-0+ (core_parsed ==LCORE_OPT_LST ) ?"-l" : + (core_parsed ==LCORE_OPT_MAP ) ?"--lcore" : + "-c");This block is repeated in slightly different forms 3 times. It should probably be replaced using a function or macro to return the appropriate string based on
core_parsedvalue.Thanks,
/Bruce