Re: Bug in short splice to socket?
From: Jakub Kicinski <kuba@kernel.org>
Date: 2023-06-02 17:38:16
Also in:
lkml
On Fri, 2 Jun 2023 13:05:14 -0400 Linus Torvalds wrote:
Just to harp some more on this - if SPLICE_F_MORE is seen as purely a performance hit, with no real semantic value, and will still set random packet boundaries but we want big packets for all the _usual_ cases, then I think something like "splice_end()" can be a fine solution regardless of exact semantics. Alternatively, if we make it the rule that "splice_end()" is only called on EOF situations - so signals etc do not matter - then the semantics would be stable and sound fine to me too. In that second case, I'd like to literally name it that way, and actually call it "splice_eof()". Because I'd like to really make it very clear what the semantics would be. So a "splice_eof()" sounds fine to me, and we'd make the semantics be the current behavior: - splice() sets SPLICE_F_MORE if 'len > read_len' - splice() _clears_ SPLICE_F_MORE if we have hit 'len' - splice always sets SPLICE_F_MORE if it was passed by the user BUT with the small new 'splice_eof()' rule that: - if the user did *not* set SPLICE_F_MORE *and* we didn't hit that "use all of len" case that cleared SPLICE_F_MORE, *and* we did a "->splice_in()" that returned EOF (ie zero), *then* we will also do that ->splice_eof() call. The above sounds like "stable and possibly useful semantics" to me. It would just have to be documented. Is that what people want?
->splice_eof() with the proposed semantics sounds perfect for the cases testers complained about it the past, IMHO. We can pencil that in as the contingency plan. Actually I like these semantics so much I'm tempted to ask David to implement it already and save users potential debugging :D
I don't think it's conceptually any different from my suggestion of saying "->splice_read() can set SPLICE_F_MORE if it has more to give", just a different implementation that doesn't require changes on the splice_read() side.
Setting SPLICE_F_MORE from the input side does feel much cleaner than guessing in splice.c. But we may end up needing the eof() callback for the corner cases, anyway :(