On Fri, May 7, 2021 at 11:21 AM Kees Cook <keescook@xxxxxxxxxxxx> wrote: > > So the question is likely, "do we want this for /dev/zero?" Well, /dev/zero should at least be safe, and I guess it's actually interesting from a performance testing standpoint (ie useful for some kind of "what is the overhead of the splice code with no data copy"). So I'll happily take a sane patch for /dev/zero, although I think it probably only makes sense if it's made to use the zero page explicitly (ie exactly for that "no data copy testing" case). So very much *not* using generic_file_splice_read(), even if that might be the one-liner. /dev/zero should probably also use the (already existing) splice_write_null() function for the .splice_write case. Anybody willing to look into this? My gu feel is that it *should* be easy to do. That said - looking at the current 'pipe_zero()', it uses 'push_pipe()' to actually allocation regular pages, and then clear them. Which is basically what a generic_file_splice_read() would do, and it feels incredibly pointless and stupid to me. I *think* we should be able to just do something like len = size; while (len > 0) { struct pipe_buffer *buf; unsigned int tail = pipe->tail; unsigned int head = pipe->head; unsigned int mask = pipe->ring_size - 1; if (pipe_full(head, tail, pipe->max_usage)) break; buf = &pipe->bufs[iter_head & p_mask]; buf->ops = &zero_pipe_buf_ops; buf->page = ZERO_PAGE(0); buf->offset = 0; buf->len = min_t(ssize_t, len, PAGE_SIZE); len -= buf->len; pipe->head = head+1; } return size - len; but honestly, I haven't thought a lot about it. Al? This is another of those "right up your alley" things. Maybe it's not worth it, and just using generic_file_splice_read() is the way to go, but I do get the feeling that if we are splicing /dev/null, the whole _point_ of it is about benchmarking, not "make it work". Linus