diff options
author | jhb <jhb@FreeBSD.org> | 2016-06-21 22:19:06 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2016-06-21 22:19:06 +0000 |
commit | a6270457f86ae61d2ff0ce1094ecd76432a0b6ce (patch) | |
tree | cff0cb0c98a02e42cb35bd9cc1f5818836d49b99 /tests/sys | |
parent | 8f9b4b00a24e0b5d13a25df826e4e2c20e0d2ced (diff) | |
download | FreeBSD-src-a6270457f86ae61d2ff0ce1094ecd76432a0b6ce.zip FreeBSD-src-a6270457f86ae61d2ff0ce1094ecd76432a0b6ce.tar.gz |
Account for AIO socket operations in thread/process resource usage.
File and disk-backed I/O requests store counts of read/written disk
blocks in each AIO job so that they can be charged to the thread that
completes an AIO request via aio_return() or aio_waitcomplete(). This
change extends AIO jobs to store counts of received/sent messages and
updates socket backends to set these counts accordingly. Note that
the socket backends are careful to only charge a single messages for
each AIO request even though a single request on a blocking socket might
invoke sosend or soreceive multiple times. This is to mimic the
resource accounting of synchronous read/write.
Adjust the UNIX socketpair AIO test to verify that the message resource
usage counts update accordingly for aio_read and aio_write.
Approved by: re (hrs)
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D6911
Diffstat (limited to 'tests/sys')
-rw-r--r-- | tests/sys/aio/aio_test.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/sys/aio/aio_test.c b/tests/sys/aio/aio_test.c index 0a3e3ab..19c9e61 100644 --- a/tests/sys/aio/aio_test.c +++ b/tests/sys/aio/aio_test.c @@ -40,6 +40,7 @@ #include <sys/param.h> #include <sys/module.h> +#include <sys/resource.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/mdioctl.h> @@ -455,6 +456,7 @@ ATF_TC_BODY(aio_unix_socketpair_test, tc) { struct aio_unix_socketpair_arg arg; struct aio_context ac; + struct rusage ru_before, ru_after; int sockets[2]; ATF_REQUIRE_KERNEL_MODULE("aio"); @@ -467,8 +469,17 @@ ATF_TC_BODY(aio_unix_socketpair_test, tc) aio_context_init(&ac, sockets[0], sockets[1], UNIX_SOCKETPAIR_LEN, UNIX_SOCKETPAIR_TIMEOUT, aio_unix_socketpair_cleanup, &arg); + ATF_REQUIRE_MSG(getrusage(RUSAGE_SELF, &ru_before) != -1, + "getrusage failed: %s", strerror(errno)); aio_write_test(&ac); + ATF_REQUIRE_MSG(getrusage(RUSAGE_SELF, &ru_after) != -1, + "getrusage failed: %s", strerror(errno)); + ATF_REQUIRE(ru_after.ru_msgsnd == ru_before.ru_msgsnd + 1); + ru_before = ru_after; aio_read_test(&ac); + ATF_REQUIRE_MSG(getrusage(RUSAGE_SELF, &ru_after) != -1, + "getrusage failed: %s", strerror(errno)); + ATF_REQUIRE(ru_after.ru_msgrcv == ru_before.ru_msgrcv + 1); aio_unix_socketpair_cleanup(&arg); } |