[英]Kernel scatterlists contiguous in virtual address?
I'd like to ask/verify whether an array of struct scatterlist
that were mapped with blk_rq_map_sg
are all contiguous at least in virtual address domain. 我想询问/验证至少在虚拟地址域中,用
blk_rq_map_sg
映射的struct scatterlist
数组是否都是连续的。 Well we all know that scatterlists are primarily for DMA, where each scatter-gather (sg) array element describes a chunk of memory and those chunks are discontiguous in their physical addresses. 众所周知,散点列表主要用于DMA,其中每个散点聚集(sg)数组元素描述一块内存,而这些块在其物理地址中是不连续的。
I'm writing a block device driver. 我正在编写块设备驱动程序。 Suppose I receive struct requests from my request_queue, and I want to do something with the I/O data that my request is holding, like
memcpy
ing them to somewhere. 假设我收到我的request_queue结构的要求,我想这样做与我的要求是持有,如I / O数据进行处理
memcpy
荷兰国际集团他们的地方。 That operation will need a virtual address and length parameter. 该操作将需要一个虚拟地址和长度参数。 Now all I know is that I can access the request's data via the scatterlist mapped through the helper function
blk_map_rq_sg()
. 现在,我所知道的是,我可以通过通过辅助函数
blk_map_rq_sg()
映射的blk_map_rq_sg()
访问请求的数据。 Is my assumption correct, that those sg elements are contiguous in virtual, and that I can get the data address via sg_virt()
, and use that address and total length for memcpy
? 我的假设正确吗,这些sg元素在虚拟中是连续的,并且我可以通过
sg_virt()
获取数据地址,并将该地址和总长度用于memcpy
? Or they are discontiguous in virtual, and I have to walk through each sg array element and memcpy
to/from each sg memory chunk (in virtual) which is harder? 还是它们在虚拟环境中是不连续的,我必须遍历每个sg数组元素和
memcpy
往返于每个sg内存块(在虚拟中),这更难吗?
Functions like writev allow to submit discontiguous requests, and pages in high memory do not have a virtual address to begin with. 诸如writev之类的功能允许提交不连续的请求,并且高内存中的页面没有虚拟地址开头。
To access SG list contents with the CPU, use something like sg_copy_from_buffer
, which automatically maps the pages temporarily. 要使用CPU访问SG列表内容,请使用
sg_copy_from_buffer
类的sg_copy_from_buffer
,它会自动临时映射页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.