Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4226307rwr; Mon, 8 May 2023 05:02:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5T6k5MDyNq1/NJCh4doOv2MeBgiw5/1iL96yZNWNB9M1KjIhkHM2/nqisS5J8IZnuLCmCc X-Received: by 2002:a17:90b:885:b0:23f:abfc:5acb with SMTP id bj5-20020a17090b088500b0023fabfc5acbmr10635112pjb.18.1683547342152; Mon, 08 May 2023 05:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683547342; cv=none; d=google.com; s=arc-20160816; b=YNlXJEtAjgtW+2v9o8zKvut5qFlAwONpgbvTJYQqmkzicFjSz4LxqiLS9kwGjEEtau AWY3J+buzpi2CHaKz9QGbRq2VUzt7FBw/dWltA7d2Rz4589GoGq7H5DH+wJWI0yrKQQN bNKZxKqwwoLLiqyEm5g0Bj7WKwV86bTRjYGCbOeaON9bH5uwqTU5zzK0IIfZzHNlmUKD VRPYijk73HAKmxV+HwluND6xzmsqLseqrf2n1WqbOkIH/in0BL3BdVTVvF9Pdf2Fpbv9 ECN3h0QPAVtQi4paiW8ALddhy3MUs8/PSov38grwpmp5QarPOBJmDW0NK7SuVw50z5R9 S0nA== 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=Lf9xP+nKNZcWbJUD0fYGLuCSyrgF1CkVpqBfetT/SAU=; b=VX6zCUmZ7S+e1rCcqZlZbjRALn08MzVCXbol0hGVW95i3ph5Gf1QHBhO2OoN2+GWWY zxal56dWwzJ1FHPG40fRZnpaVqiXXYIpMSvNpPiHGcbzE+D54j6CLETB1ctE4KTMbxzz qXZFghDmShSA3C9nB5GjnmWNO92367knMPoz7koIpJvrqLqmjjdVRYeLAEK3lTFXDZMl 49OwtrR+l5WgSLBYJB6UOFUiUwMW6l4gUQUokNbjH1Zj3vPNd/z1MxJQ/mDMq2yGUZa8 1Ck/BsINGiLEJy3N1YcYvSZ5Ya4+svnnOGjFtzsbSXgocTbG2IrCMM7Y+8LQn8wAq68G O0Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mojatatu-com.20221208.gappssmtp.com header.s=20221208 header.b=E6dUadmg; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n17-20020a17090ade9100b002476173727fsi12378435pjv.26.2023.05.08.05.02.02; Mon, 08 May 2023 05:02:22 -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=@mojatatu-com.20221208.gappssmtp.com header.s=20221208 header.b=E6dUadmg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235893AbjEHLaJ (ORCPT + 99 others); Mon, 8 May 2023 07:30:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235915AbjEHL3y (ORCPT ); Mon, 8 May 2023 07:29:54 -0400 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1255937865 for ; Mon, 8 May 2023 04:29:39 -0700 (PDT) Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-b9e27684b53so3842223276.0 for ; Mon, 08 May 2023 04:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20221208.gappssmtp.com; s=20221208; t=1683545377; x=1686137377; 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=Lf9xP+nKNZcWbJUD0fYGLuCSyrgF1CkVpqBfetT/SAU=; b=E6dUadmg+Ly4O4sVQh47014bqUNwGP9dxF8kaL5813rMQVWgWpomZo7LK4lgo+hECb X8bDFdqTn5yHRbBb3BDv7V/lZtaFQVFcPE2GNrwoKw3TA8VvoE9pZRsdn8QS0c6Ttl0K +4gSUqnMiDEb+afvJ3UHrkcmOtGQcI9aXtUiVTH7o0vBDgkQfN2H0qT80TvcAUhrxyvo z/AXJYe6goSRSsNoKCNqyyj8YaMBqfJCsGh7lWTOeI/nBUrbVGPKoVk5nw3bTiKnZYGk ZDu5+YQZS1/IgGwZCxjZBXSsPb2jOipUVkQavGRMtGGNI0vpWgyeFmI8NgNpc4x+JxUT Ry0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683545377; x=1686137377; 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=Lf9xP+nKNZcWbJUD0fYGLuCSyrgF1CkVpqBfetT/SAU=; b=TbPYojYUP9oz+gE84zwrmN8XIQU379XX9kfSMOWQaRuqcll6gdDczhCj/au8MM/xbX NHPT1XQWhOI3p5ByPBirXtttaW28wLj0WJPQqYEJUvz+1jND4CfVqZf1BB8DRxe0qtbD rf84ptR9F31UAsYzU0b1Vmb3Y8sJfPFQKOiVzYRx2NU6fCzqSQ+s366xgBFHH3yiEd9n ReHguj06v8ls5LsAAhRoNT4e8VAoX8f8enjGy0iTOZGXH33jilAumqZljcrwke5UpgBm sYFld0B+fHcbFwA/1tNCKRqMxZ3tC2KCfr8xyAYk9G+KciYcWOAQgaLwwGzK11fCoNLh nc7g== X-Gm-Message-State: AC+VfDxao1TRvGbM5BEpggPvtnk8akeO7N07X2pQL2hJ4OXW060YitHI jiH1TRS9Nv9WSCwxx/fg7CDrYmqk/dzKPUphFpw2Qw== X-Received: by 2002:a25:ab62:0:b0:b94:bbf2:6d9d with SMTP id u89-20020a25ab62000000b00b94bbf26d9dmr11309852ybi.48.1683545377452; Mon, 08 May 2023 04:29:37 -0700 (PDT) MIME-Version: 1.0 References: <1cd15c879d51e38f6b189d41553e67a8a1de0250.1683326865.git.peilin.ye@bytedance.com> In-Reply-To: <1cd15c879d51e38f6b189d41553e67a8a1de0250.1683326865.git.peilin.ye@bytedance.com> From: Jamal Hadi Salim Date: Mon, 8 May 2023 07:29:26 -0400 Message-ID: Subject: Re: [PATCH net 5/6] net/sched: Refactor qdisc_graft() for ingress and clsact Qdiscs To: Peilin Ye Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Cong Wang , Jiri Pirko , Peilin Ye , Daniel Borkmann , Vlad Buslov , Pedro Tammela , Hillf Danton , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Cong Wang , John Fastabend Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, 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 On Fri, May 5, 2023 at 8:15=E2=80=AFPM Peilin Ye wr= ote: > > 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 Fixed John's email address. This one i am not so sure; num_q =3D 1 implies it will run on the for loop only once. I am not sure it improves readability either. Anyways for the effort you put into it i am tossing a coin and saying: Reviewed-by: Jamal Hadi Salim Acked-by: Jamal Hadi Salim cheers, jamal > 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, st= ruct Qdisc *parent, > > if (parent =3D=3D NULL) { > unsigned int i, num_q, ingress; > + struct netdev_queue *dev_queue; > > ingress =3D 0; > num_q =3D dev->num_tx_queues; > if ((q && q->flags & TCQ_F_INGRESS) || > (new && new->flags & TCQ_F_INGRESS)) { > - num_q =3D 1; > ingress =3D 1; > if (!dev_ingress_queue(dev)) { > NL_SET_ERR_MSG(extack, "Device does not h= ave an ingress queue"); > @@ -1094,18 +1094,18 @@ static int qdisc_graft(struct net_device *dev, st= ruct Qdisc *parent, > if (new && new->ops->attach && !ingress) > goto skip; > > - for (i =3D 0; i < num_q; i++) { > - struct netdev_queue *dev_queue =3D dev_ingress_qu= eue(dev); > - > - if (!ingress) > + if (!ingress) { > + for (i =3D 0; i < num_q; i++) { > dev_queue =3D netdev_get_tx_queue(dev, i)= ; > + old =3D dev_graft_qdisc(dev_queue, new); > > - old =3D 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 =3D dev_ingress_queue(dev); > + old =3D dev_graft_qdisc(dev_queue, new); > } > > skip: > -- > 2.20.1 >