public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/3] Fix ADSP074 timeouts
@ 2022-09-14 13:43 Martin Doucha
  2022-09-14 13:43 ` [LTP] [PATCH v2 1/3] Add tst_validate_children() helper function Martin Doucha
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Martin Doucha @ 2022-09-14 13:43 UTC (permalink / raw)
  To: ltp

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(-)

-- 
2.37.3


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH v2 1/3] Add tst_validate_children() helper function
  2022-09-14 13:43 [LTP] [PATCH v2 0/3] Fix ADSP074 timeouts Martin Doucha
@ 2022-09-14 13:43 ` Martin Doucha
  2022-09-14 13:43 ` [LTP] [PATCH v2 2/3] Make io_read() runtime-aware Martin Doucha
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Martin Doucha @ 2022-09-14 13:43 UTC (permalink / raw)
  To: ltp

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

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

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(+)

diff --git a/include/tst_test.h b/include/tst_test.h
index ac52f268c..69e649651 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -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;
diff --git a/lib/tst_status.c b/lib/tst_status.c
index 9124faaa3..5d03871f3 100644
--- a/lib/tst_status.c
+++ b/lib/tst_status.c
@@ -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;
+}
-- 
2.37.3


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH v2 2/3] Make io_read() runtime-aware
  2022-09-14 13:43 [LTP] [PATCH v2 0/3] Fix ADSP074 timeouts Martin Doucha
  2022-09-14 13:43 ` [LTP] [PATCH v2 1/3] Add tst_validate_children() helper function Martin Doucha
@ 2022-09-14 13:43 ` Martin Doucha
  2022-09-14 13:43 ` [LTP] [PATCH v2 3/3] dio_sparse: Fix child exit code Martin Doucha
  2022-09-15  8:52 ` [LTP] [PATCH v2 0/3] Fix ADSP074 timeouts Cyril Hrubis
  3 siblings, 0 replies; 5+ messages in thread
From: Martin Doucha @ 2022-09-14 13:43 UTC (permalink / raw)
  To: ltp

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.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

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(-)

diff --git a/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c b/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c
index 88aec7952..595c76226 100644
--- a/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c
+++ b/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c
@@ -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 = {
diff --git a/testcases/kernel/io/ltp-aiodio/common.h b/testcases/kernel/io/ltp-aiodio/common.h
index d9cbd8611..68465dc54 100644
--- a/testcases/kernel/io/ltp-aiodio/common.h
+++ b/testcases/kernel/io/ltp-aiodio/common.h
@@ -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;
 		}
 	}
diff --git a/testcases/kernel/io/ltp-aiodio/dio_sparse.c b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
index b08d2ea1e..1b5834ed4 100644
--- a/testcases/kernel/io/ltp-aiodio/dio_sparse.c
+++ b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
@@ -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 = {
-- 
2.37.3


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH v2 3/3] dio_sparse: Fix child exit code
  2022-09-14 13:43 [LTP] [PATCH v2 0/3] Fix ADSP074 timeouts Martin Doucha
  2022-09-14 13:43 ` [LTP] [PATCH v2 1/3] Add tst_validate_children() helper function Martin Doucha
  2022-09-14 13:43 ` [LTP] [PATCH v2 2/3] Make io_read() runtime-aware Martin Doucha
@ 2022-09-14 13:43 ` Martin Doucha
  2022-09-15  8:52 ` [LTP] [PATCH v2 0/3] Fix ADSP074 timeouts Cyril Hrubis
  3 siblings, 0 replies; 5+ messages in thread
From: Martin Doucha @ 2022-09-14 13:43 UTC (permalink / raw)
  To: ltp

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

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

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(-)

diff --git a/testcases/kernel/io/ltp-aiodio/common.h b/testcases/kernel/io/ltp-aiodio/common.h
index 68465dc54..3a604f8f7 100644
--- a/testcases/kernel/io/ltp-aiodio/common.h
+++ b/testcases/kernel/io/ltp-aiodio/common.h
@@ -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;
 			}
-- 
2.37.3


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH v2 0/3] Fix ADSP074 timeouts
  2022-09-14 13:43 [LTP] [PATCH v2 0/3] Fix ADSP074 timeouts Martin Doucha
                   ` (2 preceding siblings ...)
  2022-09-14 13:43 ` [LTP] [PATCH v2 3/3] dio_sparse: Fix child exit code Martin Doucha
@ 2022-09-15  8:52 ` Cyril Hrubis
  3 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2022-09-15  8:52 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

Hi!
Patchset pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-15  8:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-14 13:43 [LTP] [PATCH v2 0/3] Fix ADSP074 timeouts Martin Doucha
2022-09-14 13:43 ` [LTP] [PATCH v2 1/3] Add tst_validate_children() helper function Martin Doucha
2022-09-14 13:43 ` [LTP] [PATCH v2 2/3] Make io_read() runtime-aware Martin Doucha
2022-09-14 13:43 ` [LTP] [PATCH v2 3/3] dio_sparse: Fix child exit code Martin Doucha
2022-09-15  8:52 ` [LTP] [PATCH v2 0/3] Fix ADSP074 timeouts Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox