From a6270457f86ae61d2ff0ce1094ecd76432a0b6ce Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 21 Jun 2016 22:19:06 +0000 Subject: 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 --- tests/sys/aio/aio_test.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') 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 #include +#include #include #include #include @@ -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); } -- cgit v1.1