From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mail.toke.dk (Postfix) with ESMTPS id A8C39A811BF for ; Tue, 13 Aug 2024 18:27:51 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=N01tNBbB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723566470; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=u/wxPouX1WnFR5+lpreMFAWfuh3u1ErH7E1Ghdyy2n8=; b=N01tNBbBfPWZgGXbeJxAjLcqFTnHsWq2goeBzuWkIfafi0O+stNMPsJ2zemd0DSKD09io1 U4Sk8DOwW20oRNT/azUasG4Q6PEtCPfmEBl53jwuaqi0Bvs1I27gIVWPIRmZ8/x2XSi499 wqgLknomSTJjQYKeNajBJLn7g3ZAOc8= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-593-FmVssgiiMA2fCwmV5fPl1A-1; Tue, 13 Aug 2024 12:27:46 -0400 X-MC-Unique: FmVssgiiMA2fCwmV5fPl1A-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4280e1852f3so45744685e9.3 for ; Tue, 13 Aug 2024 09:27:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723566466; x=1724171266; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=u/wxPouX1WnFR5+lpreMFAWfuh3u1ErH7E1Ghdyy2n8=; b=lKnEI0Q2SiAug3aXhK6DNSxQlUd4j3B9DGSYAh2oFhAqEp+Dsx8QTz6tyPfhCwTYsr 7zTd+spLagU5s1RWaf9D25FELFxX4n/wbmRAguFAGFxo0HAIfXc7PsTK9A47ZNk2PnNG jw0k0RemzQpTY6oPzuSkql8/zjTaZCw6qN+pnmsSBAHT4dEnT7qjTp6Jplq0otA2DWC5 W1dF1f/7G0EX6im5PsaBS7krtZW7yqvt+EOw586+HJNlLjA3TYgVGxn7FT5UdrOtZHap RuKhHIGwfowc1XKVu9bFggIxAAPosfCgMkgs/nBWUL6uc3R5tPAPdjBDvMyuLYuE2Aws 5fIg== X-Forwarded-Encrypted: i=1; AJvYcCU9ustk03BGy+n2FEKE+M5IVAaLO4PEpC4KxjaCsqE4CcY2UvkWtnSIACqrJEub2Po7bHxogC6DPlY=@xdp-project.net X-Gm-Message-State: AOJu0YzAmO4Ve40gBSmSS3XHt5VAL6MtvOIdi/092yQRyEnbeav2buJL YVJM5U8V+Mg8bmOjPa8S0p5Tx0QVlVK2qMeruK5eOAnQVkPnQjWMO9ovCt0aVPLXhqbYVv/XxGf HySE98cKXKBUBaf2P8SBaG6IC0LpMg1cnUCUbJmBZYrRsSji9/35oIY4NHQ== X-Received: by 2002:a05:600c:548e:b0:428:fb96:e94a with SMTP id 5b1f17b1804b1-429dd2365ffmr468145e9.9.1723566465669; Tue, 13 Aug 2024 09:27:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXb6pZaD/xaaqJhSa7CuewDH0CF5WczOBWAa2z7gB9cS2UU5Nuu8dznz8JPfLdSE9X4jrIYg== X-Received: by 2002:a05:600c:548e:b0:428:fb96:e94a with SMTP id 5b1f17b1804b1-429dd2365ffmr467855e9.9.1723566465062; Tue, 13 Aug 2024 09:27:45 -0700 (PDT) Received: from localhost ([2001:b07:ab5:a597:abf4:6782:4209:952e]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429c775c2b1sm149888065e9.42.2024.08.13.09.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 09:27:44 -0700 (PDT) Date: Tue, 13 Aug 2024 18:27:41 +0200 From: Lorenzo Bianconi To: Alexander Lobakin Message-ID: References: <20220628194812.1453059-1-alexandr.lobakin@intel.com> <20220628194812.1453059-33-alexandr.lobakin@intel.com> <54aab7ec-80e9-44fd-8249-fe0cabda0393@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="UyDdGDL3oIkMw4TE" Content-Disposition: inline In-Reply-To: Message-ID-Hash: HCQDQYCR63EGPG7LJMR5IVLCHTJ5QRM5 X-Message-ID-Hash: HCQDQYCR63EGPG7LJMR5IVLCHTJ5QRM5 X-MailFrom: lorenzo.bianconi@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Daniel Xu , Alexander Lobakin , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Larysa Zaremba , Michal Swiatkowski , Jesper Dangaard Brouer , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "toke@redhat.com" , Lorenzo Bianconi , David Miller , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jesse Brandeburg , John Fastabend , Yajun Deng , Willem de Bruijn , "bpf@vger.kernel.org" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.9 Precedence: list Subject: [xdp-hints] Re: [PATCH RFC bpf-next 32/52] bpf, cpumap: switch to GRO from netif_receive_skb_list() List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --UyDdGDL3oIkMw4TE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Aug 13, Alexander Lobakin wrote: > From: Alexander Lobakin > Date: Thu, 8 Aug 2024 13:57:00 +0200 >=20 > > From: Lorenzo Bianconi > > Date: Thu, 8 Aug 2024 06:54:06 +0200 > >=20 > >>> Hi Alexander, > >>> > >>> On Tue, Jun 28, 2022, at 12:47 PM, Alexander Lobakin wrote: > >>>> cpumap has its own BH context based on kthread. It has a sane batch > >>>> size of 8 frames per one cycle. > >>>> GRO can be used on its own, adjust cpumap calls to the > >>>> upper stack to use GRO API instead of netif_receive_skb_list() which > >>>> processes skbs by batches, but doesn't involve GRO layer at all. > >>>> It is most beneficial when a NIC which frame come from is XDP > >>>> generic metadata-enabled, but in plenty of tests GRO performs better > >>>> than listed receiving even given that it has to calculate full frame > >>>> checksums on CPU. > >>>> As GRO passes the skbs to the upper stack in the batches of > >>>> @gro_normal_batch, i.e. 8 by default, and @skb->dev point to the > >>>> device where the frame comes from, it is enough to disable GRO > >>>> netdev feature on it to completely restore the original behaviour: > >>>> untouched frames will be being bulked and passed to the upper stack > >>>> by 8, as it was with netif_receive_skb_list(). > >>>> > >>>> Signed-off-by: Alexander Lobakin > >>>> --- > >>>> kernel/bpf/cpumap.c | 43 ++++++++++++++++++++++++++++++++++++++----- > >>>> 1 file changed, 38 insertions(+), 5 deletions(-) > >>>> > >>> > >>> AFAICT the cpumap + GRO is a good standalone improvement. I think > >>> cpumap is still missing this. > >=20 > > The only concern for having GRO in cpumap without metadata from the NIC > > descriptor was that when the checksum status is missing, GRO calculates > > the checksum on CPU, which is not really fast. > > But I remember sometimes GRO was faster despite that. > >=20 > >>> > >>> I have a production use case for this now. We want to do some intelli= gent > >>> RX steering and I think GRO would help over list-ified receive in som= e cases. > >>> We would prefer steer in HW (and thus get existing GRO support) but n= ot all > >>> our NICs support it. So we need a software fallback. > >>> > >>> Are you still interested in merging the cpumap + GRO patches? > >=20 > > For sure I can revive this part. I was planning to get back to this > > branch and pick patches which were not related to XDP hints and send > > them separately. > >=20 > >> > >> Hi Daniel and Alex, > >> > >> Recently I worked on a PoC to add GRO support to cpumap codebase: > >> - https://github.com/LorenzoBianconi/bpf-next/commit/a4b8264d5000ecf01= 6da5a2dd9ac302deaf38b3e > >> Here I added GRO support to cpumap through gro-cells. > >> - https://github.com/LorenzoBianconi/bpf-next/commit/da6cb32a4674aa724= 01c7414c9a8a0775ef41a55 > >> Here I added GRO support to cpumap trough napi-threaded APIs (with a= some > >> changes to them). > >=20 > > Hmm, when I was testing it, adding a whole NAPI to cpumap was sorta > > overkill, that's why I separated GRO structure from &napi_struct. > >=20 > > Let me maybe find some free time, I would then test all 3 solutions > > (mine, gro_cells, threaded NAPI) and pick/send the best? > >=20 > >> > >> Please note I have not run any performance tests so far, just verified= it does > >> not crash (I was planning to resume this work soon). Please let me kno= w if it > >> works for you. >=20 > I did tests on both threaded NAPI for cpumap and my old implementation > with a traffic generator and I have the following (in Kpps): >=20 > direct Rx direct GRO cpumap cpumap GRO > baseline 2900 5800 2700 2700 (N/A) > threaded 2300 4000 > old GRO 2300 4000 out of my curiority, have you tested even the gro_cells one? Lorenzo >=20 > IOW, >=20 > 1. There are no differences in perf between Lorenzo's threaded NAPI > GRO implementation and my old implementation, but Lorenzo's is also > a very nice cleanup as it switches cpumap to threaded NAPI completely > and the final diffstat even removes more lines than adds, while mine > adds a bunch of lines and refactors a couple hundred, so I'd go with > his variant. >=20 > 2. After switching to NAPI, the performance without GRO decreases (2.3 > Mpps vs 2.7 Mpps), but after enabling GRO the perf increases hugely > (4 Mpps vs 2.7 Mpps) even though the CPU needs to compute checksums > manually. >=20 > Note that the code is not polished to the top and I also have a good > improvement for allocating skb heads from the percpu NAPI cache in my > old tree which I'm planning to add to the series, so the final > improvement will be even bigger. >=20 > + after we find how to pass checksum hint to cpumap, it will be yet > another big improvement for GRO (current code won't benefit from > this at all) >=20 > To Lorenzo: >=20 > Would it be fine if I prepare a series containing your patch for > threaded NAPI for cpumap (I'd polish it and break into 2 or 3) + > skb allocation optimization and send it OR you wanted to send this > on your own? I'm fine with either, in the first case, everything > would land within one series with the respective credits; in case > of the latter, I'd need to send a followup :) >=20 > >> > >> Regards, > >> Lorenzo > >> > >>> > >>> Thanks, > >>> Daniel >=20 > Thanks, > Olek >=20 --UyDdGDL3oIkMw4TE Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCZruJewAKCRA6cBh0uS2t rEIdAP9dns2tzikgzJ2YFjvZOk+3iBBzAnW4zrb0WTT/isfyBwD+MDFS8+HnM61f CyDD9SD3t4XZuDPiuJSLQbvRrN9jtAw= =CRDn -----END PGP SIGNATURE----- --UyDdGDL3oIkMw4TE--