* [LTP] [PATCH] dio_read: fix infinite loop when readsize >= filesize
@ 2026-03-24 8:08 Andrea Cervesato
2026-03-24 8:20 ` Petr Vorel
2026-03-24 13:21 ` Cyril Hrubis
0 siblings, 2 replies; 5+ messages in thread
From: Andrea Cervesato @ 2026-03-24 8:08 UTC (permalink / raw)
To: Linux Test Project
From: Andrea Cervesato <andrea.cervesato@suse.com>
The do_direct_reads() function had exit conditions inside the inner
for loop. When readsize >= filesize, the for loop condition is never
true, causing the while(1) loop to spin infinitely without checking
if writers completed or runtime expired.
Move the exit condition checks outside the for loop to ensure they
are evaluated on every iteration, regardless of readsize/filesize
parameters.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
There's a sporadic failure in DOR000 that causes test to loop
indefinetly under s390x. This patch tries to fix the issue by ensuring
test will check runtime and if children completed.
---
testcases/kernel/io/ltp-aiodio/dio_read.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/testcases/kernel/io/ltp-aiodio/dio_read.c b/testcases/kernel/io/ltp-aiodio/dio_read.c
index 1c913cc2b814e3f6b0673b8926ffce526eb27655..8d1b8adf675e8fa2136b972c18007b2a60dab36a 100644
--- a/testcases/kernel/io/ltp-aiodio/dio_read.c
+++ b/testcases/kernel/io/ltp-aiodio/dio_read.c
@@ -66,20 +66,20 @@ static int do_direct_reads(char *filename, char *bufptr, long long fsize, long l
fd = SAFE_OPEN(filename, O_RDONLY | O_DIRECT, 0666);
while (1) {
- for (offset = 0; offset + rsize < fsize; offset += rsize) {
- char *bufoff;
+ if (*children_completed >= numchildren) {
+ tst_res(TINFO,
+ "Writers finshed, exiting reader (iteration %i)",
+ iter);
+ goto exit;
+ }
- if (*children_completed >= numchildren) {
- tst_res(TINFO,
- "Writers finshed, exiting reader (iteration %i)",
- iter);
- goto exit;
- }
+ if (!tst_remaining_runtime()) {
+ tst_res(TINFO, "Test out of runtime, exiting");
+ goto exit;
+ }
- if (!tst_remaining_runtime()) {
- tst_res(TINFO, "Test out of runtime, exiting");
- goto exit;
- }
+ for (offset = 0; offset + rsize < fsize; offset += rsize) {
+ char *bufoff;
w = pread(fd, bufptr, rsize, offset);
if (w < 0)
---
base-commit: 475f2dbdce80cca84caf408c910cf4da4779d5a8
change-id: 20260324-fix_dio_read-31b9148b1c98
Best regards,
--
Andrea Cervesato <andrea.cervesato@suse.com>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] dio_read: fix infinite loop when readsize >= filesize
2026-03-24 8:08 [LTP] [PATCH] dio_read: fix infinite loop when readsize >= filesize Andrea Cervesato
@ 2026-03-24 8:20 ` Petr Vorel
2026-03-24 9:08 ` Andrea Cervesato via ltp
2026-03-24 13:09 ` Andrea Cervesato via ltp
2026-03-24 13:21 ` Cyril Hrubis
1 sibling, 2 replies; 5+ messages in thread
From: Petr Vorel @ 2026-03-24 8:20 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
Hi Andrea,
> The do_direct_reads() function had exit conditions inside the inner
> for loop. When readsize >= filesize, the for loop condition is never
> true, causing the while(1) loop to spin infinitely without checking
> if writers completed or runtime expired.
> Move the exit condition checks outside the for loop to ensure they
> are evaluated on every iteration, regardless of readsize/filesize
> parameters.
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> There's a sporadic failure in DOR000 that causes test to loop
> indefinetly under s390x. This patch tries to fix the issue by ensuring
> test will check runtime and if children completed.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
As a fix for indefinite loop LGTM. But why it happen readsize >= filesize? These
are related to -r and -s values, but we always use -r 512k -w 512k -s 32M.
I wonder why this happen only on s390x? (I'd expect ppc64le which has different
page size.
Also that means that pread() is skipped when this happen.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] dio_read: fix infinite loop when readsize >= filesize
2026-03-24 8:20 ` Petr Vorel
@ 2026-03-24 9:08 ` Andrea Cervesato via ltp
2026-03-24 13:09 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 5+ messages in thread
From: Andrea Cervesato via ltp @ 2026-03-24 9:08 UTC (permalink / raw)
To: Petr Vorel; +Cc: Linux Test Project
Hi Petr,
> As a fix for indefinite loop LGTM. But why it happen readsize >= filesize? These
> are related to -r and -s values, but we always use -r 512k -w 512k -s 32M.
> I wonder why this happen only on s390x? (I'd expect ppc64le which has different
> page size.
>
> Also that means that pread() is skipped when this happen.
I was trying to fix this sporadic failure on s390x and I discovered this bug
in the test so I send a patch. As you said, the DOR000 might still fail.
What happens at the moment is that children seem to stuck. This fix should
reduce the amount of messages and debug it a bit better. Let's see..
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] dio_read: fix infinite loop when readsize >= filesize
2026-03-24 8:20 ` Petr Vorel
2026-03-24 9:08 ` Andrea Cervesato via ltp
@ 2026-03-24 13:09 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 5+ messages in thread
From: Andrea Cervesato via ltp @ 2026-03-24 13:09 UTC (permalink / raw)
To: Petr Vorel; +Cc: Linux Test Project
Thanks for the review.
Merged.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] dio_read: fix infinite loop when readsize >= filesize
2026-03-24 8:08 [LTP] [PATCH] dio_read: fix infinite loop when readsize >= filesize Andrea Cervesato
2026-03-24 8:20 ` Petr Vorel
@ 2026-03-24 13:21 ` Cyril Hrubis
1 sibling, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2026-03-24 13:21 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
Hi!
> The do_direct_reads() function had exit conditions inside the inner
> for loop. When readsize >= filesize, the for loop condition is never
> true, causing the while(1) loop to spin infinitely without checking
> if writers completed or runtime expired.
>
> Move the exit condition checks outside the for loop to ensure they
> are evaluated on every iteration, regardless of readsize/filesize
> parameters.
I was looking at this when I was rewriting the runtest files and I was
wondering why we do not check that filesize <= readsize && filesize <=
writesize in the test setup() instead.
--
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:[~2026-03-24 13:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24 8:08 [LTP] [PATCH] dio_read: fix infinite loop when readsize >= filesize Andrea Cervesato
2026-03-24 8:20 ` Petr Vorel
2026-03-24 9:08 ` Andrea Cervesato via ltp
2026-03-24 13:09 ` Andrea Cervesato via ltp
2026-03-24 13:21 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox