From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.199 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795992449; b=p271hGNVwLC61+9BcYYXICuL4FcZEMk/RN7idX5dpta1vfoxPTsJhk1cZWNWIQfd8eh5 LXiuaHbvwFmnj6p5B/rS3tizuNvE5YEx80TmxRYH1YTGDphaiUVDVS8bRb6EN2uBi666s tiw07t7xoGLxOA0mg8IEaVlSWlx8FXztyNSUoX946AdJw5Z/PxbY0Xb0hcayerjU4M6A8 O+eUS7a0csxDqvD0uVRx9As0+MMMiRD2tfjVaQEvrzz3yCzPD23gs22JWcWa4T4b5wq4U DZXL83epOt9LpbaZeo9v4P0WqyjtPwB/iwOsZKNQrV4mAJ+JRPybN6EriY9Hue0yqmg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795992449; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=+j70j1oSmnm2e+yzml9oOiSUX8uQkudabb0fSLqFgSQ=; b=XP1/t1wghFzwnX9N05Qhy0XuljgmGzRXEf6lt3Chl5h3Zr266mMZ4KIAxOHqPfxyZBTD FJA8Em/wDBcnWhMcuiZiPx01fOfg4aATA9wJ3yI3H6Vg6qIZg1sgjZzhCk9YaKDhgqVEc 3ghU3XU4KPa1aw3504Y1jsoA7wm2BmzFlN1uCSdaTIiPCWLPZmTyWPOb9TtVaEeV8MJDZ 1QJ9ROyAuw8XBdvdgsuErWUusLm5J2GrUk7pChHbO6GtXpbGkZsamb1XqUAgN8PkoV2si +MHyc+3JdvPWuzH9GDtd6xuOUxoWwmBPYIbZ0jYnzq9y6GlMlZifT9/6+LiDFuieuhA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b="X/tYuXxc"; arc=none smtp.remote-ip=209.85.215.199 Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69DD9606A325 for ; Sun, 29 Nov 2026 22:47:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 69DD9606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kuniyu.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=X/tYuXxc Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cdec55db650so1446518a12.0 for ; Sun, 29 Nov 2026 14:47:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795992449; x=1796597249; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+j70j1oSmnm2e+yzml9oOiSUX8uQkudabb0fSLqFgSQ=; b=X/tYuXxcbPaX72whgtpnvTLBvTgQS5fyhWJPWhqAqzRtcCBRJ7y6U/2Q+UCtKd2rkI 8EK2GdwXTC1f7q0KZxkhvn/7QZNHlHBk03zLvYsiJ3ytR0WliBs0CWw86Red7tWEVMCp f0ARlFHQ1YOVVbKWZ98g8tvW1CcB5QhWu6Q1Qfe6/WvYwkmGyioWQY5qpFsClUs/Q7PJ piBu1PCRBjnFCBz2kxduZsHCoEbQOPc3PqYoD8P2S4M6EVH8oPQZXw6SMTmq6+rXNu+I jl/LliZ3YJRiYqIzFvhGYQoabparErUAKr63/4AagBxwaZxExfc0hIYfrUG3If2Ut/1y 1U4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795992449; x=1796597249; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+j70j1oSmnm2e+yzml9oOiSUX8uQkudabb0fSLqFgSQ=; b=gvw1uJuyFvXd+A9YaVKkNSq1OlUKt2fzIKwj8ZWXK8eYH/tq5CoVZYmjUGMpLiLcCv crJ9dfWgB3eC7MVTFv+lAwMu+mBPA+59waVPrsJBuYU+9ElKqIqJvRxlxYyGsSYEzwsJ szCuWnAF5dAnDUGnw53/1lfGxAuuApFjSvk3zDkvLukW4kLBc+rtKmOcLrVbyeu0FImw FNCWRbjkV1Q3SyQzopAuLIjk6+SdV9jO9Z3KLwS9FMteXdIdCjikU/M8IrfVeTq8+WyL Aqfuo2xGbi3LYBQF3sKxgKGEDQIEWkuyXDtzlt0c6rRnA0CTkWVWvsRqc+Ht67AG9+4I G1tA== X-Forwarded-Encrypted: i=1; AL+hErHF6NdofNRuUIh4G1CYnxpqrjMbMB9xspeDVVBMG4lX4NUO7oAxdccGpm22XRdCcmkBXwzO3cg=@vger.kernel.org X-Gm-Message-State: APuU4Z8iKAqrbmF4OJAqr1J8mIlICusGaVerKZ2/gnLN1MnpiHGAb+r0 o0FsoCXb84DmBSowOEpNu8ArhOg1ATTHrEUmG3Vz320Z7YumG/SfDtEW3DNtxuAXjTogavSlSKX iWPeAeA== X-Received: from pjzt19.prod.google.com ([2002:a17:90b:593:b0:3b0:944b:61fc]) (user=kuniyu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3d90:b0:3b3:ff70:4d0d with SMTP id 98e67ed59e1d1-3b41c8d49b7mr28584922a91.14.1795992448661; Sun, 29 Nov 2026 14:47:28 -0800 (PST) Date: Sun, 29 Nov 2026 22:47:28 +0000 In-Reply-To: <20261123154708.360226-1-edumazet@kernel.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261123154708.360226-1-edumazet@kernel.org> Message-ID: Subject: Re: [PATCH net-next] tcp: use order-0 page frags in tcp_collapse() From: Kuniyuki Iwashima To: Eric Dumazet Cc: "David S . Miller" , Jakub Kicinski , Paolo Abeni , Neal Cardwell , Simon Horman , netdev@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Mon, 23 Nov 2026 16:47:08 +0100, Eric Dumazet wrote: > tcp_collapse() copies payload into linear skbs of SKB_MAX_ORDER(0, 0) > bytes (3776 bytes on x86_64), each of them with its own sk_buff and > its own skb_shared_info. > > The truesize of such an skb is 4352 bytes: 13% of the memory is > overhead, and a collapsed range can not be denser than that. > > Store the payload in order-0 page frags instead. One sk_buff can > hold up to MAX_SKB_FRAGS pages, and the overhead of a collapsed > range is now about one sk_buff and its small head. > > What does not fill a page is stored in the linear part of the first > new skb, if this is not bigger than SKB_MAX_ORDER(0, 0) bytes: this > is never more expensive than a partially used page. Otherwise, the > last page frag is partially used. > > A range of up to SKB_MAX_ORDER(0, 0) bytes is still collapsed into > a linear skb. > > All the pages are allocated before the copy, like skbs were, so > that tcp_collapse() can still give up without side effect if an > allocation fails. The truesize of the new skbs is still known > before they are allocated, to skip the ranges that would not > shrink. > > In tcp_rcv_collapse_bloated.pkt, the 30 skbs of 1000 bytes > (truesize 69120) were collapsed into 8 skbs (truesize 34816). > They are now collapsed into a single skb with 7 pages > (truesize 30976). > > Other benefits: > > - Fewer skbs in the receive queue and in the out-of-order rbtree. > > - Collapsed data is stored in page frags which are full pages, > except possibly the last one: they can be used by > TCP_ZEROCOPY_RECEIVE. > > TCP_COLLAPSE_SCALING_RATIO is not changed: skbs with a density > above 86% are still not collapsed. > > Signed-off-by: Eric Dumazet Reviewed-by: Kuniyuki Iwashima I guess we could set recv_skip_hint = skb_headlen(skb) - offset if offset < skb_headlen(skb) to enable zcopy for collapsed skb with linear data. Thanks !