0

Say, I have a huge file which I want to load into memory. Is it possible to use the DMA to quickly load the data from the file into the memory in Linux? If so, how?

5
  • What makes you think that all file reads aren't done via DMA? Do you mean you want to access HW directly rather than calling mmap or something along those lines? Commented Nov 26, 2014 at 17:46
  • Does fread also uses DMA for copying large data? Commented Nov 26, 2014 at 17:50
  • 1
    Hard drive controllers, such as the built in SATA interface on a motherboard use a bus mastering controller which supports scatter / gather in order to work with virtual paged memory. The virtual memory is "locked", and the physical pages and lengths are programmed into an array of "descriptors". For large I/O with a single command, the "descriptors" may get reprogrammed during the I/O. Commented Nov 26, 2014 at 17:59
  • Your code interacts with the kernel using syscalls(2). Use strace to find out which. So your question about fread using DMA does not have much sense: fread uses read(2) which is done by the kernel which might do DMA (inside the kernel). Commented Nov 26, 2014 at 18:08
  • See this question, which is almost a duplicate (but phrased differently) Commented Nov 26, 2014 at 18:10

1 Answer 1

4

If DMA is available then the driver is probably already using it. If you want high-speed direct access to a file then use mmap(2) instead of second-guessing the OS.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.