怎样的memcpy是由DMA在linux处理 [英] how memcpy is handled by DMA in linux

查看:1851
本文介绍了怎样的memcpy是由DMA在linux处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的程序中使用的memcpy()。我增加变量的数目,不幸的是,CPU使用率增加。这是因为如果memcpy的是通过使用用于循环迭代运行。有没有在Linux快速memcpy函数吗?我将使用一个补丁和编译内核?

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?

推荐答案

有架构,其中CPU和内存之间的总线是相当弱;一些这些架构的添加DMA引擎,以允许存储器大块,而不必在CPU上运行的循环复制。

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.

在Linux中,你就可以使用 dmaengine 子系统访问DMA引擎,但它是非常依赖于硬件的这种发动机是否真的可用。

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 CPU有一个良好的内存子系统,同时还提供了拷贝大块特殊的硬件支持,因此使用DMA引擎将不太可能真正帮助。
(英特尔增加了一个叫做 I / OAT 有些服务器主板DMA引擎,但整体<一个href=\"http://web.archive.org/web/20061209043647/http://linux-net.osdl.org/index.php/I/OAT\">results比普通CPU将不到哪去。)

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迫使数据从CPU高速缓存,这样算​​下来DMA你的程序变量的副本将是毫无意义的,因为第一个CPU访问之后将不得不读它们放回缓存。

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.

这篇关于怎样的memcpy是由DMA在linux处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