我知道 splice() 是为零复制而设计的,并使用 Linux 内核管道缓冲区来实现这一点。例如,如果我想将数据从一个文件描述符(fp1)复制到另一个文件描述符(fp2),则不需要从“内核空间->用户空间->内核空间”复制数据。相反,它只是在内核空间中复制数据,流程将类似于“fp1 -> pipeline_read -> pipeline_write -> fp2”。我的问题是剂量内核需要在“fp1 -> pipeline_read”和“pipe_write -> fp2”之间复制数据吗?
维基百科说:
Ideally, splice and vmsplice work by remapping pages and do not actually copy any data,
which may improve I/O performance. As linear addresses do not necessarily correspond to
contiguous physical addresses, this may not be possible in all cases and on all hardware
combinations.
Run Code Online (Sandbox Code Playgroud)
我已经为我的问题跟踪了内核源代码(3.12),我发现“fp1->write_pipe”之间的流程,最终会在fs/splice.c中调用 kernel_readv() ,然后调用“do_readv_writev()”并且最后调用“aio_write()”
Ideally, splice and vmsplice work by remapping pages and do not actually …Run Code Online (Sandbox Code Playgroud)