Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp625949lqd; Wed, 24 Apr 2024 11:50:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUPv/CIQHojatV/lCFrrzvvqHt8TLqv0lE5q2xfwuY1c0Osv78FaCCLrZW8g+roQksKXcrJlgzsRknbwkkGMLGLcr3SvXkTBWmwbUiijQ== X-Google-Smtp-Source: AGHT+IGPkbPSE/8RJiX7ZFn2Yh5V4KE6kZcl5o2MNQagty9K5O7KPpBL5nn0KYTRDedCtqXxiqIC X-Received: by 2002:a05:6a20:3251:b0:1a7:84e8:8037 with SMTP id hm17-20020a056a20325100b001a784e88037mr3174265pzc.41.1713984621968; Wed, 24 Apr 2024 11:50:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713984621; cv=pass; d=google.com; s=arc-20160816; b=pQFfHZZFa2sg8rncTcjUoQiHUEiizfpAleR2Ye2XcjbprG3OW/GA1ShlVXiwkkR6wt ShyieJr4vP+ksLU0fUWPthccqw6MgUibuhE9Yt3SbtV68cFI6WQAepNY9Rf++kluzau7 RKZeJrEH7oybQ6FmsSzrO3KRWDvi1uYaapRImRUPCsRm4U1j5+wPFCYnM3nyP/emDjsA PHxsVimP6zqOS/JW5p1Tzp9bKDKhFuHtDZTOK8Zgfq/zTD0c8Pjo1w+md6sEoc/0tprk R1fTbfrcsB7FlSiR61iTqseJOPHQxtBOA+Hq5zxuSp2pMrYxfnR5zJDKBwZ5y5ulevGc 3kMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=LlfjSz+06TFcdqph25Lx5VBdUjKqbhfJRSC9oP2qMKM=; fh=zgkV1V0F4pGrjn1lrAdaBOgn+B5WgBIjHF7v4c4V/Jk=; b=vVq+/h1VBLcmJ2InqVC3gPo6b1RcAVBTQJH1Vady0YDSxR8JeCp4IUzzLUgPkwXfPy bIbGsXQMnlbnqF881G1kNCwt2KhKKiq6gAy2hdiMs9q8N6XK9lxkIZ8rJ+GPNdauGJl1 TeL/gNBgR+SC/Il4V0c1FEBeG7w/avf2WUBraEHFrfgu0IRUI3LbHB4d7QZpR4ZR1eFj /YYiqsDnpzVwx0U8tyhtgAgCRzX9rkTS4gCGGdvkymYWCD473wi/DQyStni8lj9dOYyy 6Ouz1Hl0nNFqlNGq91Pk1hYStOekIUEMIqPnXcpUT5H92IPyzk4Qv796XB0IlhFqjAxz HhNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=J1Nz0Jd8; arc=pass (i=1 dkim=pass dkdomain=nbd.name dmarc=pass fromdomain=nbd.name); spf=pass (google.com: domain of linux-kernel+bounces-157556-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k18-20020a6568d2000000b005f7fcd8a09asi9723471pgt.768.2024.04.24.11.50.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 11:50:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157556-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=J1Nz0Jd8; arc=pass (i=1 dkim=pass dkdomain=nbd.name dmarc=pass fromdomain=nbd.name); spf=pass (google.com: domain of linux-kernel+bounces-157556-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 662D9289982 for ; Wed, 24 Apr 2024 18:49:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E3FB1A716; Wed, 24 Apr 2024 18:48:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="J1Nz0Jd8" Received: from nbd.name (nbd.name [46.4.11.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 884F71BF2B; Wed, 24 Apr 2024 18:48:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.4.11.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713984536; cv=none; b=oZtWcJC8b56INTtf90LoRt8ogUJ1R+wDwsqApyGB1F7yOBn/y2R8GVxKzXFqTv1X1eGNWDA7GsE3MTK8pl+M4DdiQ+5vRsxZnGhgLjP+Isgf2Ghrfj22tDMcgw3r3DaQUrKMn4S0mZxfnwiQ21BoLUu3Tj6EyaE4DtmXnfZsM4U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713984536; c=relaxed/simple; bh=o8LJpEkE4yYPybCP4kfKGPt4Qz74mZcXYp6/YedXHTE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=U+WiZVEZ0BhmpqMys1fD4cXj6x6XKyYNDLNEIOeOp6CB1/vubrFhcWnqLaIqdHYCIGvAmvUMHQV8rNG0fSPQ52m1RNeX2/TN27L/xMnvgiw75cN8EH//U3MALrS+AuGGCSQbouoKrbl1hmg2rs5x+4+kZk/0xmek1YsZoN6SEKE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name; spf=none smtp.mailfrom=nbd.name; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b=J1Nz0Jd8; arc=none smtp.client-ip=46.4.11.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=nbd.name DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=LlfjSz+06TFcdqph25Lx5VBdUjKqbhfJRSC9oP2qMKM=; b=J1Nz0Jd8hk/pp+YNGSiBNmI3lu hZLg4JiMX4sq3G5bYJZc+8qzAD5UlgFiHtWMzKWU75/8LiuBIZw9ErC/LKKEqaC9DxXUOfZvhhA95 yDH20/RqzHOUVVRfMlOzOQeLTtEYDse+fTRgIcPX1XhCSfdZmPrj1mYtSsJBSOD3QxZI=; Received: from p200300daa70d8400593e4be1bb3506c9.dip0.t-ipconnect.de ([2003:da:a70d:8400:593e:4be1:bb35:6c9] helo=nf.local) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1rzhfj-006ski-2P; Wed, 24 Apr 2024 20:48:47 +0200 Message-ID: <87e6afb5-796b-48be-b68c-cd8a6a0f58f9@nbd.name> Date: Wed, 24 Apr 2024 20:48:47 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next 4/4] net: add heuristic for enabling TCP fraglist GRO To: Eric Dumazet Cc: netdev@vger.kernel.org, "David S. Miller" , David Ahern , Jakub Kicinski , Paolo Abeni , willemdebruijn.kernel@gmail.com, linux-kernel@vger.kernel.org References: <20240424180458.56211-1-nbd@nbd.name> <20240424180458.56211-5-nbd@nbd.name> From: Felix Fietkau Content-Language: en-US Autocrypt: addr=nbd@nbd.name; keydata= xsDiBEah5CcRBADIY7pu4LIv3jBlyQ/2u87iIZGe6f0f8pyB4UjzfJNXhJb8JylYYRzIOSxh ExKsdLCnJqsG1PY1mqTtoG8sONpwsHr2oJ4itjcGHfn5NJSUGTbtbbxLro13tHkGFCoCr4Z5 Pv+XRgiANSpYlIigiMbOkide6wbggQK32tC20QxUIwCg4k6dtV/4kwEeiOUfErq00TVqIiEE AKcUi4taOuh/PQWx/Ujjl/P1LfJXqLKRPa8PwD4j2yjoc9l+7LptSxJThL9KSu6gtXQjcoR2 vCK0OeYJhgO4kYMI78h1TSaxmtImEAnjFPYJYVsxrhay92jisYc7z5R/76AaELfF6RCjjGeP wdalulG+erWju710Bif7E1yjYVWeA/9Wd1lsOmx6uwwYgNqoFtcAunDaMKi9xVQW18FsUusM TdRvTZLBpoUAy+MajAL+R73TwLq3LnKpIcCwftyQXK5pEDKq57OhxJVv1Q8XkA9Dn1SBOjNB l25vJDFAT9ntp9THeDD2fv15yk4EKpWhu4H00/YX8KkhFsrtUs69+vZQwc0cRmVsaXggRmll dGthdSA8bmJkQG5iZC5uYW1lPsJgBBMRAgAgBQJGoeQnAhsjBgsJCAcDAgQVAggDBBYCAwEC HgECF4AACgkQ130UHQKnbvXsvgCgjsAIIOsY7xZ8VcSm7NABpi91yTMAniMMmH7FRenEAYMa VrwYTIThkTlQzsFNBEah5FQQCACMIep/hTzgPZ9HbCTKm9xN4bZX0JjrqjFem1Nxf3MBM5vN CYGBn8F4sGIzPmLhl4xFeq3k5irVg/YvxSDbQN6NJv8o+tP6zsMeWX2JjtV0P4aDIN1pK2/w VxcicArw0VYdv2ZCarccFBgH2a6GjswqlCqVM3gNIMI8ikzenKcso8YErGGiKYeMEZLwHaxE Y7mTPuOTrWL8uWWRL5mVjhZEVvDez6em/OYvzBwbkhImrryF29e3Po2cfY2n7EKjjr3/141K DHBBdgXlPNfDwROnA5ugjjEBjwkwBQqPpDA7AYPvpHh5vLbZnVGu5CwG7NAsrb2isRmjYoqk wu++3117AAMFB/9S0Sj7qFFQcD4laADVsabTpNNpaV4wAgVTRHKV/kC9luItzwDnUcsZUPdQ f3MueRJ3jIHU0UmRBG3uQftqbZJj3ikhnfvyLmkCNe+/hXhPu9sGvXyi2D4vszICvc1KL4RD aLSrOsROx22eZ26KqcW4ny7+va2FnvjsZgI8h4sDmaLzKczVRIiLITiMpLFEU/VoSv0m1F4B FtRgoiyjFzigWG0MsTdAN6FJzGh4mWWGIlE7o5JraNhnTd+yTUIPtw3ym6l8P+gbvfoZida0 TspgwBWLnXQvP5EDvlZnNaKa/3oBes6z0QdaSOwZCRA3QSLHBwtgUsrT6RxRSweLrcabwkkE GBECAAkFAkah5FQCGwwACgkQ130UHQKnbvW2GgCeMncXpbbWNT2AtoAYICrKyX5R3iMAoMhw cL98efvrjdstUfTCP2pfetyN In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 24.04.24 20:23, Eric Dumazet wrote: > On Wed, Apr 24, 2024 at 8:05 PM Felix Fietkau wrote: >> >> When forwarding TCP after GRO, software segmentation is very expensive, >> especially when the checksum needs to be recalculated. >> One case where that's currently unavoidable is when routing packets over >> PPPoE. Performance improves significantly when using fraglist GRO >> implemented in the same way as for UDP. >> >> When NETIF_F_GRO_FRAGLIST is enabled, perform a lookup for an established >> socket in the same netns as the receiving device. While this may not >> cover all relevant use cases in multi-netns configurations, it should be >> good enough for most configurations that need this. >> >> Here's a measurement of running 2 TCP streams through a MediaTek MT7622 >> device (2-core Cortex-A53), which runs NAT with flow offload enabled from >> one ethernet port to PPPoE on another ethernet port + cake qdisc set to >> 1Gbps. >> >> rx-gro-list off: 630 Mbit/s, CPU 35% idle >> rx-gro-list on: 770 Mbit/s, CPU 40% idle >> >> Signe-off-by: Felix Fietkau >> --- >> net/ipv4/tcp_offload.c | 45 ++++++++++++++++++++++++++++++++++++++- >> net/ipv6/tcpv6_offload.c | 46 +++++++++++++++++++++++++++++++++++++++- >> 2 files changed, 89 insertions(+), 2 deletions(-) >> >> diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c >> index 6294e7a5c099..f987e2d8423a 100644 >> --- a/net/ipv4/tcp_offload.c >> +++ b/net/ipv4/tcp_offload.c >> @@ -404,6 +404,49 @@ void tcp_gro_complete(struct sk_buff *skb) >> } >> EXPORT_SYMBOL(tcp_gro_complete); >> >> +static bool tcp4_check_fraglist_gro(struct sk_buff *skb) >> +{ >> + const struct iphdr *iph = skb_gro_network_header(skb); >> + struct net *net = dev_net(skb->dev); >> + unsigned int off, hlen, thlen; >> + struct tcphdr *th; >> + struct sock *sk; >> + int iif, sdif; >> + >> + if (!(skb->dev->features & NETIF_F_GRO_FRAGLIST)) >> + return false; >> + >> + inet_get_iif_sdif(skb, &iif, &sdif); >> + >> + off = skb_gro_offset(skb); >> + hlen = off + sizeof(*th); >> + th = skb_gro_header(skb, hlen, off); >> + if (unlikely(!th)) >> + return false; >> + >> + thlen = th->doff * 4; >> + if (thlen < sizeof(*th)) >> + return false; >> + >> + hlen = off + thlen; >> + if (!skb_gro_may_pull(skb, hlen)) { >> + th = skb_gro_header_slow(skb, hlen, off); >> + if (unlikely(!th)) >> + return false; >> + } >> + >> + sk = __inet_lookup_established(net, net->ipv4.tcp_death_row.hashinfo, >> + iph->saddr, th->source, >> + iph->daddr, ntohs(th->dest), >> + iif, sdif); > > Presumably all this could be done only for the first skb/segment of a GRO train. > > We could store the fraglist in a single bit in NAPI_GRO_CB(skb) ? > > GRO does a full tuple evaluation, we can trust it. I will look into that, thanks. - Felix