Skip to contentSkip to conversation

Fix ADSP074 timeouts

PATCH In review Martin Doucha 2 participants 5 messages Sep 14, 2022 – Sep 15, 2022 Library code

lore
Share & tools
lore
#0 lore raw

v2 cover Fix ADSP074 timeouts

ADSP074 runs dio_sparse with extreme number of children which can result in severe system overload and random test timeouts simply because the main test process gets blocked by scheduler for 30+ seconds. Make io_read() aware of max_runtime and redesign child failure detection to fix the timeouts.

Also fixes a bug in io_read() which could have caused false negatives.

Martin Doucha (3):
Add tst_validate_children() helper function
Make io_read() runtime-aware
dio_sparse: Fix child exit code

 include/tst_test.h                            |  8 ++++++++
 lib/tst_status.c                              | 20 +++++++++++++++++++
 .../kernel/io/ltp-aiodio/aiodio_sparse.c      |  9 +++------
 testcases/kernel/io/ltp-aiodio/common.h       |  8 +++++---
 testcases/kernel/io/ltp-aiodio/dio_sparse.c   |  8 ++------
 5 files changed, 38 insertions(+), 15 deletions(-)
Signature · 5 lines
2.37.3


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

PATCH v2 1/3 Add tst_validate_children() helper function

The function waits for given number of child processes and validates that they have all exited without error.

---

Changes since v1:
- Moved tst_validate_children_() to lib/tst_status.c
- Simplified the code using tst_strstatus()

 include/tst_test.h |  8 ++++++++
 lib/tst_status.c   | 20 ++++++++++++++++++++
 2 files changed, 28 insertions(+)
include/tst_test.h +8 -0
index ac52f268c..69e649651 100644
@@ -362,6 +362,14 @@ void tst_set_max_runtime(int max_runtime);
  */
 char *tst_get_tmpdir(void);
 
+/*
+ * Validates exit status of child processes
+ */
+int tst_validate_children_(const char *file, const int lineno,
+	unsigned int count);
+#define tst_validate_children(child_count) \
+	tst_validate_children_(__FILE__, __LINE__, (child_count))
+
 #ifndef TST_NO_DEFAULT_MAIN
 
 static struct tst_test test;
lib/tst_status.c +20 -0
index 9124faaa3..5d03871f3 100644
@@ -49,3 +49,23 @@ const char *tst_strstatus(int status)
 
 	return invalid(status);
 }
+
+int tst_validate_children_(const char *file, const int lineno,
+	unsigned int count)
+{
+	unsigned int i;
+	int status;
+	pid_t pid;
+
+	for (i = 0; i < count; i++) {
+		pid = SAFE_WAITPID(-1, &status, 0);
+
+		if (!WIFEXITED(status) || WEXITSTATUS(status)) {
+			tst_res_(file, lineno, TFAIL, "Child %d: %s", pid,
+				tst_strstatus(status));
+			return 1;
+		}
+	}
+
+	return 0;
+}
Signature · 5 lines
2.37.3


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

PATCH v2 2/3 Make io_read() runtime-aware

In reply to Martin Doucha

Running dio_sparse with too many children can cause test timeouts due to severe system overload. Make the children runtime aware and switch to exit code validation.

---

Changes since v1: None

 testcases/kernel/io/ltp-aiodio/aiodio_sparse.c | 9 +++------
 testcases/kernel/io/ltp-aiodio/common.h        | 2 +-
 testcases/kernel/io/ltp-aiodio/dio_sparse.c    | 8 ++------
 3 files changed, 6 insertions(+), 13 deletions(-)
testcases/kernel/io/ltp-aiodio/aiodio_sparse.c +3 -6
index 88aec7952..595c76226 100644
@@ -188,7 +188,6 @@ static void cleanup(void)
 static void run(void)
 {
 	char *filename = "file.bin";
-	int status;
 	int i, pid;
 
 	*run_child = 1;
@@ -222,12 +221,10 @@ static void run(void)
 		}
 	}
 
-	if (SAFE_WAITPID(-1, &status, WNOHANG))
-		tst_res(TFAIL, "Non zero bytes read");
-	else
-		tst_res(TPASS, "All bytes read were zeroed");
-
 	*run_child = 0;
+
+	if (!tst_validate_children(numchildren))
+		tst_res(TPASS, "All bytes read were zeroed");
 }
 
 static struct tst_test test = {
testcases/kernel/io/ltp-aiodio/common.h +1 -1
index d9cbd8611..68465dc54 100644
@@ -85,7 +85,7 @@ static inline void io_read(const char *filename, int filesize, volatile int *run
 				offset += r;
 			}
 
-			if (!*run_child)
+			if (!*run_child || !tst_remaining_runtime())
 				goto exit;
 		}
 	}
testcases/kernel/io/ltp-aiodio/dio_sparse.c +2 -6
index b08d2ea1e..1b5834ed4 100644
@@ -96,7 +96,6 @@ static void cleanup(void)
 static void run(void)
 {
 	char *filename = "dio_sparse";
-	int status;
 	int fd;
 	int i;
 
@@ -113,13 +112,10 @@ static void run(void)
 	}
 
 	dio_sparse(fd, alignment, filesize, writesize, offset);
+	*run_child = 0;
 
-	if (SAFE_WAITPID(-1, &status, WNOHANG))
-		tst_res(TFAIL, "Non zero bytes read");
-	else
+	if (!tst_validate_children(numchildren))
 		tst_res(TPASS, "All bytes read were zeroed");
-
-	*run_child = 0;
 }
 
 static struct tst_test test = {
Signature · 5 lines
2.37.3


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

PATCH v2 3/3 dio_sparse: Fix child exit code

In reply to Martin Doucha

dio_sparse currently ignores all child failures because children never exit with non-zero code. Fix child exit status.

---

Changes since v1:
- Use tst_res(TFAIL)+exit(1) instead of tst_brk()

 testcases/kernel/io/ltp-aiodio/common.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
testcases/kernel/io/ltp-aiodio/common.h +4 -2
index 68465dc54..3a604f8f7 100644
@@ -78,9 +78,11 @@ static inline void io_read(const char *filename, int filesize, volatile int *run
 			if (r > 0) {
 				bufoff = check_zero(buff, r);
 				if (bufoff) {
-					tst_res(TINFO, "non-zero read at offset %zu",
+					tst_res(TFAIL,
+						"non-zero read at offset %zu",
 						offset + (bufoff - buff));
-					break;
+					SAFE_CLOSE(fd);
+					exit(1);
 				}
 				offset += r;
 			}
Signature · 5 lines
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp