network socket receive splice size

From: Ezra Kissel
Date: Fri Jun 20 2008 - 15:32:02 EST


I am using the splice syscall in kernel 2.6.25.4 with network socket receive to splice incoming and outgoing TCP sockets. I perform something like the following:

#define SPLICE_SIZE (12*1024)

int fd[2];
ret = pipe(fd);

ret = splice(src, NULL, fd[1], NULL, SPLICE_SIZE, SPLICE_F_MORE | SPLICE_F_MOVE);

bytes_left = ret;

while (bytes_left > 0) {
ret = splice(fd[0], NULL, sink, NULL, bytes_left, SPLICE_F_NONBLOCK);
bytes_left -= ret;
}

This works well when SPLICE_SIZE is around 12K or lower, but anything much more than that will cause the src splice call to block either right away or after a few iterations. It almost seems as though the pipe buffer is becoming full although I have used poll to check for both sockets and pipe fds before calling splice, and the sink splice call always sends the current number of bytes. I have also tried virtually all combinations of the SPLICE_F_ options without success. Has anyone run into a similar issue with socket-to-socket splicing and larger splice sizes? I would really like to use the full 64K splice size to and from the pipe.

I should mention that the splice test applications do work correctly with 64K splice sizes when splicing to/from a network socket(s) to STDOUT or STDIN. Any thoughts?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/