Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Performance mmap/dev/mem,读取性能非常慢_Performance_Mmap - Fatal编程技术网

Performance mmap/dev/mem,读取性能非常慢

Performance mmap/dev/mem,读取性能非常慢,performance,mmap,Performance,Mmap,我编写了一个测试程序,如下所示: fd = open("/dev/mem", O_RDWR); src = mmap(0x0, 0x1000000, PROT_READ, MAP_SHARED, fd, 0x80000000);/* 0x80000000 is physical start address of DDR on my A8-cortex platform */ dst = malloc(0x1000000); start_time = get_time() memcpy(d

我编写了一个测试程序,如下所示:

fd = open("/dev/mem", O_RDWR);
src = mmap(0x0, 0x1000000, PROT_READ, MAP_SHARED, fd, 0x80000000);/* 0x80000000 is     physical start address of DDR on my A8-cortex platform */
dst = malloc(0x1000000);
start_time = get_time()
memcpy(dst, src, 0x1000000);
end_time = get_time();
print_speed();
在我的ARM A8基于cortex的板上,它提供了大约400MB/s的速度。然后我改变了上面的测试程序,src缓冲区也全部由malloc定位,再次测试,现在它给了我大约1400MB/s,大约快3~4倍

我试图找出原因。首先,我怀疑src内存是通过mmap解除缓存的,所以我检查了内核中driver/cha/mem.c中的代码。在mmap_mem函数中,我使用printk打印映射地址的页面属性,vma->vm_pgoff显示0x10f,所以它不是未缓存的。 此外,我通过vma->vm_pgoff=pgprot_nocached(vma->vm_pgoff)更改代码并将其设置为uncached类型,然后再次测试,结果约为30MB/s。因此,我们可以有理由地确认/dev/mem映射内存确实是缓存的,但与malloced内存相比,它的读取性能非常慢


那么如何解释这个测试结果呢

OP似乎在某个地方发布了帖子,并得到了一个答案: