Skip to contentSkip to conversation

test/eal: check invalid cpu value

PATCH In review Kevin Traynor 3 participants 7 messages Jun 12, 2020 – Jul 21, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test/eal: check invalid cpu value

When using --lcores option, CPU_SETSIZE allows a range of 0-1023. Check it is not being exceeded.

---
 app/test/test_eal_flags.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
app/test/test_eal_flags.c +5 -1
index 4ee809e3d..044cc1c59 100644
@@ -528,4 +528,7 @@ test_missing_c_flag(void)
 				 "--lcores",
 				 "0-1,2@(5-7),(3-5)@(0,2),(0,6),7"};
+	/* check an invalid cpu value >= CPU_SETSIZE */
+	const char * const argv30[] = { prgname, prefix, mp_flag,
+				 "--lcores", "3@1024" };
 
 	if (launch_proc(argv2) != 0) {
@@ -577,5 +580,6 @@ test_missing_c_flag(void)
 	    launch_proc(argv24) == 0 || launch_proc(argv25) == 0 ||
 	    launch_proc(argv26) == 0 || launch_proc(argv27) == 0 ||
-	    launch_proc(argv28) == 0) {
+	    launch_proc(argv28) == 0 || launch_proc(argv30) == 0) {
+
 		printf("Error - "
 		       "process ran without error with invalid --lcore flag\n");
Signature · 1 line
2.21.3
#1 lore raw

W dniu 12.06.2020 o 14:09, Kevin Traynor pisze:

Quoted 13 lines

When using --lcores option, CPU_SETSIZE allows a range of 0-1023. Check it is not being exceeded.

---
  app/test/test_eal_flags.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
app/test/test_eal_flags.c +0 -0
index 4ee809e3d..044cc1c59 100644

app/test/test_eal_flags.c test_missing_c_flag(void) · line 533

Quoted 6 lines
app/test/test_eal_flags.c +3 -0
@@ -528,4 +528,7 @@ test_missing_c_flag(void)
  				 "--lcores",
  				 "0-1,2@(5-7),(3-5)@(0,2),(0,6),7"};
+	/* check an invalid cpu value >= CPU_SETSIZE */
+	const char * const argv30[] = { prgname, prefix, mp_flag,
+				 "--lcores", "3@1024" };
 

The proper cpu values are in range 0-CPU_SETSIZE, but the CPU_SETSIZE is not always equal to 1024 (currently it is on Linux).
Check lib/librte_eal/windows/include/sched.h:17 :

#ifndef CPU_SETSIZE
#define CPU_SETSIZE RTE_MAX_LCORE
#endif

so to make your patch better, you can use CPU_SETSIZE value directly:

const char * const argv30[] = { prgname, prefix, mp_flag, "--lcores", "3@" RTE_STR(CPU_SETSIZE) };

app/test/test_eal_flags.c test_missing_c_flag(void) · line 585

Quoted 9 lines
app/test/test_eal_flags.c +2 -1
  	if (launch_proc(argv2) != 0) {
@@ -577,5 +580,6 @@ test_missing_c_flag(void)
  	    launch_proc(argv24) == 0 || launch_proc(argv25) == 0 ||
  	    launch_proc(argv26) == 0 || launch_proc(argv27) == 0 ||
-	    launch_proc(argv28) == 0) {
+	    launch_proc(argv28) == 0 || launch_proc(argv30) == 0) {
+
  		printf("Error - "
  		       "process ran without error with invalid --lcore flag\n");

Best regards

Signature · 7 lines
Lukasz Wojciechowski
Principal Software Engineer

Samsung R&D Institute Poland
Samsung Electronics
Office +48 22 377 88 25
[email protected]
#2 lore raw
Quoted 25 lines · Lukasz Wojciechowski

W dniu 12.06.2020 o 14:09, Kevin Traynor pisze:

Quoted 13 lines

When using --lcores option, CPU_SETSIZE allows a range of 0-1023. Check it is not being exceeded.

---
  app/test/test_eal_flags.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
app/test/test_eal_flags.c +0 -0
index 4ee809e3d..044cc1c59 100644

app/test/test_eal_flags.c test_missing_c_flag(void) · line 533

Quoted 6 lines
app/test/test_eal_flags.c +3 -0
@@ -528,4 +528,7 @@ test_missing_c_flag(void)
  				 "--lcores",
  				 "0-1,2@(5-7),(3-5)@(0,2),(0,6),7"};
+	/* check an invalid cpu value >= CPU_SETSIZE */
+	const char * const argv30[] = { prgname, prefix, mp_flag,
+				 "--lcores", "3@1024" };
 

The proper cpu values are in range 0-CPU_SETSIZE, but the CPU_SETSIZE is not always equal to 1024 (currently it is on Linux).
Check lib/librte_eal/windows/include/sched.h:17 :

Quoted 8 lines

#ifndef CPU_SETSIZE
#define CPU_SETSIZE RTE_MAX_LCORE
#endif

so to make your patch better, you can use CPU_SETSIZE value directly:

const char * const argv30[] = { prgname, prefix, mp_flag, "--lcores", "3@" RTE_STR(CPU_SETSIZE) };

Thanks Lukasz. You are right, this is better. I just sent a v2.

Kevin.

Quoted 13 lines

app/test/test_eal_flags.c test_missing_c_flag(void) · line 585

