Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Linux AIO [email_address]
Agenda <ul><li>IO Models </li></ul><ul><li>POSIX AIO </li></ul><ul><li>Linux Native AIO </li></ul>
IO Models
Sync Blocking IO
Sync Non-blocking IO
Async Blocking IO
Async Non-blocking IO
POSIX AIO <ul><li>glibc implementation </li></ul><ul><li>Built on top of pthread </li></ul><ul><li>All user space </li></ul>
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), ...
POSIX AIO <ul><li>__aio_enqueue_request </li></ul><ul><ul><li>if (nthreads < optim.aio_threads && idle_thread_count == 0) ...
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...
POSIX AIO <ul><li>Example... </li></ul>
Linux Native AIO <ul><li>Kernel space implementation </li></ul><ul><ul><li>Use workqueue to handle deferred left-overs </l...
Linux Native AIO <ul><li>Only support AIO-DIO </li></ul><ul><li>No AIO fsync/fdatasync </li></ul><ul><li>Not on sockets/pi...
Supported Operations <ul><li>IO_CMD_PREAD, IO_CMD_PWRITE </li></ul><ul><li>IO_CMD_FSYNC, IO_CMD_FDSYNC </li></ul><ul><li>I...
Syscall APIs <ul><li>int io_setup(int maxevents, io_context_t *ctxp); </li></ul><ul><li>int io_destroy(io_context_t ctx); ...
Libaio wrappers <ul><li>int io_queue_init(int maxevents, io_context_t *ctxp);  </li></ul><ul><li>int io_queue_release(io_c...
Kernel Implementation <ul><li>io_submit() </li></ul><ul><ul><li>aio_setup_iocb() </li></ul></ul><ul><ul><li>aio_run_iocb()...
Native AIO <ul><li>Example... </li></ul>
Q & A?
Upcoming SlideShare
Loading in …5
×

Linux aio

3,082 views

Published on

Published in: Technology
  • Be the first to comment

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?

×