Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3655093rwd; Mon, 22 May 2023 18:09:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Kgjt88iaIKP20claFTmUerI9RCqm75AAfE5VJ+pNA2YfUKfkQ7mM5XPqCWGZmh2NIpgky X-Received: by 2002:a17:902:ec85:b0:1af:c57d:1c7b with SMTP id x5-20020a170902ec8500b001afc57d1c7bmr1845312plg.32.1684804154337; Mon, 22 May 2023 18:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684804154; cv=none; d=google.com; s=arc-20160816; b=N1mFOXuy/B0tgx1xyuEmjKtjtoduNKCk8rhevMNKORaQrXvm3FoKWbvdtPxF51UPQ1 wRbTUnrKdEC3UHeNF6AXJDut6wtK9RV0RHM+yx+N0ZdPhhvHcCJx0shwxzztpFioRkbf EiMOBs4GjLv2ZEMLcVkPJrY3SSXflbZnfHN8qbK7RRAKLFqu07wHs26F5zT945N/SGpf M9AhTE70DfT8PYu/JCZRcuRzuJ/EZT7eyQ9PenzefYLeJNY62sEfn4J9a7k7lxiJU8ki WonTfmp8EdHPdXc66jK2/WIgQ6SH6v2JC24L3Fg1C/rY2+D4wJ1j0IedECQrDSnGvVSu Z4+g== 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=sQLIv+3hRLznwnCm51oPj668Ns602ev+EO/wUc0CPh0=; b=dKkOC/KSxDw8Vsva1DhLg3Rr+Ruw2FU6p1+B6FWScAaFgG+cUx0diQ2UMBSfBkHheG MgEw9cl930TTbVLq6Y6CLPBEHxA6MB1uq/Pe2BXiQHsKyn4rX0Q+GyaCyn5ycgj6judG u8YWmVysgGA1dLQE51VzxnAs0l+yssxLwqFtQSnzHggz84Jyo+55X1o4kRrU9BeBMnNi vMpVLU8gcz+NtEWdOmbEL6awBWWNiw7X5341RDQo8vwDa+SG3QsQj0JlLao7xKIF2DgW WO5Ihc8nhQ3kgroamnfgExQqhNXB3zkGQdg6xe/OluZ22vai+DRpD+cAP0IYaAzi4LUW jY6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=n2xXPRGt; 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 p10-20020a170902eaca00b001adbfba9c29si5202202pld.409.2023.05.22.18.08.59; Mon, 22 May 2023 18:09:14 -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=n2xXPRGt; 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 S232721AbjEWAlw (ORCPT + 99 others); Mon, 22 May 2023 20:41:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234712AbjEWABl (ORCPT ); Mon, 22 May 2023 20:01:41 -0400 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 200EE2681; Mon, 22 May 2023 16:55:29 -0700 (PDT) Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-6af8aac7a2eso429808a34.3; Mon, 22 May 2023 16:55:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684799728; x=1687391728; 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=sQLIv+3hRLznwnCm51oPj668Ns602ev+EO/wUc0CPh0=; b=n2xXPRGtvFpsGn52kRAG2uUGq4CN71U4+H75dmjZzCC3htNX+NrfJTZRi4yS2+hIIP 2HfJLbkolRJxawQkDwl4FptyOQv4iVzHKlu6uSMavJ0fbsH28EbR6KdGwRa/j42hT/vo /dWuiRCueLVD/s7DhY3X1KIFyIHIbbqUOWiuK3V7mPwfvOnwcEQ2SefZunO68pI6mbmT L0595pR826hRAXr7ofHCYd0WjT5LwbzvvGIFWgVQ/ah3aCBkbWXwuXbAbR4mcLchUYiF SB+dyayit4P5VhAJi8j0EsBgDTsZa0CP5BZSZ4uE7q4ax0sr+HPfiagMuNUYEWYsD2P3 SUKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684799728; x=1687391728; 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=sQLIv+3hRLznwnCm51oPj668Ns602ev+EO/wUc0CPh0=; b=MUq9wH5K6o2s1O44nDwrP7iX53Li8RtaT7ZtXIqnvBh9H9xpn/0Kjct8yRvTaGl6K3 LX6bqkuo0nQQ1XaurxZnCWgV8R5vil/28/DE6TIMmpPqPE2Xly0vPO3tXAWIBIvtprUK i+YAnwNXv2xCuuWcFDwpphifR3Sk6plcgZwtPfbAIuuEE5fqmdkxGeP//NSAAJZP10Lc G8DyQfLBtTzzjrc5xm159vUDuVCLrBv7HFRv/6orBdn1bwDqRCULZEQ9rGLNh1EJfc5O AvMU7jtQcwZ5EwkQN1JQ4BcvGKvjpqvmPp1XGgoCRWlcLX9rvhyCNAOkALWPFwr7XZQV cT3g== X-Gm-Message-State: AC+VfDzYbZ3jUoZEXNC05F9o0y+e9XUAfXynmKzRBJOZIAIvIbk5izQ2 hq/37MAhVQ9jprn9EasVLQ== X-Received: by 2002:a9d:67d4:0:b0:6ab:360b:840 with SMTP id c20-20020a9d67d4000000b006ab360b0840mr6709235otn.35.1684799728387; Mon, 22 May 2023 16:55:28 -0700 (PDT) Received: from C02FL77VMD6R.bytedance.net ([208.184.112.130]) by smtp.gmail.com with ESMTPSA id d21-20020a056830139500b006ab32e46485sm2848224otq.79.2023.05.22.16.55.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 May 2023 16:55:28 -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 v2 net 5/6] net/sched: Refactor qdisc_graft() for ingress and clsact Qdiscs Date: Mon, 22 May 2023 16:55:15 -0700 Message-Id: <9a7a44e532874f68c03a0028ad0a7a6b16620121.1684796705.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. Reviewed-by: Jamal Hadi Salim Acked-by: Jamal Hadi Salim Tested-by: Pedro Tammela 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