summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2014-12-24 18:33:56 -0800
committerKent Overstreet <kmo@daterainc.com>2014-12-24 18:33:56 -0800
commite0d16e2cf86efb49238184b7717f03e1a9616016 (patch)
tree6cd4a75f5b605108ac566f6964e3574a39455154
parent8be19c34eae6d024d4ec8f99b5bff5b208c9cc9c (diff)
update aio test
Change-Id: Id01f8ec16e69615c8056383ea7bd099a67355f8e
-rwxr-xr-xtests/aio/aio39
-rw-r--r--tests/aio/aio-multithread-test.c32
-rw-r--r--tests/aio/aio-multithread-test.mak2
3 files changed, 36 insertions, 37 deletions
diff --git a/tests/aio/aio b/tests/aio/aio
index 1fe21f3..a05cb55 100755
--- a/tests/aio/aio
+++ b/tests/aio/aio
@@ -1,32 +1,21 @@
#!/bin/bash
-if [ "$1" = "deps" ]; then
- echo "REQUIRE=../test-libs.sh,aio-multithread-test"
- echo "MEM=256M"
- echo "SCRATCH=2G"
- exit
-fi
+require-lib ../prelude.sh
-echo "func free_ioctx +p" > /sys/kernel/debug/dynamic_debug/control
-echo "func ioctx_alloc +p" > /sys/kernel/debug/dynamic_debug/control
-echo "func sys_io_setup +p" > /sys/kernel/debug/dynamic_debug/control
+config-timeout 60
+config-mem 512M
+config-scratch-devs 1G
-echo "file percpu-refcount.c +p" > /sys/kernel/debug/dynamic_debug/control
+require-make aio-multithread-test.mak aio-multithread-test
-. test-libs.sh
+main()
+{
+ DEV=sdb
-DEV="vdb"
+ #echo "file aio.c +p" > /sys/kernel/debug/dynamic_debug/control
+ #echo "func do_io_submit +p" > /sys/kernel/debug/dynamic_debug/control
+ #echo "func io_submit_one +p" > /sys/kernel/debug/dynamic_debug/control
+ #echo "func aio_run_iocb +p" > /sys/kernel/debug/dynamic_debug/control
-while true; do
- /cdrom/aio-multithread-test /dev/vdb -1 &
- pid=$!
-
- sleep 2
- kill -9 $pid
-done
-
-#test_fio $DEV
-#exit
-
-#prep_mkfs
-#prep_mounts
+ /cdrom/aio-multithread-test /dev/$DEV
+}
diff --git a/tests/aio/aio-multithread-test.c b/tests/aio/aio-multithread-test.c
index 1a41b2c..6c8ee28 100644
--- a/tests/aio/aio-multithread-test.c
+++ b/tests/aio/aio-multithread-test.c
@@ -16,9 +16,11 @@
#include <libaio.h>
#include <pthread.h>
+#define NR_WORKERS 4
+
uint64_t nr_blocks = 1024 * 1024 * 4;
-int fd;
io_context_t ioctx;
+int fd, exiting;
uint64_t getblocks(int fd)
{
@@ -42,7 +44,7 @@ static void *iothread(void *p)
char __attribute__((aligned(4096))) buf[4096];
unsigned seed = 0;
- while (1) {
+ while (!exiting) {
struct iocb iocb[64];
struct iocb *iocbp[64];
unsigned i;
@@ -64,9 +66,10 @@ static void *iothread(void *p)
}
ret = io_submit(ioctx, 64, iocbp);
- if (ret < 0 && ret != -EAGAIN)
+ if (ret < 0 && ret != -EAGAIN) {
printf("io_submit() error %i\n", ret);
-
+ exit(EXIT_FAILURE);
+ }
}
return NULL;
@@ -74,21 +77,21 @@ static void *iothread(void *p)
int main(int argc, char **argv)
{
- pthread_t threads[4];
+ pthread_t threads[NR_WORKERS];
unsigned i;
+ int flags = 0;
- memset(threads, 0, sizeof(pthread_t) * 4);
+ memset(threads, 0, sizeof(threads));
-#if 0
if (argc != 2) {
printf("Specify a file/device to test against\n");
exit(EXIT_FAILURE);
}
- fd = open(argv[1], O_RDONLY|O_DIRECT);
-#else
- fd = open("/dev/zero", O_RDONLY);
-#endif
+ if (strcmp(argv[1], "/dev/zero"))
+ flags = O_DIRECT;
+
+ fd = open(argv[1], O_RDONLY|flags);
if (fd < 0) {
perror("Open error");
exit(EXIT_FAILURE);
@@ -101,7 +104,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
- for (i = 0; i < 8; i++)
+ for (i = 0; i < NR_WORKERS; i++)
if (pthread_create(&threads[i], NULL, iothread, NULL)) {
printf("pthread_create() error\n");
exit(EXIT_FAILURE);
@@ -124,6 +127,11 @@ int main(int argc, char **argv)
}
printf("exiting\n");
+ exiting = 1;
+
+ for (i = 0; i < NR_WORKERS; i++)
+ pthread_join(threads[i], NULL);
+
io_destroy(ioctx);
printf("io_destroy done\n");
diff --git a/tests/aio/aio-multithread-test.mak b/tests/aio/aio-multithread-test.mak
new file mode 100644
index 0000000..6648328
--- /dev/null
+++ b/tests/aio/aio-multithread-test.mak
@@ -0,0 +1,2 @@
+aio-multithread-test: aio-multithread-test.c
+ cc -static -Wall -o aio-multithread-test aio-multithread-test.c -laio -lpthread