Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4016253rwd; Sat, 10 Jun 2023 21:42:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6KCAdHhjl5qY9hUK9sMFuZ8KqTJFds6PQ21hNaye4Xsl6clNTXrDEVAwOCeutUKwUufw+3 X-Received: by 2002:a05:6a21:7899:b0:101:5192:18a9 with SMTP id bf25-20020a056a21789900b00101519218a9mr6856250pzc.21.1686458553199; Sat, 10 Jun 2023 21:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686458553; cv=none; d=google.com; s=arc-20160816; b=SpHXv9tdxVOcmSlRE5fgmMOEGeJETgzVNHY52Mxqm1NZSRq5jcvdkv1OK9+oydIXqb Wkq0aYRwhGxXMcpm4/zyD2Pn/1Y69y17AHQ3p0aNyylMV1EA6ahM9rE+pFhHSB+rsp5I pQfR3gG/6j4kamB7ttMtgmi8ymCkNonQXiqDG3RCByWf+a258WXkuCuWA4TySrh+S5YD SUUct7CQvOC7fFDEKJ7J00jZ8aoDb0lCXUZtqzW7nKQsg9ctrH6mrVzAua4y9zddfLkG ad3OxiVyMmaccZCW2MkmCU173X4kWnzB/c/k7OdZAEyP50xg73y+uy8XyDnRpDhjpR59 naOQ== 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:date:subject:cc:to:from :dkim-signature; bh=200wjCR5HDe9fxLF4l8kSbZBxV+TWLYy9JzUR6Cj1Lo=; b=hbFbh6xZUWfxOUEPO3jm3MqEkg2L6lrHyNC137EmtBUC3L7gvc0GC684Si2xP4S1my 3P5fLKTA/041LGrsv/jc9LFKrnf7dwshYtPDl48iMYiH1h8g50MDyo/nVckJuflYaRxq FDXosKy6cNO6veR62zenFuOXZemwXX7pajyGE29wRbFcISdd71Kmr9H0Y1Tes5zS6vhR 20e8/2AYU0TWk0tsnWR/eyjk4LXT1KFz3mwEdJtxvrH5zV+U+ZRevebU6y9SaXr2PfF4 SuesJYNdA6VCSqCApuzzoP32bez+TmiBVnZelvozXJeX0E302DY/ZTX+y7onR8+LKEYB zZ6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ch9PnoF4; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a636907000000b00543c8ad5803si5257973pgc.65.2023.06.10.21.42.11; Sat, 10 Jun 2023 21:42:33 -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=@gmail.com header.s=20221208 header.b=ch9PnoF4; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232384AbjFKDa3 (ORCPT + 99 others); Sat, 10 Jun 2023 23:30:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231387AbjFKDaZ (ORCPT ); Sat, 10 Jun 2023 23:30:25 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B45541BF0; Sat, 10 Jun 2023 20:30:21 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-3f9e5c011cfso10116511cf.1; Sat, 10 Jun 2023 20:30:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686454221; x=1689046221; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=200wjCR5HDe9fxLF4l8kSbZBxV+TWLYy9JzUR6Cj1Lo=; b=ch9PnoF4Mb81Blwkf0hMv8D0789A3mgLbBlbKqIlSA1k1Pa1y/rN9BNzlfDclVb4Z4 WL/GkbXHJudTIoJN5Ya/3UEznQjLIb29/frvDOtse2phYFP0ZWgNW5vk0lVGYU7VltGg SKXGvI9e6r6BDCZ7sdc/d3+7AuTwetnoXH+9h9OUGGJ0SRQxw8HhxSd2tZShNYaMmeuN kOq3XXP0g4FMg8UlPSRXS8Lt9s8v2LQJyaY5jOaF2pkSQ+HTe6I9PPE9+5JK5zU4QwKu MdDwgdatmAXQzjI8x8gie4XxfpKj/BZWcd1DgekvV2gGBQNeEXgZ5ANC8gfD/PpzDf/R 2dSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686454221; x=1689046221; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=200wjCR5HDe9fxLF4l8kSbZBxV+TWLYy9JzUR6Cj1Lo=; b=EjVHWE2qlSSaVPeELUW8EqlHJw/PdW/S/OmLrhY/8EqYUdcUggWgDYZhH9dcWVWEQX mwN9dlIHJJWQ82RsCq28FKfanufFVY9AMvujynNXwvbg6N0UBu2TggsCz3Ac9qg2RvTD lvNT1sCgS90OyoTqymOXYs6NchHGh35bLPwShOkyfK7c6Lh7D23oQaI2O/64RCzH9NCw 278d9zMBLOoAaZGnUud13lSsfvzpizEesrQvrIv53FpdlDeyYkDETcBdLtWmKZy/x0Jt sKbn8a57AcKz2CxtbU8GMm2nBiYZsteIolNBvHP/9CF4yy8GKMLW3C2/UxJ3K+TYVu35 lt9g== X-Gm-Message-State: AC+VfDwJa/dAqLqJD0Y303YViqFAQfh6tASOpSEC0yCsGaIHxuQ/RJXd pwcscrwv9DaZV3v6zKrneA== X-Received: by 2002:a05:622a:1494:b0:3f3:8e79:5742 with SMTP id t20-20020a05622a149400b003f38e795742mr7082201qtx.19.1686454220829; Sat, 10 Jun 2023 20:30:20 -0700 (PDT) Received: from C02FL77VMD6R.bytedance.net ([2600:1700:65a5:6400:a53e:60df:7509:de6]) by smtp.gmail.com with ESMTPSA id bq13-20020a05622a1c0d00b003f872332a9asm2363193qtb.64.2023.06.10.20.30.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Jun 2023 20:30:20 -0700 (PDT) From: Peilin Ye X-Google-Original-From: Peilin Ye To: Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Peilin Ye , Vlad Buslov , Pedro Tammela , John Fastabend , Daniel Borkmann , Hillf Danton , Zhengchao Shao , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Cong Wang , Peilin Ye Subject: [PATCH net 1/2] net/sched: Refactor qdisc_graft() for ingress and clsact Qdiscs Date: Sat, 10 Jun 2023 20:30:15 -0700 Message-Id: X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Peilin Ye Grafting ingress and clsact Qdiscs does not need a for-loop in qdisc_graft(). Refactor it. No functional changes intended. Tested-by: Pedro Tammela Acked-by: Jamal Hadi Salim Reviewed-by: Jamal Hadi Salim Reviewed-by: Vlad Buslov Signed-off-by: Peilin Ye --- net/sched/sch_api.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index e4b6452318c0..094ca3a5b633 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1079,12 +1079,12 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, if (parent == NULL) { unsigned int i, num_q, ingress; + struct netdev_queue *dev_queue; ingress = 0; num_q = dev->num_tx_queues; if ((q && q->flags & TCQ_F_INGRESS) || (new && new->flags & TCQ_F_INGRESS)) { - num_q = 1; ingress = 1; if (!dev_ingress_queue(dev)) { NL_SET_ERR_MSG(extack, "Device does not have an ingress queue"); @@ -1100,18 +1100,18 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, if (new && new->ops->attach && !ingress) goto skip; - for (i = 0; i < num_q; i++) { - struct netdev_queue *dev_queue = dev_ingress_queue(dev); - - if (!ingress) + if (!ingress) { + for (i = 0; i < num_q; i++) { dev_queue = netdev_get_tx_queue(dev, i); + old = dev_graft_qdisc(dev_queue, new); - old = dev_graft_qdisc(dev_queue, new); - if (new && i > 0) - qdisc_refcount_inc(new); - - if (!ingress) + if (new && i > 0) + qdisc_refcount_inc(new); qdisc_put(old); + } + } else { + dev_queue = dev_ingress_queue(dev); + old = dev_graft_qdisc(dev_queue, new); } skip: -- 2.20.1