Re: Unexpected splice "always copy" behavior observed

From: Linus Torvalds
Date: Tue May 18 2010 - 12:28:34 EST




On Tue, 18 May 2010, Steven Rostedt wrote:
>
> Hopefully we can find a way to avoid the copy to file. But the splice
> code was created to avoid the copy to and from userspace, it did not
> guarantee no copy within the kernel itself.

Well, we always _wanted_ to splice directly to a file, but it's just not
been done properly. It's not entirely trivial, since you need to worry
about preexisting pages and generally just do the right thing wrt the
filesystem.

And no, it should NOT use migration code. I suspect you could do something
fairly simple like:

- get the inode semaphore.
- check if the splice is a pure "extend size" operation for that page
- if so, just create the page cache entry and mark it dirty
- otherwise, fall back to copying.

because the "extend file" case is the easiest one, and is likely the only
one that matters in practice (if you are overwriting an existing file,
things get _way_ hairier, and why the hell would anybody expect that to be
fast anyway?)

But somebody needs to write the code..

Linus
--
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/