Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp2074064pxx; Sat, 31 Oct 2020 07:20:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMLIivfftTBI4oYgddf2x3UlkUDF5sB70sFLwc/cTXKpyFRoJhopzrPTPS88Y815athZv5 X-Received: by 2002:a05:6402:1ad9:: with SMTP id ba25mr8103779edb.120.1604154009206; Sat, 31 Oct 2020 07:20:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604154009; cv=none; d=google.com; s=arc-20160816; b=q5/Gufx4y5sBCBpBVuEiE0F5xVY76yKRO0gZDQpKlKSun8IRchX3dJLBHT6940K3jW v8xahTGOMsQV+xtMQOqOzNnDCX5YXCDZiQ9yB8Fu5AoVI2gf2JNwEFZx5knjaWITpM3D ooAK0SMbKmPHRz2YiFBOykBBJHaPgJhTu6LehYy6h/aGBvlLRwLP0tz3qNbKMZuNgg1y GVn5gkKNSZ/+6YmbA9iOHO88z4oH60RVrCDH7ZpugjA7t4O8QPjl1MXiJgKJZ6QU5THK zfGTQBiPn/nJcgPPvSfoQv1J6S3g8TN4J82MgdyNMh9a1lv3bXx9Jaueod3Lwrp4K7v5 E9vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:reply-to:cc:from:to :dkim-signature:date; bh=NXlWEEClV4m+2Wq5YBkeWG1SXRGlVBbCq04Zf/Sk7C8=; b=wxWkFB+uxlPIAxhecBXNCVD16MmCufMpF+RxOBkrDvg7/yxhZo/Ya6KhaOvuNQzvKJ Fhh3VAdMzo+CMN29nC7xm+etWw1noLqdYckXHiBjzhmuDpcnu+ilBV1FsD6GstMTuK8j RxrYE6ouvQXUmFB2bPBZEYazJxQRoL6CqiEfY/1osIdyrP5HXKX+wS9R9PNPrbs63J49 39VD1mRaWElo36LOU5uh1Nzq6GbZukPWbgOcMTbnY/QQVCJrjYbNMM576QXiP9bEZCzk KfKp3e8RPMOpdTg0bs6xk64m0E/rvKU8SE4o7pv+EMY5wUrTd+3MJ2QNvVbpOru8X4Ht vL0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=IBS5UuK0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m13si6739168ejg.531.2020.10.31.07.19.43; Sat, 31 Oct 2020 07:20:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=IBS5UuK0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727702AbgJaORP (ORCPT + 99 others); Sat, 31 Oct 2020 10:17:15 -0400 Received: from mail-02.mail-europe.com ([51.89.119.103]:36552 "EHLO mail-02.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727407AbgJaORO (ORCPT ); Sat, 31 Oct 2020 10:17:14 -0400 Date: Sat, 31 Oct 2020 14:17:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1604153827; bh=NXlWEEClV4m+2Wq5YBkeWG1SXRGlVBbCq04Zf/Sk7C8=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=IBS5UuK0imxu2GUNPPcajRAkiXSaQIHDckCvHh0LPYWjLBC5lLLSCZKEDq4fisWqb wEcR1Q2tr7n2pFC9g644ZcDSq9Dk2k/eR7C1M5awO2mAVYfDqzz/S55Bg30U/B8dPe YJJLQRvcx/u9P/y1MHWYBla2dJ9bd/64G8ua/V9kjm1mzLrVTEG7BTzE/r2fvGk9c2 9QWUNIw2SBJ2eN87nJ8rLjRieS4PxMee8y3aOpA3UTyy73E/ouK1a66aLXEQ66Iw3o 9+B4JkXnfMYEJmB3QFsUCDjEfaT/I3nUoIu8IQDWFP+yFTP4kL6Kj9TXyj8aKPwoNW 5Ajy9nHWG407Q== To: Willem de Bruijn From: Alexander Lobakin Cc: Alexander Lobakin , "David S. Miller" , Jakub Kicinski , Steffen Klassert , Antoine Tenart , Mauro Carvalho Chehab , Miaohe Lin , Network Development , linux-kernel Reply-To: Alexander Lobakin Subject: Re: [PATCH net-next] net: avoid unneeded UDP L4 and fraglist GSO resegmentation Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Lobakin Date: Sat, 31 Oct 2020 10:31:31 +0000 > On Saturday, 31 October 2020, 2:12, Willem de Bruijn wrote: > > Hi Willem, > >> On Fri, Oct 30, 2020 at 2:33 PM Alexander Lobakin alobakin@pm.me wrote: >> >>> Commit 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.") added a supp= ort >>> for fraglist UDP L4 and fraglist GSO not only for local traffic, but al= so >>> for forwarding. This works well on simple setups, but when any logical >>> netdev (e.g. VLAN) is present, kernel stack always performs software >>> resegmentation which actually kills the performance. >>> Despite the fact that no mainline drivers currently supports fraglist G= SO, >>> this should and can be easily fixed by adding UDP L4 and fraglist GSO t= o >>> the list of GSO types that can be passed-through the logical interfaces >>> (NETIF_F_GSO_SOFTWARE). After this change, no resegmentation occurs (if >>> a particular driver supports and advertises this), and the performance >>> goes on par with e.g. 1:1 forwarding. >>> The only logical netdevs that seem to be unaffected to this are bridge >>> interfaces, as their code uses full NETIF_F_GSO_MASK. >>> >>> Tested on MIPS32 R2 router board with a WIP NIC driver in VLAN NAT: >>> 20 Mbps baseline, 1 Gbps / link speed with this patch. >>> >>> Signed-off-by: Alexander Lobakin alobakin@pm.me >>> ------------------------------------------------ >>> include/linux/netdev_features.h | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> diff --git a/include/linux/netdev_features.h b/include/linux/netdev_fea= utres.h >>> index 0b17c4322b09..934de56644e7 100644 >>> --- a/include/linux/netdev_features.h >>> +++ b/include/linux/netdev_features.h >>> @@ -207,8 +207,8 @@ static inline int find_next_netdev_feature(u64 feat= ure, unsigned long start) >>> NETIF_F_FSO) >>> /* List of features with software fallbacks. */ >>> -#define NETIF_F_GSO_SOFTWARE (NETIF_F_ALL_TSO | \ >>> - NETIF_F_GSO_SCTP) >>> +#define NETIF_F_GSO_SOFTWARE (NETIF_F_ALL_TSO | NETIF_F_GSO_SCTP | \ >>> - NETIF_F_GSO_UDP_L4 | NETIF_F_GSO_FRA= GLIST) >> >> What exactly do you mean by resegmenting? > > I mean pts 5-6 from the full path: > 1. Our NIC driver advertises a support for fraglists, GSO UDP L4, GSO fra= glists. > 2. User enables fraglisted GRO via Ethtool. > 3. GRO subsystem receives UDP frames from driver and merges the packets i= nto > fraglisted GSO skb(s). > 4. Networking stack queues it up for xmitting. > 5. Virtual device like VLAN doesn't advertise a support for GSO UDP L4 an= d > GSO fraglists, so skb_gso_check() doesn't allow to pass this skb as is= to > the real driver. > 6. Kernel then has to form a bunch of regular UDP skbs from that one and = pass > it to the driver instead. This fallback is *extremely* slow for any GS= O types, > but especially for GSO fraglists. > 7. All further processing performs with a series of plain UDP skbs, and t= he > driver gets it one-by-one, despite that it supports UDP L4 and fraglis= ted GSO. > > That's not OK because: > a) logical/virtual netdevs like VLANs, bridges etc. should pass GSO skbs = as is; > b) even if the final driver doesn't support such type of GSO, this softwa= re > resegmenting should be performed right before it, not in the middle of > processing -- I think I even saw that note somewhere in kernel documen= tation, > and it's totally reasonable in terms of performance. > >> I think it is fine to reenable this again, now that UDP sockets will >> segment unexpected UDP GSO packets that may have looped. We previously >> added general software support in commit 83aa025f535f ("udp: add gso >> support to virtual devices"). Then reduced its scope to egress only in >> 8eea1ca82be9 ("gso: limit udp gso to egress-only virtual devices") to >> handle that edge case. Regarding bonding and teaming: I think they should also use NETIF_F_GSO_SOFTWARE mask, not NETIF_F_ALL_TSO, as SCTP also has a software fallback. This way we could also remove a separate advertising of NETIF_F_GSO_UDP_L4, as it will be included in the first. So, if this one: 1. Add NETIF_F_GSO_UDP_L4 and NETIF_F_GSO_FRAGLIST to NETIF_F_GSO_SOFTWARE; 2. Change bonding and teaming features mask from NETIF_F_ALL_TSO | NETIF_F_GSO_UDP_L4 to NETIF_F_GSO_SOFTWARE; 3. Check that every virtual netdev has NETIF_F_GSO_SOFTWARE _or_ NETIF_F_GSO_MASK in its advertising. is fine for everyone, I'll publish more appropriate and polished v2 soon. >> If we can enable for all virtual devices again, we could revert those >> device specific options. > > Thanks, > Al Al