* [PATCH] test: fix option block @ 2024-03-14 9:46 Mingjin Ye 2024-03-15 6:49 ` Jiale, SongX ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: Mingjin Ye @ 2024-03-14 9:46 UTC (permalink / raw) To: dev; +Cc: Mingjin Ye, stable 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") Cc: stable@dpdk.org Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com> --- app/test/process.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/test/process.h b/app/test/process.h index 9fb2bf481c..388c7975cd 100644 --- a/app/test/process.h +++ b/app/test/process.h @@ -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) -- 2.25.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH] test: fix option block 2024-03-14 9:46 [PATCH] test: fix option block Mingjin Ye @ 2024-03-15 6:49 ` Jiale, SongX 2024-10-07 17:02 ` Stephen Hemminger 2024-10-12 9:35 ` [PATCH v2] " Mingjin Ye 2 siblings, 0 replies; 9+ messages in thread From: Jiale, SongX @ 2024-03-15 6:49 UTC (permalink / raw) To: Ye, MingjinX, dev; +Cc: Ye, MingjinX, stable > -----Original Message----- > From: Mingjin Ye <mingjinx.ye@intel.com> > Sent: Thursday, March 14, 2024 5:46 PM > To: dev@dpdk.org > Cc: Ye, MingjinX <mingjinx.ye@intel.com>; stable@dpdk.org > Subject: [PATCH] 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. > > Fixes: b3ce7891ad38 ("test: fix probing in secondary process") > Cc: stable@dpdk.org > > Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com> > --- Tested-by: Jiale Song <songx.jiale@intel.com> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] test: fix option block 2024-03-14 9:46 [PATCH] test: fix option block Mingjin Ye 2024-03-15 6:49 ` Jiale, SongX @ 2024-10-07 17:02 ` Stephen Hemminger 2024-10-12 9:35 ` [PATCH v2] " Mingjin Ye 2 siblings, 0 replies; 9+ messages in thread From: Stephen Hemminger @ 2024-10-07 17:02 UTC (permalink / raw) To: Mingjin Ye; +Cc: dev, stable On Thu, 14 Mar 2024 09:46:26 +0000 Mingjin Ye <mingjinx.ye@intel.com> 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") > Cc: stable@dpdk.org > > Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com> > --- > app/test/process.h | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/app/test/process.h b/app/test/process.h > index 9fb2bf481c..388c7975cd 100644 > --- a/app/test/process.h > +++ b/app/test/process.h > @@ -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) 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. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] test: fix option block 2024-03-14 9:46 [PATCH] test: fix option block Mingjin Ye 2024-03-15 6:49 ` Jiale, SongX 2024-10-07 17:02 ` Stephen Hemminger @ 2024-10-12 9:35 ` Mingjin Ye 2024-10-12 22:20 ` Stephen Hemminger 2024-10-14 10:00 ` [PATCH v3] test: fix option devices Mingjin Ye 2 siblings, 2 replies; 9+ messages in thread From: Mingjin Ye @ 2024-10-12 9:35 UTC (permalink / raw) To: dev; +Cc: Mingjin Ye, stable 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") Cc: stable@dpdk.org Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com> --- v2: The long form of the fix option is "--block". --- app/test/process.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/test/process.h b/app/test/process.h index 9fb2bf481c..75d6a41802 100644 --- a/app/test/process.h +++ b/app/test/process.h @@ -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) -- 2.25.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] test: fix option block 2024-10-12 9:35 ` [PATCH v2] " Mingjin Ye @ 2024-10-12 22:20 ` Stephen Hemminger 2024-10-14 10:22 ` Ye, MingjinX 2024-10-14 10:00 ` [PATCH v3] test: fix option devices Mingjin Ye 1 sibling, 1 reply; 9+ messages in thread From: Stephen Hemminger @ 2024-10-12 22:20 UTC (permalink / raw) To: Mingjin Ye; +Cc: dev, stable On Sat, 12 Oct 2024 09:35:19 +0000 Mingjin Ye <mingjinx.ye@intel.com> 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") > Cc: stable@dpdk.org > > Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com> > --- 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. ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v2] test: fix option block 2024-10-12 22:20 ` Stephen Hemminger @ 2024-10-14 10:22 ` Ye, MingjinX 0 siblings, 0 replies; 9+ messages in thread From: Ye, MingjinX @ 2024-10-14 10:22 UTC (permalink / raw) To: Stephen Hemminger; +Cc: dev, stable > -----Original Message----- > From: Stephen Hemminger <stephen@networkplumber.org> > Sent: Sunday, October 13, 2024 6:21 AM > To: Ye, MingjinX <mingjinx.ye@intel.com> > Cc: dev@dpdk.org; stable@dpdk.org > Subject: Re: [PATCH v2] test: fix option block > > On Sat, 12 Oct 2024 09:35:19 +0000 > Mingjin Ye <mingjinx.ye@intel.com> 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") > > Cc: stable@dpdk.org > > > > Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com> > > --- > > What is this patch trying to solve? Solve the issue of allow/block devices being added accidentally. The v3 patch will be sent. > > 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. > > 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. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3] test: fix option devices 2024-10-12 9:35 ` [PATCH v2] " Mingjin Ye 2024-10-12 22:20 ` Stephen Hemminger @ 2024-10-14 10:00 ` Mingjin Ye 2024-10-15 16:21 ` Stephen Hemminger 2024-10-16 8:17 ` [PATCH v4] " Mingjin Ye 1 sibling, 2 replies; 9+ messages in thread From: Mingjin Ye @ 2024-10-14 10:00 UTC (permalink / raw) To: dev; +Cc: Mingjin Ye, stable 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. 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") Cc: stable@dpdk.org Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com> --- 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(-) diff --git a/app/test/process.h b/app/test/process.h index 9fb2bf481c..665abae9dc 100644 --- a/app/test/process.h +++ b/app/test/process.h @@ -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 -- 2.25.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] test: fix option devices 2024-10-14 10:00 ` [PATCH v3] test: fix option devices Mingjin Ye @ 2024-10-15 16:21 ` Stephen Hemminger 2024-10-16 8:17 ` [PATCH v4] " Mingjin Ye 1 sibling, 0 replies; 9+ messages in thread From: Stephen Hemminger @ 2024-10-15 16:21 UTC (permalink / raw) To: Mingjin Ye; +Cc: dev, stable On Mon, 14 Oct 2024 10:00:26 +0000 Mingjin Ye <mingjinx.ye@intel.com> 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. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4] test: fix option devices 2024-10-14 10:00 ` [PATCH v3] test: fix option devices Mingjin Ye 2024-10-15 16:21 ` Stephen Hemminger @ 2024-10-16 8:17 ` Mingjin Ye 1 sibling, 0 replies; 9+ messages in thread From: Mingjin Ye @ 2024-10-16 8:17 UTC (permalink / raw) To: dev; +Cc: Mingjin Ye, stable 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 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. Fixes: b3ce7891ad38 ("test: fix probing in secondary process") Cc: stable@dpdk.org Signed-off-by: Mingjin Ye <mingjinx.ye@intel.com> --- 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(-) diff --git a/app/test/process.h b/app/test/process.h index 9fb2bf481c..665abae9dc 100644 --- a/app/test/process.h +++ b/app/test/process.h @@ -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 -- 2.25.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-10-16 8:40 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-03-14 9:46 [PATCH] test: fix option block Mingjin Ye 2024-03-15 6:49 ` Jiale, SongX 2024-10-07 17:02 ` Stephen Hemminger 2024-10-12 9:35 ` [PATCH v2] " Mingjin Ye 2024-10-12 22:20 ` Stephen Hemminger 2024-10-14 10:22 ` Ye, MingjinX 2024-10-14 10:00 ` [PATCH v3] test: fix option devices Mingjin Ye 2024-10-15 16:21 ` Stephen Hemminger 2024-10-16 8:17 ` [PATCH v4] " Mingjin Ye
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).