> The ideal scenario is to never copy data and it is achievable, to a
degree, through proper planning.
I have to strongly disagree with that.
You have to realize what a /driver/ is. And why it is needed:
A driver takes whatever ressources a piece of hardware offers and makes
these ressources usable to actual
application software. Thus: A driver is /necessary/ to convert and transfer
data from "the wire" to something
a program can access without having to know how this particular piece of
hardware works.
This conversion _has_ to happen using the CPU power of the host. Therefore,
you either have to let the driver
do its work on all copies of the device data in RAM, or you just do it
once, and then copy the data using the CPU.
Which is way more intelligent, flexible, well-performing... and what is
done in current architectures.

>   If you look at your argument, you are essentially saying that it is
better to copy than to have a pointer.
In many cases it is.
Example?
You have an arbitrary computer architecture with external memory (this is
desirable unless you want to be
limited to microcontrollers):
RAM---memory bus---cpu

Gigabytes of RAM aren't easy to produce cheaply, and are even harder to
access with low latency.
Therefore, modern CPUs have caches:

RAM --- memory bus --- Cache --- CPU

Those caches are designed to be fast, but are of limited size (for reasons
aforementioned).
Now take your DMA transfer: You instruct the memory controller to write
data from your device to RAM.

That automatically invalidates the cache for this RAM region,if that
happens to be cached, which is
likely, because we're in a scenario where we constantly use data from the
device.

Now assume that this data is relevant to the system. (otherwise we wouldn't
argue over performance, would we?)
So, in the next few microseconds, someone is going to access that newly
written data.
Whether the cache/dma/memory controller updated the cache or not, there
will be one valid copy in the cache soon.
Now, copying that data from RAM address to RAM address is usually a lot
faster than a DMA - because
1) the cache can "hide" the copying by reading from the original address as
long as no writes on either
original or copy take place,
2) access to dma'ed memory only present in RAM is as fast as access to the
cache _at best_.

Therefore, zero copy is not always preferable above having a RAM copy -
especially for stuff that fits into L2 cache
multiple times; for ethernet packets in special.

Hope that mail explained my point of view well enough :)
Greetings,
Marcus
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to