Sam
Sam

Reputation: 873

how memcpy is handled by DMA in linux

I am using memcpy() in my program. as I increase the number of variables, unfortunately the CPU usage increases. it is as if memcpy is run by using for loop iteration. is there a fast memcpy function in linux too? shall I use a patch and compile the kernel?

Upvotes: 3

Views: 4984

Answers (1)

CL.
CL.

Reputation: 180070

There are architectures where the bus between the CPU and memory is rather weak; some of those architectures add a DMA engine to allow big blocks of memory to be copied without having a loop running on the CPU.

In Linux, you would be able to access the DMA engine with the dmaengine subsystem, but it is very hardware-dependent whether such an engine is actually available.

X86 CPUs have a good memory subsystem, and also have special hardware support for copying large blocks, so using a DMA engine would be very unlikely to actually help. (Intel added a DMA engine called I/OAT to some server boards, but the overall results were not much better than plain CPU copies.)

DMA forces the data out of the CPU caches, so doing DMA copies for your program's variables would be utterly pointless because the first CPU access afterwards would have to read them back into the cache.

Upvotes: 6

Related Questions