Quoted 10 lines
app/test/test_eal_flags.c +2 -1
  	if (launch_proc(argv2) != 0) {
@@ -577,5 +580,6 @@ test_missing_c_flag(void)
  	    launch_proc(argv24) == 0 || launch_proc(argv25) == 0 ||
  	    launch_proc(argv26) == 0 || launch_proc(argv27) == 0 ||
-	    launch_proc(argv28) == 0) {
+	    launch_proc(argv28) == 0 || launch_proc(argv30) == 0) {
+
  		printf("Error - "
  		       "process ran without error with invalid --lcore flag\n");

Best regards

#3 lore raw

PATCH 1/1 test/eal: check invalid cpu value

In reply to Kevin Traynor

When using --lcores option, there is a limit of CPU_SETSIZE. Currently that allows 0..1023 on Linux.

Check it is caught when this limit is exceeded.

---
 app/test/test_eal_flags.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
app/test/test_eal_flags.c +4 -1
index 4ee809e3d..b019656b2 100644
@@ -528,4 +528,7 @@ test_missing_c_flag(void)
 				 "--lcores",
 				 "0-1,2@(5-7),(3-5)@(0,2),(0,6),7"};
+	/* check an invalid cpu value >= CPU_SETSIZE */
+	const char * const argv30[] = { prgname, prefix, mp_flag,
+				 "--lcores", "3@" RTE_STR(CPU_SETSIZE) };
 
 	if (launch_proc(argv2) != 0) {
@@ -577,5 +580,5 @@ test_missing_c_flag(void)
 	    launch_proc(argv24) == 0 || launch_proc(argv25) == 0 ||
 	    launch_proc(argv26) == 0 || launch_proc(argv27) == 0 ||
-	    launch_proc(argv28) == 0) {
+	    launch_proc(argv28) == 0 || launch_proc(argv30) == 0) {
 		printf("Error - "
 		       "process ran without error with invalid --lcore flag\n");
Signature · 1 line
2.21.3
#4 lore raw

PATCH v2 1/1 test/eal: check invalid cpu value

When using --lcores option, there is a limit of CPU_SETSIZE. Currently that allows 0..1023 on Linux.

Check it is caught when this limit is exceeded.

---
 app/test/test_eal_flags.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
app/test/test_eal_flags.c +4 -1
index 4ee809e3d..b019656b2 100644
@@ -528,4 +528,7 @@ test_missing_c_flag(void)
 				 "--lcores",
 				 "0-1,2@(5-7),(3-5)@(0,2),(0,6),7"};
+	/* check an invalid cpu value >= CPU_SETSIZE */
+	const char * const argv30[] = { prgname, prefix, mp_flag,
+				 "--lcores", "3@" RTE_STR(CPU_SETSIZE) };
 
 	if (launch_proc(argv2) != 0) {
@@ -577,5 +580,5 @@ test_missing_c_flag(void)
 	    launch_proc(argv24) == 0 || launch_proc(argv25) == 0 ||
 	    launch_proc(argv26) == 0 || launch_proc(argv27) == 0 ||
-	    launch_proc(argv28) == 0) {
+	    launch_proc(argv28) == 0 || launch_proc(argv30) == 0) {
 		printf("Error - "
 		       "process ran without error with invalid --lcore flag\n");
Signature · 1 line
2.21.3
Acked-by on v2 1/1
#5 lore raw

W dniu 20.07.2020 o 12:19, Kevin Traynor pisze:

Quoted 23 lines

When using --lcores option, there is a limit of CPU_SETSIZE. Currently that allows 0..1023 on Linux.

Check it is caught when this limit is exceeded.

---
  app/test/test_eal_flags.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
app/test/test_eal_flags.c +3 -0
index 4ee809e3d..b019656b2 100644
@@ -528,4 +528,7 @@ test_missing_c_flag(void)
  				 "--lcores",
  				 "0-1,2@(5-7),(3-5)@(0,2),(0,6),7"};
+	/* check an invalid cpu value >= CPU_SETSIZE */
+	const char * const argv30[] = { prgname, prefix, mp_flag,
+				 "--lcores", "3@" RTE_STR(CPU_SETSIZE) };
 
  	if (launch_proc(argv2) != 0) {

app/test/test_eal_flags.c test_missing_c_flag(void) · line 584

Quoted 6 lines
app/test/test_eal_flags.c +1 -1
@@ -577,5 +580,5 @@ test_missing_c_flag(void)
  	    launch_proc(argv24) == 0 || launch_proc(argv25) == 0 ||
  	    launch_proc(argv26) == 0 || launch_proc(argv27) == 0 ||
-	    launch_proc(argv28) == 0) {
+	    launch_proc(argv28) == 0 || launch_proc(argv30) == 0) {
  		printf("Error - "
  		       "process ran without error with invalid --lcore flag\n");

Now it's perfect.

Signature · 7 lines
Lukasz Wojciechowski
Principal Software Engineer

Samsung R&D Institute Poland
Samsung Electronics
Office +48 22 377 88 25
[email protected]
#6 lore raw
Quoted 6 lines · Lukasz Wojciechowski

W dniu 20.07.2020 o 12:19, Kevin Traynor pisze:

Quoted 4 lines

When using --lcores option, there is a limit of CPU_SETSIZE. Currently that allows 0..1023 on Linux.

Check it is caught when this limit is exceeded.

Applied, thanks Kevin.

Signature · 1 line
David Marchand