我知道splice()被設計爲零拷貝,並使用Linux內核管道緩衝區來實現。例如,如果我想將數據從一個文件描述符(fp1)複製到另一個文件描述符(fp2),則不需要從「內核空間 - >用戶空間 - >內核空間」複製數據。相反,它只是複製內核空間中的數據,流程將如同「fp1 - > pipe_read - > pipe_write - > fp2」。 我的問題是劑量內核需要在「fp1 - > pipe_read」和「pipe_write - > fp2」之間複製數據?Linux內核splice()是否零拷貝?
維基百科說:
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.
我已經追查kernel source(3.12)我的問題,我發現「write_pipe fp1->」之間的流動,它到底會叫kernel_readv()在fs/splice.c然後稱爲 「do_readv_writev()」,最後稱之爲 「aio_write()」
558 static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
559 unsigned long vlen, loff_t offset)
//*vec would point to struct page which belong to pipe
之間的流動 「read_pipe - > FP2」 到底稱之爲 「__kernel_write()」,然後被稱爲「fp2-> f_op - >寫()「
430 ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t *pos)
//*buf is the pipe buffer
而且我認爲這兩個 「aio_write()」 和 「文件 - > f_op_write()」 將執行真正的數據拷貝,所以沒有拼接()真正執行零拷貝?
請參考[答](http://stackoverflow.com/questions/17268826/splice-system-call-what-is-passed-to-the-pipe-data-or-whereabouts-info?answertab =票#標籤頂) –
感謝responing但如果有FP和管 – VTxyer