Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1606148rwr; Fri, 5 May 2023 17:32:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4uDLP0VFuLkxbKXH7kElOlfCIqO+Ji8Hd5mQJhhL0VuEVdd0O7sNDmUPHDfFEsF2Mrv1wD X-Received: by 2002:a17:903:48e:b0:1a9:4cd5:e7e0 with SMTP id jj14-20020a170903048e00b001a94cd5e7e0mr8231214plb.17.1683333161769; Fri, 05 May 2023 17:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683333161; cv=none; d=google.com; s=arc-20160816; b=KQsbedKJV5QktaPJ+C2yQUeUZ5dShdHc+wPcZKVtWwmjPDilHIUb4LrRUQ93WH6JI3 4yKipXI523c+zr4mjm3jOEa+qo5uuHMKlEQogg7gw9KHYgw+BxDCGMbJSJsiUhBRKAYg KtgXjCXUTYTABIYijJdyk8aDnYCTfe2oQxDlyNYkRNk2G6/1Pm11jMn/Cx+cYEJhj6qV 1ouAPbPMQA3TgEcRgLXjs2pBwBmgwB84eV2U4OWv+A67TJR9CdA6QG4IfftgCqvHT/JQ XBZhF7fDXhJ4Pe4u5GDgJb28tqluRHJZfWlqGDwjXHJ0hdTNYBLc++hafH0D0d2JCscb N0XA== 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=+Uvnsen7YTJ+/XuD5tR1o/JBOwU+HqDAI5vfYihveLM=; b=keyIXxoooT/pMq4E3rYmxrj5gsBPWGHABwcToW+sn6T/vHHxxBliVeDHDilIlAJBOk 1H92U4IIWZtMvwr2WbjkrP060HM187qGJb5ispudRBI0NjQNPA1FmAucyKtLYMMoPRyI FYLJdUlsIi8UwSfAaGtbrrmyAdDj4G8J7aEae1T0WuiZiiUr3CJ+RS5Cn3y4b8vhIegu 6gDio3BarFA5sIFjyLIhjIWuKKe/8vBSkoAumue5AS2jbFKFnhyB/gscykVfcWfITSlv JIL/+4tbAg1cjptfqRdwkLNw73/aqYgLKMJqSUGDoI0Z3Oun4AOESy5TzEqt7UjzAPi9 tDGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="FG/7OyvT"; 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 h9-20020a170902f7c900b001ab18eacb8csi2502246plw.526.2023.05.05.17.32.24; Fri, 05 May 2023 17:32:41 -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="FG/7OyvT"; 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 S231794AbjEFAPo (ORCPT + 99 others); Fri, 5 May 2023 20:15:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231886AbjEFAPn (ORCPT ); Fri, 5 May 2023 20:15:43 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F8196E8C; Fri, 5 May 2023 17:15:38 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-b9a6f17f2b6so16608074276.1; Fri, 05 May 2023 17:15:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683332137; x=1685924137; 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=+Uvnsen7YTJ+/XuD5tR1o/JBOwU+HqDAI5vfYihveLM=; b=FG/7OyvTnAQI17bZUseuqc3tFLR32GBm+HmmQnz/R7ESFNBaq0RaHWmcrWUCXyaX0H +LCzkQWwChzvo+zFbg61dq23hJn/vlefYt5k4g7R62VnAU9W/GsRGyAgh2rjkylU76AL rW0YckgHTWJaKoO9Wa4w2YVUdchsKfy7X9svgrPBQuWAHQPzMUV4e9Axt9QsYxe16e5/ fl9Qu648SF7Lvmfc0r2ZcPQ/XwuwfVljhj58NCQMpjWZUnMh7u1QryP5txNEXvB8wmma um7PoF0LVlIPWI2/NAFXyKgLJP0+vQfOepvfw7kKDkl6+Yvo6+sSev2FWUP9s57PYLk/ lntw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683332137; x=1685924137; 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=+Uvnsen7YTJ+/XuD5tR1o/JBOwU+HqDAI5vfYihveLM=; b=AyH2I5LXjz88MWjvjNavQPaoVGw4XC4qPaiyIc1kcvSspto741GNk4taMwJUjF4MHm dklbpXP3JGU7FNQjRXzLKUIizQPUPLyMLowve0uNH2IJPwG3SHpa5dq4zezUGuewoaf8 lR0R10wp05G3anVOUSLzT5pp0qMsdcFTR+kUCIXHtvP+ibzfSngP+KSPhEseAshKW/ua 8SqcVNleyAkWsS2z+l9lDBkr9mRlX7rfur6V0h4JkOoJjYCDLQA2Ji4ngzlUneYHQfBA t7285IJLc1r5SNxjoIKc1TBS/I1P3eWLWLoZTPeUMGBSK6GHlPmce2Ft1MYaPGF50k91 MoCw== X-Gm-Message-State: AC+VfDzyS04JqG3FIxcJFKJPbF8mFw7iI10JRh6aDYx/HKUNxyD+sVPX WIn8fR3Gx/n1Nr2vjNecbg== X-Received: by 2002:a25:6d09:0:b0:b9e:64b7:3e75 with SMTP id i9-20020a256d09000000b00b9e64b73e75mr5746289ybc.0.1683332137546; Fri, 05 May 2023 17:15:37 -0700 (PDT) Received: from C02FL77VMD6R.attlocal.net ([2600:1700:d860:12b0:5c3e:e69d:d939:4053]) by smtp.gmail.com with ESMTPSA id g4-20020a056902134400b00b7d2204cd4bsm771554ybu.21.2023.05.05.17.15.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 May 2023 17:15:37 -0700 (PDT) From: Peilin Ye X-Google-Original-From: Peilin Ye To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: Peilin Ye , Daniel Borkmann , John Fastabend , Vlad Buslov , Pedro Tammela , Hillf Danton , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Cong Wang , Peilin Ye Subject: [PATCH net 5/6] net/sched: Refactor qdisc_graft() for ingress and clsact Qdiscs Date: Fri, 5 May 2023 17:15:29 -0700 Message-Id: <1cd15c879d51e38f6b189d41553e67a8a1de0250.1683326865.git.peilin.ye@bytedance.com> 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 Grafting ingress and clsact Qdiscs does not need a for-loop in qdisc_graft(). Refactor it. No functional changes intended. 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 49b9c1bbfdd9..f72a581666a2 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1073,12 +1073,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"); @@ -1094,18 +1094,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