Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp862517rwl; Wed, 29 Mar 2023 09:21:59 -0700 (PDT) X-Google-Smtp-Source: AKy350acbPt0Bak4clsoEJ3MSY40SKNQhvUXj8hRCaEcsDlbHk4G79nla1VXe5b1XZ5NvnUHrjPC X-Received: by 2002:a17:902:e546:b0:1a1:cc5a:b04 with SMTP id n6-20020a170902e54600b001a1cc5a0b04mr22767504plf.3.1680106918900; Wed, 29 Mar 2023 09:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680106918; cv=none; d=google.com; s=arc-20160816; b=xYMOIklKEUFL7KMHQm5Zchr5KIfQPQbgQplNUPGFHNOgN9ITCoBzapSySoBrNJrI3Z 88NZbhuv0PyQiBnfKQbFxYXN2RsWQAuj3NtsXrxaKejXjU+ajIhPkT3XSKHbP1XWtHPy jK3Vgs1nQlW8YLhT5GYBeYvYEGGhqelhnlrbJFK2O0OcTn40OsjGOYCDelG85GZggifw AtbbHBrwaeccW9GlIdE8/GWJbZ/2wFsQGyNKzY0rUlbzMtNmGstjgJjeY0051JKXYNZ8 MGKbqXKj9Q1aKm9YaHqhmgjdRNqaPJgmTPYHVIQ+RFnDHw4/cpV/IvAd95SHxKEwRoOD CKLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :to:content-language:subject:cc:user-agent:mime-version:date :message-id:from:dkim-signature; bh=eyuZmyKTv1NKroiSP9E43EgXTfIl/At4weexpT2NlGU=; b=GTZGqF2rQAsOFoZbplQ8g3PdDe1GAH0G6jZe8jA45UK8nRZsMI/7vx+Ijwc+YQzFhX y6LnXXKqgche5pXQQmaFw1rnqABK1TesYbhD7E1rXBnWpkON5te5pjmbO9uVAtavHBoE 6f8ouKFch+Ac5kIf9JsZ96UB1AGgHiEf9W23cOgSFxbWrOlj3rF2rSBj1ledAPgOzUt/ 2+1ZVRCdWzPgjCuHoExryrfjPW8OFl9iohJn3Qs3tknJFLn7zd4hMGxMfAiPWLXRSwQY ra0FW4B3gJ2KLgdnk5wPGpWJrOt6xtGrYjmcppEwqsbRsZ55kuNvYFaHjjUcqnzyZosx uplw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bi1cYZPl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u18-20020a170903125200b001a24777b8ffsi7400502plh.271.2023.03.29.09.21.45; Wed, 29 Mar 2023 09:21:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bi1cYZPl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229763AbjC2QQD (ORCPT + 99 others); Wed, 29 Mar 2023 12:16:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229793AbjC2QP6 (ORCPT ); Wed, 29 Mar 2023 12:15:58 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13E115FC2 for ; Wed, 29 Mar 2023 09:14:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680106478; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eyuZmyKTv1NKroiSP9E43EgXTfIl/At4weexpT2NlGU=; b=bi1cYZPlpjfDGYeFHHTFlHP7bYF83uQtkLpgiiSFaVXaqZ9GG0Xr9hsxuvTGEdxrnN0CKI 712NUUqjaG/X9bBduBf47RgGeDTq30Ocl3DY1JteJ60ewP+pPA4Imdn0SmWLWidPtx+Cnb j3e6/xNN3qpxx9wE/sCkusOd+/dg44I= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-308-C2lr0zE3MAeJrpBTPlYIEg-1; Wed, 29 Mar 2023 12:14:35 -0400 X-MC-Unique: C2lr0zE3MAeJrpBTPlYIEg-1 Received: by mail-ed1-f71.google.com with SMTP id h11-20020a0564020e8b00b004e59d4722a3so22981917eda.6 for ; Wed, 29 Mar 2023 09:14:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680106474; h=content-transfer-encoding:in-reply-to:references:to :content-language:subject:cc:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eyuZmyKTv1NKroiSP9E43EgXTfIl/At4weexpT2NlGU=; b=uBzQgIoY5NMAQ2nDzPZRQu4gEmSSp6SxZSkLQhqD+YOCpfVJNKauZwHFWHUJSJkkcd 1IEDqPW0PsWiBZVY1DhhEls4W4uLAHdbD7gaL/Dg2YCDwKdQTmo6ENCEH87CKKv5RkG0 ZMbm39rMQE7BARdqwLveqweO7VcpH0tWhR38Agsgfekeeb91tcA0WVEH+zXwzJe/p6Fv 8GUSJMi5RR08LXJegqIsegzJ1zzTjvTHGxFk/i2OhwMNqFbI5k2stBkOpbTgVT322QbI 4UgHAl2S32PHEt232ltmUWsDYAMs88ATuxA3wJZqgY3MVe39mKpYuThYAxIrYe18+9je vo5w== X-Gm-Message-State: AAQBX9fS4iguZ9s9Vv8ASBJw+I7xpItG3nj+ljtUJXjgA/qOhpcGc1Fq kMj8XudPCN1+1QHU9JOivTUgr5R/FiRAnKwWOddOKr73YwPoLcY+ZoF8k9xwBBp/peKVISEbLds sUwOwQtrwXTGYkqCWmnf+HSMj X-Received: by 2002:a17:906:9411:b0:925:1d1d:6825 with SMTP id q17-20020a170906941100b009251d1d6825mr21570213ejx.42.1680106474351; Wed, 29 Mar 2023 09:14:34 -0700 (PDT) X-Received: by 2002:a17:906:9411:b0:925:1d1d:6825 with SMTP id q17-20020a170906941100b009251d1d6825mr21570188ejx.42.1680106473980; Wed, 29 Mar 2023 09:14:33 -0700 (PDT) Received: from [192.168.42.100] (194-45-78-10.static.kviknet.net. [194.45.78.10]) by smtp.gmail.com with ESMTPSA id e19-20020a170906c01300b009373f1b5c4esm12603786ejz.161.2023.03.29.09.14.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Mar 2023 09:14:33 -0700 (PDT) From: Jesper Dangaard Brouer X-Google-Original-From: Jesper Dangaard Brouer Message-ID: <193501d0-094a-cc5a-c3ae-4553a56e3a3a@redhat.com> Date: Wed, 29 Mar 2023 18:14:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Cc: brouer@redhat.com, netdev@vger.kernel.org, Jonathan Corbet , "David S. Miller" , Eric Dumazet , Paolo Abeni , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Dave Taht Subject: Re: [PATCH net-next] net/core: add optional threading for backlog processing Content-Language: en-US To: Felix Fietkau , Jakub Kicinski References: <20230324171314.73537-1-nbd@nbd.name> <20230324102038.7d91355c@kernel.org> <2d251879-1cf4-237d-8e62-c42bb4feb047@nbd.name> In-Reply-To: <2d251879-1cf4-237d-8e62-c42bb4feb047@nbd.name> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/03/2023 18.35, Felix Fietkau wrote: > On 24.03.23 18:20, Jakub Kicinski wrote: >> On Fri, 24 Mar 2023 18:13:14 +0100 Felix Fietkau wrote: >>> When dealing with few flows or an imbalance on CPU utilization, static RPS >>> CPU assignment can be too inflexible. Add support for enabling threaded NAPI >>> for backlog processing in order to allow the scheduler to better balance >>> processing. This helps better spread the load across idle CPUs. >> >> Can you explain the use case a little bit more? > > I'm primarily testing this on routers with 2 or 4 CPUs and limited > processing power, handling routing/NAT. RPS is typically needed to > properly distribute the load across all available CPUs. When there is > only a small number of flows that are pushing a lot of traffic, a static > RPS assignment often leaves some CPUs idle, whereas others become a > bottleneck by being fully loaded. Threaded NAPI reduces this a bit, but > CPUs can become bottlenecked and fully loaded by a NAPI thread alone. > > Making backlog processing threaded helps split up the processing work > even more and distribute it onto remaining idle CPUs. > > It can basically be used to make RPS a bit more dynamic and > configurable, because you can assign multiple backlog threads to a set > of CPUs and selectively steer packets from specific devices / rx queues > to them and allow the scheduler to take care of the rest. > My experience with RPS was that it was too slow on the RX-CPU. Meaning that it doesn't really scale, because the RX-CPU becomes the scaling bottleneck. (My data is old and it might scale differently on your ARM boards). This is why I/we created the XDP "cpumap". It also creates a kernel threaded model via a kthread on "map-configured" CPUs. It scales significantly better than RPS, but it doesn't handle flows and packet Out-of-Order (OoO) situations automatically like RPS. That is left up to the BPF-programmer. The kernel samples/bpf xdp_redirect_cpu[0] have code that shows strategies of load-balancing flows. The project xdp-cpumap-tc[1] runs in production (3 ISPs using this) and works in concert with netstack Traffic Control (TC) for scaling bandwidth shaping at the ISPs. OoO is solved by redirecting all customers IPs to the same TX/egress CPU. As the README[1] describes it is recommended to reduce the number of RX-CPUs processing packets, and have more TX-CPUs that basically runs netstack/TC. One ISP with 2x25Gbit/s is using 2 CPUs for RX and 6 CPUs for TX. --Jesper [0] https://github.com/torvalds/linux/blob/master/samples/bpf/xdp_redirect_cpu.bpf.c [1] https://github.com/xdp-project/xdp-cpumap-tc