Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5097488rwd; Tue, 23 May 2023 18:25:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7FzBK7QBfxmDWFZFjm//UXdIH90+hLZuO/0C+xpvJPG/Y4dJVVpQaf+p0dlFFI+mUavyMQ X-Received: by 2002:a05:6a20:3d88:b0:10d:12a8:c95b with SMTP id s8-20020a056a203d8800b0010d12a8c95bmr552024pzi.0.1684891524303; Tue, 23 May 2023 18:25:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684891524; cv=none; d=google.com; s=arc-20160816; b=SRvSRaTpgzfb9V+7pUBx6rOVfPLWzAqBzEHiJg/VCPxVoRth+zJdFaW7W5RT4YtSP/ ZPjOYEWZvV9DFU3P0pqh1swXsWqCJ4H9Ndl7sGO/yJcHafWsug3NCirBZLb2AsOve7Ig S5rDrunQO7Jd3NBVsE6X4exQ3JUW+THC52vmsxRJkdlObN5vaNS+B2NBJwb4BhR9KsXV ULu5wBwYA4jTnMOFKxE5EIjTiybsZAne9F2LiumS34n9121b2kd93UBtruYUxJY14tM/ WxNrC/BJV+BUZn7EsxxrPiyEakDH73XU6k8I8MXpF4fPMi3g+BzDA1iVtIP52gfTo3ro WJtw== 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=84jCH5csYFlMMdBF7z2xCF1DPFHya9qG/1Sk/ks2VEQ=; b=xQxvL2wF1yv+xl5hTX2pQ/yUQvqE6UQa+tFr8+E9J2NGv5GydG+3VVnVCsVntR8u6I Nhahdi4wb8vxhnnscduwj+fd7X/ArpSejX5NUHghkfvhj17udWfbcP8f4Z9jYwhbOK4A NObFcAHHbg9n/mcpHS+SA8kJMqiUs3HI5id9XZnavZt4/PA33+EpzVQZQ47ZVbpQ5xZs +u+NXw3IflsfNcjuJszuV8zu8D3TBEX/rijp87jBHAuv5DibqHXO0JJrYL/CHvU3hnI+ Z8KxmN1HHPPZjbphpSwF6AfhF5/fME7i9yvkmXBjmprJZWeafwf4ynG2gxDrnkPVt85Z J/NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=hOcUcInM; 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 g26-20020a63375a000000b0053009feb3b2si661354pgn.30.2023.05.23.18.25.09; Tue, 23 May 2023 18:25:24 -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=hOcUcInM; 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 S238922AbjEXBUZ (ORCPT + 99 others); Tue, 23 May 2023 21:20:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234246AbjEXBUY (ORCPT ); Tue, 23 May 2023 21:20:24 -0400 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDBB4129; Tue, 23 May 2023 18:20:10 -0700 (PDT) Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-3f6bb5e8ed2so3665891cf.0; Tue, 23 May 2023 18:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684891210; x=1687483210; 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=84jCH5csYFlMMdBF7z2xCF1DPFHya9qG/1Sk/ks2VEQ=; b=hOcUcInMs4JnVjQj2ZGvkpXlgz5dC1ExyBx89pSGavh3uY3f/mXgkaIXKa/ttgPc4a tG52vcl5hWvhNvGdfeDx5/3CuBgpEImIEFa5n9oZUpcVslaKy9/Uo+9o0grj2HIRnSWE 0aoImLF8dqdzIyO1EePCTTfboXa4mEb4v1fm3dkTIH4TrrPk0+7d9Gs7ZatiZfl2O1fm 2I+xYJwIEWYFkIjjEg36HQuXEqxNnhWU6V0v60Qgt+H1462O6vMV/zkciG/1TZT5QHU9 4BizBXXqmRkORlq3hMLjV2zVGWnVNq7UPZ3Qb/cDqgp+0KW596oAR/OfAamUy3RM/YKT qZSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684891210; x=1687483210; 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=84jCH5csYFlMMdBF7z2xCF1DPFHya9qG/1Sk/ks2VEQ=; b=gp5/pi2kv3u3AUXeCGHYrUypqebQFEg52O8ZE7AzoqKujZFK53Jn7tTANfQy6OPZZe fs0Ip/0uQjLOlwHAbJ2jCtiuycw3KHa+PtA6IVM5zgkgQRhKdFgSUDo1J4dgS1KvcRt1 9+DMynS5nVwfy9c6VI5Fe9mwurcTHTrRZ+xZmHFm5urmWx69my06iDIuLaavHa+Bzug+ iMvctWo2T6WQ5pZNgR712lJ60/ClF8/YmrCqqI2MDdB4Qd629olKhZVWCCVSF+++yDHi +0kfkmJwOeqQUF8hm6Znnd4KdjrgF3XYD4hpUxfeEZ7rNq8umT9iRXXsrk/kF0ARgcbX kJpQ== X-Gm-Message-State: AC+VfDxX8IUd4eQ20JjNc3V9kViCUW7w6Lq+ThYfd5RODI37tYT3Kp1m lsvzeKYT+RSC746E1i37MSNcV3vNKg== X-Received: by 2002:a05:622a:652:b0:3e6:3851:b945 with SMTP id a18-20020a05622a065200b003e63851b945mr24754439qtb.67.1684891210003; Tue, 23 May 2023 18:20:10 -0700 (PDT) Received: from C02FL77VMD6R.bytedance.net ([2600:1700:d860:12b0:c32:b55:eaec:a556]) by smtp.gmail.com with ESMTPSA id g14-20020ac8774e000000b003e38c9a2a22sm3298930qtu.92.2023.05.23.18.20.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 May 2023 18:20:09 -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 v5 net 5/6] net/sched: Refactor qdisc_graft() for ingress and clsact Qdiscs Date: Tue, 23 May 2023 18:20:02 -0700 Message-Id: <304dfaef69e0212b98c355a45daf85316d7ce47d.1684887977.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 From: Peilin Ye 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 --- change in v3, v4: - add in-body From: tag 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