On 2024-02-15 12:46, Eric Dumazet wrote:
On Thu, Feb 15, 2024 at 6:41 PM Paolo Abeni
wrote: Note: please send text-only email to netdev.
On Thu, 2024-02-15 at 10:11 -0500, Jon Maloy wrote:
I wonder if the following could be acceptable:
if (flags & MSG_PEEK) sk_peek_offset_fwd(sk, used); else if (peek_offset > 0) sk_peek_offset_bwd(sk, used);
peek_offset is already present in the data cache, and if it has the value zero it means either that that sk->sk_peek_off is unused (-1) or actually is zero. Either way, no rewind is needed in that case. I agree the above should avoid touching cold cachelines in the fastpath, and looks functionally correct to me.
The last word is up to Eric :)
An actual patch seems needed.
In the current form, local variable peek_offset is 0 when !MSG_PEEK.
So the "else if (peek_offset > 0)" would always be false.
Yes, of course. This wouldn't work unless we read sk->sk_peek_off at the beginning of the function. I will look at the other suggestions. ///jon