summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorasomers <asomers@FreeBSD.org>2017-12-08 05:20:54 +0000
committerasomers <asomers@FreeBSD.org>2017-12-08 05:20:54 +0000
commitb424ac9a7cc85628f05bfd6af13c9501f369fe78 (patch)
tree94b37ce91c5cf3e47f404acd381c7a2ba12ebad1 /tests
parenteb19f9fe36ddd52ab1e99457e42beb42a14aa490 (diff)
downloadFreeBSD-src-b424ac9a7cc85628f05bfd6af13c9501f369fe78.zip
FreeBSD-src-b424ac9a7cc85628f05bfd6af13c9501f369fe78.tar.gz
MFC r325817, r325827
r325817: AIO tests: increase limits tests/sys/aio/aio_kqueue_test.c Instead of using a hard-coded queue depth, use vfs.aio.max_aio_queue_per_proc tests/sys/aio/lio_kqueue_test.c The old, small limit on lio_listio's operation count was lifted by change 324941. Raise the operation count as high as possible without exceeding the process's operation limit. Sponsored by: Spectra Logic Corp r325827: Fix build on arm after r325817 Reported by: rpokala X-MFC-With: 325817 Sponsored by: Spectra Logic Corp
Diffstat (limited to 'tests')
-rw-r--r--tests/sys/aio/aio_kqueue_test.c27
-rw-r--r--tests/sys/aio/lio_kqueue_test.c47
2 files changed, 43 insertions, 31 deletions
diff --git a/tests/sys/aio/aio_kqueue_test.c b/tests/sys/aio/aio_kqueue_test.c
index 1e98d78..95f49a4 100644
--- a/tests/sys/aio/aio_kqueue_test.c
+++ b/tests/sys/aio/aio_kqueue_test.c
@@ -51,28 +51,37 @@
#define PATH_TEMPLATE "aio.XXXXXXXXXX"
-#define MAX_IOCBS 128
#define MAX_RUNS 300
/* #define DEBUG */
int
main (int argc, char *argv[])
{
- struct aiocb *iocb[MAX_IOCBS], *kq_iocb;
+ struct aiocb **iocb, *kq_iocb;
char *file, pathname[sizeof(PATH_TEMPLATE)+1];
struct kevent ke, kq_returned;
struct timespec ts;
char buffer[32768];
+ int max_queue_per_proc;
+ size_t max_queue_per_proc_size;
#ifdef DEBUG
int cancel, error;
#endif
int failed = 0, fd, kq, pending, result, run;
int tmp_file = 0;
- unsigned i, j;
+ int i, j;
PLAIN_REQUIRE_KERNEL_MODULE("aio", 0);
PLAIN_REQUIRE_UNSAFE_AIO(0);
+ max_queue_per_proc_size = sizeof(max_queue_per_proc);
+ if (sysctlbyname("vfs.aio.max_aio_queue_per_proc",
+ &max_queue_per_proc, &max_queue_per_proc_size, NULL, 0) != 0)
+ err(1, "sysctlbyname");
+ iocb = calloc(max_queue_per_proc, sizeof(struct aiocb*));
+ if (iocb == NULL)
+ err(1, "calloc");
+
kq = kqueue();
if (kq < 0) {
perror("No kqeueue\n");
@@ -95,7 +104,7 @@ main (int argc, char *argv[])
#ifdef DEBUG
printf("Run %d\n", run);
#endif
- for (i = 0; i < nitems(iocb); i++) {
+ for (i = 0; i < max_queue_per_proc; i++) {
iocb[i] = (struct aiocb *)calloc(1,
sizeof(struct aiocb));
if (iocb[i] == NULL)
@@ -103,7 +112,7 @@ main (int argc, char *argv[])
}
pending = 0;
- for (i = 0; i < nitems(iocb); i++) {
+ for (i = 0; i < max_queue_per_proc; i++) {
pending++;
iocb[i]->aio_nbytes = sizeof(buffer);
iocb[i]->aio_buf = buffer;
@@ -139,7 +148,7 @@ main (int argc, char *argv[])
}
}
#ifdef DEBUG
- cancel = nitems(iocb) - pending;
+ cancel = max_queue_per_proc - pending;
#endif
i = 0;
@@ -173,11 +182,11 @@ main (int argc, char *argv[])
break;
#ifdef DEBUG
printf("Try again left %d out of %lu %d\n",
- pending, nitems(iocb), cancel);
+ pending, max_queue_per_proc, cancel);
#endif
}
- for (j = 0; j < nitems(iocb) && iocb[j] != kq_iocb;
+ for (j = 0; j < max_queue_per_proc && iocb[j] != kq_iocb;
j++) ;
#ifdef DEBUG
printf("kq_iocb %p\n", kq_iocb);
@@ -204,7 +213,7 @@ main (int argc, char *argv[])
i++;
}
- for (i = 0; i < nitems(iocb); i++)
+ for (i = 0; i < max_queue_per_proc; i++)
free(iocb[i]);
}
diff --git a/tests/sys/aio/lio_kqueue_test.c b/tests/sys/aio/lio_kqueue_test.c
index fdbe72a..3226573 100644
--- a/tests/sys/aio/lio_kqueue_test.c
+++ b/tests/sys/aio/lio_kqueue_test.c
@@ -27,14 +27,7 @@
/*
* Note: it is a good idea to run this against a physical drive to
- * exercise the physio fast path (ie. lio_kqueue /dev/<something safe>)
- * This will ensure op's counting is correct. It is currently broken.
- *
- * Also note that LIO & kqueue is not implemented in FreeBSD yet, LIO
- * is also broken with respect to op's and some paths.
- *
- * A patch to make this work is at:
- * http://www.ambrisko.com/doug/listio_kqueue/listio_kqueue.patch
+ * exercise the physio fast path (ie. lio_kqueue_test /dev/<something safe>)
*/
#include <sys/types.h>
@@ -55,8 +48,8 @@
#define PATH_TEMPLATE "aio.XXXXXXXXXX"
#define LIO_MAX 5
-#define IOCBS_PER_LIO 16
-#define MAX_IOCBS (LIO_MAX * IOCBS_PER_LIO)
+#define MAX_IOCBS_PER_LIO 64
+#define MAX_IOCBS (LIO_MAX * MAX_IOCBS_PER_LIO)
#define MAX_RUNS 300
int
@@ -65,7 +58,9 @@ main(int argc, char *argv[])
int fd;
struct aiocb *iocb[MAX_IOCBS];
struct aiocb **lio[LIO_MAX], **kq_lio;
- int i, result, run, error, j, k;
+ int i, result, run, error, j, k, max_queue_per_proc;
+ int max_iocbs, iocbs_per_lio;
+ size_t max_queue_per_proc_size;
char buffer[32768];
int kq;
struct kevent ke, kq_returned;
@@ -78,6 +73,13 @@ main(int argc, char *argv[])
PLAIN_REQUIRE_KERNEL_MODULE("aio", 0);
PLAIN_REQUIRE_UNSAFE_AIO(0);
+ max_queue_per_proc_size = sizeof(max_queue_per_proc);
+ if (sysctlbyname("vfs.aio.max_aio_queue_per_proc",
+ &max_queue_per_proc, &max_queue_per_proc_size, NULL, 0) != 0)
+ err(1, "sysctlbyname");
+ iocbs_per_lio = max_queue_per_proc / LIO_MAX;
+ max_iocbs = LIO_MAX * iocbs_per_lio;
+
kq = kqueue();
if (kq < 0)
err(1, "kqeueue(2) failed");
@@ -104,9 +106,9 @@ main(int argc, char *argv[])
#endif
for (j = 0; j < LIO_MAX; j++) {
lio[j] =
- malloc(sizeof(struct aiocb *) * IOCBS_PER_LIO);
- for (i = 0; i < IOCBS_PER_LIO; i++) {
- k = (IOCBS_PER_LIO * j) + i;
+ malloc(sizeof(struct aiocb *) * iocbs_per_lio);
+ for (i = 0; i < iocbs_per_lio; i++) {
+ k = (iocbs_per_lio * j) + i;
lio[j][i] = iocb[k] =
calloc(1, sizeof(struct aiocb));
iocb[k]->aio_nbytes = sizeof(buffer);
@@ -116,8 +118,8 @@ main(int argc, char *argv[])
= iocb[k]->aio_nbytes * k * (run + 1);
#ifdef DEBUG
- printf("hello iocb[k] %ld\n",
- iocb[k]->aio_offset);
+ printf("hello iocb[k] %jd\n",
+ (intmax_t)iocb[k]->aio_offset);
#endif
iocb[k]->aio_lio_opcode = LIO_WRITE;
}
@@ -126,12 +128,13 @@ main(int argc, char *argv[])
sig.sigev_notify = SIGEV_KEVENT;
time(&time1);
result = lio_listio(LIO_NOWAIT, lio[j],
- IOCBS_PER_LIO, &sig);
+ iocbs_per_lio, &sig);
error = errno;
time(&time2);
#ifdef DEBUG
- printf("Time %ld %ld %ld result -> %d\n",
- time1, time2, time2-time1, result);
+ printf("Time %jd %jd %jd result -> %d\n",
+ (intmax_t)time1, (intmax_t)time2,
+ (intmax_t)time2-time1, result);
#endif
if (result != 0) {
errno = error;
@@ -202,10 +205,10 @@ main(int argc, char *argv[])
failed++;
} else
printf("PASS: run %d, operation %d result %d \n", run, LIO_MAX - i -1, result);
- for (k = 0; k < MAX_IOCBS / LIO_MAX; k++) {
+ for (k = 0; k < max_iocbs / LIO_MAX; k++) {
result = aio_return(kq_lio[k]);
#ifdef DEBUG
- printf("Return Resulto for %d %d is %d\n", j, k, result);
+ printf("Return Result for %d %d is %d\n", j, k, result);
#endif
if (result != sizeof(buffer)) {
printf("FAIL: run %d, operation %d sub-opt %d result %d (errno=%d) should be %zu\n",
@@ -219,7 +222,7 @@ main(int argc, char *argv[])
printf("\n");
#endif
- for (k = 0; k < MAX_IOCBS / LIO_MAX; k++)
+ for (k = 0; k < max_iocbs / LIO_MAX; k++)
free(lio[j][k]);
free(lio[j]);
lio[j] = NULL;
OpenPOWER on IntegriCloud