In testing aio on a fast storage device, I found that the context lock takes up a fair amount of cpu time in the I/O submission path. The reason is that we take it for every I/O submitted (see __aio_get_req). Since we know how many I/Os are passed to io_submit, we can preallocate the kiocbs in batches, reducing the number of times we take and release the lock. In my testing, I was able to reduce the amount of time spent in _raw_spin_lock_irq by .56% (average of 3 runs). The command I used to test this was: aio-stress -O -o 2 -o 3 -r 8 -d 128 -b 32 -i 32 -s 16384 <dev> I also tested the patch with various numbers of events passed to io_submit, and I ran the xfstests aio group of tests to ensure I didn't break anything.
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -117,6 +117,7 @@ struct kiocb { · 116 unmodified lines | |||
| 117 | 117 | ||
| 118 | struct list_head ki_list; /* the aio core uses this | 118 | struct list_head ki_list; /* the aio core uses this |
| 119 | * for cancellation */ | 119 | * for cancellation */ |
| 120 | struct list_head ki_batch; /* batch allocation */ | ||
| 120 | 121 | ||
| 121 | /* | 122 | /* |
| 122 | * If the aio_resfd field of the userspace iocb is not zero, | 123 | * If the aio_resfd field of the userspace iocb is not zero, |