Netdev List
 help / color / mirror / Atom feed
* [PATCH net 0/3] tcp: fix zerocopy leftover copy and mid-frag recv_skip_hint
@ 2026-12-04  5:41 Octavian Purdila
  2026-12-04  5:41 ` [PATCH net 1/3] tcp: avoid spurious leftover copy in tcp_zerocopy_receive() Octavian Purdila
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Octavian Purdila @ 2026-12-04  5:41 UTC (permalink / raw)
  To: netdev, Eric Dumazet, David S. Miller, Jakub Kicinski,
	Paolo Abeni, Willem de Bruijn
  Cc: Neal Cardwell, Kuniyuki Iwashima, Simon Horman, Arjun Roy,
	Soheil Hassas Yeganeh, Shuah Khan, linux-kselftest, linux-kernel,
	Octavian Purdila

When TCP receive zerocopy is used with copybuf enabled on skbs larger
than the caller's mapping buffer (such as GRO, coalesced, or BIG TCP
skbs), two bugs in tcp_zerocopy_receive() cause sustained fallback from
zerocopy to copying:

1. After the mapping loop fills zc->length while >= PAGE_SIZE bytes
   remain in the current skb, tcp_zc_handle_leftover() still runs using
   zc->recv_skip_hint (the remaining skb length) and copies copybuf_len
   bytes out of the next mappable page, misaligning copied_seq mid-frag.

2. When copied_seq is mid-frag (offset_frag != 0), tcp_zerocopy_receive()
   breaks with zc->recv_skip_hint left as skb->len - offset instead of
   computing the exact bytes to the next mappable frag, forcing callers
   or copybuf to copy the remainder of the skb instead of realigning at
   the next page boundary.

Patch 1 skips tcp_zc_handle_leftover() when length == zc->length and at
least PAGE_SIZE bytes remain in the skb, preserving sub-page tail
straggler copying. Patch 2 calls tcp_zerocopy_set_hint_for_skb() when
offset_frag is non-zero. Patch 3 adds a kselftest covering both fixes
and sub-page tail straggler copying for IPv4 and IPv6.

Octavian Purdila (3):
  tcp: avoid spurious leftover copy in tcp_zerocopy_receive()
  tcp: set exact recv_skip_hint on mid-frag in tcp_zerocopy_receive()
  selftests: net: add TCP_ZEROCOPY_RECEIVE leftover and hint tests

 net/ipv4/tcp.c                                |   9 +-
 tools/testing/selftests/net/.gitignore        |   1 +
 tools/testing/selftests/net/Makefile          |   1 +
 .../selftests/net/tcp_zerocopy_receive.c      | 428 ++++++++++++++++++
 4 files changed, 437 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/net/tcp_zerocopy_receive.c


base-commit: 90ae4042bd9f35a9098d14b1a12a43df9b326e2b
-- 
2.56.1.915.g69d5ec7298-goog


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-04  5:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  5:41 [PATCH net 0/3] tcp: fix zerocopy leftover copy and mid-frag recv_skip_hint Octavian Purdila
2026-12-04  5:41 ` [PATCH net 1/3] tcp: avoid spurious leftover copy in tcp_zerocopy_receive() Octavian Purdila
2026-12-04  5:41 ` [PATCH net 2/3] tcp: set exact recv_skip_hint on mid-frag " Octavian Purdila
2026-12-04  5:41 ` [PATCH net 3/3] selftests: net: add TCP_ZEROCOPY_RECEIVE leftover and hint tests Octavian Purdila

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox