[dpdk-dev] [PATCH] test: ensure EAL flags autotest works properly on BSD

Anatoly Burakov anatoly.burakov at intel.com
Mon Jul 16 18:34:04 CEST 2018


FreeBSD does not support running multiple primary processes
concurrently, because all DPDK instances will allocate memory
from the same place (memory provided by contigmem driver).
While it is technically possible to launch a DPDK process
using no-shconf switch, it will actually corrupt main process'
for the above reason.

Fix EAL flags autotest to not run primary processes unless
both no-shconf and no-huge are specified.

Cc: stable at dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
---

Notes:
    Testing of this patch is a little tricky. The issue was
    initially discovered because of a different patch:
    
    http://patches.dpdk.org/patch/36946/
    
    merged as:
    
    commit a3d6026711d00183e308f1dd79933f6161840e04
    Author: Olivier Matz <olivier.matz at 6wind.com>
        ring: relax alignment constraint on ring structure
    
    On some machines with FreeBSD, this resulted in weird
    behavior of EAL flags autotest [1], and, following
    investigation it was discoevered that the root cause
    was not that patch, but rather corrupted main memory
    of the test process. The reason for this corruption was
    eventially narrowed down to running one of the tests
    with a primary process, with no-shconf, but without
    no-huge, which resulted in second primary process
    attaching to the same contigmem segments and corrupting
    memory of the test process.
    
    After applying this patch, this issue goes away on my
    FreeBSD machine. This patch applies directly atop of
    that commit, so it can be tested against it.
    
    [1] http://patches.dpdk.org/patch/36946/#81432

 test/test/test_eal_flags.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/test/test/test_eal_flags.c b/test/test/test_eal_flags.c
index f840ca50b..8d1da2c60 100644
--- a/test/test/test_eal_flags.c
+++ b/test/test/test_eal_flags.c
@@ -376,17 +376,17 @@ test_invalid_vdev_flag(void)
 #endif
 
 	/* Test with invalid vdev option */
-	const char *vdevinval[] = {prgname, prefix, "-n", "1",
+	const char *vdevinval[] = {prgname, prefix, no_huge, "-n", "1",
 				"-c", "1", vdev, "eth_dummy"};
 
 	/* Test with valid vdev option */
-	const char *vdevval1[] = {prgname, prefix, "-n", "1",
+	const char *vdevval1[] = {prgname, prefix, no_huge, "-n", "1",
 	"-c", "1", vdev, "net_ring0"};
 
-	const char *vdevval2[] = {prgname, prefix, "-n", "1",
+	const char *vdevval2[] = {prgname, prefix, no_huge, "-n", "1",
 	"-c", "1", vdev, "net_ring0,args=test"};
 
-	const char *vdevval3[] = {prgname, prefix, "-n", "1",
+	const char *vdevval3[] = {prgname, prefix, no_huge, "-n", "1",
 	"-c", "1", vdev, "net_ring0,nodeaction=r1:0:CREATE"};
 
 	if (launch_proc(vdevinval) == 0) {
@@ -849,13 +849,10 @@ test_misc_flags(void)
 	const char *argv4[] = {prgname, prefix, mp_flag, "-c", "1", "--syslog"};
 	/* With invalid --syslog */
 	const char *argv5[] = {prgname, prefix, mp_flag, "-c", "1", "--syslog", "error"};
-	/* With no-sh-conf */
+	/* With no-sh-conf, also use no-huge to ensure this test runs on BSD */
 	const char *argv6[] = {prgname, "-c", "1", "-n", "2", "-m", DEFAULT_MEM_SIZE,
-			no_shconf, nosh_prefix };
+			no_shconf, nosh_prefix, no_huge};
 
-#ifdef RTE_EXEC_ENV_BSDAPP
-	return 0;
-#endif
 	/* With --huge-dir */
 	const char *argv7[] = {prgname, "-c", "1", "-n", "2", "-m", DEFAULT_MEM_SIZE,
 			"--file-prefix=hugedir", "--huge-dir", hugepath};
@@ -889,6 +886,7 @@ test_misc_flags(void)
 	const char *argv15[] = {prgname, "--file-prefix=intr",
 			"-c", "1", "-n", "2", "--vfio-intr=invalid"};
 
+	/* run all tests also applicable to FreeBSD first */
 
 	if (launch_proc(argv0) == 0) {
 		printf("Error - process ran ok with invalid flag\n");
@@ -902,6 +900,16 @@ test_misc_flags(void)
 		printf("Error - process did not run ok with -v flag\n");
 		return -1;
 	}
+	if (launch_proc(argv6) != 0) {
+		printf("Error - process did not run ok with --no-shconf flag\n");
+		return -1;
+	}
+
+#ifdef RTE_EXEC_ENV_BSDAPP
+	/* no more tests to be done on FreeBSD */
+	return 0;
+#endif
+
 	if (launch_proc(argv3) != 0) {
 		printf("Error - process did not run ok with --syslog flag\n");
 		return -1;
@@ -914,13 +922,6 @@ test_misc_flags(void)
 		printf("Error - process run ok with invalid --syslog flag\n");
 		return -1;
 	}
-	if (launch_proc(argv6) != 0) {
-		printf("Error - process did not run ok with --no-shconf flag\n");
-		return -1;
-	}
-#ifdef RTE_EXEC_ENV_BSDAPP
-	return 0;
-#endif
 	if (launch_proc(argv7) != 0) {
 		printf("Error - process did not run ok with --huge-dir flag\n");
 		return -1;
-- 
2.17.1


More information about the dev mailing list