20111210 linux aio

840 views
737 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
840
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

20111210 linux aio

  1. 1. Linux AIO [email_address]
  2. 2. Agenda <ul><li>IO Models </li></ul><ul><li>POSIX AIO </li></ul><ul><li>Linux Native AIO </li></ul>
  3. 3. IO Models
  4. 4. Sync Blocking IO
  5. 5. Sync Non-blocking IO
  6. 6. Async Blocking IO
  7. 7. Async Non-blocking IO
  8. 8. POSIX AIO <ul><li>glibc implementation </li></ul><ul><li>Built on top of pthread </li></ul><ul><li>All user space </li></ul>
  9. 9. POSIX AIO <ul><li>man 3 aio </li></ul><ul><li>aio_init(3), aio_cancel(3), aio_cancel64(3), aio_error(3), aio_error64(3), aio_fsync(3), aio_fsync64(3), aio_init(3), aio_read(3), aio_read64(3), aio_return(3), aio_return64(3), aio_suspend(3), aio_suspend64(3), aio_write(3), aio_write64(3) </li></ul>
  10. 10. POSIX AIO <ul><li>__aio_enqueue_request </li></ul><ul><ul><li>if (nthreads < optim.aio_threads && idle_thread_count == 0) </li></ul></ul><ul><ul><li>aio_create_helper_thread (&thid, handle_fildes_io, newp) </li></ul></ul><ul><li>Queued operations: </li></ul><ul><ul><li>LIO_READ,LIO_WRITE,LIO_NOP </li></ul></ul><ul><ul><li>LIO_DSYNC, LIO_SYNC, LIO_READ64,LIO_WRITE64 </li></ul></ul>
  11. 11. POSIX AIO <ul><li>handle_fildes_io </li></ul><ul><ul><li>pread/read </li></ul></ul><ul><ul><li>pwrite/write </li></ul></ul><ul><ul><li>fdatasync/fsync </li></ul></ul>
  12. 12. POSIX AIO <ul><li>Example... </li></ul>
  13. 13. Linux Native AIO <ul><li>Kernel space implementation </li></ul><ul><ul><li>Use workqueue to handle deferred left-overs </li></ul></ul><ul><li>Libaio wrappers </li></ul>
  14. 14. Linux Native AIO <ul><li>Only support AIO-DIO </li></ul><ul><li>No AIO fsync/fdatasync </li></ul><ul><li>Not on sockets/pipes </li></ul>
  15. 15. Supported Operations <ul><li>IO_CMD_PREAD, IO_CMD_PWRITE </li></ul><ul><li>IO_CMD_FSYNC, IO_CMD_FDSYNC </li></ul><ul><li>IO_CMD_POLL, IO_CMD_NOOP </li></ul><ul><li>IO_CMD_PREADV, IO_CMD_PWRITEV </li></ul>
  16. 16. Syscall APIs <ul><li>int io_setup(int maxevents, io_context_t *ctxp); </li></ul><ul><li>int io_destroy(io_context_t ctx); </li></ul><ul><li>int io_submit(io_context_t ctx, long nr, struct iocb *ios[]); </li></ul><ul><li>int io_cancel(io_context_t ctx, struct iocb *iocb, struct io_event *evt); </li></ul><ul><li>int io_getevents(io_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout); </li></ul>
  17. 17. Libaio wrappers <ul><li>int io_queue_init(int maxevents, io_context_t *ctxp); </li></ul><ul><li>int io_queue_release(io_context_t ctx); </li></ul><ul><li>int io_queue_run(io_context_t ctx); </li></ul><ul><li>io_prep_pread, io_prep_pwrite, io_set_callback </li></ul>
  18. 18. Kernel Implementation <ul><li>io_submit() </li></ul><ul><ul><li>aio_setup_iocb() </li></ul></ul><ul><ul><li>aio_run_iocb() </li></ul></ul><ul><li>kiocb->ki_retry callback </li></ul><ul><li>aio_complete() </li></ul><ul><li>static struct workqueue_struct *aio_wq; </li></ul>
  19. 19. Native AIO <ul><li>Example... </li></ul>
  20. 20. Q & A?

×