[PATCH v2 net-next 0/7] tcp: Prevent tcp_collapse() from bloating queue.

Kuniyuki Iwashima posted 7 patches 6 days, 21 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20261116230555.2305867-1-kuniyu@google.com
There is a newer version of this series
include/linux/skbuff.h                        |   2 +
net/core/skbuff.c                             |  26 ++-
net/ipv4/tcp_input.c                          | 171 +++++++++++++-----
.../selftests/net/packetdrill/ksft_runner.sh  |   9 +
.../packetdrill/tcp_rcv_collapse_bloated.pkt  | 135 ++++++++++++++
5 files changed, 292 insertions(+), 51 deletions(-)
create mode 100644 tools/testing/selftests/net/packetdrill/tcp_rcv_collapse_bloated.pkt
[PATCH v2 net-next 0/7] tcp: Prevent tcp_collapse() from bloating queue.
Posted by Kuniyuki Iwashima 6 days, 21 hours ago
This is a follow-up for commit 031c403d13e5 ("tcp: do not let
tcp_collapse() drive sk_forward_alloc negative").

The core algorithm in tcp_collapse() is so simple and has not
been changed since commit 1da177e4c3f4 ("Linux-2.6.12-rc2");
finding a collapsible skb and repacking it into up-to-SKB_MAX_ORDER()
skb.

Now that we use 4K MSS and tp->scaling_ratio, the simple algorithm
does not work well, and it could even end up consuming more memory
contrary to the intention.

For example, the scaling ratio of SKB_MAX_ORDER() is 222, but
typically tp->scaling_ratio for 4K MSS flow is 252, and repacking
data rather bloats high-density skb.

Also, once a low-density skb starts collapsing, it drags all the
following skbs into collapsing regardless of the density.

This series changes the algorithm so that it skips high-density
skb and a single low-density skb between high-density skbs, batches
memory accounting at the end, and removes sk_forced_mem_schedule().

This series still keeps linear SKB_MAX_ORDER(0, 0) skbs as the
collapse target, and Eric is working on a follow-up patch to
store the collapsed payload in order-0 page frags instead.

https://lore.kernel.org/netdev/CAL4WiiqekjxZw3EoDYXLc0Phd3i0GStE2ZHWQkH2iAkSM5D8TQ@mail.gmail.com/


Changes:
  v2:
    * Patch 1: Describe SYN/FIN behaviour change
    * Patch 3: Describe behavioural change for MPTCP
    * Patch 4: Add compute_skb_truesize() instead of macro
    * Patch 7: Rename test to tcp_rcv_collapse_bloated.pkt

  v1: https://lore.kernel.org/netdev/20261114040101.1043546-1-kuniyu@google.com/


Kuniyuki Iwashima (7):
  tcp: Refactor the first loop in tcp_collapse().
  tcp: Don't collapse high density skb.
  tcp: Stop collapsing if not bloated.
  tcp: Skip collapsing if collapsed skb is less-dense.
  tcp: Allocate all new skb before collapsing.
  tcp: Batch memory accounting in tcp_collapse().
  selftest: packetdrill: Add test for tcp_collapse().

 include/linux/skbuff.h                        |   2 +
 net/core/skbuff.c                             |  26 ++-
 net/ipv4/tcp_input.c                          | 171 +++++++++++++-----
 .../selftests/net/packetdrill/ksft_runner.sh  |   9 +
 .../packetdrill/tcp_rcv_collapse_bloated.pkt  | 135 ++++++++++++++
 5 files changed, 292 insertions(+), 51 deletions(-)
 create mode 100644 tools/testing/selftests/net/packetdrill/tcp_rcv_collapse_bloated.pkt

-- 
2.56.0.679.gc527c65306-goog
Re: [PATCH v2 net-next 0/7] tcp: Prevent tcp_collapse() from bloating queue.
Posted by MPTCP CI 6 days, 18 hours ago
Hi Kuniyuki,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Unstable: 1 failed test(s): selftest_diag ⚠️ 
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Perf: Unstable: 1 failed test(s): validation:sched-weak-secondary ⚠️ 
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/43984329957

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/2bc9687ac49a
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1213235


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)