Hi Greg, > The gadget code has always used AIO since the very beginning, this is > nothing new (decades old). While it might feel "odd", I recommend > working with it first before trying to create new kernel apis that > duplicate existing functionality for the only reason being that AIO is > "different". Forget my patch: You are right: I am now convinced, that using the AIO of the kernel should really provide the same. For me it was the other way round: I wrote code talking to "devio.c" on the USB Host and using "ioctl"; so that sounded natural to me. I think "devio.c" does not support async I/O ? So when starting, I was not aware at all that the gadget side supports AIO; and then I got misled by the POSIX aio interface (which did hide the native Linux aio system calls from me.) The "bug" I found is a bug in the example code (not in the kernel) as far as I can tell. The other thing I want in the future: > > > The final goal here is to be able to directly let user space > > > provide data buffers (via mmap I guess), which are then > > > transferred via USB; but this is the next step. > > > Isn't that kind of what the AIO inteface provides today? :) > > I think my explanation was not clear at all: > What I want to have is a "zero copy" transfer. I now think this can be implemented within the already existing AIO framework in f_fs.c by implementing a suitable mmap call. But before doing any of that I need test code. So my plan right now: - Write a working (fast) echo example using libaio - Write a working (fast) echo example using liburing (https://github.com/axboe/liburing) because this should result in even faster AIO. Another big reason for not doing extra ioctls; using the existing AIO framework in the kernel should allow to use liburing :) - Once I have done that I will look into extending f_fs.c with a mmap call so that complete zero copy transfers to/from USB bulk endpoints should become possible. Then I should be able to do some performance tests via USB 3.0 to see how much this helps. I will post again once I have some working code. Thank you for your time and comments; that really helps me to find a better solution :-) so long Ingo PS: Not important: > > https://pagure.io/libaio > > version 0.3.111 > > I do not know if this is the latest one or not, sorry. Ask your Linux > distro about this, or use the "raw" kernel aio syscalls. Thanks to gentoo, I found out there is https://releases.pagure.org/libaio/ and this one has the 0.3.112 release; and of course there is always the git repository (which unfortunately does not include tags for anything more recent than 0.3.110).