All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/3] posix: aio_cancel: 3-1, 4-1: prepare aiocb structures in advance
Date: Tue, 12 Dec 2017 14:52:26 +0300	[thread overview]
Message-ID: <1513079548-23022-1-git-send-email-stanislav.kholmanskikh@oracle.com> (raw)

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


             reply	other threads:[~2017-12-12 11:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-12 11:52 Stanislav Kholmanskikh [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1513079548-23022-1-git-send-email-stanislav.kholmanskikh@oracle.com \
    --to=stanislav.kholmanskikh@oracle.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.