Closed dogtopus closed 3 years ago
Is what I said actually true?
Yes, this is consistent with my understanding.
Do I need to use mmap to allocate buffers for use with
EndpointINFile.submit()
(and the return value ofonComplete()
) to get best compatibility?
Yes, for lack of (...at least to my knowledge) any other way in python to get memory-aligned buffers (page-aligned in the case of mmap, and I expect that no UDC would have alignment constraints stricter than a page). This is the other edge of the zero-copy sword: nothing in the code path will more any byte from the handed-down buffer, so they have to be in the correct spot from the beginning. So obscure constraints originating in the silicon become apparent to userland.
Maybe not all UDC have this constraint, and maybe the alignment can be enforced before handing the buffer over to the UDC, but then performance is worse than if no alignment fix was needed.
Thanks for clarifying this.
Maybe not all UDC have this constraint, and maybe the alignment can be enforced before handing the buffer over to the UDC, but then performance is worse than if no alignment fix was needed.
The test devices I use (PC with dummy_hcd
and Pinephone which is powered by Allwinner A64) don't require aligned buffer. However that's just 1 real device so idk about the big picture.
In python-libaio docs, there's the note:
And I'm pretty sure there is at least one mention about
EndpointINFile.submit()
being "zero-copying", which implies that the kernel directly ingests the buffer provided by thesubmit()
call (via libaio) and push it to the UDC driver.Since there are little information about this, here's the question: Is what I said actually true? Do I need to use mmap to allocate buffers for use with
EndpointINFile.submit()
(and the return value ofonComplete()
) to get best compatibility?