Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4487091rwl; Tue, 28 Mar 2023 07:36:30 -0700 (PDT) X-Google-Smtp-Source: AKy350aiYQsJRcTM6vhIpV8nfDeO80AhYYhx4fGHNBEvE+PkscRNSOEPBj7Zu2ZQhywA+DyG9R9U X-Received: by 2002:a17:90a:c402:b0:234:656d:2366 with SMTP id i2-20020a17090ac40200b00234656d2366mr17689739pjt.42.1680014190338; Tue, 28 Mar 2023 07:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680014190; cv=none; d=google.com; s=arc-20160816; b=xi1DIFH2nkiSTBRXDd0c7prt3UEVeH4aIU6zUi+77w48hpaDyczR4fHK9uuxmCiUA6 q6zFZa+xD+FYjjPTkI1KUlCsW+LCQQNJEfXbPMSJ4v+E8/dgWsIpj4sHcVT3RCkecBTK Ia6/qPRzyMFFUWKy54n0w3ls6UP0rgsppR3SNhJ7BkW6+n8ZBgysCp7BTsV0aYm6G6+g sr6e8FZDCoiuIgzWD5xCt0KjWMBy+DMkDpjNK5tYb3iH8ASQI2XWLY2NlwvaoAkjHIyP rB8ldG3ZZJOFndbjqYNR42/DBouZapu2ZC2s69ikaDN86LFRTg2/OZ5vk5ZxIIvb4nif Ev2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GusYEHXMJbcUKnmY5cnn7tZjPE6Mz2n+Wk5NJNEtiNU=; b=aGsHZP1ouTRQ6ydxqEW8OO9sjiEwqpDNZQx/i1BX9kPGRpyZRlAS+Ed1ZTiNn3afG1 Ge9q/LGwVuNlee0wBjXgbxRqKMQypfp8uYPoFVQ8ztI+cpssu0hezzgdkGPDk+xHGimQ 113pI99vS0Ik1bUVqF+sUcjZZIjfa6yjUg1SQ10ZJlbvhHIcEEZB5vzqoT0Ep5E5hPUW NMel0TXpy05qUETKRHz6KMGm0UGL/2ViUMwqM18pnS2v6Fn+CR164P9nIWPER9aedW3D 5xczrJtVAslIEUdVfl4Z1i3lsxZ0akA4FMRv5dGc4TinHwYlTwGYXDpqQCyXjZFBzZBk 0EEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Qg+Yt+Og; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w12-20020a17090a380c00b0023a6ea894a0si8369478pjb.88.2023.03.28.07.36.18; Tue, 28 Mar 2023 07:36:30 -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=@google.com header.s=20210112 header.b=Qg+Yt+Og; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232371AbjC1OdU (ORCPT + 99 others); Tue, 28 Mar 2023 10:33:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230171AbjC1OdT (ORCPT ); Tue, 28 Mar 2023 10:33:19 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07C6718B for ; Tue, 28 Mar 2023 07:33:19 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id m22so5438766ioy.4 for ; Tue, 28 Mar 2023 07:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680013998; 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=GusYEHXMJbcUKnmY5cnn7tZjPE6Mz2n+Wk5NJNEtiNU=; b=Qg+Yt+OgVU/6zQ4xrb0tJogRbOJzCHgXBA7r6+g14HrsOD3OWOaq1gbZ1tevnkDEmz 7PA23kHHTgGrNCiNfKBmKpzn/TWVRp4ZafGDG1EzdR9XX1p0wxsOaBW2IMzcEYy04a1t H7VUjG4g+Pzx+BHmJpwmI2URTiZioE+UIkFPPfalNx7y3h/28Ex41UVD1WLmk4+qE5Ld rb4/pSGBdHVTlvSTCtS1Y7wfg64PM/5o8ur7kD8mAEsEdIAvoZ2EmB+/XMUOYpkTa4Zn Ui29T9+hnJHJx5Sy2TonC4X8Gg2oQa7g98jU6pl1Q8OL4TpzqaYklUW4NWZt88G+L3TP /udg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680013998; 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=GusYEHXMJbcUKnmY5cnn7tZjPE6Mz2n+Wk5NJNEtiNU=; b=aHgHg8itc9o2svmlblcACHRbamo7hT8yytzOT4tgzOxkbX3NNZhjqHBt2SMOS3kj8d GrrTCY5gH8sqdF/ASvxjpdwwezoOgpqykel/tbfdO173aqOimFeoaarU4DCQPd4s4AoN XUknzug0QvAwquTe2+l4aGQWYgcT2Mv0xX0Rcpw6Ntqf3o9/Dn9d6kouVRBdBtL3idXI 9rnv+I18FLqCVA7u55VU5TiDe+JuA0SnSp75LZiAhohgeNaAW2go04IC2xIWppVi8E+1 XE7hVdcHFvRF/aQJM7107WxNwV/yG3KpCWCrs/XJ9OoQzpVl+uqW2ylNXQcD4szZJUNW y3gA== X-Gm-Message-State: AAQBX9epdqMN7ncCopEE8BZY5nV8Qy97LjaT9KutQUGXtKVe7lYrX7A/ 6leE8lGy1A4q/yYYFJggXiT/gtKuUcc2LKlhlgQuSw== X-Received: by 2002:a05:6602:394b:b0:75c:9538:fdcb with SMTP id bt11-20020a056602394b00b0075c9538fdcbmr1401594iob.2.1680013998206; Tue, 28 Mar 2023 07:33:18 -0700 (PDT) MIME-Version: 1.0 References: <20230328142112.12493-1-kerneljasonxing@gmail.com> In-Reply-To: <20230328142112.12493-1-kerneljasonxing@gmail.com> From: Eric Dumazet Date: Tue, 28 Mar 2023 16:33:06 +0200 Message-ID: Subject: Re: [PATCH v2 net] net: rps: avoid raising a softirq on the current cpu when scheduling napi To: Jason Xing Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jason Xing Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-15.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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 Tue, Mar 28, 2023 at 4:21=E2=80=AFPM Jason Xing wrote: > > From: Jason Xing > > When we are scheduling napi and then RPS decides to put the skb into > a backlog queue of another cpu, we shouldn't raise the softirq for > the current cpu. When to raise a softirq is based on whether we have > more data left to process later. But apparently, as to the current > cpu, there is no indication of more data enqueued, so we do not need > this action. After enqueuing to another cpu, net_rx_action() or > process_backlog() will call ipi and then another cpu will raise the > softirq as expected. > > Also, raising more softirqs which set the corresponding bit field > can make the IRQ mechanism think we probably need to start ksoftirqd > on the current cpu. Actually it shouldn't happen. > > Here are some codes to clarify how it can trigger ksoftirqd: > __do_softirq() > [1] net_rx_action() -> enqueue_to_backlog() -> raise an IRQ > [2] check if pending is set again -> wakeup_softirqd > > Comments on above: > [1] when RPS chooses another cpu to enqueue skb > [2] in __do_softirq() it will wait a little bit of time around 2 jiffies > > In this patch, raising an IRQ can be avoided when RPS enqueues the skb > into another backlog queue not the current one. > > I captured some data when starting one iperf3 process and found out > we can reduces around ~1500 times/sec at least calling > __raise_softirq_irqoff(). > > Fixes: 0a9627f2649a ("rps: Receive Packet Steering") No Fixes: tag, when you are trying to optimize things, and so far fail at t= his. > Signed-off-by: Jason Xing > --- > v2: > 1) change the title and add more details. > 2) add one parameter to recognise whether it is napi or non-napi case > suggested by Eric. > Link: https://lore.kernel.org/lkml/20230325152417.5403-1-kerneljasonxing@= gmail.com/ > --- Wrong again. I think I will send a series, instead of you trying so hard to break the st= ack. You have not considered busy polling, and that netif_receive_skb() contract does not enforce it to be called from net_rx_action().