Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Direct Memory Access

I have this basic doubt about DMA. When the CPU has relinquished the bus for DMA to carry on with data fetching/ storing, how does it continue processing?

I mean even the CPU's got to get it instructions, store back results to the memory/IOs through the bus, does it not?

like image 753
Agent007 Avatar asked Feb 15 '26 07:02

Agent007


1 Answers

CPUs have cache, so they can do a lot without any actual main-memory accesses. Even low-power systems tend to have caches, because driving signals off-chip costs enough energy that a cache pays for itself in energy saved by cache hits.

More importantly, DMA doesn't "take over" the RAM, or even necessarily saturate memory bandwidth. The CPU doesn't "relinquish the bus"; the memory controller accepts read/write requests from the CPU core(s) and other system devices. Running a memory-heavy task on the CPU will slow down delay DMA, as well as the other way around, as the memory controller or system agent arbitrates access to memory, queuing read and write requests from all sources.

DMA is great for transfers that are still much slower than memory bandwidth. For example SATAIII is 6 Gbits/s, while main memory bandwidth for dual-channel DDR3-1600MHz is about 25 GBytes/s. So programmed-io would spend most of its time waiting for data from the SATA controller, not even bottlenecked on storing to RAM.


An example of how the pieces fit together in a modern Intel x86 CPU: this diagram of Intel Skylake's system architecture (including eDRAM as memory-side cache). Sorry I didn't find a simpler diagram showing just the cores and system agent, but in a system without eDRAM, the only thing to the right of the system agent is the memory controller, and everything else stays the same.

The memory controller is on-die, so the only off-chip connection in this diagram is the PCIe bus, and the DDR4 bus between memory controller (MC) and DRAM.

Skylake system agent diagram, from IDF via ARStechnica

like image 55
Peter Cordes Avatar answered Feb 19 '26 09:02

Peter Cordes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!