Article View: linux.kernel.netdev
Article #25975[PATCH net 7/9] mptcp: reclaim forward memory after coalescing skbs
From: "Matthieu Baerts (NGI0)"
Date: Wed, 02 Dec 2026 21:29
Date: Wed, 02 Dec 2026 21:29
72 lines
11323 bytes
11323 bytes
From: Chris Mason <mason@kernel.org>
If MPTCP sockets receive many small segments whose data stays queued,
TCP can stall on the whole host, and an MPTCP server can be OOM killed
in its memory cgroup, although almost no memory is in use.
When the MPTCP socket (msk) takes over an skb from a subflow,
mptcp_borrow_fwdmem() adds skb->truesize to the sk_forward_alloc of the
msk, and the subflow reserves new memory for the next skb. Both
sk_forward_alloc and sk_rmem_alloc count against tcp_mem and the memory
cgroup, but only sk_rmem_alloc has a limit, sk_rcvbuf, so what queueing
the skb does not move to sk_rmem_alloc has to be released. But
mptcp_try_coalesce() moves only the increase in truesize of the skb that
receives the data, and skb_condense() in mptcp_data_queue_ofo() can
lower skb->truesize, so the rest piles up in sk_forward_alloc.
The fix used here is to return every whole page of sk_forward_alloc with
sk_mem_reclaim(), in mptcp_try_coalesce() once the merged skb is freed,
and in mptcp_data_queue_ofo() once the skb is queued.
This issue has been found with the help of an LLM, and reproduced in a
VM, with the reproducer shared with the original version of this patch:
a remote peer sends 33000 segments of one byte after a hole in the data
sequence, which are merged in the out-of-order queue. Without this
patch, the memory forward-allocated by the MPTCP socket -- msk_f -- grew
with each merged segment, above 29 MB, versus 3200 bytes with it:
SNAP label=stage1-1-connections tcp_mem_pages=7168 [...] msk_f=29445248 [...]
[...] OFOQueue=33000 OFOMerge=32862 [...]
With more connections, the original version of this patch reported that
the TCP memory went above tcp_mem[2], stalling the other TCP
connections, or that the memory cgroup went above its limit.
Fixes: 9db5b3cec4ec ("mptcp: borrow forward memory from subflow")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Mason <mason@kernel.org>
[ Shorter comment. Commit message: the rest of the borrowed amount has
to be released + how the issue was found, and its symptoms. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
net/mptcp/protocol.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index e89ed0b1e421..8649e739ae50 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -196,6 +196,9 @@ static bool mptcp_try_coalesce(struct sock *sk, struct sk_buff *to,
sk_mem_charge(sk, delta);
kfree_skb_partial(from, fragstolen);
+ /* release what is left of the borrowed 'from' truesize */
+ sk_mem_reclaim(sk);
+
return true;
}
@@ -421,6 +424,9 @@ static void mptcp_data_queue_ofo(struct mptcp_sock *msk, struct sk_buff *skb)
end:
skb_condense(skb);
skb_set_owner_r(skb, sk);
+
+ /* skb_condense() can shrink the truesize borrowed from the subflow */
+ sk_mem_reclaim(sk);
}
static void mptcp_init_skb(struct sock *ssk, struct sk_buff *skb, int offset,
--
2.55.0
Technical Details
Message-ID:
<20261202-net-mptcp-misc-fixes-7-4-rc7-v1-7-9f03efcb1a17@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376067-linux-kernel-netdev=dewy.ruReferences:
<20261202-net-mptcp-misc-fixes-7-4-rc7-v1-0-9f03efcb1a17@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376067-linux-kernel-netdev=dewy.ru
From: matttbe@kernel.org ("Matthieu Baerts (NGI0)")
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 7/9] mptcp: reclaim forward memory after coalescing
skbs
Date: Wed, 02 Dec 2026 22:29:37 +0100
Organization: Usenet Network
Message-ID: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-7-9f03efcb1a17@kernel.org>
References: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-0-9f03efcb1a17@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="2066002"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:OcjgTEpW7fgf3dNgA0utEJpGyLY= sha256:U2SYJGUjGkDZlRyuxFPlSpcui7wRQseggvkxZB8Iib4=
sha1:wj0P+IfpBWiSaoZkZKhsPE9ODw0= sha256:tfFD8cf2G7a2q7sFRJHD/XB0gcCYKdYMYLVm7MOfFCs=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 99D9E117737; Thu, 3 Dec 2026 00:32:34 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 1TCywBNVSuoG;
Thu, 3 Dec 2026 00:32:31 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-376067-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id 55C28117739; Thu, 3 Dec 2026 00:32:22 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sto.lore.kernel.org (Postfix) with ESMTP id 178A7602378; Wed, 2 Dec 2026 21:32:21 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796247131;
b=TVXART6wpfEWzhyE9iUsgd133fTBYB4B+2vL8JLHKIYr+J1HjmQwZ0C//F2KpvdqKDcd
ddp+ENGXBhk7BGcT9XRRfSJTdM/ZMUGK5E67HKj0N4ZVcK6MRozfyTvv2WPyDKWlaNvS9
qbeoG34521FKRixjcVroKyJctfiMH+QMn/3eGxA9R6W0iDb84IN9xky3Mh2qkQQzkdar3
26p/sab21sWQCmwgtIZoHewW/9HiKBGL3UNaIIDjkny+XJd5yIeIJp3mS0frABhle3drJ
b3Mh8b53mCNkup+j/qNow5ddeDJoHi0M3DNgEu/3yXK8CJ1J2rvSy/E2+z+9QMZxOTw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796247131;
h=X-Original-To:Received:Received:DKIM-Signature:From:Date:Subject:
X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc:
X-Mailer:X-Developer-Signature:X-Developer-Key;
bh=K9ZJlT59nwcTitgWC03Bt3N52Ps4nGsDxhxS8uif1Mc=;
b=jKcrNbraNnvgw3a3BAf20DGaUuuap9VQ+Kt6mcHNbyCwRWTDs7JAho8e3phgO/ej9HRn
roezN92SizfAxPVdcNFOPMPfcCvfOx8Nx0AN+L+jRtRIoQEgVj/Q/PU2mKAmZ6hLwLqCT
auHB9nqDUI2cw8Jx4RR3Za+RhId0F0+j3jLqscXvirnq/rGjDl9YfNlojsUq/0mfopFWV
V1eHYF0b6TniDX7hqgUeeK8tKvSYtINWRJYb+Orqk7Dq7QnEU4fcsALZddTqaTrByjjFQ
YRaLA93LkEHTucuBDF62rZUld7C6mV8Fa6muh9bg8O/iHVGskTjJfEUlBee6dnuh3iQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="m7/b+mBN";
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id D3C3E606A6BB;
Wed, 2 Dec 2026 21:32:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=m7/b+mBN
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796247131;
b=Ky81Y0riAjO8ZxoKEaofFpLUIGz9+n7jHH3PhiTPJKKh/Z5CXdJUg6ys0c58W6/cEU67
y4iOgHE5pyGfDXb644l/GOxATOf0ib6AbXpR5dHt8O2OkpDioFk+NzG4tFdtKMNQWQ7Po
j+OSKXMnkfbPI9Dp8hPPXdF+TVykq4kBrBuHElBCYksWhkAXHG6ixu7bnZAF+vujb7EC8
eDZKBKvuLZB89/wsWLWHWpBNpMRhzXEZ1inC9nuU/P6DRQ1j+Al7b3eCOvC6+fgyj0lph
B+sV5eogR4GJZiswA4cKj7jdLWyX1+VVELkgCzt2pjl0OoaLrz5n8A/AyItagCe8ZHA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796247131;
h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type:
Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc:
X-Mailer:X-Developer-Signature:X-Developer-Key;
bh=K9ZJlT59nwcTitgWC03Bt3N52Ps4nGsDxhxS8uif1Mc=;
b=V3fu4ksZcMjkuRUpk+mXgIjo2Xl0Mm/MSNyhviw/CWJ0oM3MTKA68khJqMqKBHGNGjoP
R52tjir3yxUawjg2SUApBUyqEx57nD378ILcUSBuv6WQpq2nWeT1ZE4D5jTDy4Gp9aS9u
dMEC5WfLoOk5CAcQ9/ooOd2J7aIi2FzY9zJ5yRYN+lV+aUj/GlH1CJWguc98zakoBasZx
/vzZCi5SGgZVUINqfa70ZWfOpdODoNFgO42O7mwpivPeKFcLsm66rJ+Xg809AyGgwdYV8
lcjVYlJayEpayqR9f0CxDXKWCU/G+XGmXzBsmt102IDLvXBux40c9v6ilNEgsqDHaAg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="m7/b+mBN";
arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature ECDSA (prime256v1))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 004D6606A32F;
Wed, 2 Dec 2026 21:32:11 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A4721F0089C;
Wed, 2 Dec 2026 21:32:08 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
s=k20260515; t=1796247130;
bh=K9ZJlT59nwcTitgWC03Bt3N52Ps4nGsDxhxS8uif1Mc=;
h=From:Date:Subject:References:In-Reply-To:To:Cc;
b=m7/b+mBNASf5noltVgy7wKBnp4B8P6qWDOroxlL3eLmPIjI/cw9TuddOytNGlIbEi
nFGl6AWKJ8FGNMb59ZQrCV/ebB0DPELalWl54piZhCZRqmw+LPNGosc6+CwzomJbQK
GbQAL0CTBW3j3Pn1r7r5U7yx1DVnNFIyFTPPp7lYKFUy8H+vJRYbo2wm7mTPaxf5Vb
TIRYktvS/FKflfTDpfk3tZ4giuOMj7REb8IABTr58sBiqFO0Mu9N7ysgzgR9XM9/ws
wZZB7SZHHzCsn3VA50PQB4ngnBn3d0+e5BHk9BDM+aLDv5MtQkr+DpgWPzGp5g2Wis
9lJczJ84xhPtA==
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-0-9f03efcb1a17@kernel.org>
X-Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev,
"Matthieu Baerts (NGI0)" <matttbe@kernel.org>,
Chris Mason <mason@kernel.org>, stable@vger.kernel.org
X-Mailer: b4 0.16.0
X-Developer-Signature: v=1; a=openpgp-sha256; l=2985; i=matttbe@kernel.org;
h=from:subject:message-id; bh=NQktYGrkhF9dobfoB4r3hpVbA0ZEFlP8gkq9gAoa5DQ=;
b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIF+hx3MFlflgyrWHhH1qz4xtLz/dzKN2alnjdPdAtdE
RQwo6S5o5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCJf1jEyvDf2vb7UruIW+3Fm
tn+3Ztbz7wxnfD9xwq+W0xeec1/p9WH4nxoiJ570YIGmVba4oGdIY7dXy8yUxt3e6WofPSalBps
xAQA=
X-Developer-Key: i=matttbe@kernel.org; a=openpgp;
fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073