All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/3] posix: aio_cancel: 3-1, 4-1: prepare aiocb structures in advance
@ 2017-12-12 11:52 Stanislav Kholmanskikh
  2017-12-12 11:52 ` [LTP] [PATCH 2/3] posix: aio_cancel: 5-1, 6-1, 7-1: initialize aio_reqprio Stanislav Kholmanskikh
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Stanislav Kholmanskikh @ 2017-12-12 11:52 UTC (permalink / raw)
  To: ltp

The tests work this way. They sequentially issue a number of aio_write()
operations and then cancel them all. They expect that at least
one of the operations has not been completed when they issue
the cancel request. However, while preparing a request two
calls to malloc() are made, one of them is for a 1 MB block. This is
a relatively time-expensive operation, so on some systems it may (and does)
happen that all AIO writes are completed before aio_cancel() is called.

Preparing all aiocb structures in advance eliminates this problem.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../conformance/interfaces/aio_cancel/3-1.c        |    7 ++++++-
 .../conformance/interfaces/aio_cancel/4-1.c        |    2 ++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/3-1.c
index ccb85e5..ead3be1 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/3-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/3-1.c
@@ -65,6 +65,7 @@ int main(void)
 {
 	char tmpfname[256];
 	int fd;
+	struct aiocb *aiocb_list[BUF_NB];
 	struct aiocb *aiocb;
 	struct sigaction action;
 	int i;
@@ -121,7 +122,11 @@ int main(void)
 		aiocb->aio_sigevent.sigev_value.sival_ptr = aiocb;
 		aiocb->aio_reqprio = 0;
 
-		if (aio_write(aiocb) == -1) {
+		aiocb_list[i] = aiocb;
+	}
+
+	for (i = 0; i < BUF_NB; i++) {
+		if (aio_write(aiocb_list[i]) == -1) {
 			printf(TNAME " loop %d: Error@aio_write(): %s\n",
 			       i, strerror(errno));
 			return PTS_FAIL;
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/4-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/4-1.c
index 76a45a1..7304857 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/4-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_cancel/4-1.c
@@ -86,7 +86,9 @@ int main(void)
 		aiocb[i]->aio_nbytes = BUF_SIZE;
 		aiocb[i]->aio_offset = 0;
 		aiocb[i]->aio_sigevent.sigev_notify = SIGEV_NONE;
+	}
 
+	for (i = 0; i < BUF_NB; i++) {
 		if (aio_write(aiocb[i]) == -1) {
 			printf(TNAME " loop %d: Error@aio_write(): %s\n",
 			       i, strerror(errno));
-- 
1.7.1


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

end of thread, other threads:[~2017-12-14 11:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-12 11:52 [LTP] [PATCH 1/3] posix: aio_cancel: 3-1, 4-1: prepare aiocb structures in advance Stanislav Kholmanskikh
2017-12-12 11:52 ` [LTP] [PATCH 2/3] posix: aio_cancel: 5-1, 6-1, 7-1: initialize aio_reqprio Stanislav Kholmanskikh
2017-12-13 15:10   ` Cyril Hrubis
2017-12-12 11:52 ` [LTP] [PATCH 3/3] posix: aio_error: 2-1: " Stanislav Kholmanskikh
2017-12-13 15:10   ` Cyril Hrubis
2017-12-14 11:45     ` Stanislav Kholmanskikh
2017-12-13 15:06 ` [LTP] [PATCH 1/3] posix: aio_cancel: 3-1, 4-1: prepare aiocb structures in advance Cyril Hrubis
2017-12-14 11:58   ` Stanislav Kholmanskikh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.