Skip to contentSkip to conversation

Fix ltp-aiodio tests failing on s390

PATCH In review Andrea Cervesato 4 participants 5 messages May 19, 2022 – May 20, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix ltp-aiodio tests failing on s390

run_child flag is commonly used by aiodio tests in order to check if tests are passed or not and compiler seems to optimize run_child flag because it's not defined as volatile. With this patch we ensure that the flag is set as volatile so tests will work as expected on s390.

---
 testcases/kernel/io/ltp-aiodio/aiodio_append.c | 4 ++--
 testcases/kernel/io/ltp-aiodio/aiodio_sparse.c | 4 ++--
 testcases/kernel/io/ltp-aiodio/dio_append.c    | 7 +++++--
 testcases/kernel/io/ltp-aiodio/dio_sparse.c    | 4 ++--
 testcases/kernel/io/ltp-aiodio/dio_truncate.c  | 4 ++--
 5 files changed, 13 insertions(+), 10 deletions(-)
testcases/kernel/io/ltp-aiodio/aiodio_append.c +2 -2
index 46cc74ee4..e42c577cd 100644
@@ -24,7 +24,7 @@
 #include <libaio.h>
 #include "common.h"
 
-static int *run_child;
+static volatile int *run_child;
 
 static char *str_numchildren;
 static char *str_writesize;
@@ -133,7 +133,7 @@ static void cleanup(void)
 {
 	if (run_child) {
 		*run_child = 0;
-		SAFE_MUNMAP(run_child, sizeof(int));
+		SAFE_MUNMAP((void *)run_child, sizeof(int));
 	}
 }
 
testcases/kernel/io/ltp-aiodio/aiodio_sparse.c +2 -2
index 2aa5662bb..9aa9b8d54 100644
@@ -28,7 +28,7 @@
 #include <libaio.h>
 #include "common.h"
 
-static int *run_child;
+static volatile int *run_child;
 
 static char *str_numchildren;
 static char *str_writesize;
@@ -181,7 +181,7 @@ static void cleanup(void)
 {
 	if (run_child) {
 		*run_child = 0;
-		SAFE_MUNMAP(run_child, sizeof(int));
+		SAFE_MUNMAP((void *)run_child, sizeof(int));
 	}
 }
 
testcases/kernel/io/ltp-aiodio/dio_append.c +5 -2
index c099793f6..3a7e7c836 100644
@@ -19,7 +19,7 @@
 #include "tst_test.h"
 #include "common.h"
 
-static int *run_child;
+static volatile int *run_child;
 
 static char *str_numchildren;
 static char *str_writesize;
@@ -49,7 +49,10 @@ static void setup(void)
 
 static void cleanup(void)
 {
-	SAFE_MUNMAP(run_child, sizeof(int));
+	if (run_child) {
+		*run_child = 0;
+		SAFE_MUNMAP((void *)run_child, sizeof(int));
+	}
 }
 
 static void run(void)
testcases/kernel/io/ltp-aiodio/dio_sparse.c +2 -2
index 0039daa8d..661afde4c 100644
@@ -26,7 +26,7 @@
 #include "tst_test.h"
 #include "common.h"
 
-static int *run_child;
+static volatile int *run_child;
 
 static char *str_numchildren;
 static char *str_writesize;
@@ -85,7 +85,7 @@ static void cleanup(void)
 {
 	if (run_child) {
 		*run_child = 0;
-		SAFE_MUNMAP(run_child, sizeof(int));
+		SAFE_MUNMAP((void *)run_child, sizeof(int));
 	}
 }
 
testcases/kernel/io/ltp-aiodio/dio_truncate.c +2 -2
index 1fbf83de0..0fe6b87ac 100644
@@ -33,7 +33,7 @@
 #include "tst_test.h"
 #include "common.h"
 
-static int *run_child;
+static volatile int *run_child;
 
 static char *str_numchildren;
 static char *str_filesize;
@@ -109,7 +109,7 @@ static void cleanup(void)
 {
 	if (run_child) {
 		*run_child = 0;
-		SAFE_MUNMAP(run_child, sizeof(int));
+		SAFE_MUNMAP((void *)run_child, sizeof(int));
 	}
 }
 
Signature · 5 lines
2.36.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#1 lore raw

Hi Andrea,

Quoted 12 lines
testcases/kernel/io/ltp-aiodio/dio_append.c +1 -1
@@ -19,7 +19,7 @@
 #include "tst_test.h"
 #include "common.h"
 
-static int *run_child;
+static volatile int *run_child;
 
 static char *str_numchildren;
 static char *str_writesize;

testcases/kernel/io/ltp-aiodio/dio_append.c static void setup(void) · line 55

Quoted 8 lines
testcases/kernel/io/ltp-aiodio/dio_append.c +4 -1
@@ -49,7 +49,10 @@ static void setup(void)
 
 static void cleanup(void)
 {
-	SAFE_MUNMAP(run_child, sizeof(int));
+	if (run_child) {
+		*run_child = 0;
+		SAFE_MUNMAP((void *)run_child, sizeof(int));
+	}

nit: This looks like unrelated, right? If yes it could be in separate commit. But I'm ok to merge it in single commit.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi Petr,

that was missing from the previous implementation indeed. Something that was checked in the other tests, but not this one. Probably because it's also the older test we refactor in the aiodio testing suite. It seems related to the bug and the volatile variable, so I added it as well.

Andrea

Quoted 27 lines · Petr Vorel

Hi Andrea,

Quoted 10 lines
testcases/kernel/io/ltp-aiodio/dio_append.c +1 -1
@@ -19,7 +19,7 @@
 #include "tst_test.h"
 #include "common.h"
-static int *run_child;
+static volatile int *run_child;
 static char *str_numchildren;
 static char *str_writesize;

testcases/kernel/io/ltp-aiodio/dio_append.c static void setup(void) · line 54

Quoted 7 lines
testcases/kernel/io/ltp-aiodio/dio_append.c +4 -1
@@ -49,7 +49,10 @@ static void setup(void)
 static void cleanup(void)
 {
-	SAFE_MUNMAP(run_child, sizeof(int));
+	if (run_child) {
+		*run_child = 0;
+		SAFE_MUNMAP((void *)run_child, sizeof(int));
+	}

nit: This looks like unrelated, right? If yes it could be in separate commit. But I'm ok to merge it in single commit.

Kind regards,
Petr

Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#3 lore raw
In reply to Andrea Cervesato

Hi!

Quoted 2 lines

run_child flag is commonly used by aiodio tests in order to check if tests are passed or not and compiler seems to optimize run_child flag

^
test has finished?

Quoted 4 lines

because it's not defined as volatile. With this patch we ensure that the flag is set as volatile so tests will work as expected on s390.

The change itself looks fine and should go in before the release.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Hi all,

Quoted 6 lines

Hi!

Quoted 2 lines

run_child flag is commonly used by aiodio tests in order to check if tests are passed or not and compiler seems to optimize run_child flag

^
test has finished?

Quoted 6 lines
Quoted 4 lines

because it's not defined as volatile. With this patch we ensure that the flag is set as volatile so tests will work as expected on s390.

The change itself looks fine and should go in before the release.

Merged with amended commit message. Thanks Andrea!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp