Hello I have a scenario where the only thing I should do is to output data and I must use DMA. Which one is the best option ifI only have to output data,write back or write through and why? Thank you!
Asked
Active
Viewed 930 times
0
-
1Best according to what criteria? Write-back has high performance for stores because it enables merging multiple writes to the same line. You only need to force a flush when you want non-coherent DMA to be able to read the data. WT doesn't help at all for a write-only workload. – Peter Cordes Jun 17 '18 at 20:22
-
If you writing to an output buffer, use memory mapped IO and mark the write as uncacheable. In that way you wouldnt need either, IMO. Any thoughts on this approach, @PeterCordes – Isuru H Jun 18 '18 at 09:09
-
1@IsuruH: UC without write combining sucks for writing a big buffer to an MMIO device directly (e.g. video RAM or a NIC). You'd get a small separate PCIe (or whatever external bus) transaction for every store, instead of one larger one for a whole cache line. This is why x86 systems map video RAM as WC (write-combining), not UC. And why NICs typically DMA packets from main memory instead of having drivers store directly into a buffer on the NIC. I'm assuming that "best" = highest performance, not simplest to implement, but in real life there are tradeoffs. You'd need a `clflush` insn... – Peter Cordes Jun 18 '18 at 11:29
-
I would have thought that write-back was the fastest, first you write the data to cache (preferable with some instruction saying the cache line is not to be read from memory as we are going to overwrite it) and then when the DMA starts it can get the data faster from L3 cache than from main memory, especially if you have a NUMA system. – Surt Jun 19 '18 at 20:16