简体   繁体   English

直接磁盘IO与缓冲区之间的直接IO由mmap分配

[英]Direct disk IO to/from buffer was allocated by mmap

I need help regarding to direct disk IO. 我需要有关直接磁盘IO的帮助。 I open a file by file descriptor (fd) with flag O_DIRECT. 我通过带有标志O_DIRECT的文件描述符(fd)打开文件。 In my user space application, I want to read large amount of data from the file and these data was used once only. 在我的用户空间应用程序中,我想从文件中读取大量数据,并且这些数据仅使用了一次。 A piece of un-cached memory buffer was allocated in my kernel module through "set_memory_uc" (using x86) and "remap_pfn_range" with vm_page_prot set noncached (pgrot_noncached). 通过“ set_memory_uc”(使用x86)和“ remap_pfn_range”在我的内核模块中分配了一个未缓存的内存缓冲区,其中vm_page_prot设置为非缓存(pgrot_noncached)。 This buffer is aim to be used for DMA transfer via PCIe. 该缓冲区旨在用于通过PCIe进行DMA传输。

I tried 我试过了

read(fd, buffer, len) 读取(fd,buffer,len)

and

lseek(fd, 0x1000, SEEK_SET) lseek(fd,0x1000,SEEK_SET)

'buffer' VA is aligned to 4k boundary. “缓冲区” VA与4k边界对齐。 So does 'len' (n*4k) len(n * 4k)也是如此

for somehow ,'lseek'seems works because after calling lseek it returns 0x1000 出于某种原因,'lseek'似乎可以正常工作,因为调用lseek后返回0x1000

but 'read' return -1 但“读”返回-1

Is there any restriction for direct disk read disk data to a mmap buffer? 将磁盘直接读取的磁盘数据发送到mmap缓冲区是否有任何限制?

代替O_DIRECT ,考虑将posix_fadvise()POSIX_FADV_NOREUSE标志一起使用,以指示“数据将仅使用一次”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM