test: fix option block
PATCH 1/1 test: fix option block
The options allow (-a) and block (-b) cannot be used at the same time. Therefore, allow (-a) will not be added when block (-b) is present.
--- app/test/process.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
app/test/process.h +14 -3
@@ -44,7 +44,7 @@ add_parameter_allow(char **argv, int max_capacity)int count =0 ; RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { -if (strlen (devargs->name) ==0 ) +if (strlen (devargs->name) ==0 || devargs->type !=RTE_DEVTYPE_ALLOWED )continue ;if (devargs->data ==NULL ||strlen (devargs->data) ==0 ) {
@@ -74,7 +74,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value) {int num =0 ;char **argv_cpy; -int allow_num; +int allow_num, block_num;int argv_num;int i, status;char path[32 ];
@@ -89,7 +89,18 @@ process_dup(const char *const argv[], int numargs, const char *env_value)if (pid <0 )return -1 ;else if (pid ==0 ) { - allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); + allow_num =0 ; + block_num =0 ; + +/* If block (-b) is present, allow (-a) is not added. */ +for (i =0 ; i < numargs; i++) { +if (strcmp (argv[i],"-b" ) ==0 || +strcmp (argv[i],"-block" ) ==0 ) + block_num++; + } +if (!block_num) + allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); + argv_num = numargs + allow_num +1 ; argv_cpy =calloc (argv_num,sizeof (char *));if (!argv_cpy)
Signature · 1 line
2.25.1
Quoted 7 lines
-----Original Message-----
From: Mingjin Ye <[email protected]>
Sent: Thursday, March 14, 2024 5:46 PM
To: [email protected]
Cc: Ye, MingjinX <[email protected]>; [email protected]
Subject: [PATCH] test: fix option block
Quoted 8 lines
The options allow (-a) and block (-b) cannot be used at the same time. Therefore, allow (-a) will not be added when block (-b) is present.
Fixes b3ce7891ad38 ("test: fix probing in secondary process")Signed-off-by Mingjin Ye <[email protected]>---
A message that is not in the archive (sent off-list or not yet received): LV3PR11MB8601B4FC344CC7102C5AC010E5DD2@LV3PR11MB8601.namprd11.prod.outlook.com
PATCH 1/1 test: fix option block
Quoted 7 lines
Quoted 7 lines
The options allow (-a) and block (-b) cannot be used at the same time. Therefore, allow (-a) will not be added when block (-b) is present.
Fixes b3ce7891ad38 ("test: fix probing in secondary process")Signed-off-by Mingjin Ye <[email protected]>
Hi Mingjin, in general the patch looks ok to me.
A general question of the behaviour of block and allow, is it always the case that the two are not allowed to be used side by side? I had a look through the EAL documentation and didn't see and mention of this behaviour, but maybe I missed it?
Thanks
ian
Quoted 52 lines
Quoted 52 lines
--- app/test/process.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)app/test/process.h index renamed from app/test/process.h +0
-0
9fb2bf481c..388c7975cd100644app/test/process.h +2
-1@@ -44,7 +44,7 @@ add_parameter_allow(char **argv, int max_capacity)int count =0 ; RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { -if (strlen (devargs->name) ==0 ) +if (strlen (devargs->name) ==0 || devargs->type != +RTE_DEVTYPE_ALLOWED )continue ;if (devargs->data ==NULL ||strlen (devargs->data) ==0 ){ @@ -74,7 +74,7 @@
process_dup(const char *const argv[], int numargs, const char *env_value){app/test/process.h +13
-2int num =0 ;char **argv_cpy; -int allow_num; +int allow_num, block_num;int argv_num;int i, status;char path[32 ];@@ -89,7 +89,18 @@ process_dup(const char *const argv[], int numargs, const char *env_value)if (pid <0 )return -1 ;else if (pid ==0 ) { - allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); + allow_num =0 ; + block_num =0 ; + +/* If block (-b) is present, allow (-a) is not added. */ +for (i =0 ; i < numargs; i++) { +if (strcmp (argv[i],"-b" ) ==0 || +strcmp (argv[i],"-block" ) ==0 ) + block_num++; + } +if (!block_num) + allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); +app/test/process.h +0
-1argv_num = numargs + allow_num +1 ; argv_cpy =calloc (argv_num,sizeof (char *));if (!argv_cpy) --2.25.1
Quoted 14 lines
-----Original Message-----
From: Stokes, Ian <[email protected]>
Sent: Wednesday, July 3, 2024 10:35 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Subject: [PATCH] test: fix option blockQuoted 6 lines
Quoted 6 lines
The options allow (-a) and block (-b) cannot be used at the same time. Therefore, allow (-a) will not be added when block (-b) is present.
Fixes b3ce7891ad38 ("test: fix probing in secondary process")
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Signed-off-by Mingjin Ye <[email protected]>Hi Mingjin, in general the patch looks ok to me.
A general question of the behaviour of block and allow, is it always the case that the two are not allowed to be used side by side?
Both cannot be used at the same time.
Quoted 2 lines
I had a look through the EAL documentation and didn't see and mention of this behaviour, but maybe I missed it?
The "eal_common_usage" function has a clear description, see below: lib/eal/common/eal_common_options.c:2206
Quoted 56 lines
Thanks
ianQuoted 11 lines
Quoted 11 lines
--- app/test/process.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)app/test/process.h index renamed from app/test/process.h +0
-0
9fb2bf481c..388c7975cd100644app/test/process.h +0
-0@@ -44,7 +44,7 @@ add_parameter_allow(char **argv, int max_capacity)int count =0 ;Quoted 7 lines
app/test/process.h add_parameter_allow(char **argv, int max_capacity)
Quoted 7 lines
app/test/process.h +2
-1RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { -if (strlen (devargs->name) ==0 ) +if (strlen (devargs->name) ==0 || devargs->type != +RTE_DEVTYPE_ALLOWED )continue ;if (devargs->data ==NULL ||strlen (devargs->data) ==0 ){ @@
Quoted 34 lines
Quoted 34 lines
-74,7 +74,7 @@
process_dup(const char *const argv[], int numargs, const char *env_value){app/test/process.h +13
-2int num =0 ;char **argv_cpy; -int allow_num; +int allow_num, block_num;int argv_num;int i, status;char path[32 ];@@ -89,7 +89,18 @@ process_dup(const char *const argv[], int numargs, const char *env_value)if (pid <0 )return -1 ;else if (pid ==0 ) { - allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); + allow_num =0 ; + block_num =0 ; + +/* If block (-b) is present, allow (-a) is not added. */ +for (i =0 ; i < numargs; i++) { +if (strcmp (argv[i],"-b" ) ==0 || +strcmp (argv[i],"-block" ) ==0 ) + block_num++; + } +if (!block_num) + allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); +app/test/process.h +0
-1argv_num = numargs + allow_num +1 ; argv_cpy =calloc (argv_num,sizeof (char *));if (!argv_cpy) --2.25.1
Quoted 16 lines
Quoted 16 lines
-----Original Message-----
From: Stokes, Ian <[email protected]>
Sent: Wednesday, July 3, 2024 10:35 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Subject: [PATCH] test: fix option blockQuoted 7 lines
Quoted 7 lines
The options allow (-a) and block (-b) cannot be used at the same time. Therefore, allow (-a) will not be added when block (-b) is present.
Fixes b3ce7891ad38 ("test: fix probing in secondary process")Signed-off-by Mingjin Ye <[email protected]>Hi Mingjin, in general the patch looks ok to me.
Quoted 8 lines
Quoted 2 lines
A general question of the behaviour of block and allow, is it always the case that the two are not allowed to be used side by side?
Both cannot be used at the same time.
Quoted 2 lines
I had a look through the EAL documentation and didn't see and mention of this behaviour, but maybe I missed it?
The "
eal_common_usage" function has a clear description, see below:lib/eal/common/eal_common_options.c:2206
I understand that, but that is a comment in code, I think the behaviour is worthy of being called out in documentation API too for usability factors.
Thanks
Ian
Quoted 57 lines
Quoted 7 lines
Thanks
ianQuoted 4 lines
Quoted 4 lines
--- app/test/process.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)Quoted 5 lines
Quoted 5 lines
app/test/process.h add_parameter_allow(char **argv, int
Quoted 5 lines
app/test/process.h index renamed from app/test/process.h +0
-0
9fb2bf481c..388c7975cd100644app/test/process.h +0
-0@@ -44,7 +44,7 @@ add_parameter_allow(char **argv, int
max_capacity)Quoted 44 lines
Quoted 9 lines
app/test/process.h add_parameter_allow(char **argv, int max_capacity)
Quoted 9 lines
app/test/process.h +2
-1int count =0 ; RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { -if (strlen (devargs->name) ==0 ) +if (strlen (devargs->name) ==0 || devargs->type != +RTE_DEVTYPE_ALLOWED )continue ;if (devargs->data ==NULL ||strlen (devargs->data) ==0 ){ @@
Quoted 34 lines
Quoted 34 lines
-74,7 +74,7 @@
process_dup(const char *const argv[], int numargs, const char *env_value){app/test/process.h +13
-2int num =0 ;char **argv_cpy; -int allow_num; +int allow_num, block_num;int argv_num;int i, status;char path[32 ];@@ -89,7 +89,18 @@ process_dup(const char *const argv[], int numargs, const char *env_value)if (pid <0 )return -1 ;else if (pid ==0 ) { - allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); + allow_num =0 ; + block_num =0 ; + +/* If block (-b) is present, allow (-a) is not added. */ +for (i =0 ; i < numargs; i++) { +if (strcmp (argv[i],"-b" ) ==0 || +strcmp (argv[i],"-block" ) ==0 ) + block_num++; + } +if (!block_num) + allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); +app/test/process.h +0
-1argv_num = numargs + allow_num +1 ; argv_cpy =calloc (argv_num,sizeof (char *));if (!argv_cpy) --2.25.1
Quoted 28 lines
-----Original Message-----
From: Stokes, Ian <[email protected]>
Sent: Thursday, July 4, 2024 8:02 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Subject: RE: [PATCH] test: fix option blockQuoted 20 lines
Quoted 12 lines
-----Original Message-----
From: Stokes, Ian <[email protected]>
Sent: Wednesday, July 3, 2024 10:35 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Subject: [PATCH] test: fix option blockQuoted 6 lines
Quoted 6 lines
The options allow (-a) and block (-b) cannot be used at the same time. Therefore, allow (-a) will not be added when block (-b) is present.
Fixes b3ce7891ad38 ("test: fix probing in secondary process")Quoted 6 lines
Quoted 1 line
Quoted 1 line
Signed-off-by Mingjin Ye <[email protected]>Hi Mingjin, in general the patch looks ok to me.
A general question of the behaviour of block and allow, is it always the case that the two are not allowed to be used side by side?
Both cannot be used at the same time.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I had a look through the EAL documentation and didn't see and mention of this behaviour, but maybe I missed it?
The "
eal_common_usage" function has a clear description, see below:lib/eal/common/eal_common_options.c:2206I understand that, but that is a comment in code, I think the behaviour is worthy of being called out in documentation API too for usability factors.
Sorry for not providing complete information. There is processing logic in "eal_parse_common_option". Unsatisfied condition outputs "Options allow (-a) and block (-b) can't be used at the same time".
Quoted 62 lines
Thanks
IanQuoted 15 lines
Quoted 7 lines
Thanks
ianQuoted 4 lines
Quoted 4 lines
--- app/test/process.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)Quoted 5 lines
Quoted 5 lines
app/test/process.h add_parameter_allow(char **argv, int
Quoted 5 lines
app/test/process.h index renamed from app/test/process.h +0
-0
9fb2bf481c..388c7975cd100644app/test/process.h +0
-0@@ -44,7 +44,7 @@ add_parameter_allow(char **argv, int
max_capacity)Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
app/test/process.h +0
-0int count =0 ;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
app/test/process.h add_parameter_allow(char **argv, int max_capacity)
Quoted 7 lines
app/test/process.h +2
-1RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { -if (strlen (devargs->name) ==0 ) +if (strlen (devargs->name) ==0 || devargs->type != +RTE_DEVTYPE_ALLOWED )continue ; if (devargs->data == NULL || strlen(devargs->data)== 0)
Quoted 35 lines
Quoted 35 lines
{ @@
Quoted 34 lines
Quoted 34 lines
-74,7 +74,7 @@
process_dup(const char *const argv[], int numargs, const char *env_value){app/test/process.h +13
-2int num =0 ;char **argv_cpy; -int allow_num; +int allow_num, block_num;int argv_num;int i, status;char path[32 ];@@ -89,7 +89,18 @@ process_dup(const char *const argv[], int numargs, const char *env_value)if (pid <0 )return -1 ;else if (pid ==0 ) { - allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); + allow_num =0 ; + block_num =0 ; + +/* If block (-b) is present, allow (-a) is not added. */ +for (i =0 ; i < numargs; i++) { +if (strcmp (argv[i],"-b" ) ==0 || +strcmp (argv[i],"-block" ) ==0 ) + block_num++; + } +if (!block_num) + allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); +app/test/process.h +0
-1argv_num = numargs + allow_num +1 ; argv_cpy =calloc (argv_num,sizeof (char *));if (!argv_cpy) --2.25.1
Stokes, Ian
Acked-byQuoted 41 lines
-----Original Message-----
From: Ye, MingjinX <[email protected]>
Sent: Friday, July 5, 2024 2:39 AM
To: Stokes, Ian <[email protected]>; [email protected]
Subject: RE: [PATCH] test: fix option blockQuoted 31 lines
-----Original Message-----
From: Stokes, Ian <[email protected]>
Sent: Thursday, July 4, 2024 8:02 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Subject: RE: [PATCH] test: fix option blockQuoted 24 lines
Quoted 12 lines
-----Original Message-----
From: Stokes, Ian <[email protected]>
Sent: Wednesday, July 3, 2024 10:35 PM
To: Ye, MingjinX <[email protected]>; [email protected]
Subject: [PATCH] test: fix option blockQuoted 6 lines
Quoted 6 lines
The options allow (-a) and block (-b) cannot be used at the same time. Therefore, allow (-a) will not be added when block (-b) is present.
Fixes b3ce7891ad38 ("test: fix probing in secondary process")Quoted 6 lines
Quoted 1 line
Quoted 1 line
Signed-off-by Mingjin Ye <[email protected]>Hi Mingjin, in general the patch looks ok to me.
A general question of the behaviour of block and allow, is it always the case that the two are not allowed to be used side by side?
Both cannot be used at the same time.
Quoted 2 lines
I had a look through the EAL documentation and didn't see and mention of this behaviour, but maybe I missed it?
The "
eal_common_usage" function has a clear description, see below:lib/eal/common/eal_common_options.c:2206
Quoted 7 lines
Quoted 2 lines
I understand that, but that is a comment in code, I think the behaviour is worthy of being called out in documentation API too for usability factors.
Sorry for not providing complete information. There is processing logic in "
eal_parse_common_option".
Unsatisfied condition outputs "Options allow (-a) and block (-b) can't be used at the same time".
Ah Ok, thanks for the clarification. I see this has been tested as well previously by Jiale Song. In that case this looks good to me.
Quoted 62 lines
Quoted 62 lines
Thanks
IanQuoted 15 lines
Quoted 7 lines
Thanks
ianQuoted 4 lines
Quoted 4 lines
--- app/test/process.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)Quoted 5 lines
Quoted 5 lines
app/test/process.h add_parameter_allow(char **argv, int
Quoted 5 lines
app/test/process.h index renamed from app/test/process.h +0
-0
9fb2bf481c..388c7975cd100644app/test/process.h +0
-0@@ -44,7 +44,7 @@ add_parameter_allow(char **argv, int
max_capacity)Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
app/test/process.h +0
-0int count =0 ;Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
app/test/process.h add_parameter_allow(char **argv, int max_capacity)
Quoted 7 lines
app/test/process.h +2
-1RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { -if (strlen (devargs->name) ==0 ) +if (strlen (devargs->name) ==0 || devargs->type != +RTE_DEVTYPE_ALLOWED )continue ; if (devargs->data == NULL || strlen(devargs->data)== 0)
Quoted 35 lines
Quoted 35 lines
{ @@
Quoted 34 lines
Quoted 34 lines
-74,7 +74,7 @@
process_dup(const char *const argv[], int numargs, const char *env_value){app/test/process.h +13
-2int num =0 ;char **argv_cpy; -int allow_num; +int allow_num, block_num;int argv_num;int i, status;char path[32 ];@@ -89,7 +89,18 @@ process_dup(const char *const argv[], int numargs, const char *env_value)if (pid <0 )return -1 ;else if (pid ==0 ) { - allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); + allow_num =0 ; + block_num =0 ; + +/* If block (-b) is present, allow (-a) is not added. */ +for (i =0 ; i < numargs; i++) { +if (strcmp (argv[i],"-b" ) ==0 || +strcmp (argv[i],"-block" ) ==0 ) + block_num++; + } +if (!block_num) + allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); +app/test/process.h +0
-1argv_num = numargs + allow_num +1 ; argv_cpy =calloc (argv_num,sizeof (char *));if (!argv_cpy) --2.25.1
Quoted 35 lines · On Thu, 14 Mar 2024 09:46:26 +0000 Mingjin Ye <[email protected]> wrote:
The options allow (-a) and block (-b) cannot be used at the same time. Therefore, allow (-a) will not be added when block (-b) is present.
Fixes b3ce7891ad38 ("test: fix probing in secondary process")Signed-off-by Mingjin Ye <[email protected]>--- app/test/process.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)app/test/process.h +2
-2@@ -44,7 +44,7 @@ add_parameter_allow(char **argv, int max_capacity)int count =0 ; RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { -if (strlen (devargs->name) ==0 ) +if (strlen (devargs->name) ==0 || devargs->type !=RTE_DEVTYPE_ALLOWED )continue ;if (devargs->data ==NULL ||strlen (devargs->data) ==0 ) {@@ -74,7 +74,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value) {int num =0 ;char **argv_cpy; -int allow_num; +int allow_num, block_num;int argv_num;int i, status;char path[32 ];@@ -89,7 +89,18 @@ process_dup(const char *const argv[], int numargs, const char *env_value)if (pid <0 )
app/test/process.h process_dup(const char *const argv[], int numargs, const char *env_value) · line 98
Quoted 10 lines
app/test/process.h +7
-1return -1 ; else if (pid == 0) { - allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); + allow_num =0 ; + block_num =0 ; + +/* If block (-b) is present, allow (-a) is not added. */ +for (i =0 ; i < numargs; i++) { +if (strcmp (argv[i],"-b" ) ==0 || +strcmp (argv[i],"-block" ) ==0 )
The long form of the option is "--block" not "-block".
Why is a test infrastructure adding both options anyway, seems like that is the real problem.
PATCH v2 1/1 test: fix option block
In reply to Mingjin YeThe options allow (-a) and block (-b) cannot be used at the same time. Therefore, allow (-a) will not be added when block (-b) is present.
---
v2: The long form of the fix option is "--block".
--- app/test/process.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
app/test/process.h +14 -3
@@ -44,7 +44,7 @@ add_parameter_allow(char **argv, int max_capacity)int count =0 ; RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { -if (strlen (devargs->name) ==0 ) +if (strlen (devargs->name) ==0 || devargs->type !=RTE_DEVTYPE_ALLOWED )continue ;if (devargs->data ==NULL ||strlen (devargs->data) ==0 ) {
@@ -74,7 +74,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value) {int num =0 ;char **argv_cpy; -int allow_num; +int allow_num, block_num;int argv_num;int i, status;char path[32 ];
@@ -89,7 +89,18 @@ process_dup(const char *const argv[], int numargs, const char *env_value)if (pid <0 )return -1 ;else if (pid ==0 ) { - allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); + allow_num =0 ; + block_num =0 ; + +/* If block (-b) is present, allow (-a) is not added. */ +for (i =0 ; i < numargs; i++) { +if (strcmp (argv[i],"-b" ) ==0 || +strcmp (argv[i],"--block" ) ==0 ) + block_num++; + } +if (!block_num) + allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); + argv_num = numargs + allow_num +1 ; argv_cpy =calloc (argv_num,sizeof (char *));if (!argv_cpy)
Signature · 1 line
2.25.1
Quoted 8 lines · On Sat, 12 Oct 2024 09:35:19 +0000 Mingjin Ye <[email protected]> wrote:
The options allow (-a) and block (-b) cannot be used at the same time. Therefore, allow (-a) will not be added when block (-b) is present.
Fixes b3ce7891ad38 ("test: fix probing in secondary process")Signed-off-by Mingjin Ye <[email protected]>---
What is this patch trying to solve?
Right now starting dpdk-test with both options together causes an error in EAL init.
root@hermes:/home/shemminger/DPDK/main# ./build/app/dpdk-test -a ae:00.0 -b 00:1f.6 EAL: Detected CPU lcores: 8 EAL: Detected NUMA nodes: 1 EAL: Options allow (-a) and block (-b) can't be used at the same time
Usage: ./build/app/dpdk-test [options]
Therefore it should never get into the process_dup function at all.
Quoted 15 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Sunday, October 13, 2024 6:21 AM
To: Ye, MingjinX <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v2] test: fix option blockQuoted 3 lines · On Sat, 12 Oct 2024 09:35:19 +0000 Mingjin Ye <[email protected]> wrote:
The options allow (-a) and block (-b) cannot be used at the same time. Therefore, allow (-a) will not be added when block (-b) is present.
Quoted 7 lines
Quoted 5 lines
Fixes b3ce7891ad38 ("test: fix probing in secondary process")Signed-off-by Mingjin Ye <[email protected]>---
What is this patch trying to solve?
Solve the issue of allow/block devices being added accidentally. The v3 patch will be sent.
Quoted 3 lines
Right now starting dpdk-test with both options together causes an error in EAL init.
EAL does not support adding both allow (-a) and block (-b) options.
Quoted 10 lines
root@hermes:/home/shemminger/DPDK/main# ./build/app/dpdk-test -a ae:00.0 -b 00:1f.6 EAL: Detected CPU lcores: 8 EAL: Detected NUMA nodes: 1 EAL: Options allow (-a) and block (-b) can't be used at the same timeUsage: ./build/app/dpdk-test [options]
Therefore it should never get into the
process_dupfunction at all.
PATCH v3 1/1 test: fix option devices
In reply to Mingjin YeWithout using allow (-a) or block (-b), EAL loads all devices by default. Unexpected devices may be loaded when running test cases in sub-processes.
This patch fixes the issue by copying the parameters of the master process if the allow (-a) or block (-b) option is not used when starting the child process.
Also, EAL does not allow the options allow (-a) and block (-b) to be used at the same time.
---
v2: The long form of the fix option is "--block".
---
v3: new scheme.
--- app/test/process.h | 58 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-)
app/test/process.h +54 -4
@@ -36,6 +36,7 @@ extern uint16_t flag_for_send_pkts;#endif #define PREFIX_ALLOW "--allow=" +#define PREFIX_BLOCK "--block="static int add_parameter_allow (char **argv,int max_capacity)
@@ -44,7 +45,7 @@ add_parameter_allow(char **argv, int max_capacity)int count =0 ; RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { -if (strlen (devargs->name) ==0 ) +if (strlen (devargs->name) ==0 || devargs->type !=RTE_DEVTYPE_ALLOWED )continue ;if (devargs->data ==NULL ||strlen (devargs->data) ==0 ) {
@@ -63,6 +64,32 @@ add_parameter_allow(char **argv, int max_capacity)return count; } +static int +add_parameter_block (char **argv,int max_capacity) +{ +struct rte_devargs *devargs; +int count =0 ; + + RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { +if (strlen (devargs->name) ==0 || devargs->type !=RTE_DEVTYPE_BLOCKED ) +continue ; + +if (devargs->data ==NULL ||strlen (devargs->data) ==0 ) { +if (asprintf (&argv[count],PREFIX_BLOCK "%s" , devargs->name) <0 ) +break ; + }else { +if (asprintf (&argv[count],PREFIX_BLOCK "%s,%s" , + devargs->name, devargs->data) <0 ) +break ; + } + +if (++count == max_capacity) +break ; + } + +return count; +} +/* * launches a second copy of the test process using the given argv parameters, * which should include argv[0] as the process name. To identify in the
@@ -74,7 +101,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value) {int num =0 ;char **argv_cpy; -int allow_num; +int allow_num, block_num;int argv_num;int i, status;char path[32 ];
@@ -89,8 +116,27 @@ process_dup(const char *const argv[], int numargs, const char *env_value)if (pid <0 )return -1 ;else if (pid ==0 ) { - allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); - argv_num = numargs + allow_num +1 ; + allow_num =0 ; + block_num =0 ; + +for (i =0 ; i < numargs; i++) { +if (strcmp (argv[i],"-b" ) ==0 || +strcmp (argv[i],"--block" ) ==0 ) + block_num++; +if (strcmp (argv[i],"-a" ) ==0 || +strcmp (argv[i],"--allow" ) ==0 ) + allow_num++; + } +/* If block (-b) and allow (-a) are present, they will not be added. */ +if (!block_num && !allow_num) { + allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); + block_num =rte_devargs_type_count (RTE_DEVTYPE_BLOCKED ); + }else { + allow_num =0 ; + block_num =0 ; + } + + argv_num = numargs + allow_num + block_num +1 ; argv_cpy =calloc (argv_num,sizeof (char *));if (!argv_cpy)rte_panic ("Memory allocation failed\n" );
@@ -101,8 +147,12 @@ process_dup(const char *const argv[], int numargs, const char *env_value)if (argv_cpy[i] ==NULL )rte_panic ("Error dup args\n" ); } + +/* EAL limits block (-b) and allow (-a) to not exist at the same time. */ if (allow_num >0 ) num =add_parameter_allow (&argv_cpy[i], allow_num); +else if (block_num >0 ) + num =add_parameter_block (&argv_cpy[i], block_num); num += numargs;#ifdef RTE_EXEC_ENV_LINUX
Signature · 1 line
2.25.1
Re: [PATCH v3] test: fix option devices
Quoted 6 lines · On Mon, 14 Oct 2024 10:00:26 +0000 Mingjin Ye <[email protected]> wrote:
Without using allow (-a) or block (-b), EAL loads all devices by default. Unexpected devices may be loaded when running test cases in sub-processes.
This patch fixes the issue by copying the parameters of the master process if the allow (-a) or block (-b) option is not used when starting the child process.
Should be described as primary process, not master process. That is also causing the checkpatch warning.
PATCH v4 1/1 test: fix option devices
In reply to Mingjin YeWithout using allow (-a) or block (-b), EAL loads all devices by default. Unexpected devices may be loaded when running test cases in sub-processes.
This patch fixes the issue by copying the parameters of the primary process if the allow (-a) or block (-b) option is not used when starting the child process.
Also, EAL does not allow the options allow (-a) and block (-b) to be used at the same time.
---
v2: The long form of the fix option is "--block".
---
v3: new scheme.
---
v4: Changing the commit log.
--- app/test/process.h | 58 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-)
app/test/process.h +54 -4
@@ -36,6 +36,7 @@ extern uint16_t flag_for_send_pkts;#endif #define PREFIX_ALLOW "--allow=" +#define PREFIX_BLOCK "--block="static int add_parameter_allow (char **argv,int max_capacity)
@@ -44,7 +45,7 @@ add_parameter_allow(char **argv, int max_capacity)int count =0 ; RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { -if (strlen (devargs->name) ==0 ) +if (strlen (devargs->name) ==0 || devargs->type !=RTE_DEVTYPE_ALLOWED )continue ;if (devargs->data ==NULL ||strlen (devargs->data) ==0 ) {
@@ -63,6 +64,32 @@ add_parameter_allow(char **argv, int max_capacity)return count; } +static int +add_parameter_block (char **argv,int max_capacity) +{ +struct rte_devargs *devargs; +int count =0 ; + + RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { +if (strlen (devargs->name) ==0 || devargs->type !=RTE_DEVTYPE_BLOCKED ) +continue ; + +if (devargs->data ==NULL ||strlen (devargs->data) ==0 ) { +if (asprintf (&argv[count],PREFIX_BLOCK "%s" , devargs->name) <0 ) +break ; + }else { +if (asprintf (&argv[count],PREFIX_BLOCK "%s,%s" , + devargs->name, devargs->data) <0 ) +break ; + } + +if (++count == max_capacity) +break ; + } + +return count; +} +/* * launches a second copy of the test process using the given argv parameters, * which should include argv[0] as the process name. To identify in the
@@ -74,7 +101,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value) {int num =0 ;char **argv_cpy; -int allow_num; +int allow_num, block_num;int argv_num;int i, status;char path[32 ];
@@ -89,8 +116,27 @@ process_dup(const char *const argv[], int numargs, const char *env_value)if (pid <0 )return -1 ;else if (pid ==0 ) { - allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); - argv_num = numargs + allow_num +1 ; + allow_num =0 ; + block_num =0 ; + +for (i =0 ; i < numargs; i++) { +if (strcmp (argv[i],"-b" ) ==0 || +strcmp (argv[i],"--block" ) ==0 ) + block_num++; +if (strcmp (argv[i],"-a" ) ==0 || +strcmp (argv[i],"--allow" ) ==0 ) + allow_num++; + } +/* If block (-b) and allow (-a) are present, they will not be added. */ +if (!block_num && !allow_num) { + allow_num =rte_devargs_type_count (RTE_DEVTYPE_ALLOWED ); + block_num =rte_devargs_type_count (RTE_DEVTYPE_BLOCKED ); + }else { + allow_num =0 ; + block_num =0 ; + } + + argv_num = numargs + allow_num + block_num +1 ; argv_cpy =calloc (argv_num,sizeof (char *));if (!argv_cpy)rte_panic ("Memory allocation failed\n" );
@@ -101,8 +147,12 @@ process_dup(const char *const argv[], int numargs, const char *env_value)if (argv_cpy[i] ==NULL )rte_panic ("Error dup args\n" ); } + +/* EAL limits block (-b) and allow (-a) to not exist at the same time. */ if (allow_num >0 ) num =add_parameter_allow (&argv_cpy[i], allow_num); +else if (block_num >0 ) + num =add_parameter_block (&argv_cpy[i], block_num); num += numargs;#ifdef RTE_EXEC_ENV_LINUX
Signature · 1 line
2.25.1
RE: [PATCH v4] test: fix option devices
Quoted 13 lines
-----Original Message-----
From: Mingjin Ye <[email protected]>
Sent: Wednesday, October 16, 2024 4:17 PM
To: [email protected]
Cc: Ye, MingjinX <[email protected]>; [email protected]
Subject: [PATCH v4] test: fix option devicesWithout using allow (-a) or block (-b), EAL loads all devices by default. Unexpected devices may be loaded when running test cases in sub-processes.
This patch fixes the issue by copying the parameters of the primary process if the allow (-a) or block (-b) option is not used when starting the child process.
Quoted 8 lines
Also, EAL does not allow the options allow (-a) and block (-b) to be used at the same time.
Fixes b3ce7891ad38 ("test: fix probing in secondary process")Signed-off-by Mingjin Ye <[email protected]>---
Re: [PATCH v4] test: fix option devices
In reply to Mingjin Yeapp/test/process.h process_dup(const char *const argv[], int numargs, const char *env_value) · line 129
Quoted 8 lines · On Wed, 16 Oct 2024 08:17:19 +0000 Mingjin Ye <[email protected]> wrote:
app/test/process.h +8
-0+for (i =0 ; i < numargs; i++) { +if (strcmp (argv[i],"-b" ) ==0 || +strcmp (argv[i],"--block" ) ==0 ) + block_num++; +if (strcmp (argv[i],"-a" ) ==0 || +strcmp (argv[i],"--allow" ) ==0 ) + allow_num++; + }
The long options format allows the equals form, but this doesn't.
The argv scan for -a/-b/--allow/--block uses exact strcmp, so it won't detect the --allow=DEVICE or --block=DEVICE joined form. If callers use the = form, the parent's device list will be duplicated in the child's arguments. Consider adding strncmp checks for the PREFIX_ALLOW and PREFIX_BLOCK prefixes or use getopt_long to scan.
This is not a huge issue, but could you change and resubmit.