svn commit: r325817 - head/tests/sys/aio
Alan Somers
asomers at FreeBSD.org
Tue Nov 14 17:46:39 UTC 2017
Author: asomers
Date: Tue Nov 14 17:46:37 2017
New Revision: 325817
URL: https://svnweb.freebsd.org/changeset/base/325817
Log:
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.
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp
Modified:
head/tests/sys/aio/aio_kqueue_test.c
head/tests/sys/aio/lio_kqueue_test.c
Modified: head/tests/sys/aio/aio_kqueue_test.c
==============================================================================
--- head/tests/sys/aio/aio_kqueue_test.c Tue Nov 14 17:16:03 2017 (r325816)
+++ head/tests/sys/aio/aio_kqueue_test.c Tue Nov 14 17:46:37 2017 (r325817)
@@ -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]);
}
Modified: head/tests/sys/aio/lio_kqueue_test.c
==============================================================================
--- head/tests/sys/aio/lio_kqueue_test.c Tue Nov 14 17:16:03 2017 (r325816)
+++ head/tests/sys/aio/lio_kqueue_test.c Tue Nov 14 17:46:37 2017 (r325817)
@@ -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>
@@ -54,9 +47,10 @@
#define PATH_TEMPLATE "aio.XXXXXXXXXX"
+#define DEBUG
#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 +59,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 +74,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 +107,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);
@@ -126,7 +129,7 @@ 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
@@ -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;
More information about the svn-src-all
mailing list