Received: by 2002:ab2:5f8c:0:b0:1ed:23e0:acc3 with SMTP id j12csp328861lqn; Fri, 1 Mar 2024 07:03:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXRCI6CYRq7J0DJl25tgXRMnx+1Rdlo/otbRSHL2DS5wHPYpXYl48QUEr6PbkGb2kk77bhB3Mtm+nHsFOWoUUcXPWH+4FKcrWQD9Am4EA== X-Google-Smtp-Source: AGHT+IEKuQkgAAoC/ucWyAMiU/fZhZUS+zNC0rh1QH0CyyR56+hqemDSERqQsGPrIfVls4Y2SNUy X-Received: by 2002:a05:6a20:5499:b0:1a1:3ca8:7742 with SMTP id i25-20020a056a20549900b001a13ca87742mr1222624pzk.17.1709305389938; Fri, 01 Mar 2024 07:03:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709305389; cv=pass; d=google.com; s=arc-20160816; b=nUAOtEhgerVJf9gC2n0Zrj9ALU8NLpX7dMQIadIYFziVk/qzTENeFGwVcNbH9bxknO bcuvut5jRbs+fOj2vHDYc72mMDueS2FDppkwNnTRroqab1MAiBce1dIeeT3atg/Wo8+3 XwOhSS0TlIGzE/6FPJs3jFGNt8ffa5WH8u+Bq7mxlDKASybuEpc0qLxQ9Mbvbq5H/PLl J6CUT/kU2g8/vLzYAA0X7yqvkRRfCfkywAaYbw66MCmoAb1vkNvcvhdb0M+zZaqCpcu/ C0IICRRRmAgeZ36BhoKCCbkwFMD1hTXjL1QMX5CmVAdZZoFJkWiPhru7V37Nwe4dyCfD mzzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=TXEv9EP2Y22NukxIhiLYf8BGk4fGYg5i0JkzdzS8yhk=; fh=SYFHQDNmYGbeMTq1SINnjuP3LFiByjN+XrDtK3rXO/E=; b=VkSBP83Qh6oo1cU5GFeNWcGZhtBRKrlc3uS+Fd0saCGJdpHAfSO/0yNIm7nYs/SMQs dm+LDoMUcoVr/S3zXhRMNmZjNJ4zQlT1T5xnH6JmGFIDKIVmTocWPJTCUUOPvQSaoTYm zuScwtOYEKde6ibDRz8tyJKHV+EH+gJKScowpsDLVKEdlGsgAY1vdNKcjU0efBVWGS8D uhpbjHcgdZI1HgQctl2MDJW1+GrnYLTWwHnvGtySJGPa3eAHiC0+0U4kV4jHTy5puD4E XECyibBQlfPM1URD/ErJPYs0r5Gtc8a/ZyTFdpequ7dvG/Fsov2p5pC4EAZbJBcTMgxt rUBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ZdvvhqT5; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-88595-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88595-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id a27-20020a62d41b000000b006e57c870fa5si3648769pfh.189.2024.03.01.07.03.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 07:03:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88595-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ZdvvhqT5; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-88595-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88595-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9DCCBB22631 for ; Fri, 1 Mar 2024 15:03:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8028941E4E; Fri, 1 Mar 2024 15:02:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZdvvhqT5" Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 F29831C33; Fri, 1 Mar 2024 15:02:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305376; cv=none; b=KzW+lEUHFUG4m4UIzyB0ktAVdEp+D9VYsiNfzRB5XmGhTk8QVqw3IzeYACfXy00Vw80IgIa23DorY43cYfR2Zk1AwAkwdcAYHzNJBw7dtO9/BAF/+RGiR5b6SBXk4KdGPcveFY2IAfgWmT9avW5EKluyDz64RgZ7F117Loq2hzQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709305376; c=relaxed/simple; bh=iAO65WgB4KgPDeH34KBkH8XenXcHBUEjtlarWO4AjMM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=XhrwVRAwvAUqcSP+oNlKI4T9o7n5g0lV094a6v3wW2Jra5iIz3nDHd3+pHP02codJFeWBVjhlaumgseFNX8gtzVQK0aaAkv73zSnjO4yjpP4sZy9VeTwMc3ZoTTh4GVhC/NTqDT5twF32Qiv+E5P9DZHgkH5qXpyl/3oetwlhi4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZdvvhqT5; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-412ce4f62f8so603285e9.0; Fri, 01 Mar 2024 07:02:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709305373; x=1709910173; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=TXEv9EP2Y22NukxIhiLYf8BGk4fGYg5i0JkzdzS8yhk=; b=ZdvvhqT5IVMBmY7/xDACy3t1BuLoFJ1g70OTFL0x4LUqM6C27ur7UmvP+p3OdFt4HT aEsjGMVgRqasME05qCODpS67hYhgr8mvJttLFpk3eS2D86hD25FdbqDocO2Jv8DCnVeT lkuOYlClL4CHJASwT7zqMpfvvF5AZW1Qx5v4wcUoBbpiI5maN8IuwpBJMTV3TaadahWb qTte9cz7KDmBPoGqoNLdKnyyyfnmOG2Ruf7quSreQysM3Jrm+j+/90V2F58d11IKw+kx SEQNfCIH2VN4iGRRKoPhQXKs54NhKj2wKEPLvptZUfv7cWPapyrRVLiEpv6vFO0mdBod cZ9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709305373; x=1709910173; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=TXEv9EP2Y22NukxIhiLYf8BGk4fGYg5i0JkzdzS8yhk=; b=CyAl3QxKXfvuo4/kwv60XR0e3mwGAetw5AXaWazJ6tOmOeUiF95rcxltXBP1nkEH/w l1nQLKiNxwqcpQpzvQU6lu2uYT51v9/hOrf18NFzMUWVQrWQAOFOvfT+XaI7YPGRt2xn 3yWmNl1yT/g8vG4rB01cjtY1GgfZDh55Az3qvv5Crl9SNFHS18/UGErl6QCVfWtFqGnT RyxKftEBIspMMiWYtVuGZOAr58TmWiQm9vRDQDp5AGb5g4+24D2kA4/3IZp4lcfb9OGn xzT6Ev+vvYs+htZJs9Jn0QVhppXlXoW1FZwq4AAU7XWVbgQIO96Acwwc7seGXrS9CNjf I0Jg== X-Forwarded-Encrypted: i=1; AJvYcCWGovptbQm27XOJ6lnYsZCs857h69P+IHmtIi/s8sz0K6EK3VPeWZLd/KErwWk5ERYLNBmA2XpQepvjaoBWVVwLPufIf6t+3gt533U6shgI/ZBBUvpNAqDHi21NncTX7a1x+WM82ic9rEZWV5ZVuULHJx+1UErfBW9nSdG3pDcDszNYXbJZ X-Gm-Message-State: AOJu0YzqXiP5Y/UzDUTRAZ442dzgjZjg2q0NwGFMYCS7gDL9DmHWe4Si YY/DAMcdx2u2s/fDU4OjfpSxk+20cEQAFIVgYTzO4/qxKtqcGOs+ X-Received: by 2002:a05:600c:190a:b0:412:c9e6:fcfd with SMTP id j10-20020a05600c190a00b00412c9e6fcfdmr1116333wmq.23.1709305372934; Fri, 01 Mar 2024 07:02:52 -0800 (PST) Received: from debian ([146.70.204.204]) by smtp.gmail.com with ESMTPSA id 14-20020a5d47ae000000b0033cf80ad6f5sm4911569wrb.60.2024.03.01.07.02.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Mar 2024 07:02:52 -0800 (PST) Message-ID: Date: Fri, 1 Mar 2024 16:02:26 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH net-next 1/3] net: gro: set {inner_,}network_header in receive phase To: Eric Dumazet Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, shuah@kernel.org, liujian56@huawei.com, horms@kernel.org, aleksander.lobakin@intel.com, linyunsheng@huawei.com, therbert@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org References: <446695cb-50b8-4187-bf11-63aedb6e9aed@gmail.com> From: Richard Gobert In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Eric Dumazet wrote: > On Thu, Feb 29, 2024 at 2:22 PM Richard Gobert wrote: >> >> >> >> Eric Dumazet wrote: >>> >>> My intuition is that this patch has a high cost for normal GRO processing. >>> SW-GRO is already a bottleneck on ARM cores in smart NICS. >>> >>> I would suggest instead using parameters to give both the nhoff and thoff values >>> this would avoid many conditionals in the fast path. >>> >>> -> >>> >>> INDIRECT_CALLABLE_SCOPE int udp6_gro_complete(struct sk_buff *skb, int >>> nhoff, int thoff) >>> { >>> const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)(skb->data + nhoff); >>> struct udphdr *uh = (struct udphdr *)(skb->data + thoff); >>> ... >>> } >>> >>> INDIRECT_CALLABLE_SCOPE int tcp6_gro_complete(struct sk_buff *skb, int >>> nhoff, int thoff) >>> { >>> const struct ipv6hdr *iph = (const struct ipv6hdr *)(skb->data + nhoff); >>> struct tcphdr *th = (struct tcphdr *)(skb->data + thoff); >>> >>> Why storing in skb fields things that really could be propagated more >>> efficiently as function parameters ? >> >> Hi Eric, >> Thanks for the review! >> >> I agree, the conditionals could be a problem and are actually not needed. >> The third commit in this patch series introduces an optimisation for >> ipv6/ipv4 using the correct {inner_}network_header. We can remove the >> conditionals; I thought about multiple ways to do so. First, remove the >> conditional in skb_gro_network_offset: >> >> static inline int skb_gro_network_offset(const struct sk_buff *skb) >> { >> const u32 mask = NAPI_GRO_CB(skb)->encap_mark - 1; >> return (skb_network_offset(skb) & mask) | (skb_inner_network_offset(skb) & ~mask); >> } > > I was trying to say that we do not need all these helpers, storing > state in NAPI_GRO_CB(skb), > dirtying cache lines... > > Ideally, the skb network/transport/... headers could be set at the > last stage, in gro_complete(big_gro_skb), > instead of doing this for each segment. > > All the gro_receive() could be much faster by using additional > parameters (nhoff, thoff) > > skb_gro_offset() could be replaced by the current offset (nhoff or > other name), passed as a parameter. > > Here is a WIP for gro_complete() step, this looks large but this is > only adding a 2nd 'offset' parameter > > Prior offset (typically network offset), called p_off > Old argument nhoff, (renamed thoff if that makes sense), pointing to > the current offset. > You're right, it seemed to me like a broad change but it is mainly cosmetic. I'll finish your version and submit it to fix the bug. I still believe that setting inner_network_header is a valuable change. For example, although skb_gro_network_offset is used - setting it in encapsulation protocol functions (such as ipip_gro_receive) allow us to remove conditionals from {ipv6,inet}_gro_receive gro_list loop and remove flush_id from napi_gro_cb as written in the 3rd commit. What are your thoughts about it as a separate patch?