Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH] openposix: Fix aio_suspend/1-1 completion race
@ 2026-10-01 11:00 Andrea Cervesato
  2026-10-01 12:01 ` Martin Doucha
  0 siblings, 1 reply; 3+ messages in thread
From: Andrea Cervesato @ 2026-10-01 11:00 UTC (permalink / raw)
  To: Linux Test Project

From: Andrea Cervesato <andrea.cervesato@suse.com>

The selected read may finish before the test calls aio_suspend().
Treating this as an unresolved result makes the test depend on I/O
speed and scheduling.

POSIX permits aio_suspend() to return immediately for a completed
request. Drop the racy precondition and retain the completion checks.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Two aio_suspend tests assume that queued I/O cannot complete before
the test checks its status. Depending on I/O speed and scheduling,
this can produce an unresolved result or a false test failure.

In 1-1, early completion is valid: aio_suspend() must return
immediately when a listed request has already completed. Remove the
check that rejects this case.
---
 .../conformance/interfaces/aio_suspend/1-1.c             | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c
index 8f0c9ae95..2de7c87d2 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c
@@ -25,7 +25,6 @@
  *
  *	- write to a file
  *	- submit a list of read requests
- *	- check that the selected request has not completed
  *	- suspend on selected request
  *	- check that the selected request has completed using aio_error and
  *	  aio_return
@@ -146,20 +145,7 @@ int test_main(int argc PTS_ATTRIBUTE_UNUSED, char **argv PTS_ATTRIBUTE_UNUSED)
 		exit(PTS_UNRESOLVED);
 	}
 
-	/* Check selected request has not completed yet */
-	err = aio_error(aiocbs[WAIT_FOR_AIOCB]);
-	if (!err) {
-		printf(TNAME " Error : AIOCB %d already completed before "
-		       "suspend\n", WAIT_FOR_AIOCB);
-		for (i = 0; i < NUM_AIOCBS; i++)
-			free(aiocbs[i]);
-		free(bufs);
-		free(aiocbs);
-		close(fd);
-		exit(PTS_UNRESOLVED);
-	}
-
-	/* Suspend on selected request */
+	/* The selected request may have already completed, which is valid. */
 	ret = aio_suspend((const struct aiocb **)plist, 2, NULL);
 	if (ret) {
 		printf(TNAME " Error at aio_suspend() %d: %s\n",

---
base-commit: 65c0cffc7dda79320e551f6437327a5625e88d65
change-id: 20261001-fix_aio_suspend-1-1-2b05a5fddd53

Best regards,
--  
Andrea Cervesato <andrea.cervesato@suse.com>


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

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

* Re: [LTP] [PATCH] openposix: Fix aio_suspend/1-1 completion race
  2026-10-01 11:00 [LTP] [PATCH] openposix: Fix aio_suspend/1-1 completion race Andrea Cervesato
@ 2026-10-01 12:01 ` Martin Doucha
  2026-10-01 12:30   ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Doucha @ 2026-10-01 12:01 UTC (permalink / raw)
  To: Andrea Cervesato, Linux Test Project

Hi,
removing the check defeats the purpose of the test. The proper fix is to 
block on a full socket instead, but aio_suspend() tests will also need a 
second thread that'll drain the socket while the main thread is suspended.

On 10/1/26 13:00, Andrea Cervesato wrote:
> From: Andrea Cervesato <andrea.cervesato@suse.com>
> 
> The selected read may finish before the test calls aio_suspend().
> Treating this as an unresolved result makes the test depend on I/O
> speed and scheduling.
> 
> POSIX permits aio_suspend() to return immediately for a completed
> request. Drop the racy precondition and retain the completion checks.
> 
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> Two aio_suspend tests assume that queued I/O cannot complete before
> the test checks its status. Depending on I/O speed and scheduling,
> this can produce an unresolved result or a false test failure.
> 
> In 1-1, early completion is valid: aio_suspend() must return
> immediately when a listed request has already completed. Remove the
> check that rejects this case.
> ---
>   .../conformance/interfaces/aio_suspend/1-1.c             | 16 +---------------
>   1 file changed, 1 insertion(+), 15 deletions(-)
> 
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c
> index 8f0c9ae95..2de7c87d2 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/1-1.c
> @@ -25,7 +25,6 @@
>    *
>    *	- write to a file
>    *	- submit a list of read requests
> - *	- check that the selected request has not completed
>    *	- suspend on selected request
>    *	- check that the selected request has completed using aio_error and
>    *	  aio_return
> @@ -146,20 +145,7 @@ int test_main(int argc PTS_ATTRIBUTE_UNUSED, char **argv PTS_ATTRIBUTE_UNUSED)
>   		exit(PTS_UNRESOLVED);
>   	}
>   
> -	/* Check selected request has not completed yet */
> -	err = aio_error(aiocbs[WAIT_FOR_AIOCB]);
> -	if (!err) {
> -		printf(TNAME " Error : AIOCB %d already completed before "
> -		       "suspend\n", WAIT_FOR_AIOCB);
> -		for (i = 0; i < NUM_AIOCBS; i++)
> -			free(aiocbs[i]);
> -		free(bufs);
> -		free(aiocbs);
> -		close(fd);
> -		exit(PTS_UNRESOLVED);
> -	}
> -
> -	/* Suspend on selected request */
> +	/* The selected request may have already completed, which is valid. */
>   	ret = aio_suspend((const struct aiocb **)plist, 2, NULL);
>   	if (ret) {
>   		printf(TNAME " Error at aio_suspend() %d: %s\n",
> 
> ---
> base-commit: 65c0cffc7dda79320e551f6437327a5625e88d65
> change-id: 20261001-fix_aio_suspend-1-1-2b05a5fddd53
> 
> Best regards,
> --
> Andrea Cervesato <andrea.cervesato@suse.com>
> 
> 


-- 
Martin Doucha   mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic

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

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

* Re: [LTP] [PATCH] openposix: Fix aio_suspend/1-1 completion race
  2026-10-01 12:01 ` Martin Doucha
@ 2026-10-01 12:30   ` Petr Vorel
  0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2026-10-01 12:30 UTC (permalink / raw)
  To: Martin Doucha; +Cc: Linux Test Project

Hi Martin, Andrea,

> Hi,
> removing the check defeats the purpose of the test. The proper fix is to
> block on a full socket instead, but aio_suspend() tests will also need a
> second thread that'll drain the socket while the main thread is suspended.

Martin, thanks to double check this, I also worried it would not be that simple.

And I hoped similar approach you already used for fixing aio_cancel() could be
reused. Thanks for describing a possible solution.

Kind regards,
Petr

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

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

end of thread, other threads:[~2026-10-01 12:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-01 11:00 [LTP] [PATCH] openposix: Fix aio_suspend/1-1 completion race Andrea Cervesato
2026-10-01 12:01 ` Martin Doucha
2026-10-01 12:30   ` Petr Vorel

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