Saturday 1 February 2014

Mapping DMA buffers to userspace

Take a good look at the Infiniband drivers. They go to much effort to make zero-copy DMA and RDMA to user-space work.
I forgot to add this before saving:
Doing DMA directly to user-space memory mappings is full of problems, so unless you have very high performance requirements like Infiniband or 10 Gb Ethernet, don't do it. Instead, copy the DMA'd data into the userspace buffers. It will save you much grief.
For just one example, what if the user's program exits before the DMA is complete? What if the user memory is reallocated to another process after exit but the hardware is still set to DMA into that page? Disaster!

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More