From owner-svn-src-stable-11@freebsd.org Fri Dec 8 05:20:56 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 381ADE9A95B; Fri, 8 Dec 2017 05:20:56 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 129086447B; Fri, 8 Dec 2017 05:20:56 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vB85KtGY028842; Fri, 8 Dec 2017 05:20:55 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vB85KtaT028840; Fri, 8 Dec 2017 05:20:55 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201712080520.vB85KtaT028840@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 8 Dec 2017 05:20:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r326677 - stable/11/tests/sys/aio X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: stable/11/tests/sys/aio X-SVN-Commit-Revision: 326677 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Dec 2017 05:20:56 -0000 Author: asomers Date: Fri Dec 8 05:20:54 2017 New Revision: 326677 URL: https://svnweb.freebsd.org/changeset/base/326677 Log: 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 Modified: stable/11/tests/sys/aio/aio_kqueue_test.c stable/11/tests/sys/aio/lio_kqueue_test.c Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/aio/aio_kqueue_test.c ============================================================================== --- stable/11/tests/sys/aio/aio_kqueue_test.c Fri Dec 8 04:21:31 2017 (r326676) +++ stable/11/tests/sys/aio/aio_kqueue_test.c Fri Dec 8 05:20:54 2017 (r326677) @@ -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: stable/11/tests/sys/aio/lio_kqueue_test.c ============================================================================== --- stable/11/tests/sys/aio/lio_kqueue_test.c Fri Dec 8 04:21:31 2017 (r326676) +++ stable/11/tests/sys/aio/lio_kqueue_test.c Fri Dec 8 05:20:54 2017 (r326677) @@ -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/) - * 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/) */ #include @@ -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;