Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp105432lqf; Fri, 26 Apr 2024 00:32:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWHHO1hrqQs0mGQp1JXQiyqAS3RuvL039KlVcMulmhHjE0PIaqCoGOFsBwPY2LBI72aJbFhwvtLHTBd+3Ux6JdqrOERZnA9bHe8vgGkmw== X-Google-Smtp-Source: AGHT+IHLqw0VGS+T5JuZaYBKEPGUr8LK6C+XZjKwBL1b4yQx2ONiFcQNSJrxdUn7HlPqnQHf5bFu X-Received: by 2002:a05:622a:3cf:b0:43a:765f:cf48 with SMTP id k15-20020a05622a03cf00b0043a765fcf48mr985668qtx.8.1714116757024; Fri, 26 Apr 2024 00:32:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714116757; cv=pass; d=google.com; s=arc-20160816; b=038YhGGzW++fSwKgLo3iZJ01Cd5NW+SUhGO0F/PR8uJGUkHiVrPn5dI9Q1MbLE0z9p QV5DU9Wu1pfW83gLsfEg2G1nnWf3kPUy+lRXqtUMOFcw3uNsXQZf6dOBMNLOGWkLgATv 5W/1uBoujKcBDnHkoageFPlbGaZlwzinrUU6iAoNK2/hlkbCDRQyEy4DI6DlaecRH4aQ Q4N0KHoSHERWPafMBLT2mv4vin361uK6HWwGh4jHNt/6IaLdxSgbLgyO3oNqQp8wyN52 Rtx1v69ml7rjNGGiNqeKppS6XPLthUXeYeWtum0r42ryQ+wrFf7qcB6ppyfGZlgEndkr 4Urw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=55aGktq7fs+SXar6JRKvBBqXiEBqzDHYlydi7Q0XdwU=; fh=ihxtdvp/ITLenH+94vtdLd+JNlBQWO2QNxGw5vfL6yQ=; b=FDVNziSQ/V7Xjg+K5dkBfb/nfkZYDzSLx1j2ZccCM1wzwXvUjEsh389qfSZRCbRTQB leCvtkmnkRxC0h4xL5kuMbID4X+mmNWLrCGwopTWCco/Z+Aw02GPcxxd5cEQgaXX6j6P XSt4WGJsqfz+XaOS1sMxKJC/nAAkUsoYPZSq1uGVguiPYOiei8HUt1o/LOTLmZqKKMkm XOviXJVDzEgs/Y2EOPTLOwVaJVKcCIB7kocfqpuOh1mae1nrsqQZYCd0BpSOzRBSo4ei abD/n8aezSTTlmNIbHJBqqVS+lrSeFxAn/6gvry65HAnfQEVpjsr60Rl/h3fw/VPuYWv aV0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HJSTZU7j; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-159635-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ff21-20020a05622a4d9500b0043984ebe0acsi15032506qtb.660.2024.04.26.00.32.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 00:32:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159635-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HJSTZU7j; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-159635-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6E18D1C222D1 for ; Fri, 26 Apr 2024 07:32:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C768013C3C9; Fri, 26 Apr 2024 07:32:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="HJSTZU7j" Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33CA413BC2B for ; Fri, 26 Apr 2024 07:32:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714116745; cv=none; b=TD6Dh9h9Gl/YTujHq9mjC2TeMhXSlOarQv3gs0gQ21LwhpVfMRDfDCTO4j/rxqIBKlavhJlDU8qftzPc4EYZCGY3ZxGAiKZeQf930NFiqurA0NVcQvMl/RAVSNnRDTYhIuAwJL1pdyfSUYJr02AZgg71WWOo4BkjOknU1l4Hi5c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714116745; c=relaxed/simple; bh=huZdh8GW0EXWSaQhXBQtDCOGAUHcTkfS3ydWBvzJTfs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=tvJJBJPez4I0UTFtFnILukevHnLpNYsDpVA9hDYF/K45+r6f9+ZlnNd24Nlws15dzy7uvdZJTuximD1PrwjBddkKBcp5SyE4jNRkRAygI7K7x8Vzl7dPKOFEeDbBS5ck21b2L7cV0EsZ4rJyWXob2V6YmxcCOGEVowLU7AuAwjQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=HJSTZU7j; arc=none smtp.client-ip=209.85.208.41 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=google.com Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5724736770cso5110a12.1 for ; Fri, 26 Apr 2024 00:32:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714116742; x=1714721542; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=55aGktq7fs+SXar6JRKvBBqXiEBqzDHYlydi7Q0XdwU=; b=HJSTZU7j+4tZ/XgJccHtoLutXeJL0szwCVMk0kOv5/nyKUPJzzW0dw+V1WX0hVng9h FM5aX2LcP5SbLPpS1oeH+KtpuYNgIPi1CZkCIsZoeeLqZTkjKh159YqmOl2G4C87WU2a qqukPDrzrTkgD8UDpBtFqi1CE6y3SmE05k/rdbH3R+sjGKSwdwh88i9q8rhFDdw9+ymB KIJFtVY85ECnRtQ+0L3xK8KzcezYiJZbBGFE9xJWmpPJA+GCXkmpi0A+5LQP3uLMl92y G1UjxgaWTqTuzjgX6vOnKFshhqdYASpNPvjeHpEj/SIyrbhs2OO7unZqX/KouOkJRU8N ZedQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714116742; x=1714721542; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=55aGktq7fs+SXar6JRKvBBqXiEBqzDHYlydi7Q0XdwU=; b=HLoRJ5XsAYLDoySAmRqwcjKcb+3UwqciyoRFRf2PZZeFhqG7BjuA8nU8WgTErvJN6/ bvn5fimnjZBJheYFwaI/F0StYp99H1y3PiParZ7NUU+wA40HPNm0z4iBcQFCsk+4fszA uLz7uC7QZaWUR6pvU+sjZzc84lUZJCmTKiqhBY+ufUoZys5Ounlx9KQezjKpM0YxN7ze tl6Wmz9VIj6wyuHVz5zuWDIayXvhC7yoaUoF1IGiM4Pfit1yaHLWte1Y4dZsuD5BrzDs ERr2Nce1tBKk56iSgxjyDZvJvvowXhNOu6Hkzi0T0QGueK+U3cpd9r6cju84VHeUePAK 3aZQ== X-Forwarded-Encrypted: i=1; AJvYcCUKyY/LcV6CdNkVd+VsvnoymZLuHKAxjxDfv1v1+1/2otlyYJE9ZFKNHPs98XbdmzNZoLo5xlN+esr0MOCpuVH30gYTnzuQrxtYTKOI X-Gm-Message-State: AOJu0YyF/BOKqy99UgOErHazMCjJ7YowpKV+lvBMMASaNjlG3UPKW9o3 sb9coLXb2dGrBbFfKrJJyxMW6BV/I7v72LhU3HZg+naPemFs37rq1G+araMnf0dx3e5QSILjsjD cbIBGE2ARb8dREcUAAaJQdsSPZfFxhM7DQCHO X-Received: by 2002:a05:6402:2285:b0:570:49e3:60a8 with SMTP id cw5-20020a056402228500b0057049e360a8mr70016edb.7.1714116742251; Fri, 26 Apr 2024 00:32:22 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240426065143.4667-1-nbd@nbd.name> <20240426065143.4667-7-nbd@nbd.name> In-Reply-To: <20240426065143.4667-7-nbd@nbd.name> From: Eric Dumazet Date: Fri, 26 Apr 2024 09:32:11 +0200 Message-ID: Subject: Re: [PATCH v3 net-next v3 6/6] net: add heuristic for enabling TCP fraglist GRO To: Felix Fietkau Cc: netdev@vger.kernel.org, "David S. Miller" , David Ahern , Jakub Kicinski , Paolo Abeni , willemdebruijn.kernel@gmail.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Apr 26, 2024 at 8:51=E2=80=AFAM 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 | 30 ++++++++++++++++++++++++++++++ > net/ipv6/tcpv6_offload.c | 33 +++++++++++++++++++++++++++++++++ > 2 files changed, 63 insertions(+) > > diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c > index ee5403760775..2ae83f4394dc 100644 > --- a/net/ipv4/tcp_offload.c > +++ b/net/ipv4/tcp_offload.c > @@ -406,6 +406,34 @@ void tcp_gro_complete(struct sk_buff *skb) > } > EXPORT_SYMBOL(tcp_gro_complete); > > +static void tcp4_check_fraglist_gro(struct list_head *head, struct sk_bu= ff *skb, > + struct tcphdr *th) > +{ > + const struct iphdr *iph =3D skb_gro_network_header(skb); > + struct net *net =3D dev_net(skb->dev); Could you defer the initializations of iph and net after the NETIF_F_GRO_FRAGLIST check ? dev_net() has an implicit READ_ONCE() ... > + struct sk_buff *p; > + struct sock *sk; > + int iif, sdif; > + > + if (!(skb->dev->features & NETIF_F_GRO_FRAGLIST)) > + return; > + > + p =3D tcp_gro_lookup(head, th); > + if (p) { > + NAPI_GRO_CB(skb)->is_flist =3D NAPI_GRO_CB(p)->is_flist; > + return; > + } > + > + inet_get_iif_sdif(skb, &iif, &sdif); > + sk =3D __inet_lookup_established(net, net->ipv4.tcp_death_row.has= hinfo, > + iph->saddr, th->source, > + iph->daddr, ntohs(th->dest), > + iif, sdif); > + NAPI_GRO_CB(skb)->is_flist =3D !sk; > + if (sk) > + sock_put(sk); > +} > + > INDIRECT_CALLABLE_SCOPE > struct sk_buff *tcp4_gro_receive(struct list_head *head, struct sk_buff = *skb) > { > @@ -421,6 +449,8 @@ struct sk_buff *tcp4_gro_receive(struct list_head *he= ad, struct sk_buff *skb) > if (!th) > goto flush; > > + tcp4_check_fraglist_gro(head, skb, th); > + > return tcp_gro_receive(head, skb, th); > > flush: > diff --git a/net/ipv6/tcpv6_offload.c b/net/ipv6/tcpv6_offload.c > index c01ace2e9ff0..1ab45cca3936 100644 > --- a/net/ipv6/tcpv6_offload.c > +++ b/net/ipv6/tcpv6_offload.c > @@ -7,12 +7,43 @@ > */ > #include > #include > +#include > #include > #include > #include > #include > #include "ip6_offload.h" > > +static void tcp6_check_fraglist_gro(struct list_head *head, struct sk_bu= ff *skb, > + struct tcphdr *th) > +{ > +#if IS_ENABLED(CONFIG_IPV6) > + const struct ipv6hdr *hdr =3D skb_gro_network_header(skb); > + struct net *net =3D dev_net(skb->dev); Same remark here. > + struct sk_buff *p; > + struct sock *sk; > + int iif, sdif; > + > + if (!(skb->dev->features & NETIF_F_GRO_FRAGLIST)) > + return; > + > + p =3D tcp_gro_lookup(head, th); > + if (p) { > + NAPI_GRO_CB(skb)->is_flist =3D NAPI_GRO_CB(p)->is_flist; > + return; > + } > + > + inet6_get_iif_sdif(skb, &iif, &sdif); > + sk =3D __inet6_lookup_established(net, net->ipv4.tcp_death_row.ha= shinfo, > + &hdr->saddr, th->source, > + &hdr->daddr, ntohs(th->dest), > + iif, sdif); > + NAPI_GRO_CB(skb)->is_flist =3D !sk; > + if (sk) > + sock_put(sk); > +#endif /* IS_ENABLED(CONFIG_IPV6) */ > +} > + > INDIRECT_CALLABLE_SCOPE > struct sk_buff *tcp6_gro_receive(struct list_head *head, struct sk_buff = *skb) > { > @@ -28,6 +59,8 @@ struct sk_buff *tcp6_gro_receive(struct list_head *head= , struct sk_buff *skb) > if (!th) > goto flush; > > + tcp6_check_fraglist_gro(head, skb, th); > + > return tcp_gro_receive(head, skb, th); > > flush: > -- > 2.44.0 >