Subject: Asynchronous I/O
To: None <tech-kern@NetBSD.org>
From: Mindaugas R. <rmind@NetBSD.org>
List: tech-kern
Date: 04/25/2007 04:24:32
--Signature=_Wed__25_Apr_2007_04_24_32_+0300_akq/VTJn1Ndk80/r
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Hello,

As some of you already know, I have made a support for POSIX Asynchronous I/O.
Essentially, it is done, but there probably may be some optimizations,
improvements and, of course, more testing, testing and testing. I have run a
POSIX Test-Suite, and mostly (there are few details in POSIX strictness) it
looks OK. Some tests fails because we have not full support for signaling
mechanism (which is used in tests), and some because tests are buggy.

Shortly about the mechanism: each process may have an AIO-worker thread,
which is initialized only after the first AIO operation call, and destroyed
when process exits. All I/O operations are processed in this thread, queue of
the operations is also per-process. There are no queue of the completed
operations - state and values are stored in the internal kernel variables of
aiocb structure (this is allowed by POSIX) for the performance purposes.
As far as I know, similar behaviour is in the other systems.
Having per-process AIO structures may gain a better performance by the
differentiation of the operations. Please note, that thread is not a kernel
thread, but a user thread - in such case we are working with the same
vmspace. Also, it is not protected from user's actions. In future we should
protect it, but for now it could be leaved as is - currently, user could only
kill the thread (correct me, if I am wrong), which would cause AIO calls not
work in that concrete process, but all the rest should be fine.

However, I think it is time to commit this code into the -current, since it
works quite stable (at least I have tested), and it will not hurt anything
(it almost does not touch the existing code). If nobody objects, and no
serious problems will be found - I will probably do this in the beginning
of the next week.

[1] http://www.netbsd.org/~rmind/aio-2.tar.bz2
[2] http://www.netbsd.org/~rmind/vfs_aio.c

Emulation stubs and manual pages will be soon.
Hence, please review and comment.
Thanks for Andrew <ad> and others who helped with this code :)

--
Best regards,
Mindaugas
www.NetBSD.org

--Signature=_Wed__25_Apr_2007_04_24_32_+0300_akq/VTJn1Ndk80/r
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iQEVAwUBRi6t0FRvu6lvcna8AQJ6FAgAkd2YHcS5Rn9HZdRksudXPSVBTHh4o4w6
nWQ4m1eXFICcHPMZRgYULY1Kb6rcno0exwq/ck/Xeu03Q5fK9vjSTTbOt/NRpJly
ygJY1f+QSu2zaYMSLeH3r5lnhj6TIvxPoMp5hd/ZZhQugcabW6EJSuqCOlDOMDKG
1LHggjgCvXTdssKWCNiMaS6hx8a2Nd1ZiCQoDcua3oDfbIbIskHgH+nGDawplsnZ
Lgzg/ZM7tLLeaz5YpIcO3rNmVWKHzeA9AXylLV8oiLvHwQmeh57jLxnEozPNp0vD
vl171H8NlCme3dg8hX+YsZnsb9egkMbTmhUE6mcZKQaA80BfH/I/Mw==
=oQ2v
-----END PGP SIGNATURE-----

--Signature=_Wed__25_Apr_2007_04_24_32_+0300_akq/VTJn1Ndk80/r--