From patchwork Tue Feb 7 13:54:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2861905wrn; Tue, 7 Feb 2023 05:57:41 -0800 (PST) X-Google-Smtp-Source: AK7set/jdr0dCyNsMdFn08Ol/hlJLNRPema+dt0W3bOh4Swjfpvvtga+/AA5JRuotf9juSdLG/un X-Received: by 2002:a17:906:a297:b0:877:7113:71f3 with SMTP id i23-20020a170906a29700b00877711371f3mr3387606ejz.25.1675778261734; Tue, 07 Feb 2023 05:57:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778261; cv=pass; d=google.com; s=arc-20160816; b=HMUWLkvXbdTypCGQh2PlnNzEGZ37SS/a9+DEp9M6ZgbRNbTIN/KrnBjl1lSW9vCWkJ y+k81pJIKmuMEQZC8H2NTpFcLvX4WnkKfN21YuGVPj8VPygbWlN4tKsb8cJ02EFYzZ4M jGdnhdtmvzyF2ArU/HLQZKgk4SAaf6fPBL5z/CDN1rWcc4nJMunvBzTgi2s4jktYCnAn LzRgL1Z+akFd3s99V7Ln0EjmFsq/HFARxewJYIRczOACePWnOoTe62vKa6XlYOV6yigl xWGUyOqiwINb41JEV8faGI2jDRmJF5V168HYwe9v9+Kbx4+ZOxFUqPFlw4yCFHIC0PQc 80Lw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iBGNKAdOIbIQ/2WkVic7Z6QJr7zWWMBUUGX1u6+3xjM=; b=m0NDgLiak1DH6NtIdnAWl0EUUlJml9lFbn16optm3FsW991xVLUe6C6kxPwsTxS0XG jODfeyKreMXhjHhCGoQeSzXzN2W51zlTtVe7mBhyJHyJm9aIRyVMnSZqK8UxltaqIJ6f wEbC1TH4OqIB6sUFLMSEXFkTib5leu3En2cgDFNrfGKLJDz06wPs5Ww4K3GG9dk6WVgA oXj6yX48AvM2jJXIQ9kMKykpNJvwHzGjwtmLz73d2EsovIRPpwFk3sDdsOUWc6IgR3be 9pPGYi8B+5EqLyp3c08ui+1jFbQMErNrkjMZ6WothO5aEFiDHWrvP06U4hMtdRJme6dr vZpQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="B/O8rySN"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 9-20020a17090601c900b0088937812d25si19720150ejj.569.2023.02.07.05.57.17; Tue, 07 Feb 2023 05:57:41 -0800 (PST) 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=@nxp.com header.s=selector2 header.b="B/O8rySN"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232146AbjBGNzO (ORCPT + 99 others); Tue, 7 Feb 2023 08:55:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231956AbjBGNzJ (ORCPT ); Tue, 7 Feb 2023 08:55:09 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2041.outbound.protection.outlook.com [40.107.8.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2FF6F4; Tue, 7 Feb 2023 05:55:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kuMGCmTlVQULIPWG0O9oerq8GUNmSzS65S0bXhaSdfQss+Ai2dxGbdqX+vMXBhvQid1/noEkCD2V0SmKbnb+eUo/qj2h0GKGE1mtbsVm0G4MnCaoyTlpKt3zqcrmyZy1Ny4/BBOLiClnLd3MmUi4MxKzZ3qfL6X2lFXt5clgcfc29R5Z7PRZ2iFw6T1LkV4SpbtF4hpZTyUFhNXKHW97IfWrY2nl9fedWjKkdFrlB3T3PkMsRcdBE65bn9u0u0cdmhHyFZUncLj5ZJi1pjqTsVa6x1ouDLbcwJiJ2zakGQDtr7ksalUIEZCn1B3aIhOwqnG2YfMo84C5mPNOxov2IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iBGNKAdOIbIQ/2WkVic7Z6QJr7zWWMBUUGX1u6+3xjM=; b=OG4pScokNqSavJLveUjPsCvsDX9UjdFHcJlT2LpG4/BFM00TTlpHJFGvg1npSH735Z40XyAUs2mwjKCF0L/cd+VHr+PNbFXnoMPFO/Mk6A0qS+KWgOxaeux98GYTtQkNN6HjD8KT8PC1ykecnu9798RUnPV8PvkSFca4iH9yWWBkBKGMCFJ/nWJt5f4qXqwWXUqA/XvUSTp+4wQCxhcxr/kcE3Q+bu23AK0PO63hzo3mBQx/9GMrXXeHgC0GrL9n0cxrdD3ZhKp/M+bh9lsWnkbR5cfMC36YHFw0WMVN37EZqipD0VHrVi3L+kybZnFUsnZB1TvNVyS9q1nx35w78Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iBGNKAdOIbIQ/2WkVic7Z6QJr7zWWMBUUGX1u6+3xjM=; b=B/O8rySNVHrpknm0NzNNNoB/7VGPL5FY8+wzLgiaSwIaRFOWtVTBk5rnqH9QmN9dCFvs7MVp+YkZXYN45Oi/l8F+Y+dvP5rxOhrfU+wHv3xhEI/fFTinG/J6ODhuVWLh9OqKYE2OaeQ1jzlzspSawbMZvsaWF29sR6znMExLkng= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM8PR04MB7299.eurprd04.prod.outlook.com (2603:10a6:20b:1d4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.29; Tue, 7 Feb 2023 13:55:05 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:04 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 01/15] net/sched: taprio: delete peek() implementation Date: Tue, 7 Feb 2023 15:54:26 +0200 Message-Id: <20230207135440.1482856-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM8PR04MB7299:EE_ X-MS-Office365-Filtering-Correlation-Id: f4c3b158-b05a-49d8-9268-08db0912e973 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a9ykhu6Bwrmh2IpDm7J9OHPnuOX+zY5Lx5pMGFW1dvL+v/GZ6J6JJzoLEHWwgK0DmuPVjhMHaMlAgh+zwWP7gHQkeBP9kG9SGsJne/P7VMGBwjWvsiCZQrEiZ9/xyhLXGYisICL78AYj2NkE+qD1G0lh/GuW54ewClCEh6nH58ZmhZbchMCOYHi2UPjrghlbmdxchVzIqEcmj4QX48jNtC+t3DuoGx3ksWFTt1PHIl45Q+7maeSEKOGvSz4URba69Lg84PfnsAFCvrh3EKuyb3poBHx1ERWX8yLb/klorxNoBqC7qgRm/b93iHpaAaXmrZtuBcebcqwOkUzeSIU086rOvX5D0TO5YdWIThnoi5kn1fQqcFBLMJNRdGmg1zTBbPgypZKzKW6HojeUD8G4UOcTQIMYC556Zn+F2Z5bPIBjQBLM3mNdt/0P0jbczptzLI/yrjYZ7hThcJtiEnuiJzWCThjQ92AlNcVMvMJvzouWgyTRH1LMEidL/Wl/ebxUrMBsTxUIeJSSOw3yfG/+C6HPtxlshlFFp7zPxfqeY6vlF35/JN71r1btvZAJP3Ibm8g6+87QXyUQXLxLH+ltfMmtH2mqHHFil76rFB+T6y9nsxtsOwK8l38SnbS0SbYNhwGDps4A+yjwbpbxTbcDIzOoW7oVZuj3p3I6Agm3h/OE0sq2l1gZS7wzLxhioee53Ch5Eph4SZSiuKU/60cPaA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(376002)(366004)(346002)(136003)(451199018)(2616005)(316002)(26005)(4326008)(6486002)(8936002)(6512007)(36756003)(8676002)(6666004)(41300700001)(6506007)(1076003)(86362001)(186003)(478600001)(5660300002)(7416002)(2906002)(54906003)(44832011)(83380400001)(66556008)(52116002)(6916009)(38350700002)(38100700002)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 92202rSHbf+eOf9ecuP/XoUEKURX/NTjGO4O+RqPk6XgAftA+ngI1x+YeiSy1+8P8AmzJrKddWw8blGHZyntVb9MNb7IqP4rMtj20lKQzOdGnfvu73O+4gx5aQ8xMXFPvfB91iaj/IYN+K3FzPLBmy10cn5IXww1DQl5HvQ9LbrcrfqwQ7MNUDgmi3seE94MQK+sQGNMZ892WdNw5VaUdMfh5GqWxgJGOym9YRxWbMx2jq7K7FEYqpCVH3S3Ob1QjG5LWFTsDS/iWRSwPvn8DFcwuiw+sBlCHbOBgyfSM8XTZStpysRwdOeP4vuH/IzMvVNDOWJY99OYcgA/y3DL3vHArD5ADih7Qf8fNOoi3Yrn/OtStBqvCyfOtcsygJ2vt8xe/hyZigw65oU6RV7bYquqM1exBuylglbEug/bgxhHuGUs/ssekNmIj3bkl/YYjLtfycbJ4iaMZL4bTOu8r/idKkE15x7BcH6YGsJzJfZL+7r0EblkpRzcP7aeEttoVadBRFrgTMWWAyyR696Qw23bGyvD6dtHV4Mei5t9IHcdARLVH8nepWqkgd1oPTrwNPFqm7UbZuON738Zjj/z6ZXp4pG6SheGYeTTdy64pf5vPpRSIHkLSnt+VVyEMW1ESQ26l3/aKU+oJVn1l0pSmIi6ZdosalQzr4PRwCaOwm4RQpA+zZGYj27JFgPUw/okZf+zgqtCHDVxzAQKU9y2ImCqFWQBeUkI3qHvk6pChIe7FJZyG+2qVqviTuyTa6qHZAstyzk4UYG9BZI1hEBb14+cBVAGg80G0JhSHBIh/Fb2WeuMndlkc+jGSNbkM3N3SPU9S6ThUjbbB278VsM5OV8SUkmQD4SjYQ3SbEq4JAALLhOUDQzkyWwnpGj1D3xM/TB/RXObzz59RRe/317N7/tKvur257bJalYdrfABKHhG7hwpHvhsrX61jb7piB+I1gvvH8tJ5ZzrizPqvtGuoXNKXbaPa37oYx2nffuvQJurclHiXbI/B2pmUbi8k/5wVqtATgEaDFmSUIIBa0FV/YvQ0lMYdq2x+XI7d1bTEHd+FQ37hvdCdy9Q1CHf0hgV715ciblPWR3Tsh8ZxWlJbyALF0VUQDU3xooNI+W6CQQFx0zbZrq+ZsqgkWS0eweqdWZVqq+cBOqWDjkifppMEnkmHmELXT3vjcuj/HSLzx3tmP55vpOHn3WWt/1vCsBSuCQACv2AVNfzgjj8wg3L1Lp6Yb504xnTzbN+PpWuaUZG/LIs+iMmNyJcZ0KK6/a0vDYv9MYqtEzlh6lbFtbQphE+FvBw4hSTDw0utUUxhIYlwYt+MsmkV/x3Hia5UxBxxnSEBUEsCm0jZNezQW4xeeoMSntHZQaBR0/tHqyOTVhFiQwhTklMAXo3BICrqaacUK7JOrKxSC+InnJ6iEOUrQ+hOaAdOLdie0T2Tu3Vu9z191KfjGxleu356Qk2mKHfmG3BdIpA/mM0Wg8PsBmn2Bj2Lcq7ZwsvAdLxbPAQV88TowLpeV4xUsAB/5Ka6k3+hYk7eGDqvwuFfiKrOY1ulFTu2/W0zNr/nejcDSMpBDSpNMHGs2tjna/Ecq/U24Seua0+g6S4NtCIzPesH38oFQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4c3b158-b05a-49d8-9268-08db0912e973 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:04.8626 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HBP7/2Zvv8G3wGi9XKzDeNrDDFXxAo4DtKRZcPJJEKdYkN4L1WVNFzDqPWdfWspzU9c3kIKGn8kp6MlcpD3HJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7299 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757180866360024989?= X-GMAIL-MSGID: =?utf-8?q?1757180866360024989?= There isn't any code in the network stack which calls taprio_peek(). We only see qdisc->ops->peek() being called on child qdiscs of other classful qdiscs, never from the generic qdisc code. Whereas taprio is never a child qdisc, it is always root. This snippet of a comment from qdisc_peek_dequeued() seems to confirm: /* we can reuse ->gso_skb because peek isn't called for root qdiscs */ Since I've been known to be wrong many times though, I'm not completely removing it, but leaving a stub function in place which emits a warning. Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: none net/sched/sch_taprio.c | 43 +----------------------------------------- 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 1c95785932b9..d9e26ddaa7f2 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -499,50 +499,9 @@ static int taprio_enqueue(struct sk_buff *skb, struct Qdisc *sch, return taprio_enqueue_one(skb, sch, child, to_free); } -/* Will not be called in the full offload case, since the TX queues are - * attached to the Qdisc created using qdisc_create_dflt() - */ static struct sk_buff *taprio_peek(struct Qdisc *sch) { - struct taprio_sched *q = qdisc_priv(sch); - struct net_device *dev = qdisc_dev(sch); - struct sched_entry *entry; - struct sk_buff *skb; - u32 gate_mask; - int i; - - rcu_read_lock(); - entry = rcu_dereference(q->current_entry); - gate_mask = entry ? entry->gate_mask : TAPRIO_ALL_GATES_OPEN; - rcu_read_unlock(); - - if (!gate_mask) - return NULL; - - for (i = 0; i < dev->num_tx_queues; i++) { - struct Qdisc *child = q->qdiscs[i]; - int prio; - u8 tc; - - if (unlikely(!child)) - continue; - - skb = child->ops->peek(child); - if (!skb) - continue; - - if (TXTIME_ASSIST_IS_ENABLED(q->flags)) - return skb; - - prio = skb->priority; - tc = netdev_get_prio_tc_map(dev, prio); - - if (!(gate_mask & BIT(tc))) - continue; - - return skb; - } - + WARN_ONCE(1, "taprio only supports operating as root qdisc, peek() not implemented"); return NULL; } From patchwork Tue Feb 7 13:54:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53896 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2861939wrn; Tue, 7 Feb 2023 05:57:47 -0800 (PST) X-Google-Smtp-Source: AK7set/v1hH6fnfPribGht/kPUoDl9gbpYsUR5w+lkEIcDqVcK5B3yv9I8Y+9khRIcDNjazVa5nx X-Received: by 2002:a50:cd81:0:b0:4aa:b18e:24bc with SMTP id p1-20020a50cd81000000b004aab18e24bcmr3481042edi.39.1675778266957; Tue, 07 Feb 2023 05:57:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778266; cv=pass; d=google.com; s=arc-20160816; b=A4L/qzRVI2GMinOwWadaAxaRAEfDATFZr9TNear9Vu+1MIdPdwUCrQHlwhegs56QAl XYMs0AJVBGsqVW74bol9A+d23puTlANe0NHsLQNqVJX1CSp7lwZS80Ptms9RPG1WtZqH hkuUNpgfwhjat+v24B+3sBTIOjAviaUqNilCp8iGXwCuC/4KSQg6TgMtmCJuO9VQtUVP ciGC6+2CdzLCrF1Q8L3RNpMDJzxs9EPhd9KX5ICkMdiw3JDlpaijNrAdX2qoYDBSismV X2wSSdAp9CjMkoGsfcDueYZcb6E9GWOsmJU4qWvX85J9vzNmMk3Njx+YW/xFdnxR/zTb MFBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hFYn1LUwHig6bqMdHhQTcZdRtANbkDTMUdKiVG+jejE=; b=NMeKSyKP2loI6jkQcWeLKbE6rUtIVaF4CclSzwVpwEfqE+tPogmOKOQCG9LvTBjljz tmN0u/m9ms8wvKTHW7n1EtbiEBaoNp9yJT8oCYvho1a13HVNPfebdz9WLlfOta6i8jvd 3JzvbWENkAs9fpbn67l6XEbMbMDb/D63vgJjsOQTp0dsdVOEblyF7ghThMym3BBtW5zQ mEVUYCfGUZRUJPCud3eGy6ubUAIn+l4AhTQN2NW/ZJS6vQRGlWd+ARM4Wt3rjOCLCFBL RI4USj3/j2HNwUcq6TXwi9STONYeXzTgVUEBBRvYVbuxjk3qqlh6f36wqRYf9A2Ve5Of JZzg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=QoOF426T; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fd11-20020a056402388b00b0049e24a14a25si17090115edb.250.2023.02.07.05.57.23; Tue, 07 Feb 2023 05:57:46 -0800 (PST) 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=@nxp.com header.s=selector2 header.b=QoOF426T; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232137AbjBGNz2 (ORCPT + 99 others); Tue, 7 Feb 2023 08:55:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232218AbjBGNzX (ORCPT ); Tue, 7 Feb 2023 08:55:23 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2089.outbound.protection.outlook.com [40.107.15.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB58F38EAD; Tue, 7 Feb 2023 05:55:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fkvGjWMvsZWYDgI3tWl5ClxwmEJbnNOE7t6ncdIOvAfB5D5Yej18WuY05UfqJ6G339S9TE+Tw9fOHMNCz9+OlCownQLssm0bLXF6mQXW+/ScEyJANjy7huZetKMB5L456PQEad8UNbkJUkqPZqwQLcA79gBhTwfCO7QieIqT+DfloS92Lwzsv81b+HHB601SPyI+KJfsW3x0t0+Tq4NCZv0RI4AQsLFe4QPb7kdzBgoejnuJI7Uv5Erd2vcB8Pci9iWy/Qo9fGhSEkzXQXqVxQxeabzdiMvVnO6QL5G+UQbQpmHUfAsMfYb3vFI10sZfrPbwNB7GxI3c7H71Wg0GYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hFYn1LUwHig6bqMdHhQTcZdRtANbkDTMUdKiVG+jejE=; b=JAZtB3UYndaYCM74VnyooNLkBOOVcQHGkKEX72PK80Jt4SkEjfFS/CbcuK6+j3NVszppIY8u1LS8bph1eiTjkkM238JhVcboU4zFrNQZOwqE5MPO4XoY1wIzo3KUPZwHBlY+LA0/b2uccrkmZJIDsYfUzuPl+mFMUXPC1CzYxdMH2KSLaEHvH1Bt+X6uXjFFy3HQLTlZwiWO5R4cIoR1RORenV3U7gnW0bWhMYFis9VS9i4EF9mdHO4jSYtsBNtVtX1qyMvOso4PsPuxIQupMFancf/RjzSd8rTj1QsXhmB5EZ0426tXJI5Nzzz5g1SFQfM7vmCKG29EhQHOpDe5rw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hFYn1LUwHig6bqMdHhQTcZdRtANbkDTMUdKiVG+jejE=; b=QoOF426T8rA3IVDmGxt4ErkmYafZOcpxYIMnAuWj57f0RJAB1QfU7WzzxTGEFd3OWv6J4cdgtx1vkGHrabvCcwStywE8dicpiTYFanY+ZTT2pCKlmThDCFEQfhfIe3+G8xj4N4QyoUazGeJL4FQWbFicsEr2marTvLD7sJNUbh4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:06 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:06 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 02/15] net/sched: taprio: continue with other TXQs if one dequeue() failed Date: Tue, 7 Feb 2023 15:54:27 +0200 Message-Id: <20230207135440.1482856-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 865c8c28-d67c-419c-4d9e-08db0912eb3d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1nVR8tYHFHve1f+7siCcuqVc3Uk5NpKF6RigXxdRmt4dW8xUXC4sH0rbdUwq4OB9y8acYXKhmtceSbWD1IYiRgWWvFFNz4nHBsxPHHTxuGXzovZ0mxOi8MR5srwj6FPIMP01j4Kfn2/4rmhWq0Kq0JseqV8qxB2HsFSRptr5NqV4rVQf+eTgIfKPeB1I7xCpc2HZ2gobofCjqIGPn7yCTYoUuQHVx/932dYwU/pBELoI3V3W0rHa7zfzsQ6TnpVroxMLNqRmagInPBMPnO2D4U6S5VWXlOh0l4TVeQcQvDDo+UWsXp6uSUX3QQL8+OYOi0Aq6HWbZ/YnTkec3MfdgaX1iew7eNC2pi0DjQlLAhC0NOH+4+oeDdMIzWmttlzO9nIo//gtgx+gEhTAAqzzkj033QPRik0+IfROGq6NCoxKe19KTbtB4myC6nU7bHQ/bcsqKNLjW1OFz9MAUoY0ZpbB8hUVINSnyou7R9Wo7yI+4k//VDUzWTya8CA+ZiKUjtSXnCRdBF2ZT7UOxUwUSIBSvrYgcpo1Wtzaqsyvbm1GYi7mZHCGH109drziXOIrarEaFpWQ54gdwoVROs2ddbbyWOhCe3N/TDZOlqgjsvHR4omUqy7tSuerEhqNv+onFw2g1pk/DhuU35baC8YEG+neVjcVcoWNTfFQKUDJFQiv9U6LvoP86oKHXl8XEKC6uB4N1En6pAzL0kzJ8o/vJQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(2616005)(6666004)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003)(66899018);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4ysDQypWn5AaN0x1tXMq1nha2TuhqA1+pYkbbLAJFD8TycpgihJO8DVUE1ppErOmI2rPAHvyU5tLl5XG8qEbvJtboAeIW4W69QnpQ3azbtR9Y333PgYPojvFwR3Ny5ZuT07cYI+j4BjpIWNULJD/p3wFVlCtOckDpQg/sjBY8DbSreVE0j4CfLThcBXfnDGRXuuqe3lvr0Fd45sGyoNufUtKjSc53HR85iA1dM65MbyrhCNAZD43RS1B9G1zksgQ9vWbqc2Rp0f1Spxtrqb+YWExCuQPNMdFAB5VfFI8e1GciamFdwZPqobHOpe9XU7MjVfFpRpQ3AC6CcsEGcOy+A8v8qx8bbRpkW1VthTDwvnt1kg/T+BMcnMjWWYlW8Bm5owOIS6sO7dYQmlSVIuuuxmj89lcP4IInebfX5Hq7F/0kCZ0vMEebWJIOkHY1pbIFR5woGRsdhJDuF86ZIqvt5UKMwSxkH6QdZNBLmaepOTeflt4EkDl1oaXzeY1iCoR7rE5HUIFBCuQaZuW6LFfI4ucZAA51J3rDWqSxXofD5v8ijrGtc3WwQ6cUmishHbDHW0enioxr2BQrBDqQ95padC1zxV8ndhYI795Jdy9B+jGBfXPJo+WguWqes2T4y/RL04/Gw7mJ9K9DHNQa+KXgMTIxa6X8c6FprOaGYeECpF+QkAvfjeZx0TBtSrUmxPutqKz3C4oFnQolCtoPi5CIsLGgY9jktrf13q10q/B4dfcN2ap9LnvEB826PjP7tseoPoSihbkclI2CgCAJ2jucs7kM4UmNvbNxPWkEW/FygrhjBY/fNOnHMudWlXVyWHhnOUkivi3PmqBvwyuadAYYIyV3xIKr6hoeO2LdX5VsXSJM5ir+PcvHlAzO/IfKdNI5Z4ziS0NTEZx5GIdsHH4bQlgMf9eZgnuIusb1DHnuzyK4/FfG4GTDifeZsRNGK/PbYU72unzAo/d1bXyWgQ+3xakNkOrTbW+E2g8DhOxbnP4EhTJ2ZUmQ5FWc1mSfpfo7Ct6d8Kw95vfHx30SnA4a/Fw/kJXotInzlrEdwQU0Z9Imln26g2Hz345YQ2Qo1Ra3zXJNnbW8soMbVW21GCAYyz0U241um38bEzgx75gWLtPR3St6jd2kV+Rb8OqZOiCQk1tHDUFqfaSrXSpCKdqjwh0e+M9GeF79jbTXCXIWYhrZEu0kBfAaH8V+2yllo/56w9FXoOb39FcjgM/tjPCF2v7vUEJHnM7pMNNVIaqj0/he3oIb5WoUDzTagqlk40QIHA+bqQKFhANPp8m7KfR64rs4xZ7s69AshrQYlj3EHgPTAnDKjDM041srImpTxlKT0uFflI9ZXqhWB2eyJJn8BChGn1q9JQxqxzliCF9kP5I+u6TjPW7k/74f2f435ySE4hFSvv2iaEc8VdgHjvpSE/79ITDsE1c3Ba+fzwGxQCLh2DbGydYvnqrhKwx6ZgDN4Jzo2bkpDjoV/gJZcsPfjgc658wwRKkFKJK3f0clItgrMFjq8Xp6OHMiNgP7s+qWVb6SbsfO9CC7GapQGnog7F9nxasbr1398b2kVLN37KVS46ywVjaHiWwks90dRnBGmWcgqNxxqgMy7ySRu1VSQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 865c8c28-d67c-419c-4d9e-08db0912eb3d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:06.6906 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KVdRDMN1Y3EpGCtgavt4PwuSltua+1KH9DK4e3vbjfMgqENz6zgFRVlUNGeD7G3sGGOM4R+QMpVakFcYsVKO5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757180872022005128?= X-GMAIL-MSGID: =?utf-8?q?1757180872022005128?= This changes the handling of an unlikely condition to not stop dequeuing if taprio failed to dequeue the peeked skb in taprio_dequeue(). I've no idea when this can happen, but the only side effect seems to be that the atomic_sub_return() call right above will have consumed some budget. This isn't a big deal, since either that made us remain without any budget (and therefore, we'd exit on the next peeked skb anyway), or we could send some packets from other TXQs. I'm making this change because in a future patch I'll be refactoring the dequeue procedure to simplify it, and this corner case will have to go away. Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: none net/sched/sch_taprio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index d9e26ddaa7f2..0fde303978a5 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -587,7 +587,7 @@ static struct sk_buff *taprio_dequeue(struct Qdisc *sch) skb = child->ops->dequeue(child); if (unlikely(!skb)) - goto done; + continue; skb_found: qdisc_bstats_update(sch, skb); From patchwork Tue Feb 7 13:54:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53897 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2861954wrn; Tue, 7 Feb 2023 05:57:49 -0800 (PST) X-Google-Smtp-Source: AK7set/dO0kGV7q9Ac4G68E3IhJYJI3zS1Kg9EVzG4TfHoL4AxUOgaRba+SMWJaz16OyrHMlINiH X-Received: by 2002:a17:906:36cc:b0:896:43bd:7914 with SMTP id b12-20020a17090636cc00b0089643bd7914mr3350228ejc.28.1675778269150; Tue, 07 Feb 2023 05:57:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778269; cv=pass; d=google.com; s=arc-20160816; b=Enz9NWX+6XtZ4rNl0cYuxshbMWjoY6qtN1iJ3gUTtw3M11AYlj1JSdX8jBmkYz3VGH GDGdLz86RqU40SqmiWKir3Xw1CwnrIAr0bQ0psp9/3VLzHyL2S8nhqlzYiY6XFLs6JFN 1ywTkE4W3vLZ2j9NwPZDZRpQkuXoqsogUivoT7MdHIC81rp4Yj8c07yz4N9BRcuUVpKY 8mu+WGYSwAmCeElOAD1PySfkv0NsU+PQZ2HAtTQCxb/IUFVHn/QfkUgyRdmrfbNRTf7t YqLhw974m6dVCrUbxA/1LvlKX32n1izX3kXSlBzZ7585C7/QVMw65sk6lQCrj05TprWn EDEQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zfhrjPSjui4if/GUKgW56m5Qa6cwOnErqbD1OIc1QKE=; b=KK4WrMqdXw/Zyb1uzh2cxPAwDtnKR+bG+KWL4xJW0JkK9/rtnes7BCLrVClcGpHmJN I4TzkfKf7Y6/tr+RaUxJGrts2FD9OgkwlMr6hAWSx52kLCSRt1wte2aRKTXICU4TCJZX bwl+yN5hJ/ckPBz33h19boABwJe6NkhUmPrzW6i+hrZ7qCX1jYphWkW41t1zYEEF6ydB I2G2CxdiNUQzuHzwvWq1twk2hfN5u2iEVHHAyg6X8hfdK47rSm4DQ5BnSeHhlwd1TV3b 5FziPzaJrWMly2+Jhstzb++HjVrhRMvD4Jm6ukXMeTVKGC88jr8xKFtv3hhKtBD48gKX vcSg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=E13BP41u; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fx32-20020a1709069ea000b008aa7c6e555asi1183967ejc.57.2023.02.07.05.57.26; Tue, 07 Feb 2023 05:57:49 -0800 (PST) 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=@nxp.com header.s=selector2 header.b=E13BP41u; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232135AbjBGNzc (ORCPT + 99 others); Tue, 7 Feb 2023 08:55:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232236AbjBGNzY (ORCPT ); Tue, 7 Feb 2023 08:55:24 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2089.outbound.protection.outlook.com [40.107.15.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1517392AB; Tue, 7 Feb 2023 05:55:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jhin7T+3sep4cfnBejxE6lXjilUdQbmOAEIkjIpablbpdcG/f6SqvW5+qI1aGCQKxEw/QuR0hsHi0siFb+vozJBh+Ow6GNiRUM8RIwYZmI3oMEA0GAclgTTFoDOz5Pc1lk6iTafmnZEHRkN14Pf0e/nXOLcqNakhzt4szcgxKaUfJQ19sFXUH+zArUK7Nw/qZByX17ftOOYZew1qS2DR93uay4esdCPxQPjcalxk/EzJ46nPZoomeFKyRPZ/A7FpZCU/jZStG3Frm5NrWIdQAbPR1H1BexSTFA9u7mvndiXdozsrici7+7NXgSVAa/mucph9Z+MBeJ22K4zm1eqqBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zfhrjPSjui4if/GUKgW56m5Qa6cwOnErqbD1OIc1QKE=; b=YR0hxPyklRvKpOBscP9YVgp7fWZLQttckUTEeoKHeMp0PsHjjLJQcnyCJXzUQ7nYjVp/l77gSuPleNHwGh8GlppcATnGYmwkuC0WCuLKRpVodj41VZTT4v6+riR8KgeingtExDDwkOfhJ7h/9pqFs6gJDM4QgToE+UFGbza/CMPmHtGEJ96QpKpvKMiOhmemJuWkBlvGnybEEVPCRH195pIHbylEj5FkxxHkAmU94TeMxUJkr3uZ9PxhJSn6kKRYXblKJb4jNFFGKW8FTdK1SkvGqy7tkUaqo7NK+U8YxigVMC1BDCHIxyQXz/pAxn2pXl184EIXmX0JcxVwdEXxHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zfhrjPSjui4if/GUKgW56m5Qa6cwOnErqbD1OIc1QKE=; b=E13BP41utSGx/QRWzre8/cpoKOkJpTrINPtBqyfvFWXpBGFiIHO9Ki1uDDgoxxHiRzQbcAjl28HbBb2qxPbrhLaQlGPg0GspFbjeCqnYizbqDgR6qcJx5Ty4Oe05SbfrfPJmrnj3aMW1G9Xyg+SmdBEKHnAyxyTpB1/2GlKAc78= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:08 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:08 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 03/15] net/sched: taprio: refactor one skb dequeue from TXQ to separate function Date: Tue, 7 Feb 2023 15:54:28 +0200 Message-Id: <20230207135440.1482856-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: af1f0f20-4742-45de-9e97-08db0912ec56 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nYzKwNjxBjDKEDsxO4lIqXq2qSZ1Rpb4zpDFXMgA/Si+oAyLnygAHOLuQezyZq9yU8YD/mGoahsTOSPkHAKoS8YWAavNY6sXDOR4Vm5moc/y94Zd+WWXBtGqQCFajegEDb9KDOwLsSyIRb8Qv41uLKDYbP3v5QXXgavMrbVU2RilOp7arXdqQCcSg/pjk2yuZhxEsDinuJU0303sfrCRZGB+U5mKUahbQ5sx1lG1Tbb1k/66PFutRsZ3EgiiCyOE5UD6Z6GdvLawBgY/zVYYr9RT0vAGaeBvegFfGn1g3mSY45en9n37LJMezcQ8Yjcv9CbllJKXDANfjmZAdJ0jZ3lg9BW+mY+eVhXA2TS9BuR0UQzLvgt5s7jnvEtTTMIVdqcBqUModafI3/7puMvWG4nfXiYW9wNEdbhISoerG8bbmqKXm2kcOdnCcP1mBCsB1t75vVR+ykuQhDxIPXWGxOkKUuALt9LJPOiojWWUsIE1cCYstfG6LBo3yx/XEvKYAisktPgnbrr1cXkPNStVbQzsNWO52efwIKyFCtTCtT6hxG2nIFOgrhDZWDlflC2vGgdHh5TJJdi3QOQ7y+gjs1uWNnZhPRyt95+sd0moXex6+9z+mwwjx6z3RrXGhSbVByHGq6mVn5qqoxPXK1Dze9LUe9kDvfadwTTXsZEGhBrMlTXbSkpqmOtJVGdnYaAbI5Gxmlo7H0Le5D+2LorfVQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(2616005)(6666004)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r0zTEVyFLOB+JQnoOUAPZr7i/tyfie9JUef8Gl9zmgmP7DdB5C55GJeOo4vQ9pIYaaxI8tWPFP7l6qYvPVflvQQRyv2tOsLHIVJHqaeSSCIHIR5AoPL2bKPd8dDtxj+YXlGlNzwgDiHUYVhsmHQMshwQv9djcFlddWtBgqe8J2SmebYGwjKfFz7uWAUVGO3ZBsMV03Dz3rPJHDuBnDcLjkQFKxYBSmF/bdsDRiDmpNJqOlnIdWGxWmMRAPXQrN1w5ChPf0K4Of/NudZFrBq7+d4NsdkTbpqE0D5Eb/VXW/3jOitUCr+DKNdy93EjuDZlmRD2ZT+kuDPVn4Qhik8HhIaKlzJbwHGh8QTjzvVQVIa439Zw1EIL1fapd9Ggwraj/9nd9msNOTmWj1oCTtv2iZQR9PHzEZi3ukYUqR/Ipci7xQp4G5YPf2da/iDvDgtATZ9UgqWnbr/9n3H55zj0zAsbp+cfA6VipWUpDXlNFEl687coi/yNWaD1YeRJkw0y/p6Gzjvk2GtmT4pJ9tzOVr27VNUS2LqY3itJH09LtVYDf1z6aq7UOz20MmVpKeJr2hysW9+69jO9oeT0MJvkMgDcUYWNHihQucLvasyGGjbe3f2RPY3MhonPn1uRRjVpjeIv0VbHJykXdgagdl1dHocft7fS9ldzFj4NJ9mEiPqVX2q2V+5Cni53+kw8tK6PA4kih5qldB3v8oi60ZVwjDPj8ZoZD1Af06v4N/TMRMIv3bltBZ1lH7xRO+6K13+SiA0jMULs6qHx3ccYdjXF7W3Sdw+QMa9eeIorKSGIe1/+puNjxw/GT8xJmJ/AIevG2eBYadydTYI9+Vf/5N+IUAwbh29wG5PytrbTXBtDcsJazp5653zH3wgD4K1MpjFUChWZjYxPiz0gVMt4pLguCc+lRV+YLWCIpSpwgSDluCVaWXN20RqOE9Wdd6Zqc1nZ/5qLXErGUOB+ItoiWhEYMEOjrLKTLdivMSI8HiUz/3+3djWXgIauf9337y5MniZHqCnTz0IjZ5X/r7r7FOQyBQm9TDMrF8L+9i+weRsxPOP8mxMNIM21hNAk5TYF88QzROxNlTacuABy9H4anVJaoLyXipnxsJTbHQ5hKAMgMh3t7Q7Ro/BYS/qCZaoc8F7kSbV0+uzK3FnZ4zrS9AqaCo0hLZxpaPRIzkO3UVKQEqLRnXBtwTUwC/G1BVh6howPMkslsIc17iHdCXmb/NK+aIeDbzisJyWPJlW/HJFc1O/GBgHinhCR+szIT/18Et8gv2rAgHqSl6mqTSuBvo1O5ZjDnOqrQEapJqDVDG5dyZsH0m/UzHnBoGCpKg12Zx4mZx4uJnWj6+kL93EcOjCDajG4zlRawpXPEPw2hz2N9Pi17YvZ+kP0djM1vZWR0UrFBMSSUYPyqQ6POznaWSji59T+qoM1ImmARAo53cZAgN4A9XXr49QvO2C1DGZ3al3sd62gU73mOTj41EqoUY2/PfojEBDVl5j5vWMGSWR46F2GrD2ygsMZf+MfWtyHOwZ346yqdvr+8VLFoJ2w0XBm+LcJPQCGE3A12ZlpBK2XN8JUmsJOaT7HYRjgtFYlnXRExe0F3uWQCgjZ43kERGFt4A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: af1f0f20-4742-45de-9e97-08db0912ec56 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:08.7217 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kI7xcjmsZ1AMQbmkJdWZb/edO2Ywy4rXu1NdMEUtE9hbfjpO9sC5d0O9ua95nvb/7zcSsmKgHuk4Zj2B9lApxw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757180874317363940?= X-GMAIL-MSGID: =?utf-8?q?1757180874317363940?= Future changes will refactor the TXQ selection procedure, and a lot of stuff will become messy, the indentation of the bulk of the dequeue procedure would increase, etc. Break out the bulk of the function into a new one, which knows the TXQ (child qdisc) we should perform a dequeue from. Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: none net/sched/sch_taprio.c | 121 +++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 58 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 0fde303978a5..272a8b7c0f9f 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -512,6 +512,66 @@ static void taprio_set_budget(struct taprio_sched *q, struct sched_entry *entry) atomic64_read(&q->picos_per_byte))); } +static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, + struct sched_entry *entry, + u32 gate_mask) +{ + struct taprio_sched *q = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + struct Qdisc *child = q->qdiscs[txq]; + struct sk_buff *skb; + ktime_t guard; + int prio; + int len; + u8 tc; + + if (unlikely(!child)) + return NULL; + + if (TXTIME_ASSIST_IS_ENABLED(q->flags)) { + skb = child->ops->dequeue(child); + if (!skb) + return NULL; + goto skb_found; + } + + skb = child->ops->peek(child); + if (!skb) + return NULL; + + prio = skb->priority; + tc = netdev_get_prio_tc_map(dev, prio); + + if (!(gate_mask & BIT(tc))) + return NULL; + + len = qdisc_pkt_len(skb); + guard = ktime_add_ns(taprio_get_time(q), length_to_duration(q, len)); + + /* In the case that there's no gate entry, there's no + * guard band ... + */ + if (gate_mask != TAPRIO_ALL_GATES_OPEN && + ktime_after(guard, entry->close_time)) + return NULL; + + /* ... and no budget. */ + if (gate_mask != TAPRIO_ALL_GATES_OPEN && + atomic_sub_return(len, &entry->budget) < 0) + return NULL; + + skb = child->ops->dequeue(child); + if (unlikely(!skb)) + return NULL; + +skb_found: + qdisc_bstats_update(sch, skb); + qdisc_qstats_backlog_dec(sch, skb); + sch->q.qlen--; + + return skb; +} + /* Will not be called in the full offload case, since the TX queues are * attached to the Qdisc created using qdisc_create_dflt() */ @@ -537,64 +597,9 @@ static struct sk_buff *taprio_dequeue(struct Qdisc *sch) goto done; for (i = 0; i < dev->num_tx_queues; i++) { - struct Qdisc *child = q->qdiscs[i]; - ktime_t guard; - int prio; - int len; - u8 tc; - - if (unlikely(!child)) - continue; - - if (TXTIME_ASSIST_IS_ENABLED(q->flags)) { - skb = child->ops->dequeue(child); - if (!skb) - continue; - goto skb_found; - } - - skb = child->ops->peek(child); - if (!skb) - continue; - - prio = skb->priority; - tc = netdev_get_prio_tc_map(dev, prio); - - if (!(gate_mask & BIT(tc))) { - skb = NULL; - continue; - } - - len = qdisc_pkt_len(skb); - guard = ktime_add_ns(taprio_get_time(q), - length_to_duration(q, len)); - - /* In the case that there's no gate entry, there's no - * guard band ... - */ - if (gate_mask != TAPRIO_ALL_GATES_OPEN && - ktime_after(guard, entry->close_time)) { - skb = NULL; - continue; - } - - /* ... and no budget. */ - if (gate_mask != TAPRIO_ALL_GATES_OPEN && - atomic_sub_return(len, &entry->budget) < 0) { - skb = NULL; - continue; - } - - skb = child->ops->dequeue(child); - if (unlikely(!skb)) - continue; - -skb_found: - qdisc_bstats_update(sch, skb); - qdisc_qstats_backlog_dec(sch, skb); - sch->q.qlen--; - - goto done; + skb = taprio_dequeue_from_txq(sch, i, entry, gate_mask); + if (skb) + goto done; } done: From patchwork Tue Feb 7 13:54:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53900 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2862213wrn; Tue, 7 Feb 2023 05:58:21 -0800 (PST) X-Google-Smtp-Source: AK7set/+SQ6AJXucrcNBk1nMW0xcW9X0D+hpdjxqFjHcsTzgmmT2p8ITPgZhRjJZ0CPQJnrsN9FD X-Received: by 2002:a50:9b13:0:b0:4aa:a856:e2d6 with SMTP id o19-20020a509b13000000b004aaa856e2d6mr3369367edi.37.1675778301459; Tue, 07 Feb 2023 05:58:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778301; cv=pass; d=google.com; s=arc-20160816; b=gLN1Tz02r7LNlZWjKSxH97Sxifx3wPtgc6/ml2fDTsieRP7prf5AqvEtyNoYvLJLEE MISnjAi/9M9Ift0pK0BmFPnmz+c4BlfCitF6n9XjKWChjVXB3Z5JCKHaRqCzALQ/RFlR AIYxPPcWp3K379DKDJUH8J/St5XWztMgPT81udarHvcPzeu8FfwTrpV1tt+h9ZgKLR30 Qbzxv9LBkv36N8HZE3BX11L/6sLbblC3/30i7DawF3AqEvhzqhTpx0XrjO36EK6Rbur/ aQXsRC9zIGhLYqQaitq9o4A8n97oLg81j9luLtbzPFjqtaLRKMPPnb6Wae7r6rJJd2xl 6apg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JGPCc0HrFlOBWwNUYy9zVP6x9GjYLQMVOZ6bc3/woHA=; b=zYC54UNt0JkCKpB3LDT6CzuSjbZyDZ2v1gXuRdRNAV5z47DyiFIZ/5bWxcbA5zvDDq TxwI1dI2fSBWAfSjWr9NOdluJOP7M5jkqkmzMWMGP/Z1TgF3M/bQfYBfGrcs+tMCU5Zs TgfEwUyWurNqLQljjFXWPRZou9qWHjo6oXQ6uFQ+qtJWPdZ/h01z3b2LnMLL9y5n924T zu17Mebn4tANTLEQWnWxbNNU1v/jzQ9SUnKZbCUj1bz+WXDBdq83/g6n06y0O21ug34J /9RgYpSpkbG7FFcTA5qubeKYWoRVJBOYMxr7R7ddFORb0cWELMcszaVmLww73ZjbY+8j o1UQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="cuaKGE/0"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020aa7ccca000000b004aab1a86bffsi7485296edt.405.2023.02.07.05.57.58; Tue, 07 Feb 2023 05:58:21 -0800 (PST) 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=@nxp.com header.s=selector2 header.b="cuaKGE/0"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231987AbjBGNzv (ORCPT + 99 others); Tue, 7 Feb 2023 08:55:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232261AbjBGNzj (ORCPT ); Tue, 7 Feb 2023 08:55:39 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2081.outbound.protection.outlook.com [40.107.7.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06D7737B57; Tue, 7 Feb 2023 05:55:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J/kxGlbpXNMdcQTuJ6M3Ja68UO2/dx8Ux42gBBfIeVLILUIuZu/I9fHp1eP8WbmnCYz5yYksJMsAU+V/YjiUJbs5NXkOoP/Gju3m3bSg2RzWVoNwoT+HRRNceA9bZ8zPzVEJTOTap4yjXDUVaSdJXAdbsqEX2GXtSJYFJxlWc2f6K5Y6cJBQGBfN1Q4/y3Z8gBPA+ipK3n3UqoRyRnR28QU4A4+lkJ1FyEPks+7DCyCnTzsJPQDisxovDsX/ahXCh3IdSYa7xu99iGA9kBpQJTsJyquCgwyHC7vNcXyTcqzSx19bpwdu8aZWojOCGD97gJbfyCnQgS3IKhZann06eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JGPCc0HrFlOBWwNUYy9zVP6x9GjYLQMVOZ6bc3/woHA=; b=cX0vogpp/Im+QL2fq4TXxT5/GBvLjMPoxD6M93YgFVGpDv3gqwKY/0IkirJU652DlpC1Tlxw2zrqmHQn0EFZ1WA4rp9jWKsS08osQCRbVbkpbVFfmqWR6K8ZzzPBXICLpJBTShiWz5yG24GLQ8rdp1sjG9tcDRCl17Sk9lkXeoWY6aU3mtZedeSWF4QYIDYCNCmiiivxXeVKHbBun/jHOeOLAly3Z+/4HDOLa4YzDxUMAqPdBQgNqNC+E+47wS+kNcuHPuvdFsar870ELvmEidQWjS8zxHUVh9F1djom8kVRF/uKoyaMhZkpaVFKZCWk8un5f+g3YSqaZ9Y1b9y9NA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JGPCc0HrFlOBWwNUYy9zVP6x9GjYLQMVOZ6bc3/woHA=; b=cuaKGE/0KtexwpY7GpruTJ13cQmHqRFs039SK9A83Pau8DOAzv1N4dbLqhK/86lkbP9kr3nQ/Crqmfg/FcTfTDLbIMCDBbmDdthGaO6WkiMWR0XIpyVh/SViZ+EGWHzxFsccRKezjzKe9+eed/ZTQJD9quKPYsAu6xdIoERZMko= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:11 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:11 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 04/15] net/sched: taprio: avoid calling child->ops->dequeue(child) twice Date: Tue, 7 Feb 2023 15:54:29 +0200 Message-Id: <20230207135440.1482856-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: c5aa62ae-90ed-4b21-613a-08db0912eda4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: igXzlynyrJ5FhF9x16TyzzzKc2DDbIvoLLuWCn+I4B5D8AwLhC3fKIX4fTorlgdVivuBrwGeZp7yloezR71VT7N5FEaZHgtF42MOWViu5MtEczM6+qJ/72CeRAE9jtxshWhTleYh6gBRilMf8p39WIyxL5KypOZVxsp0IwtK7Q4wUbDVHrPpDBrHRtwxawZmhCYRpPmqnEf5dmoDxCFQv71uZ+VLyau6rSwc0tldGJbQdGfafo7DWCDZuEbDTo5w7hGw4xxywNWVaPeH+uvx6n5d4ptqUbfXkTPrRQCqgw5mr2yco4u2DwSq9TqcpxnxB7Lb+4L1dNZAdwHwlV+qUjyFGzJAjJW/4piPwYHdfCV+tMM6M9OANGEXVeqtRRt+Hk1+h63o+jxqH2dcrJ+vil9wtf/JS3b/UJc1Eq28xDjBeXO0KJbKIwjPYJ2pO/zH4XmNrDACSHmtlm6aE07XNXC4RJQ4WABHyIsR5o28JphQE8nWzzCVrcRqTOcgLH9H61QInoeMpK0hCHYhQLCVQFiX7kZvFOM/hfgmcGKp+sWkAx4/p0O6mJqwsB/JAazmQKFRljn8vaE04KmP+RGfLrcw3cFVrIiwCZLmVHFK8UeSLtxG8WcpozdrmMaYrKtPH9RwSaDe43z8QKh0vqyVIofVh38t6bfyYHCw/wuC0jq8Mrd+SM7nGunwU5CdritKb3eaDT1rzM/dBo8CxRDWHQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(2616005)(6666004)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 69Pp796jHKetVYRB8SjFEqOcfTahwcRze0v4hXE8liLfFgJOUvfy/5gkBA/5f3JoVtth48dAIVBnoxg3G7Y4eulfWVtAoQMuBXspltK6NFR9x3y3LhzN9LSX08/2A8GDOEL5t1sAaIeNRNhq6BpG/i6iJFFhce8rRZ4rtsKxGdvfhnstIEiilohMBJL1XllRklgCIgz7nluVIDFeikXHL7yJ0VBJyxtbEpn+TQ8YaHPcFtIeJ3Y4x+PEliRDNwWXaLZKxKqbKHuUdSOP0QqI0g9KtbUSk3epmcNyVY4o8t65Pdi8Uati3/pQn/G9K7UAGWXUolmPdOUXl0DmMHcwmOHjQq4tmFjR5uOtha8j+CTEF5zvlkWSAE2K/pPt0F+dIEeC4y+S5CkI/m0rKV+YbF+qPHoe1q+PQmBHS1hc544cwOON2kYuTNbsa02EFKEHDkSZVk+FfVFj0LhACF51jAc27LMP+9EVVYuatn5/H8YfmOD8QpSA3GyN/SwCowxfOEMA/81Z+PRBSbaB0eIxVoumTkyuQvYA5HRcax0GnmFwMaEJtoRYReBvZAslxrMuoAnknAksVBLK8m4QPRuWwEf750mp6z/z69DQz0yTK5kan5YU2TYQs1jQSgwYH8MYhsz4uDyDGlcZGscTNjafgVEcKZ6cqX3tRw7+L9WkmK8xbB4ABzes2UnBCzUcIJsD2nvTRCBey2Nm3sGna1BRmHG3mzdBjGLWM+w/gvJRlBjee0pp0jFV0hlzW3VMZP4sdUqCn62j3Ku2Q6/b9rw37P97btdqry9PwnSDfhvFe7drYC7aOardI+ey/5Lu+0Q/ClEgrzX8W8ZAGZScJ3OAn5ribP4xI1z8XZQ6x0Nrk7EKzrQcVqsO97aW5XXJqIseHjlF+ceCN7s0ZbXuOnDmGurQ6ZA4xvDt5NdL2Ae37si//yvrXgBZyhPUldoAvdVPbRbOjE6GEsfXoCfpDe1TsNQjkFAuHpEX/9lvo5hx22MZsTJFuJbth2g2j4KZz72fWtiUj7FjTRV7NeyC6/WaWu7BvmCNPfJhZHxVeKDFdscD+fqGb4WujCuC0xDRTKmR4i2+sbHKuvZJrzEFjc0ipzFFUi5EaUlLjGhiXXpF3jqRtC5/ytprEpiO168CDALP6MhuN80ZZklB8FBKkDTLa+2p5sVuZ0Y1x7cRqqJmOJCdYr1Buyv6lM71LJiG6cAKNwa87IRXTFM6q9NnyQ0Gd6spB+DRYbBY+O5yTWI4DVc85bkJr1I+dKhSoxIG3gzeoLa9gcktgLfckbPZHGu2OQEMHvgpRvccCg5AKILmC0nbk6VYZzr+k+xFBIYs0wOAqaGMwVChZkDcCi1xCJxuKkhwFoNDWzqVvxYNrje/SIqCsf90rMUTZX4UiHsqJo0pndpaf0BT3GHk8mHAcwDFcSX3VnNFTnulTqGcsMhoNOTh7JDfDBBUt8FZLdssBqiO+IxOD3v4X2fh28wN/iA521bz5+qZXmLiE7P5L1NN3Ixj0JeTBZw5EDbS8MbvmXpQ3Qtjoko+RCOFn71rgR5wRjpTbjA1fa4MQRGpEiSD8CCQ1Ih/MhbpjMMYTPFi35cl427P9ESZ71Xhz+BpYTQ6gQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c5aa62ae-90ed-4b21-613a-08db0912eda4 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:10.9716 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QlUnC3V7+OEF51OieHrwdJ8BndOTEQNMdXOzcvQEKvQlx5r6JvDTrvMJjKXjIsReSxCHOL3uiF6GGTVVM5AlKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757180908540327872?= X-GMAIL-MSGID: =?utf-8?q?1757180908540327872?= Simplify taprio_dequeue_from_txq() by noticing that we can goto one call earlier than the previous skb_found label. This is possible because we've unified the treatment of the child->ops->dequeue(child) return call, we always try other TXQs now, instead of abandoning the root dequeue completely if we failed in the peek() case. Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: none net/sched/sch_taprio.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 272a8b7c0f9f..a3770d599a84 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -528,12 +528,8 @@ static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, if (unlikely(!child)) return NULL; - if (TXTIME_ASSIST_IS_ENABLED(q->flags)) { - skb = child->ops->dequeue(child); - if (!skb) - return NULL; - goto skb_found; - } + if (TXTIME_ASSIST_IS_ENABLED(q->flags)) + goto skip_peek_checks; skb = child->ops->peek(child); if (!skb) @@ -560,11 +556,11 @@ static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, atomic_sub_return(len, &entry->budget) < 0) return NULL; +skip_peek_checks: skb = child->ops->dequeue(child); if (unlikely(!skb)) return NULL; -skb_found: qdisc_bstats_update(sch, skb); qdisc_qstats_backlog_dec(sch, skb); sch->q.qlen--; From patchwork Tue Feb 7 13:54:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53904 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2862606wrn; Tue, 7 Feb 2023 05:59:10 -0800 (PST) X-Google-Smtp-Source: AK7set8v4TGtWtCliV21R3fGwDZKEhEpwVDsCbVT9GPVwrZJQJcj8iotKRrbSlSKB4X4BFas/9g9 X-Received: by 2002:a17:907:9626:b0:8aa:6edf:2a7 with SMTP id gb38-20020a170907962600b008aa6edf02a7mr1965513ejc.41.1675778350123; Tue, 07 Feb 2023 05:59:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778350; cv=pass; d=google.com; s=arc-20160816; b=edNvIqPfKXBdDwtGIR9W4Q+Ksvw8ablymbt3GCwyZ8lrpFQA87/5eSjfCW+wjj7iSp Hf+FU3EFM2rS+xN6L0dPbHheYig1PrUMG1OtaYG7qfmRPuPo3d8KvNW+iWCGM7h6x5/N TUrv7zMW7AKUSxdUzwSawo+OgIQD/Jhk25Yc4SI0Nums5SBaCb7JKyPhgtW+LpmlDnie Cy6ysDiBf21l4QT78NdAmOI2j9WyyfwuJ/Dl4Z7k2rBH/FisyzWjVkS7JuIcS/zoT3HK QtMk/QSDJlwJnazMFEURcVnx996cqYy/MWuQX7/Y1bx6nuJA1PXI+w2CR3g9QPIEYgt8 05Qg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qpi+uPxsjArsBATRINtYEXihuvppWQAER7BReEFj5bI=; b=f0feu5Z+t66ZYNVvn6r+0NFqvqEySp34Ufywtnn5RqrryXB+TtN4Me6eWSH6XaryvT I/+314L3TF9S5IBPht5I1EvHvXz8VGqaBOjrJ+aVn7FKh4xzInCkY1CulJ1VeP10nQk5 JTUjs2eoxRKa/C/IE/vhkjg8ITBy8L4ohF2V6fUEEKWrhUWGZciee+IVerKrcwIU9sst EJzW5l1mwZ3c0RwObPzcSMxjo/XWv9RL8RSJ9cc1L+u4GPO45ZwaZHIumXun+HmHJ3+m 79/HNsLlA8kk/gHsvws1QPV5lhjBDcAziMYLsceM03pzA4qbCN+CSO0mPTG8SAiGofB7 qNag== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=q0qRqCGc; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 14-20020a17090600ce00b008848299b48fsi18314938eji.914.2023.02.07.05.58.46; Tue, 07 Feb 2023 05:59:10 -0800 (PST) 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=@nxp.com header.s=selector2 header.b=q0qRqCGc; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232225AbjBGNzr (ORCPT + 99 others); Tue, 7 Feb 2023 08:55:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232248AbjBGNzf (ORCPT ); Tue, 7 Feb 2023 08:55:35 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2089.outbound.protection.outlook.com [40.107.15.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE81B3A588; Tue, 7 Feb 2023 05:55:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hJ8oKjWW9HRS8oRYaTuYJWFWx4DDY0lFZVbu7uKKEIY2nNvKU8unGqeGfVYtMxIIjUBARssZcTqF/+tHDwy73hS1sUiFr594Tq/ciEg6K17JlqPZgrZyrCStOFA1AlUgYuG52xsnyfLLE1zKm4/BiRxmPlezHv7o4E8sWmCTv7ariLjDdGlFTf3xgTcA3z/u9e/E0x0FuxO6ovA+84FabgW8ffxQF+rQz8TRcHCuM7Q6plQ9KBmnhpBWePAXkKPVQaue9hE5bvAnZY4o7T2u7h6VUz4+vAnFWCPkPJVNBNyn/PE6uC2MOsm7/bQgO2dUiKFxfRzS3TDKytxdH8kWHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qpi+uPxsjArsBATRINtYEXihuvppWQAER7BReEFj5bI=; b=NpW0OmttSe9RnpMtci4HtA3mov8RTE54q+eMzHBljJG+s9Ok9QeA04U60QcHfYpdiTtxKnPCPWG7Ezgkkcl4h3lSCvv/Bi+w0TFI0Z5I/4C75rFNa0lpswitl1MwZ4+MjoPVHXv3YSMiU0k49xXj1OWnJZG1woLkcTFFgsZZxxxv/T6CWZgzNAG6bin448NDVn7mxcr36HPtAOxPtyn54RG4UKRVWmbFFAxmGbn86sPaesQmfmBxhYzYb6C80fr0bVmr7PTopsfYBE394thP262tpga9TuNYk4sTMgVHc6Zqg7IkSpn1Apja22/33+dXvYUwL2NDulw4A3r+pnzLnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qpi+uPxsjArsBATRINtYEXihuvppWQAER7BReEFj5bI=; b=q0qRqCGcP9kTugeasaDBRLLOInaub6f63dtMKDLZtAvUXQzK9msxo+kpFYQ31CE62CdU/V0rPGobqN1gRjXwV+nQy/IhcnbUhzxP4NbztEII6rzVnrE710EpNvGkjDcPjer7zRRrQC1UCDQgmkEu94+JMzpQExkLq7yHRlbkcO4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:13 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:13 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 05/15] net/sched: taprio: give higher priority to higher TCs in software dequeue mode Date: Tue, 7 Feb 2023 15:54:30 +0200 Message-Id: <20230207135440.1482856-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 6496ea75-9382-4132-4b56-08db0912eef9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Rlq0vXoCVa+AWqk3HZ+K3gZGUOiqb9B455PpP/Od2sDiWGrAT0e02lNulgWkFnsbQF1qDokGJ6IaG/Tuq31s6BaZeOK17obP2pJlFRWRb7RC1cOUIFJ8YyDWVPWZO6Uj8xSEVKd4/1Hqbon9hnR6WY4y+/pUCW23ctTaDiMDMnqXnKFL1h2KFmeptVIC+zk+YZaq0f4zJ8uCMO0LitCe3KagEffLILzC/c6MjO0uXeaYuS2kzuyMZXaWBmaswExmo0exebQZ8wYE1343dxqUESe/9vr1XbwLhnXriP2yWBc/DvUroixC7MXa+kcTq8aki6IQsRLfQc5TqDDHIdjqXwgH2tZs2dP3zciiiAhFI/vhc6Pb3gH6b6RFotJVS15BftpOCc7s9/wkIu/+6TFe1FxH+esfE0sMs4v4K5Pov4rabRK4u7lxXORSvddzVZca9GAdRfvw7iesLj8k4k1gfsjX/US9pT8J+sdeXzo6aaLcy+LjlZfFd4xpMBunj4fivd/Y9qEZWvZc46pCXiUL/087FJIrVVN+FKDZ2lvzWOmrfYd6VpsWw5cymBIHfcLCA8lUr+Tupqk1PTSR1RF6NR8ZTDgAn3te47D1Zaz3oHKhcEIaZPqggDQirlMoNrd+NBm6KN82AM5m+XqxJtFzmsINgA3W5KVbs4IpcI8qQqlGBvJNFxCgQeqJ2FGLY4XQFK36qoiUQXOFebVfVBlwGQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(30864003)(5660300002)(7416002)(66946007)(2616005)(6666004)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lO+DcU2w9gE3L4kO5mzwodAroKdIS+tX6zjspffNC36yusXMOpG3BHrJ5UIh1oJ6EXMFHYQjZG2j6gZWxZUiMpRzb6OA3GhwfLLAdGTVrT6saG/H0HFdhBaCW4xdg899SvvgLq68phkMcAvaYhmbBkFrV1f/e4a106VbVY3sdRFSyzV0L87OauJOpZANUGGT1K4E5vVkp05Y+w7HteCbAZLao3vc3pFyt1llZ+6g5zKdjJ9XSiT4j7ALGSATP4x9QLcXQRiBOJ1fNAgDqBOv8Myp0y6SUD5Zon6N5GqA5Y/DweQO8La7jhwj5KDdVfcrclQpwFhEeAN8g7JAPwpEQWYQrtvpBR+zrzOJcZtHHks3hMa8mmw2JtiN+up7Rb0LDu9p5P3hbIFeW3bgAATci0dRv4trsyBE3vyEnsg8Lmz1ZhJj2l9VqwuldLq2KTVd/UIaL+Ly+5bZr2x4VBV3wI66WiJnhwh1SQIuax9p9CtBlbxbEx0//3x6L+9/e9A3dp/I5FftxFgKV40G5YeQur3Le097Vx0XFsAkjoAM3BGFHdjvV3YWwWjDnTANFhk8m3WeRTecUItxLPpfjSNg91hVeYO5qYq2zTqZMET5DjBqyRcTDUQMT2BxyLp7E1jJ9GFLEwR6HyTM6eGvwSbPyQFu2blB7HswIxhbuirF3vgY1+jJfqAfiap8KIb+5IajzyyLCuB2PGFw7dZPyfXEUpYYrDZn9+qzqNtRYynoKUfCybKtu2kFY7c+CZCmSM4lJylXxNwyxFeoWHWwt0paJpg2lvriZiyCJLpJ4xOIEeV9G0c7SK9RsF1HaDEiqtAcCLsqE8WJDqUrynH3hyO/gRJCtLLO01Pn//JvJLs5gU9YvHID3/IOP/V0BvjiYNXTPEdlrOU4afGG/em65+7Qae9AAXWm7fw8nI/84z4mJk5USu1dGfxPretczW/jxNEVef2XvLl/Vu5LIYJiS43MrvdY7iN2LUJG2BCpO1aBRV3U8/giEHupr6VLU+Je5O+2ts//oMz69Sdon5zjEHNsf7fmsvkj2M4kImeIR6OsL/sXqk99/YuRuPbuoq+1MKgdG7zviKvKi1Cf/fWtwvmsf6KLUAWqEghA4BoNbH8J4Yu5kejq88vUEQFDMmGFbsLqvRehXW/faMbxBAYY+8xSM+TIO4j32lAwbWHP+g13hIPBCRocZ1JWh0Dus472CSitg9IZSk3OxLJuITtgHt8KahIq2TIt8BXwTCRK8YxETv7ekdTZ19QvTKN9WZ8+DOGoza9ZpMRNM43hmFCtJkCGuQcsUMfjD+0uKdHzVmp5VUlcwMrWbQ13sEmSQALWSkJmhaXdwQu7JCfMeF6YMJLSkuj0wEO/mTWDcFwrvrOXpEGqWZPsCPG548NFRl01A7Kv3kmSuVkQvQt0xoCUEVojtXujGZYyByp0PiSpqjURgoehGItDDSdGcgsI1ddD0AsiUqQj3+TbiDjcZDoimm2dADbn6j0n3m2uRhMjcq/udBkUICOxFu9ZazXTC9xaw/GQ1kohRPHYRulK1sSuZmpg0IlzxSihS0Mupzl1iN6D1AzR+u/kgWNtnmKsGVMMQV+HCsLNgR9AKOB48jBDp72NFA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6496ea75-9382-4132-4b56-08db0912eef9 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:13.0339 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cm0jSkkbn4N/ygIM8/eIwodJXlHKpoOd/qeuhG16EDrlHmHaMzVVdBOZ+6uuBFgNmGIH5VFgNkScSbCGjUlARw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757180959346028263?= X-GMAIL-MSGID: =?utf-8?q?1757180959346028263?= Current taprio software implementation is haunted by the shadow of the igb/igc hardware model. It iterates over child qdiscs in increasing order of TXQ index, therefore giving higher xmit priority to TXQ 0 and lower to TXQ N. According to discussions with Vinicius, that is the default (perhaps even unchangeable) prioritization scheme used for the NICs that taprio was first written for (igb, igc), and we have a case of two bugs canceling out, resulting in a functional setup on igb/igc, but a less sane one on other NICs. To the best of my understanding, taprio should prioritize based on the traffic class, so it should really dequeue starting with the highest traffic class and going down from there. We get to the TXQ using the tc_to_txq[] netdev property. TXQs within the same TC have the same (strict) priority, so we should pick from them as fairly as we can. We can achieve that by implementing something very similar to q->curband from multiq_dequeue(). Since igb/igc really do have TXQ 0 of higher hardware priority than TXQ 1 etc, we need to preserve the behavior for them as well. We really have no choice, because in txtime-assist mode, taprio is essentially a software scheduler towards offloaded child tc-etf qdiscs, so the TXQ selection really does matter (not all igb TXQs support ETF/SO_TXTIME, says Kurt Kanzenbach). To preserve the behavior, we need a capability bit so that taprio can determine if it's running on igb/igc, or on something else. Because igb doesn't offload taprio at all, we can't piggyback on the qdisc_offload_query_caps() call from taprio_enable_offload(), but instead we need a separate call which is also made for software scheduling. Introduce two static keys to minimize the performance penalty on systems which only have igb/igc NICs, and on systems which only have other NICs. For mixed systems, taprio will have to dynamically check whether to dequeue using one prioritization algorithm or using the other. Signed-off-by: Vladimir Oltean --- v1->v2: keep old dequeue algorithm too, gated by a tc qdisc capability (requires driver opt-in) and two static keys drivers/net/ethernet/intel/igb/igb_main.c | 18 ++++ drivers/net/ethernet/intel/igc/igc_main.c | 6 +- include/net/pkt_sched.h | 5 + net/sched/sch_taprio.c | 125 ++++++++++++++++++++-- 4 files changed, 143 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index c56b991fa610..45fbd8346de7 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -2810,6 +2810,22 @@ static int igb_offload_txtime(struct igb_adapter *adapter, return 0; } +static int igb_tc_query_caps(struct igb_adapter *adapter, + struct tc_query_caps_base *base) +{ + switch (base->type) { + case TC_SETUP_QDISC_TAPRIO: { + struct tc_taprio_caps *caps = base->caps; + + caps->broken_mqprio = true; + + return 0; + } + default: + return -EOPNOTSUPP; + } +} + static LIST_HEAD(igb_block_cb_list); static int igb_setup_tc(struct net_device *dev, enum tc_setup_type type, @@ -2818,6 +2834,8 @@ static int igb_setup_tc(struct net_device *dev, enum tc_setup_type type, struct igb_adapter *adapter = netdev_priv(dev); switch (type) { + case TC_QUERY_CAPS: + return igb_tc_query_caps(adapter, type_data); case TC_SETUP_QDISC_CBS: return igb_offload_cbs(adapter, type_data); case TC_SETUP_BLOCK: diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index cf7f6a5eea3d..4c626f756a8b 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -6214,10 +6214,10 @@ static int igc_tc_query_caps(struct igc_adapter *adapter, case TC_SETUP_QDISC_TAPRIO: { struct tc_taprio_caps *caps = base->caps; - if (hw->mac.type != igc_i225) - return -EOPNOTSUPP; + caps->broken_mqprio = true; - caps->gate_mask_per_txq = true; + if (hw->mac.type == igc_i225) + caps->gate_mask_per_txq = true; return 0; } diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index fd889fc4912b..2016839991a4 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -177,6 +177,11 @@ struct tc_mqprio_qopt_offload { struct tc_taprio_caps { bool supports_queue_max_sdu:1; bool gate_mask_per_txq:1; + /* Device expects lower TXQ numbers to have higher priority over higher + * TXQs, regardless of their TC mapping. DO NOT USE FOR NEW DRIVERS, + * INSTEAD ENFORCE A PROPER TC:TXQ MAPPING COMING FROM USER SPACE. + */ + bool broken_mqprio:1; }; struct tc_taprio_sched_entry { diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index a3770d599a84..5f57dcfafffd 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -29,6 +29,8 @@ #include "sch_mqprio_lib.h" static LIST_HEAD(taprio_list); +static struct static_key_false taprio_have_broken_mqprio; +static struct static_key_false taprio_have_working_mqprio; #define TAPRIO_ALL_GATES_OPEN -1 @@ -69,6 +71,8 @@ struct taprio_sched { enum tk_offsets tk_offset; int clockid; bool offloaded; + bool detected_mqprio; + bool broken_mqprio; atomic64_t picos_per_byte; /* Using picoseconds because for 10Gbps+ * speeds it's sub-nanoseconds per byte */ @@ -80,6 +84,7 @@ struct taprio_sched { struct sched_gate_list __rcu *admin_sched; struct hrtimer advance_timer; struct list_head taprio_list; + int cur_txq[TC_MAX_QUEUE]; u32 max_frm_len[TC_MAX_QUEUE]; /* for the fast path */ u32 max_sdu[TC_MAX_QUEUE]; /* for dump and offloading */ u32 txtime_delay; @@ -568,17 +573,78 @@ static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, return skb; } +static void taprio_next_tc_txq(struct net_device *dev, int tc, int *txq) +{ + int offset = dev->tc_to_txq[tc].offset; + int count = dev->tc_to_txq[tc].count; + + (*txq)++; + if (*txq == offset + count) + *txq = offset; +} + +/* Prioritize higher traffic classes, and select among TXQs belonging to the + * same TC using round robin + */ +static struct sk_buff *taprio_dequeue_tc_priority(struct Qdisc *sch, + struct sched_entry *entry, + u32 gate_mask) +{ + struct taprio_sched *q = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + int num_tc = netdev_get_num_tc(dev); + struct sk_buff *skb; + int tc; + + for (tc = num_tc - 1; tc >= 0; tc--) { + int first_txq = q->cur_txq[tc]; + + if (!(gate_mask & BIT(tc))) + continue; + + do { + skb = taprio_dequeue_from_txq(sch, q->cur_txq[tc], + entry, gate_mask); + + taprio_next_tc_txq(dev, tc, &q->cur_txq[tc]); + + if (skb) + return skb; + } while (q->cur_txq[tc] != first_txq); + } + + return NULL; +} + +/* Broken way of prioritizing smaller TXQ indices and ignoring the traffic + * class other than to determine whether the gate is open or not + */ +static struct sk_buff *taprio_dequeue_txq_priority(struct Qdisc *sch, + struct sched_entry *entry, + u32 gate_mask) +{ + struct net_device *dev = qdisc_dev(sch); + struct sk_buff *skb; + int i; + + for (i = 0; i < dev->num_tx_queues; i++) { + skb = taprio_dequeue_from_txq(sch, i, entry, gate_mask); + if (skb) + return skb; + } + + return NULL; +} + /* Will not be called in the full offload case, since the TX queues are * attached to the Qdisc created using qdisc_create_dflt() */ static struct sk_buff *taprio_dequeue(struct Qdisc *sch) { struct taprio_sched *q = qdisc_priv(sch); - struct net_device *dev = qdisc_dev(sch); struct sk_buff *skb = NULL; struct sched_entry *entry; u32 gate_mask; - int i; rcu_read_lock(); entry = rcu_dereference(q->current_entry); @@ -588,14 +654,23 @@ static struct sk_buff *taprio_dequeue(struct Qdisc *sch) * "AdminGateStates" */ gate_mask = entry ? entry->gate_mask : TAPRIO_ALL_GATES_OPEN; - if (!gate_mask) goto done; - for (i = 0; i < dev->num_tx_queues; i++) { - skb = taprio_dequeue_from_txq(sch, i, entry, gate_mask); - if (skb) - goto done; + if (static_branch_unlikely(&taprio_have_broken_mqprio) && + !static_branch_likely(&taprio_have_working_mqprio)) { + /* Single NIC kind which is broken */ + skb = taprio_dequeue_txq_priority(sch, entry, gate_mask); + } else if (static_branch_likely(&taprio_have_working_mqprio) && + !static_branch_unlikely(&taprio_have_broken_mqprio)) { + /* Single NIC kind which prioritizes properly */ + skb = taprio_dequeue_tc_priority(sch, entry, gate_mask); + } else { + /* Mixed NIC kinds present in system, need dynamic testing */ + if (q->broken_mqprio) + skb = taprio_dequeue_txq_priority(sch, entry, gate_mask); + else + skb = taprio_dequeue_tc_priority(sch, entry, gate_mask); } done: @@ -1157,6 +1232,34 @@ static void taprio_sched_to_offload(struct net_device *dev, offload->num_entries = i; } +static void taprio_detect_broken_mqprio(struct taprio_sched *q) +{ + struct net_device *dev = qdisc_dev(q->root); + struct tc_taprio_caps caps; + + qdisc_offload_query_caps(dev, TC_SETUP_QDISC_TAPRIO, + &caps, sizeof(caps)); + + q->broken_mqprio = caps.broken_mqprio; + if (q->broken_mqprio) + static_branch_inc(&taprio_have_broken_mqprio); + else + static_branch_inc(&taprio_have_working_mqprio); + + q->detected_mqprio = true; +} + +static void taprio_cleanup_broken_mqprio(struct taprio_sched *q) +{ + if (!q->detected_mqprio) + return; + + if (q->broken_mqprio) + static_branch_dec(&taprio_have_broken_mqprio); + else + static_branch_dec(&taprio_have_working_mqprio); +} + static int taprio_enable_offload(struct net_device *dev, struct taprio_sched *q, struct sched_gate_list *sched, @@ -1538,10 +1641,12 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, err = netdev_set_num_tc(dev, mqprio->num_tc); if (err) goto free_sched; - for (i = 0; i < mqprio->num_tc; i++) + for (i = 0; i < mqprio->num_tc; i++) { netdev_set_tc_queue(dev, i, mqprio->count[i], mqprio->offset[i]); + q->cur_txq[i] = mqprio->offset[i]; + } /* Always use supplied priority mappings */ for (i = 0; i <= TC_BITMASK; i++) @@ -1676,6 +1781,8 @@ static void taprio_destroy(struct Qdisc *sch) if (admin) call_rcu(&admin->rcu, taprio_free_sched_cb); + + taprio_cleanup_broken_mqprio(q); } static int taprio_init(struct Qdisc *sch, struct nlattr *opt, @@ -1740,6 +1847,8 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt, q->qdiscs[i] = qdisc; } + taprio_detect_broken_mqprio(q); + return taprio_change(sch, opt, extack); } From patchwork Tue Feb 7 13:54:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53916 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2864923wrn; Tue, 7 Feb 2023 06:02:21 -0800 (PST) X-Google-Smtp-Source: AK7set+Yy8UCRSC2+eA36VnF+0AoJtTlmlyhLkeh1wxzKzJqG0fc7OdrmNX4S5tHiAaT/KoW1rvj X-Received: by 2002:a05:6402:5383:b0:4a3:43c1:843c with SMTP id ew3-20020a056402538300b004a343c1843cmr18914615edb.16.1675778541479; Tue, 07 Feb 2023 06:02:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778541; cv=pass; d=google.com; s=arc-20160816; b=rQujzHSSfYNn0V9V1ehMGBtQbKXvcPrdCfSafieQrejK+sPixh3XsXoiXOukQk49Sm VW6aOq4WH4Y+13rY+gAcKjMC5dBYc87Fr6BozCbXyvSmK/AffZABu3cD8dPYXHZkBy/b lgztvs/PUvua7Hki5bG6193fkg5NpNyC1IyL66PxMq46uBfYpUxzDTYtvpdrpKDuLo9w WnepWyzYNrhHX7dQdDSCEieVVHIhkLpMcF5nEc90pk85LslM4dWWJhoCfjfupH7NcMW7 1yyeustjwHfrLAQKS/2enzksmUWJFmm5ykScUZX2Wpqnh17IJjDI8xv53X6QQuTodSBe MPCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=u6Fr4Rdqpr4JQviI55Ygp77iGJtasSXSwdbN3XXp8d4=; b=H7hK4T1pc/sUXA9IcHHfw9I0DVnx1YUKsEaV7f8OUIovrFBaKxZIjCeGz7Ir8poMls kMFUBkg0X5Ookg+SHYqnEoPkNbGiuOo/qZMguPcM2LvQaZHCmKBI7JgTiDvIetquYytJ hjT0SUCQ3xHUiAnfdrJ/vcQCx1mVle8IwZMKHoVXUczPYzfOY9JvqSA2h5Qs91RMEjE6 jDwvCCNTvm5v2/K3zCcjLSQIlOB78ekFX8YrkSPirnFEFDywTo/cJV8Uu3GcFn5sFGF5 NNJr0Wpvw/up9sbwScZtc4UUqrSgWyQgMmnA1G0bfXQKqBCy9ATNK5ayJfb5DmcuK57q +t3Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=b7SHpFXU; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020aa7cd41000000b004aab3450a00si6336989edw.498.2023.02.07.06.01.55; Tue, 07 Feb 2023 06:02:21 -0800 (PST) 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=@nxp.com header.s=selector2 header.b=b7SHpFXU; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230440AbjBGOAC (ORCPT + 99 others); Tue, 7 Feb 2023 09:00:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232301AbjBGN7o (ORCPT ); Tue, 7 Feb 2023 08:59:44 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0624.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::624]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA9C33D0B5; Tue, 7 Feb 2023 05:59:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k3REPI6fRYeKrNa2BwSE/zagkI5fxIJz9O0ut3eGYgLcbijLZrNWEPb7cpmrnDIOXQwIUW4DEzVZsmcwFI1681GyBR+Sz80AgNS1SSB+gbPZ3sJLQM8sl39RUGrqguHPMCInHNQM+c+oafGq682pR9wyu2I+dd4LC4DpFYZkyvXPdhkwCXElJ0orVDJqFFJkJRv7EcyF9XihxY1SoGlJrs2l0lSIRECZRLJhs9xsAN2wVgfufcNMPIELoRzlpvV2oQsLqTlxr8wX0OL6xk/GWDi8Ay+r6C0nqkF89I4QpxrDdRTa1y+dJHHCwqlGNIzz8CfnsacWxiKUkCa6AEesUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=u6Fr4Rdqpr4JQviI55Ygp77iGJtasSXSwdbN3XXp8d4=; b=AuteZoyYeDncA8EgM3vDHBR8RdySJBJMgxaySf25qQd6T5QAQ5Oey2BjALpsUDUGO7z6HcwCtn175gv1lf0jLzdmibR+k5sOa6bA/02QNyp0mMaD2eeNtrEW4hCvz3/PNI1itDJf1LaHLDlWRCSe7uNOpDM68B/xZxD+QuRRhVVPuu4Q+SXDsbd8ZeHItH48LA9+ucDa9fdGDUhYuZBcImfqS96FTWR5082Rh19uV3OUs8upE7zxGvgbEXRN2sb6A52Sno2iZxTybjQE23UKMMsBvUyJNfvUpqpucofDL+AVbanjvskZ8P2RnjiXl2NMhbyzqE1YfeaVXSPUdJWKlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u6Fr4Rdqpr4JQviI55Ygp77iGJtasSXSwdbN3XXp8d4=; b=b7SHpFXUkbv2BkpVjLbtqbPR6qPecnTezIgyyHME1GcAiPsD72YQyVxzJq7TjthxFLjEnm3KYoo7X+4DmtOMarm5Y9evjdMi3D7v0KyPcHkGdwSJoHLODKMVI/iQIq3yoQjo225RzjFMle/FwBZnFxrXknOioRTCuaPTAhvjpCM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:15 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:15 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 06/15] net/sched: taprio: calculate tc gate durations Date: Tue, 7 Feb 2023 15:54:31 +0200 Message-Id: <20230207135440.1482856-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: a74c2a09-2596-415d-c2b0-08db0912f019 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ubJS1OF6HQMBYJlGfj1YGGJp/vRT3a3fUjaDLT3qWyNegwroSSZdY2uv88bMdeVAU3KUywGqkFZxxBrDO50gBmF5/fdiuavwb58B7kl8QIvu9IuHEwbGnsTTOsmJBJ0iFH3+N2MQvukSV2c0n45zfLb9ur8fXTkiwNuU+LpPSocWWmJfVxTNnS31yxZbtaNiNjxMulN1Xdm0s8NKIewX5W6fxeYTvfBd5gxugaaEvkzpIycG/BOXoaWT6/vr2zo1d2qjQ2M02gnqcsVvwl6qhJpIfjrtC5VMeb9C0cgg2XDAKnnnlYR/ziHtGS3lel7xJypI4vGdFNgcu8e+jEjVSC3obL+GklrNJppghM+7XhTkFAAfQgXZJiGk2GO9E+Zb50kRWRKDvtdiPGj2+XUxaLRMkvFex2MK65SDj9tSZG/fV+hq22lo38amHIgXwtuuuyI5FDp1z1Huq/NTC180ia+ATvbV9IDQ/rIkCQ28hJJz7fZvg82WlF38C+X4iYdF9u1OCDNa4RmyyIgwiYMubXaf/+6vrhoWl1SGf8ZUJYkADxKwqoYOtl0S+f4VGMuNtVP4manZATMdOIUPyXsqh7bJkTpCAdaUdbs3IX9wtnP8KBd6tvzYmnFeEtMtp9S6jLZ1sQF9teYr/xv4nS72XoUBKMgylbG/7IJG+S31K8MpJ6jQqMgXgRltKYUlOjnFFmL3RGtU3fuISkzgmGWzZg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(2616005)(6666004)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MjicDT4IJHk8QZCBgAHlnJUTeqsStLllOeYiCHu9FB3alLr7mrTM1BPedi3RPwR3Kk3nDxMJDpDz2g0GSo8Pwq3OOvHw9GD0SEmnRb0TqzG0ba76yuvQNmfM4+i6j50CHea0TyJLDrJub/N9bjVsZ69HxkFtS9tYVKDlm+y3i0pMA7EgJn+v7r5Zd0ieBQuUm3uZvRloW8l/UrQRbbOP4YPP2pm8TCHrp0aS//4s3b1YM8FN0JCLY9PD40WaxWiO3yyDTeLHa0h6OwP9qknwrV/72i/VUEP1blFRVAaU+mc3Yb4sBsMIY2f+tWuRbzIQ3uCXRbXC8bD3w59wU0d+puPmsa3KCANO76l1tlgY58UXV7gEL3B7ThYKCCuWQ7J9U+dmPs/byfTXZHag7iICtIxyaSfuvjwZSWlkgrPvb+dS4gwFU6C9b67ZIDyWItv6k54rs595dC/NX3Z871BH3YCgXwsceiJx2Dm7i6Wch+JybdW+0lomFNHoKStXQEiSYgP+Ri5aZVtG2DYOY1MGW8tZtHQfeMWkc+RevYNe6zDzgzBO9b/LO1LtxisWUccT+bt2fmaqgwExnAbYMSuATu1poVEqc6htUE9F9i9iNBzYL9fq9T569B3AY257hde5bgK3S6kcXg8K/UpfTq2x5hCl0FowUamNotzUc/52vGqipfDh49fxUMtWEIuQwVM5Rvyb+e0G6lmQRBmHPSpXoiAX4XzhNm2NsqFjVI7jRuM9e/9fH3oj6btLX0icl37VIXCb3VW9CDwZuwRm7mbfagsZnAZ5f98uwxdBGBeT+VBGuvrER4U9R06ElzRDGzDrPoweisOIMOymQh13umrHZ3hQq1+BGq+D4+tll4BB3otbpIPCesIsYqO/FWlHXeodMBBTFb4xgelYcsyzvSbkX1geiIu3yUeTkGR5GtsKOl6TubmKg9bbGoX19pXBJ05F33Z7ED71sgvJPMvPEnNSTrTgJfUGe5RRddK9/NQHyxMu0q0uIjR6oY1kbqxw7BFWz8z+f1SZ8Ot1nEqhAwDwjE76ClUtSJI6dCaDwpbuXqpVaaa0vbshVPEeg3DwMZE/4wgN18FK4XG3VXSLIz2YH0OWfH4v/X5LbPjqIsBX/M1W45+eprDwqwG2fGyDo5FJ6u9yArtBSHvRwpEialwAvo1nWvqhOx1fxjnpYH/Uvzt4FYJG4GuB2QoHDo2BCJQoPr7SjZrCVYyF3u0UzqgcK5PqkFd1vqZdndI/s/cPukEfq0gyWULDzAKvji89wMcT/4VgOmz5+Edylu5XlVX3JlDubflQGesP9QDX7WoQQpejzUxbaDxhpwK4h1e75Q/1ruEg0lSSnNWwPwfjX+qP2fRlrHtydyx2W3t+BXxwgQsjnZIR4NEruCACsRDbLLVucdoc1Bn0Cblf7IKymBusPhr4nimTU64WQjM0lkQtwt1s0yF/zfj6ul7abImAtREFU1oRPxCYnqxiIBMdLwNBV8o2TdpCOiuyXiACOrbzFP308wvy1UiAP1bTkwnm1aDP2c+Xp5z6e5bOnfm/v04tqdFgnGS7a63R/YmmGt9B5qFEiVhdxBnk9lxQFlYeurVbHO24aX47FBT31PEUb+pEzA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a74c2a09-2596-415d-c2b0-08db0912f019 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:15.0806 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1VFoOv6hbqakzEWnyhITby6R8W/enJKg6OEb/3we2ptNT52OsnFvU09SLg9mof6oELzoGoq+N1/BXtQ8u+nbPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,SPF_HELO_PASS, T_SPF_PERMERROR autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757181159690565532?= X-GMAIL-MSGID: =?utf-8?q?1757181159690565532?= Current taprio code operates on a very simplistic (and incorrect) assumption: that egress scheduling for a traffic class can only take place for the duration of the current interval, or i.o.w., it assumes that at the end of each schedule entry, there is a "gate close" event for all traffic classes. As an example, traffic sent with the schedule below will be jumpy, even though all 8 TC gates are open, so there is absolutely no "gate close" event (effectively a transition from BIT(tc)==1 to BIT(tc)==0 in consecutive schedule entries): tc qdisc replace dev veth0 parent root taprio \ num_tc 2 \ map 0 1 \ queues 1@0 1@1 \ base-time 0 \ sched-entry S 0xff 4000000000 \ clockid CLOCK_TAI \ flags 0x0 This qdisc simply does not have what it takes in terms of logic to *actually* compute the durations of traffic classes. Also, it does not recognize the need to use this information on a per-traffic-class basis: it always looks at entry->interval and entry->close_time. This change proposes that each schedule entry has an array called tc_gate_duration[tc]. This holds the information: "for how long will this traffic class gate remain open, starting from *this* schedule entry". If the traffic class gate is always open, that value is equal to the cycle time of the schedule. We'll also need to keep track, for the purpose of queueMaxSDU[tc] calculation, what is the maximum time duration for a traffic class having an open gate. This gives us directly what is the maximum sized packet that this traffic class will have to accept. For everything else it has to qdisc_drop() it in qdisc_enqueue(). Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: rename "tc_gate" to just "gate" to reduce line length net/sched/sch_taprio.c | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 5f57dcfafffd..7d897bbd48ca 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -39,6 +39,10 @@ static struct static_key_false taprio_have_working_mqprio; #define TAPRIO_FLAGS_INVALID U32_MAX struct sched_entry { + /* Durations between this GCL entry and the GCL entry where the + * respective traffic class gate closes + */ + u64 gate_duration[TC_MAX_QUEUE]; struct list_head list; /* The instant that this entry "closes" and the next one @@ -55,6 +59,10 @@ struct sched_entry { }; struct sched_gate_list { + /* Longest non-zero contiguous gate durations per traffic class, + * or 0 if a traffic class gate never opens during the schedule. + */ + u64 max_open_gate_duration[TC_MAX_QUEUE]; struct rcu_head rcu; struct list_head entries; size_t num_entries; @@ -95,6 +103,51 @@ struct __tc_taprio_qopt_offload { struct tc_taprio_qopt_offload offload; }; +static void taprio_calculate_gate_durations(struct taprio_sched *q, + struct sched_gate_list *sched) +{ + struct net_device *dev = qdisc_dev(q->root); + int num_tc = netdev_get_num_tc(dev); + struct sched_entry *entry, *cur; + int tc; + + list_for_each_entry(entry, &sched->entries, list) { + u32 gates_still_open = entry->gate_mask; + + /* For each traffic class, calculate each open gate duration, + * starting at this schedule entry and ending at the schedule + * entry containing a gate close event for that TC. + */ + cur = entry; + + do { + if (!gates_still_open) + break; + + for (tc = 0; tc < num_tc; tc++) { + if (!(gates_still_open & BIT(tc))) + continue; + + if (cur->gate_mask & BIT(tc)) + entry->gate_duration[tc] += cur->interval; + else + gates_still_open &= ~BIT(tc); + } + + cur = list_next_entry_circular(cur, &sched->entries, list); + } while (cur != entry); + + /* Keep track of the maximum gate duration for each traffic + * class, taking care to not confuse a traffic class which is + * temporarily closed with one that is always closed. + */ + for (tc = 0; tc < num_tc; tc++) + if (entry->gate_duration[tc] && + sched->max_open_gate_duration[tc] < entry->gate_duration[tc]) + sched->max_open_gate_duration[tc] = entry->gate_duration[tc]; + } +} + static ktime_t sched_base_time(const struct sched_gate_list *sched) { if (!sched) @@ -953,6 +1006,8 @@ static int parse_taprio_schedule(struct taprio_sched *q, struct nlattr **tb, new->cycle_time = cycle; } + taprio_calculate_gate_durations(q, new); + return 0; } From patchwork Tue Feb 7 13:54:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53898 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2862103wrn; Tue, 7 Feb 2023 05:58:06 -0800 (PST) X-Google-Smtp-Source: AK7set+JCxKX4PQna+7e9NQDnvLmw+0k1VkmSReLwsQuAwBnlMvHPjqeF45EmFBCh8S1IcMUQdkx X-Received: by 2002:a50:bb26:0:b0:4aa:a65b:eb8e with SMTP id y35-20020a50bb26000000b004aaa65beb8emr4144467ede.1.1675778286392; Tue, 07 Feb 2023 05:58:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778286; cv=pass; d=google.com; s=arc-20160816; b=eXwa/v7Q8rldkey0pgbw6BV/NVhbpni+qkubjP80gGIDkBXe1bJTvnsJWRdf0vHPrw u22UuWCgE9c0i3rRv+9PvJ14RH89TSJ6V72aNJBPXit7UngYBIZiXRwNF0WZD5MzkLmN V+JE870QgCAtsQPCwbKejDyQW/B+Z6yoq2Ew3Xa7LrWnrgUCiAUzVZuGmhdJpQapC+kT SEzjdTsX29ySI2KJZXLg/C07wXiOM9vJ1YdPeynFwjqAhAVK7iw/Q9Pq/Ogmo6yQwAuf ioKkPTtk/ZUx8d+rHhRsjzUFBxrOVvR+E8yrfMlkvBgDARiWuPPfaUpjR/hcIygM1fVW +adA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2Vx238rJ90P6wkkhoauMB2d2JNtugRnFwNwtbfQMEBQ=; b=oJWsEFJhAFTQJJhBMKDHl/OL/6R0G4CptWULNKGo0Igd4FQeCKY8CWAGNw+fnXIFXQ 81z7iUXaT9Nq2KBNRZ2tujl7FVJf7ANad0jv2F44u0eZhumg3MmE/5k9QS18pxJ19VU4 YWY13JCmFy5+DjdP4mirEMjz2PYSg+OnduzhcGBclUsL23IjnPEb/4Q90Ii715RCR3Jv v1e36CJg79im1FwdNCjcsus2ufcX59RSJlDFEZ1KcMAAivw6WXcPlH694zz6MzHmTxEM 42kMBpkrJ5XkT2qWhk91TN+nZhEsguCf5MBHvCZL7e99FfnqiIgoSXEYNOUtIEoG7TzZ 6JAw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=oUgHRrED; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs11-20020a0564020c4b00b004a0e0ca3f4csi17061981edb.488.2023.02.07.05.57.42; Tue, 07 Feb 2023 05:58:06 -0800 (PST) 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=@nxp.com header.s=selector2 header.b=oUgHRrED; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232244AbjBGN4P (ORCPT + 99 others); Tue, 7 Feb 2023 08:56:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232177AbjBGN4G (ORCPT ); Tue, 7 Feb 2023 08:56:06 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2058.outbound.protection.outlook.com [40.107.7.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FF2938EB2; Tue, 7 Feb 2023 05:55:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EJ3yHu+4bveH69T7yrD+kFbBZyLmn+HTBQYUJIndyuDKXCdp7Ujz0FgsHXUWRIKBvmzwcNwa5Xq1AzG0wdjacEV6ha5uMWr9at45z4QfjnfsZHyB7tF94kngL0utxQg7YYdETdMqyTRpgMXtoqkpBK8pnWtPEOMy7HxF17J+Ap0c9IjnXCp55lIoTkNNKRY/sUXz20v2A15YlWPu6lZ1sn6beQvhdkiyDeRarTjk5jDb/t/GnR1XI/60eVd1Tm+8JaDL8o5vsi0oXcyKCjxpQN8XBrQxpWL1Vz54gjfwbPpsg+Jp3eP4l7dMQXd4fx+tIG6hxY/IcgD6/3xzsCjCLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2Vx238rJ90P6wkkhoauMB2d2JNtugRnFwNwtbfQMEBQ=; b=MGe+Ev7HfGducVbbcJ0GqkiF5r9Gq/zCcCT3WXJgP6jj2pnqw09/6rw3uf+bTLQTtTaRBe4pb7rR5WEZ2pqMJCUD2Rlufj/l35TUfDASzEgaxI8LUqUv1sYgVSSOdI5VAR4gestbc2d9pq1QTDusT71MP6hNNI3oWJfnVg9CDTSXW46sUMz3J86/zLXPQDRyetOcpcW8DUlzaSat/1wKo8IVNIhn/C0jjWK1dPZhlb/FL1hQfFdGPxxOIC39AU62hfCLdc4joZnrm7uDoiJZmDRxng4DfY7z1j6dKOd4+zDL4mWFLeFyrhqZTr4gxODsBQwHpd0h2ja0DKpTWZVsBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2Vx238rJ90P6wkkhoauMB2d2JNtugRnFwNwtbfQMEBQ=; b=oUgHRrEDTIG4CZiBqTnZs9w0S2X3IDuSY8+eP9I8kFaAVDRjHkp1Co08URClgmBGpk8XzaHSCjMZudzuReSfgY3HMkkAfs7bULAERTN401NRn0/VyVPQUNME9cTN/IncT9Q1JoOoqUG5Njv8PLungWi19GDW09AJnyM9agcGDuk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:16 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:16 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 07/15] net/sched: taprio: rename close_time to end_time Date: Tue, 7 Feb 2023 15:54:32 +0200 Message-Id: <20230207135440.1482856-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: e454eb61-440e-4b37-113a-08db0912f152 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lZcLZp5DPqcsJy2G6wiCsPOcu9FjCNBZuDU63ucxbjpxdcEr53pUr6hG2R53VQ+VBnNroxPoyvocItzBQFdqKSrY0ahtPLdm4NfgOGPEjl6ZKog7ZwxB1IqwWgCo2PaKlzgis6Wmc6BOX1g5KZ8TbDr+msZ8EervKp502gGYrsxwBUOj4yIbLtcdpxVg6+cULUnCXQ2/J+/Q7vcjTKwRbeZ2hWI3WnT+/0506Gz2MOHbI0xDSj1dLrOSVJjzg/wHA6MP/cInLV43FzINEhICLTzO91TZKdL2OSWoJrUjGMwWPsKn04ED+vVpSFLnpTL9aX9gm2lL2OX+8VcRlwYXbQAKrX/WKKPnsVyskg6C/R5khMXc1xJfL0vQO/hd80OYXIg3NWsU/gsi6ylfzALZ7oDwXYYySaQt/BUVvcjlYygKGr6clbnjxk7826DOoG9MNkE4AsEAb319dUHUyJFEy7Uonvsmm24rrrmoHb2ztIkbQ6DDUFOkKGYpGwSzotFRu/WHl/N3tY7IJUIpUGEo2xOq87hFarOjUPBxvoMm+Mlq8DqDvfqs7uL1AXZKsVJuDsurAKrHsBw2Y4+afywQM0bdFNX+bOW+p9zqbw6Va6LWAHirHrhQRZ4yDLuFd15LQMPS7DgCoxAfpghQ2k3THgQGyB8EawFhyUO84X385oGfZAYy25BjJlH4WAltjFzEatEt+JJ3UYA+CbFgr5nq6g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(2616005)(6666004)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cgo4iWPHgv8ytlYQZf2THvQjWhvRO02W6XrjiII+qkRBgTgzQBVkvmQ76bd3MGlrEpzNfY6S+qNeLe8Bmwc624f/z8H4UYJWOokHagHt5M98Hrnduw/SjULf+TOP+NKjFQbPPAYTp65RnSI2FEZGliCCUWV1YE/PJVH5mWXdPKvbzPX/sOw6BkI4aMLfrEbFdznrO0oIE5pbadxLN9JF81hrUgqsyHPnIxUeGhgDX/v+dN377OvDkJboSRlFEbLUgJfM5YrzCmXyErthQFHUAJP/kvIALKsLypikz/oLjXKmj6Srztixnf/SzfRbLBpByhUcyX4IUL0lbnbBsENrfQ/LhmHegtJzz99JbAR1mCVYQ1DS0peWaOTBu2cIwMv+cIr4jtcaxh6Kg82n19cCsC6ITH6QW2GQJuzMRe5ZCc0DBAehoCuJSO+M/5dZDcA+Zd+DUvfPh0UfskJtOwLjMLmACdLUkntCN0Qrf+zcPSoRNpu6eV0u9QEQ94wES38GWF9B+veEh/at/mvOiXY77EeIIEBKhcg4Icac1FUvUK4vTE+3fhSLLvmWXRrfOIT2pF5PALJgXTE4VqtzloFdHMA4L6GAFFM+RPhCEHI93epAXc+9pJWPHtBx6oNVUsE8CbFuqVqMvgUskaKChwCSuwBLO63MNZzgzAsLcmF1EAmwmhWd3N+1GI2pusM7TMXVtIYVtC6MgUvbwzZYkkX/HGo0M0cTbo49k7fhsEeJ7tR2xXDPp67ce4SW703fKcXx+bIgH6kh8O6RH320ZLVe7M/7juIW+MGs7qHrpaIe2Jp6gXQVX10tYuir+uojJmOGX6GTJraacfHHd5Y0BXeHNv4PcAhvqcTlFysjJa5IwkIQruyH1Q0FmC5USaGELiNLnGfOlqzmotQfnVyURmVI08ARrRhZUEII/M70cw093JnIGel01NiTMcuA0CVhbcHWQe6RWpL3tS+uGjzK019MrbbUPo47cyqkySuOThcYe2mMZyIxD99XksYEfPeU7XZpCE6RHZrTf6sjZwIKncLg1bTESXPrbGsQpO4UgiA3DcsQIVrvfVOj1VdD+yz8HWACx8rc/WeEhSXHHZkXcMzE343qLr++/45GLohrVY5hXQZoF++yuiR12vtkq5fqgbo6oDqZLsQBrQkScPAcAuBM1lKy8ETTyMjO9bKSnW210UeCI0ZlZYuZXD0vgWyL8kKueCuJQbLY2+P8cn12eATEiQS8jX3HDwCqFp9TzSq9fh1lkvpr7qU1sluX43ZGXqt/MraNx4nq4b56JYvckrgn+2TWab+ptD9N6fBCYcZJiULNG7goHKvbhv4mcrKsj/hJAKgHfvMS9Df4rnsIP6W1wv7A5f7jsRmX+GDuq+h6R4RoG/Zgn4DxNEi0W5gOmnqmuq/kXocwZJ//qXjL/BPtVz1dTcnlBM4n1pJMTfwrIW2eXocI87Guc/m+htVrhNHzv1diH2zaaSoCr695NyyQrVYwoLdkQEB3/jwDKx344s4HjKTDenlz15GBimt12n9SgdZDOK4iWVqy0NcU4oL1T7KjVWwznuo+pzJ/zJ3QdDLoY1QDl3ZtP/LQBBu/uyKG2c9LBcTPTgrK6YcRMOkd5g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e454eb61-440e-4b37-113a-08db0912f152 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:16.8305 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lIDe1fLsej7bX8Z/ROm2nBBEcTrH7WrftS5d57+/DzrIoLRytL2GL/jv87QUhwOfBcKvGu6sUxhCmNOuKULAEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757180892506112100?= X-GMAIL-MSGID: =?utf-8?q?1757180892506112100?= There is a confusion in terms in taprio which makes what is called "close_time" to be actually used for 2 things: 1. determining when an entry "closes" such that transmitted skbs are never allowed to overrun that time (?!) 2. an aid for determining when to advance and/or restart the schedule using the hrtimer It makes more sense to call this so-called "close_time" "end_time", because it's not clear at all to me what "closes". Future patches will hopefully make better use of the term "to close". This is an absolutely mechanical change. Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: none net/sched/sch_taprio.c | 52 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 7d897bbd48ca..3e798c8406ae 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -45,11 +45,11 @@ struct sched_entry { u64 gate_duration[TC_MAX_QUEUE]; struct list_head list; - /* The instant that this entry "closes" and the next one + /* The instant that this entry ends and the next one * should open, the qdisc will make some effort so that no * packet leaves after this time. */ - ktime_t close_time; + ktime_t end_time; ktime_t next_txtime; atomic_t budget; int index; @@ -66,7 +66,7 @@ struct sched_gate_list { struct rcu_head rcu; struct list_head entries; size_t num_entries; - ktime_t cycle_close_time; + ktime_t cycle_end_time; s64 cycle_time; s64 cycle_time_extension; s64 base_time; @@ -606,7 +606,7 @@ static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, * guard band ... */ if (gate_mask != TAPRIO_ALL_GATES_OPEN && - ktime_after(guard, entry->close_time)) + ktime_after(guard, entry->end_time)) return NULL; /* ... and no budget. */ @@ -738,7 +738,7 @@ static bool should_restart_cycle(const struct sched_gate_list *oper, if (list_is_last(&entry->list, &oper->entries)) return true; - if (ktime_compare(entry->close_time, oper->cycle_close_time) == 0) + if (ktime_compare(entry->end_time, oper->cycle_end_time) == 0) return true; return false; @@ -746,7 +746,7 @@ static bool should_restart_cycle(const struct sched_gate_list *oper, static bool should_change_schedules(const struct sched_gate_list *admin, const struct sched_gate_list *oper, - ktime_t close_time) + ktime_t end_time) { ktime_t next_base_time, extension_time; @@ -755,18 +755,18 @@ static bool should_change_schedules(const struct sched_gate_list *admin, next_base_time = sched_base_time(admin); - /* This is the simple case, the close_time would fall after + /* This is the simple case, the end_time would fall after * the next schedule base_time. */ - if (ktime_compare(next_base_time, close_time) <= 0) + if (ktime_compare(next_base_time, end_time) <= 0) return true; - /* This is the cycle_time_extension case, if the close_time + /* This is the cycle_time_extension case, if the end_time * plus the amount that can be extended would fall after the * next schedule base_time, we can extend the current schedule * for that amount. */ - extension_time = ktime_add_ns(close_time, oper->cycle_time_extension); + extension_time = ktime_add_ns(end_time, oper->cycle_time_extension); /* FIXME: the IEEE 802.1Q-2018 Specification isn't clear about * how precisely the extension should be made. So after @@ -785,7 +785,7 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer) struct sched_gate_list *oper, *admin; struct sched_entry *entry, *next; struct Qdisc *sch = q->root; - ktime_t close_time; + ktime_t end_time; spin_lock(&q->current_entry_lock); entry = rcu_dereference_protected(q->current_entry, @@ -804,41 +804,41 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer) * entry of all schedules are pre-calculated during the * schedule initialization. */ - if (unlikely(!entry || entry->close_time == oper->base_time)) { + if (unlikely(!entry || entry->end_time == oper->base_time)) { next = list_first_entry(&oper->entries, struct sched_entry, list); - close_time = next->close_time; + end_time = next->end_time; goto first_run; } if (should_restart_cycle(oper, entry)) { next = list_first_entry(&oper->entries, struct sched_entry, list); - oper->cycle_close_time = ktime_add_ns(oper->cycle_close_time, - oper->cycle_time); + oper->cycle_end_time = ktime_add_ns(oper->cycle_end_time, + oper->cycle_time); } else { next = list_next_entry(entry, list); } - close_time = ktime_add_ns(entry->close_time, next->interval); - close_time = min_t(ktime_t, close_time, oper->cycle_close_time); + end_time = ktime_add_ns(entry->end_time, next->interval); + end_time = min_t(ktime_t, end_time, oper->cycle_end_time); - if (should_change_schedules(admin, oper, close_time)) { + if (should_change_schedules(admin, oper, end_time)) { /* Set things so the next time this runs, the new * schedule runs. */ - close_time = sched_base_time(admin); + end_time = sched_base_time(admin); switch_schedules(q, &admin, &oper); } - next->close_time = close_time; + next->end_time = end_time; taprio_set_budget(q, next); first_run: rcu_assign_pointer(q->current_entry, next); spin_unlock(&q->current_entry_lock); - hrtimer_set_expires(&q->advance_timer, close_time); + hrtimer_set_expires(&q->advance_timer, end_time); rcu_read_lock(); __netif_schedule(sch); @@ -1076,8 +1076,8 @@ static int taprio_get_start_time(struct Qdisc *sch, return 0; } -static void setup_first_close_time(struct taprio_sched *q, - struct sched_gate_list *sched, ktime_t base) +static void setup_first_end_time(struct taprio_sched *q, + struct sched_gate_list *sched, ktime_t base) { struct sched_entry *first; ktime_t cycle; @@ -1088,9 +1088,9 @@ static void setup_first_close_time(struct taprio_sched *q, cycle = sched->cycle_time; /* FIXME: find a better place to do this */ - sched->cycle_close_time = ktime_add_ns(base, cycle); + sched->cycle_end_time = ktime_add_ns(base, cycle); - first->close_time = ktime_add_ns(base, first->interval); + first->end_time = ktime_add_ns(base, first->interval); taprio_set_budget(q, first); rcu_assign_pointer(q->current_entry, NULL); } @@ -1756,7 +1756,7 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, if (admin) call_rcu(&admin->rcu, taprio_free_sched_cb); } else { - setup_first_close_time(q, new_admin, start); + setup_first_end_time(q, new_admin, start); /* Protects against advance_sched() */ spin_lock_irqsave(&q->current_entry_lock, flags); From patchwork Tue Feb 7 13:54:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53906 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2862729wrn; Tue, 7 Feb 2023 05:59:26 -0800 (PST) X-Google-Smtp-Source: AK7set8+bAOJDIWVyan6ToztkFv5zd22gDjv2LB9o4sgBFHn7tfmKbI+gr7EsHJdcvYttXpggkYx X-Received: by 2002:a17:907:3e0a:b0:88d:ba89:1842 with SMTP id hp10-20020a1709073e0a00b0088dba891842mr22269842ejc.19.1675778366372; Tue, 07 Feb 2023 05:59:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778366; cv=pass; d=google.com; s=arc-20160816; b=hhMZr8Q+VjvcuFP7tCwP1yegeSjaXi8Ovu3O4uXBZ6FdM6vWgrnK2sHcSASFDmHhBh cHBrb/8wndkitenV1PjcjpOQ16s9drt7dyW/vDieZjeq27b9NpHdYE9aGouSt5Hznnq8 mApOTT0olCC4yBGoXC31g1tklwcAl52v3M5eHoXjPH7ogqctGqnOztwJnqnJEMqZhOdJ dfElZBFW7Gj3jyFPlVtx7OIEOZWAUhh/V/dAfJr831nqwFd+rGwfqIpAPbFO/fVmBh0j g8A+Z2PObM4yS8Vn8i8FTz6bVCK1kUvLHdF2YNs3+N41wRf47bCuZK1Ag6+r1hLiYfzw dn4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DMmFt6mlpFfnnPitylfG+Ez+lWXNDlzRbLVDgli5hm4=; b=EWzaPpGwJOwipw4ZmYoUonu0pINgxaQw+/NF7tYtC56svwqoJbIihUHyp/mAkoQwpZ 6+Tibg0KJR2ZS3pDlgV0QCK207NyerGsYoy0Ex9LryyXMceBeVmKveMm9KUvdNnvcbUX Kxy60lBEjrQj7xy/rnPHJsCFZEQ4FJ4famM15iQVOTeW946emqL45QXRcPzXL1m9xAVc +CYDVWhhIrWaLVNsjDo5VfIKBUb1+6eHnb2nyyuRvcSHWYAB9cZOqqoLMEUUYpwUm+Vw nOXCr9lMDkh06JR4rR6LqslrGRHtCPiRoobiZddhTAjfzu/QqgiDwtqgaxBWHqkL5pgR zFwA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=hzBPlSA4; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r5-20020a170906a20500b007330c08fe49si17238106ejy.206.2023.02.07.05.59.01; Tue, 07 Feb 2023 05:59:26 -0800 (PST) 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=@nxp.com header.s=selector2 header.b=hzBPlSA4; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232266AbjBGN4T (ORCPT + 99 others); Tue, 7 Feb 2023 08:56:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232201AbjBGN4I (ORCPT ); Tue, 7 Feb 2023 08:56:08 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2081.outbound.protection.outlook.com [40.107.7.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3B4C3B0C3; Tue, 7 Feb 2023 05:55:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZhOctSsSn1rh/5cSX5yJZFhlQTFKdRs3f7qFKwhP4pVE7Vm/Ye2bSeWxm5QfxMCWpF5wWR1URFb3Z8vkvDFnjQf6Pz3T28KDZOECDWgMZtajPvE9JYIUklnFZDkc/Dx7iiSMTTolmVEJrfBHvAbj5n+3TKI1+1iSj4msSzLhQ5sxT2Ks6xikW7Inq5Y/pQ67TAKKClhXYpklOOVAPme1yvoy08Rm+UX5p03vu89odsOc9UnqQKHXOX3K/hWlVl4/xxFam6dzJBTQ0JPU7lpYwEp5G86sCxPBQOpO1OKIArvALkWNyPS9ghvP5iJHpIJ3owjUH0FpV8hjh/ELXNmPqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DMmFt6mlpFfnnPitylfG+Ez+lWXNDlzRbLVDgli5hm4=; b=QgIj5RCPSY794wGKsZdQGYK3R+BV+kxCsmiZBEanQxPIdgyqpNUzBgA9v2WrncXsckk9/yN7vZW9YAStRCWSHczh2Frbg4M3bohvXon9FxauylOBtFhlQ/tvr1kHkCD0TALStCjxq8efzqrumq6d+malok6oRgfJxuTIUngNKPoCTySeqEYl9CB6o4hHb7BCtK3zIVviqVlOb4Vak1FCmcTHxLAz+vwhwVn32IZfRqzSyFG+Vg0qU4TH/urG6QAiyKapU+X7lUDjHv7FIlriEHY6CmRMaJU3O8BaUe+S2+KaoRZWKUk5e1RYeq2w+Gcz8scytC1/s3xhRkpgJn/nSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DMmFt6mlpFfnnPitylfG+Ez+lWXNDlzRbLVDgli5hm4=; b=hzBPlSA4PMGgAMrXft48trUik6mxEAlKlk4n7YUVpZlIoWGDYHelAevqboGLIFFUaVD6w8e48J+zpvstRzAjv2ddSOr/Dy2of5dCbNBcnKJPq2fSZ/3VnNIgtZQ69v0C5+xdEtWzG+Hxq0yZru0VlNS0LXhMNNB+NvVuObIKWR8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:19 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:19 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 08/15] net/sched: taprio: calculate budgets per traffic class Date: Tue, 7 Feb 2023 15:54:33 +0200 Message-Id: <20230207135440.1482856-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 71294eea-7e93-4f8e-eab5-08db0912f274 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gE6BvCboGs/nNslhr6ZHOxfhvwgxHICJYdzBjdHrxHedw2WRcRqGW1bMz3CR4w8Oja0SB8qUpTeNTT1IpH9aKqnK7e68x6yF//mayw1O8F1zNE4B/+XE95Xj38DNIfNeLtm0K7/Vq93Qt2fhEqlLpC35z16oA2nau8uNBhj30sokIOQhR/RcxDqSAoImzQdi9NzmrYmZrhVUFkv7cRQWmEWeA3qAIXFNZ1NwWWK96ARyS7PVkTEqdEmqr5u/EC6410Q6yu1rzYMoRaxBBR01Bg0P18GioHZLjL3WrhQkjJE41pY70EgaQ+O7/LjPskuxz3Aw4nOWATZh0Ms1Drt6KsA5r+yGiYe37VKMe2PgKbPDFTNV4zhuxjCTVcJMhjcfawz1l/EDtN0rif0jHAEXPvs7yewkC91tGYg7/VG3gVORStdVZ7Q29s/zWBgL1EGiPhVm42mfyEQavMMxWOWOSg4mwyOFglgJqT8JG1VTazv0D/+O9N3JBpbKuoFYSRPJVMfh1KmNPlOvHLIA56t6JnB3OICju8Nohtyqn4Kb1t9EN1BNAKVBz6KjoBVCqiaKwfoCqzfcJN3thvYmjmJkDGtFC8rX/TR1L1Bl4YOgOohLjIw5x1/P160UPmItWXnTJi7Tcz7GtCPv27HlHgsSVoDjTI0eH7vxwFDEBhg6+MDYdY2vWmBfEOxFK45bMvbYxSaVerxc2+9rvoUc/iq4SA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(2616005)(6666004)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: td58KToSpLsRlhFz8tQcW+DIix2M//3idArY3i5BTjW/ADgh8Mgn3gZDVwLbg7Amv2f5fHrJBozqMifK8aFu6mmVb3vnHdCCOXdwYZJWXma7q6dMreLq0G3qlvjVM0xDlQPJW/cSD/kZm3EfiBw76t74dehAvo2bFyrFi0mYqnnidLfokZ6R0AFrzBT2dPd2QbwSOnuE4HMBcRYIq/yjM9oGp/jZVCBP+rtjvyj6bFmW6wjCbZLqqj+0ramPPMTVIr7q569GRL3QlMqGzkYlE7CuCMzbBvB6aS5UDEJXg3rFJSJPW9Q8Sp5/Fn8uoG9M/urRPE4uIeUUBqxq53z4MYQWKibExtJ6pCKY5f3kkJn04alIX9iK6sbLUzp+RxR/o2CLW42U/XTKi7cM4PlXE0OCuVbbPWGjGbX05HLLAfdvB7l5QdbeX3iN8zRdLtmIO4h3xl+hC12rHQgXbY1lVYjviN5k/I9IIsM3XR3lcFQxXKT0FbxeOSyWD1wO0XD0J6GtYBlgVsW/aQKAoMP8somGF8ffaswxlTp2n2P3mRFG+XgjupL1wHvXutupL4kiX5BgHZrh/bIhGCL4x1RC9MflKPkCGrTkPzR5JF5AAIRNGW4GeUcdaIG9VZ9dy4MAxxjrP3113OB38CAMDQhGClonJKCP86+5T7t9o3AMvhq7uzRkwua70ozuCEaGhvHcOnIHA5Flq6M8Jfn52iVaZOjbtBQh+d1Tp3Voc8VTr0Bo5PG5skkfmammk8IPnMSqssHGSuGOqUkpGSuKXPu2z0mRo+0fLjrBO6sNWtJXrVLZjPzXnMKPIkAM6OGBoK+7brUTXnZ8jRRquvYHYLTPrtd6hazsXYCJxrHJ5L3ICm4m2JzZK5C4F4a08goTBXftwCdX4TVSY1Qx+QJ5h3onmBA7LHWsXzElTryX0t1a4iyAPIjgV+WamTvIU/JbvrRV0flG8ScqA4FaUSjqujjsccnUsotiZNNMrxbR1QBEnfBjmJv/OZ4+8lHY8YTD6fqSXtzHP6tS4hZD0etvp9cB/L/yqByf4glvpICrvsro5QLjJxfglfLFkSRjI6y2CLDpVgYPVOzccnuXay70SnN+lNdcQ4UECTvSyE8v+YUIjNvDutV10JtMtmf9Hueczr6fhRtvmU7UUV0TY/g1Taspi6MlqNJESn06V/PVkaKeDcxjV/sJ1El5W+tDQ0F6k1kPrxBNqHMjP0jHegaw/n+hhnRMWewyJPN2z0qUmrJsZ/4oaaFQtwRKDiE52cYRLKzNludl7VH8ciV70tneOmaeueNU4OWXrrLvVVB5SPDcIjUT72dGFqoMrLTEjkj0OFTqi3IdIbVHZYSIvUr8JlNiCP5+asG2FnKsLjzyQlvXxsPWoKd6rdLUD7BUfbg4GQdG9ggAvcuLhOXp2SVorWsyBmNc31XhyGiPYr7PBiB+9NHoeOIr7ZtdLNJ2WlZzxWgXg+7pHfdfCcZ9xyRGCOF8XYGNf+KZJqbjFOJeatf4Wt/4P+kDotFE7HpZvJCtMuMS9rR4FpJJ6zUEnz1eV2j4q6R3jp+UP2EHXWjizR9mraPe4fQcG6uGEe2IFusg5qmb49CpegdAxtXiEiogOLoTMg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71294eea-7e93-4f8e-eab5-08db0912f274 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:19.0335 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Uhp2jhmKryxD3k5makB0ajgfovMDKe/CMJ6+ZjeW+PjLuy41ugUdPjrm1trquyfyFVy1cszEpXxka6SBE1A4YA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757180976364056273?= X-GMAIL-MSGID: =?utf-8?q?1757180976364056273?= Currently taprio assumes that the budget for a traffic class expires at the end of the current interval as if the next interval contains a "gate close" event for this traffic class. This is, however, an unfounded assumption. Allow schedule entry intervals to be fused together for a particular traffic class by calculating the budget until the gate *actually* closes. This means we need to keep budgets per traffic class, and we also need to update the budget consumption procedure. Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: none net/sched/sch_taprio.c | 54 +++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 3e798c8406ae..08099c1747cc 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -43,6 +43,7 @@ struct sched_entry { * respective traffic class gate closes */ u64 gate_duration[TC_MAX_QUEUE]; + atomic_t budget[TC_MAX_QUEUE]; struct list_head list; /* The instant that this entry ends and the next one @@ -51,7 +52,6 @@ struct sched_entry { */ ktime_t end_time; ktime_t next_txtime; - atomic_t budget; int index; u32 gate_mask; u32 interval; @@ -563,11 +563,48 @@ static struct sk_buff *taprio_peek(struct Qdisc *sch) return NULL; } -static void taprio_set_budget(struct taprio_sched *q, struct sched_entry *entry) +static void taprio_set_budgets(struct taprio_sched *q, + struct sched_gate_list *sched, + struct sched_entry *entry) { - atomic_set(&entry->budget, - div64_u64((u64)entry->interval * PSEC_PER_NSEC, - atomic64_read(&q->picos_per_byte))); + struct net_device *dev = qdisc_dev(q->root); + int num_tc = netdev_get_num_tc(dev); + int tc, budget; + + for (tc = 0; tc < num_tc; tc++) { + /* Traffic classes which never close have infinite budget */ + if (entry->gate_duration[tc] == sched->cycle_time) + budget = INT_MAX; + else + budget = div64_u64((u64)entry->gate_duration[tc] * PSEC_PER_NSEC, + atomic64_read(&q->picos_per_byte)); + + atomic_set(&entry->budget[tc], budget); + } +} + +/* When an skb is sent, it consumes from the budget of all traffic classes */ +static int taprio_update_budgets(struct sched_entry *entry, size_t len, + int tc_consumed, int num_tc) +{ + int tc, budget, new_budget = 0; + + for (tc = 0; tc < num_tc; tc++) { + budget = atomic_read(&entry->budget[tc]); + /* Don't consume from infinite budget */ + if (budget == INT_MAX) { + if (tc == tc_consumed) + new_budget = budget; + continue; + } + + if (tc == tc_consumed) + new_budget = atomic_sub_return(len, &entry->budget[tc]); + else + atomic_sub(len, &entry->budget[tc]); + } + + return new_budget; } static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, @@ -577,6 +614,7 @@ static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, struct taprio_sched *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); struct Qdisc *child = q->qdiscs[txq]; + int num_tc = netdev_get_num_tc(dev); struct sk_buff *skb; ktime_t guard; int prio; @@ -611,7 +649,7 @@ static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, /* ... and no budget. */ if (gate_mask != TAPRIO_ALL_GATES_OPEN && - atomic_sub_return(len, &entry->budget) < 0) + taprio_update_budgets(entry, len, tc, num_tc) < 0) return NULL; skip_peek_checks: @@ -832,7 +870,7 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer) } next->end_time = end_time; - taprio_set_budget(q, next); + taprio_set_budgets(q, oper, next); first_run: rcu_assign_pointer(q->current_entry, next); @@ -1091,7 +1129,7 @@ static void setup_first_end_time(struct taprio_sched *q, sched->cycle_end_time = ktime_add_ns(base, cycle); first->end_time = ktime_add_ns(base, first->interval); - taprio_set_budget(q, first); + taprio_set_budgets(q, sched, first); rcu_assign_pointer(q->current_entry, NULL); } From patchwork Tue Feb 7 13:54:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53909 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2862857wrn; Tue, 7 Feb 2023 05:59:39 -0800 (PST) X-Google-Smtp-Source: AK7set+rYZV3uxfSkgRIDTZNLa3wYf9JxFh9BGBQiO+q0bSPFq3u79AGFqvhSnPSeJJ6VjxX4taP X-Received: by 2002:a17:907:6d03:b0:8aa:bf92:b3c6 with SMTP id sa3-20020a1709076d0300b008aabf92b3c6mr129137ejc.52.1675778379479; Tue, 07 Feb 2023 05:59:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778379; cv=pass; d=google.com; s=arc-20160816; b=s2TICpqjtVf+81l2YbKmdl+O1cSJrd8C5oPNb2lS5jV0+MvpGYnvUFIrkGMS5cP5et LYFwMGWGe55Kus8J5+Q0NDAvADzrrUS3FjU4aH4BT7vadiS/IzdAC/5uwjXSdWe54Gkm xCSWCza0WzqROp2lbOIvgP4TF+7wWKi+cP371VbeIT6CGcTOZz3rR33mzqAIsWFfH8EW pXzcyAOKD+CLwKRSHdsFy0u5FBP9QE1j8hmKkBpmr9tjq9iXmsJhejJHOSdL0YwnbMdI ZxJOxxPPH5c9mcjRMtkmHcxP09lJa1ora0T+UmXw8+ZtD+cECNjwhiMgil9vMLDIxgXN odQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P1cgxpP38hEiVNWBLSx5k6HskTdkIJ1sBnRPwfabdhI=; b=hbzIf+/nUgK+1unczVyhC0Movre1VtfYbv3dp0yuT+NfY8tEHNPmfbXoXbqc6/tzDm jsyT9sNDX53dNuFLDp2PYSwKYRvtqJjAdMkdjxHTpK9jsSHjRbtd7U3fmJGjKxk/VQin iNuGkXNvgBrvhphT/ueg4iSLBBjEnlge794mXMGbo8vHHzbGTRnrXH2cpTjr46Tx943K upXRFRrHkHK1Ye23LKZ2IfrOYLYlL2aZSl1m40kWGjXXW9q1V4VP7r0JvFEu03WSfu5w 7qFVZjFBs7NqnVYeGE0lCfmHdtJKdPwDwM5cPSUC/0YFRZGNi6TB0tEVy4VtbIOt1oWC +fBA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=I4YO8SVz; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z26-20020a170906271a00b0088f1e51d2b2si17332579ejc.52.2023.02.07.05.59.16; Tue, 07 Feb 2023 05:59:39 -0800 (PST) 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=@nxp.com header.s=selector2 header.b=I4YO8SVz; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231565AbjBGN4q (ORCPT + 99 others); Tue, 7 Feb 2023 08:56:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230503AbjBGN4j (ORCPT ); Tue, 7 Feb 2023 08:56:39 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2058.outbound.protection.outlook.com [40.107.7.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0FD537F17; Tue, 7 Feb 2023 05:56:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BmFVCwJpqdVYHhwL54yiSRiGFmSAk/49xSyEOMKPlEzt7topGSe4/G6oL0FKeAogCbq6gxSkJc5jk0MUFQ4NvWX74gJINAuF+EnxibII80kyqePtRDO7CFkJ0a0IQADw1mBwdY8rvhSIExAZVmLhR4qiLcUvu//6h7abG/Nqy1aiT1JDS89sBVVTZoRMSYIADqe9F8xTHYqyX+2Vb9X5FtmpjNOlIc1eNFxygK5yqip7GYYcWh5jLtB/ZSsmGVpVpX1MmIoAgM1w5Nom81RVEWZICHFoIcjQGxSpNbPEchOW/gkjpTHopf+jiooTtVe2/OxSQql3g58WvY89pyk3/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=P1cgxpP38hEiVNWBLSx5k6HskTdkIJ1sBnRPwfabdhI=; b=gdbV5+XTbFxHjoGRUw16/grYFZewHoVu9Nf1mHmbmWXKnJAIFkfYtqyGnViWkrTUuBEDx62UyEtwt1ZOr/fOj35QV7yT8FCjJnvqc5aW53DHoHirENoFU5slWDzrVhNxSH+PxaFoAlmy9R9EIK7jlK49VfSiMDWy1Gi1beKyDR9D7+Xr8HDkcv3R/PxEI4RuHfYHgQpw1o89ZId+asGCcKabQwPKT/S5ziv2Qy0YzH/7CyMgtZ2acfS5bAUc+xAcA75eJNXZjpfuKpP70Ra4wCtPNqrk3Sh2DcPzoZ9iqXW+JK3ZcLgzodgF142aulmA8LmJWGlBljOkxOxpvhgQ4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P1cgxpP38hEiVNWBLSx5k6HskTdkIJ1sBnRPwfabdhI=; b=I4YO8SVzNVir4H6xRXLK+J7CiD1hOiIbI5koQjMCItYLxXnIZxh6USzZN4CoDwcHLJdimfqINy9WlaTIX+TIgC6r0dpuKl2oEtL07CeqM3+N3zAjAS55Rxe4PlyNynE3vqmrLCZ5JwhhZ4Z3OH/atg47iDvZXVfmxYbn12RC3GA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:22 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:21 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 09/15] net/sched: taprio: calculate guard band against actual TC gate close time Date: Tue, 7 Feb 2023 15:54:34 +0200 Message-Id: <20230207135440.1482856-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a8ba8be-0566-4e7c-d6ce-08db0912f3aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pl5OsLdRRZbX+LJX6cpgBzSxCnRBo/bRleIAjgH2ilOXrnVckLRQdi74jBt013ixo8atQVPvmMNlO0Av2h4rX9sFlcp60V7bRzzOgST5r4P364Z9bOfoJz2r2sf9hLOCDKf5AuC2W8xioHwHpXeghk76qAdFTshK8zHUxi6JQfyZAQHA4ysXXZgIzv/5LEKh2Jfz4CfzI0qd0dM6EhVxnVxzY0nvslUMdoVinWxa9079m0BuyX6fDumun1fgc2ex+tsIIUfGC4s9k6TnrVcw8eVQnq/hx0mUQKGEgkSjQG0iPfUnMy3dBwI5UOl8W+nDq80icnIolIZXiFj64+gduNrRQhpiXcYGVb4dXLYdZYP2AgyHf/TRGSZFp+DzqmprJyZ1rG0d4snKaqyBOvyMP5x9YRkgCJOGWstvYVSWV2AuHIF5kyc4OQKoFC7qGMfNc1mRUtUIga1bzWalLec4mPf4dfBUg8OZBHYLrEqu/N48t8kRBwZPigUiuZnspcHXZjT2LpDEf5JpcbO3eHuchDU/FFFAhIjXDfpgCtP5V/buAvJe/UIu0NgjBjWbew7FQvxyKUOZ08xPgQrPM4QZcx1ryLjlL4bu1rQrIKnwBr+8yx70i/aZnzJNsvbZiKc0GQD1FONvBahEtisFp1Ukh6W+AhC2TMBgFaQMUS0v+XTNncJNMHqb/vTWjdHlO0PpJ1dTvxy0nY4hvm/lJH4rQQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(2616005)(6666004)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sBChaVsy92Ga6/5l/bQDCf8qgpzV4AW7Yag4+k83TwlHmcaKEosaS2b326m87VwjDxpbCodMXX3PMYyPbXgrTIIuP/fDATC7tSPfm0FQDdnmPW8JFiPLW+oFm905/SakhR6va4iiXJJhurhfWwsMXbVznWzc93gk+21LBVCVA5m1RIG7qEH6mrhKfRruN9hqWbR4WoVKlFGIMOgkmYvnXp6SbPevNHVSmdH9bzmou1IrZ5KTKpZQvp7gKw86bIp5b6RHZx0iMzlD5wfeicPK4XgWq5y15WxZ6juYbL7J/vbOPTf7EVwGgow4FLWab0cgsNLD+okw9KhCyNVmIiTOcu7LIkLPZltGvbSw++n5QkCmc8gIDE9pjet5KNpC9hYzbAaVXUNPA0iC1HtJaY2zj9G6uIjOXTCi/TPxy3cqse6hrCowrlVyJ4So68WHfZKt0Y2f9uhdk83mrPeZSnyQsKbEqSyHcbONKIg4SIXisuGV2okgfWGFiiUiq82gKKrU8eTf/3qntYBKqH55QN9sEy1Z1GVC+LAQpc5xcsloHULKZWuhj+T/wQa3o8ZnXeBVwnjcEuZfd19Kpr+lO3qN/23+5mJ983deds6SfLk/3W64GIuq+x/hc5ZKMg/Xe4fIiVeB+IwxBK0nPptZC635GmVav+MYX3ekwCvJD9RuS1ANOQ9AFtFktdJyJzZnMRYv/eN9bw4sC+Z9RJTEgA/JUa5D2VUvqVtm+TTLX2BI88lHJjdpmDJwp68mo8URz+5Nrdzxven1zBacZrLzAEnFBOwvkK+UCSXv2ZBvNdlZ+zLC2dj9cFCztO8GZ+3QRwT1fPBOGwYHMgq7h1YSdafic1ol5DL+CjlZ5HG8/Yd4HaCPkQChiUtFXBwHffWsf81Ff/5PKBTYjj2sVOfCDINRQg8h/S/VPhqTYCI+MKBja98UZDGDTa5fX+5u8Q47XUTcPdxBUMmOTg4xbFiOPyZQ/F3DcJjaPt7u9EjZT4/39L5DELIfBFrzRKhdXANL9TzBSsKVu4vN0XJcvORYee5jGiPJLrKRkqJDVWW8BGIIeclm0Ydp0j8dx5Jwhr/Z4wRn6gpHtmmfB6U9YOMFzpCiWItkovKVMvGn4TwGGPPbH4A8PR3BCeymUlnNpvslvIVD9/fncuwpr6V0W7H7g0OZdKqq8AUZGl5VCpO7NFyxJLcpJWl1jeIlMXPWb3bdcfDVtGRcWNRtF1XRcup3+Sf1qBpVZd+mNNpFC90yKJqWbW6GWd2kTQPjUUECfyEq49c6DAYi/3oyYM6Oz1ZN90IBE2iOueNgJ55q5TGOYyRjEnamLog0YpxGRvkjag5DvdcoBOp6VBFvMNHHRW5CdrloFj+0WGffKCMk7SxJdJKzISG6Ksx9Jm+2K9QJeYmFgyeAHzH0GWjchLrcLxyir0tgSLAgTHLWf7rVt7vypy3FOepmiD+eTB4ETBOT0jsRd7xrLgQVMnf+NjFrW10Dm7GdkMzeSdaYQkuSmcbsEv6+LaCBTrLfWPk1Yijj0wJi8A/PnB66gQpjoI1Q2bHnSeu1ic022ZYpA/qUBh3fBLPmKACdtBobv+FCU1OoQ/mIV5ndLWmI0/5Ql6j1aumDcRsk2g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a8ba8be-0566-4e7c-d6ce-08db0912f3aa X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:21.8927 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GBHkmlMoUYc+W9vFkzUVxyyf4gOccZXB1xExk5V6sCUl9LgjXggF8NBf/unhQ/U5TD5h7hQGp2KNk0kElRV/Yg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757180990021556611?= X-GMAIL-MSGID: =?utf-8?q?1757180990021556611?= taprio_dequeue_from_txq() looks at the entry->end_time to determine whether the skb will overrun its traffic class gate, as if at the end of the schedule entry there surely is a "gate close" event for it. Hint: maybe there isn't. For each schedule entry, introduce an array of kernel times which actually tracks when in the future will there be an *actual* gate close event for that traffic class, and use that in the guard band overrun calculation. Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: rename "tc_gate" to just "gate" net/sched/sch_taprio.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 08099c1747cc..e625f8f8704f 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -44,12 +44,12 @@ struct sched_entry { */ u64 gate_duration[TC_MAX_QUEUE]; atomic_t budget[TC_MAX_QUEUE]; - struct list_head list; - - /* The instant that this entry ends and the next one - * should open, the qdisc will make some effort so that no - * packet leaves after this time. + /* The qdisc makes some effort so that no packet leaves + * after this time */ + ktime_t gate_close_time[TC_MAX_QUEUE]; + struct list_head list; + /* Used to calculate when to advance the schedule */ ktime_t end_time; ktime_t next_txtime; int index; @@ -148,6 +148,12 @@ static void taprio_calculate_gate_durations(struct taprio_sched *q, } } +static bool taprio_entry_allows_tx(ktime_t skb_end_time, + struct sched_entry *entry, int tc) +{ + return ktime_before(skb_end_time, entry->gate_close_time[tc]); +} + static ktime_t sched_base_time(const struct sched_gate_list *sched) { if (!sched) @@ -644,7 +650,7 @@ static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, * guard band ... */ if (gate_mask != TAPRIO_ALL_GATES_OPEN && - ktime_after(guard, entry->end_time)) + !taprio_entry_allows_tx(guard, entry, tc)) return NULL; /* ... and no budget. */ @@ -820,10 +826,13 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer) { struct taprio_sched *q = container_of(timer, struct taprio_sched, advance_timer); + struct net_device *dev = qdisc_dev(q->root); struct sched_gate_list *oper, *admin; + int num_tc = netdev_get_num_tc(dev); struct sched_entry *entry, *next; struct Qdisc *sch = q->root; ktime_t end_time; + int tc; spin_lock(&q->current_entry_lock); entry = rcu_dereference_protected(q->current_entry, @@ -861,6 +870,14 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer) end_time = ktime_add_ns(entry->end_time, next->interval); end_time = min_t(ktime_t, end_time, oper->cycle_end_time); + for (tc = 0; tc < num_tc; tc++) { + if (next->gate_duration[tc] == oper->cycle_time) + next->gate_close_time[tc] = KTIME_MAX; + else + next->gate_close_time[tc] = ktime_add_ns(entry->end_time, + next->gate_duration[tc]); + } + if (should_change_schedules(admin, oper, end_time)) { /* Set things so the next time this runs, the new * schedule runs. @@ -1117,8 +1134,11 @@ static int taprio_get_start_time(struct Qdisc *sch, static void setup_first_end_time(struct taprio_sched *q, struct sched_gate_list *sched, ktime_t base) { + struct net_device *dev = qdisc_dev(q->root); + int num_tc = netdev_get_num_tc(dev); struct sched_entry *first; ktime_t cycle; + int tc; first = list_first_entry(&sched->entries, struct sched_entry, list); @@ -1130,6 +1150,14 @@ static void setup_first_end_time(struct taprio_sched *q, first->end_time = ktime_add_ns(base, first->interval); taprio_set_budgets(q, sched, first); + + for (tc = 0; tc < num_tc; tc++) { + if (first->gate_duration[tc] == sched->cycle_time) + first->gate_close_time[tc] = KTIME_MAX; + else + first->gate_close_time[tc] = ktime_add_ns(base, first->gate_duration[tc]); + } + rcu_assign_pointer(q->current_entry, NULL); } From patchwork Tue Feb 7 13:54:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2862994wrn; Tue, 7 Feb 2023 05:59:54 -0800 (PST) X-Google-Smtp-Source: AK7set9n+gV6ueGYq+HryQ5fhzAZdYZUckMYlYTXl2/6y0ZMPB08QmSKWu+vZPIy/ar58SKYfPxm X-Received: by 2002:a50:8719:0:b0:4aa:a4ea:cdc4 with SMTP id i25-20020a508719000000b004aaa4eacdc4mr3777630edb.12.1675778394151; Tue, 07 Feb 2023 05:59:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778394; cv=pass; d=google.com; s=arc-20160816; b=UcSjyQYhYRQADv2+MWTWBiGM+uyZ2BLCTnqNpcQwRdHav82aeip/GUXeNuOfNXiToY s0duwxK7+LFCq8NafLQwkUfohw1h2K0hhx/b9wf2VaE/8vyqwB/dRdQoZqMB5YwQ15Vq pzTTEJz0Uxq7qksyO8ApkA9b8zblXmzVYbW44LDAScax+s+ZfimDSk73xyHlBLpS2TBj dZ37rCD7rpKfn9in0pRx6Y2Z6c4b77CjOkiAcUKjnheK7b7uKAdU7/o5B6UaaHFMQJ38 0efC/u64SwQqhBJuGHFVMXZ+LbKUV/YUAR0Isr0ZQcl9fAeQEW1ocGYFY/VR+ymPzVzd NXqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CP0C8XuxhRhjJ3S8DDhYJcQ3CWW3ebtd1z1t6Dke0iw=; b=nx5EYtnM1UuVKiOKNVXZZ5uvf4BGvbwhc8LHS7R5u/F+Vz/vJZzpRq4ixLDMVkLYwP /xflaXAIJVUYJuMuCfPGZfjS7se5RLRzzTq3UUnkATRmW/IQVsGgywDkckJnDf3NOFCK xn18EN1b/iDETDq8dMPTM+lITM9MZcPmzCNx3ECeiJjBfJSTSDWndZs4r/w88mMJEk/t YAex9TaVKQ9lflQpDfFrBvKr4uIlvhRzn5q7VPwS3ODmMCVvKDwwe+Wky10LsjXJ9nPz 8abrNdG/e6WCiw+aDb0xcl9O83iyqFDq47rK/JAG745fveZycJ6EW6MNVW61vF3Hsl9r CvLw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=NnmDgqkL; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gk18-20020a17090790d200b0088e9bbae7edsi15089444ejb.198.2023.02.07.05.59.31; Tue, 07 Feb 2023 05:59:54 -0800 (PST) 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=@nxp.com header.s=selector2 header.b=NnmDgqkL; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232308AbjBGN4w (ORCPT + 99 others); Tue, 7 Feb 2023 08:56:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231435AbjBGN4k (ORCPT ); Tue, 7 Feb 2023 08:56:40 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2081.outbound.protection.outlook.com [40.107.7.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D375C38023; Tue, 7 Feb 2023 05:56:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tw0TYAPApxagtVnRUaWswVFZJmEWCPNEW479i5tuZUtxdS6DtP9idYPIbkbO9lx/XDMlPVNCt/gzbYsdabfDmi0XLXVeAjsYPGSiJ+D7bj0qTunRRhuf2AEASCLECKPG+nrxG5bDBI/eFa5viHEgqwTR/MMke6aptE6w9224fRMeZHM/CH3bdKaT4zRvGdOXBGButHvMJehwIn21m422DPJs575mRrBPe7CJzOHq3u3cd5Wh/4uFlOHpHQnbv6vg5DWF9EOBSbDoChMRiBXcwzwa4BA1uPrtB+X7Z4fHM7HhIBNv4n+9EdzlvoeBDC4yVFheDtNrrKIkc2tjaSVhWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CP0C8XuxhRhjJ3S8DDhYJcQ3CWW3ebtd1z1t6Dke0iw=; b=ENemoPMaCI4IHOxdo6TkGA3fVUUNW8aUv9YMvn6DUSeOI9PmlOZta5+zEtbjTBi9TycwPyyHiHCiF494wThcvbUmyeHBM2Dp0cCsQ4+dboBzvV8nQ7iLQaiutRAi5N4Mt44M65eF7v9gk0n55YE4luwK0KNX5So85A8xTeEh2aIwZw2M6OQ3KuJT25QzxZJJiYlC961gQOV3mHUSyKuP4afB39K94k6MdveSk0iMPQKvcXTRWFPD9odMea2NSqcxg2DM6gFWAGyvuH6Q6ohOmJtgaEBYkWoSFL3JAYERmcvKix8W/pp0LifAZIyYqrlPpt09JVwXTUw2++ScbuWnkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CP0C8XuxhRhjJ3S8DDhYJcQ3CWW3ebtd1z1t6Dke0iw=; b=NnmDgqkL73qfZdMBNlUnTeJD3ihyU+SGHJY+ICXgpzxgm/W+vUNUwtT9YYza4cjXh15F7wAaqN9bgIWRV6+3odYB4sdN3QMkFNKijR7Fdj+bZa7X1+t7xaMI6BV1fmXvvQ4gcLnj6fp5T0ypOn9BgY1dkmbc76tcDV907hvDAng= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:25 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:24 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 10/15] net/sched: make stab available before ops->init() call Date: Tue, 7 Feb 2023 15:54:35 +0200 Message-Id: <20230207135440.1482856-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 61534432-ed8e-4701-a47b-08db0912f587 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UiYMPGAI2GuYzdNfgAa/Om9GtNwYwY3fycUGxCFqfxMYG60jaS8T31KSXvhIqEfIFoMVP5UslURYBQyEZecpzWCGk+PKLf1uPYLOKfNHDU4s9JMSStWpbY8CollYcbl6sZRVC6lUgDC2uzlxSz0qN9RYX4V5s20WSap9qCeS5kOYMAzsQ1CS85oGHdj+1a2xbSb618nu1s7fQ1a95UGrI83rnxj3RqAiAlsw3s/vbEIpXf4IVCB2wB2kSIuFuYKTSsGsq3Rhk3EE/eMPOYHSyeUUV+eBZFSsBYEFlREhCudSHe/aARSlzAPfNkxjftXM/QSYY/u28uuX4KPKhjF6KDMlQZ19QNScFqFg0OP8du+ufySinVWUGzoSoNbBbU22Y68BpI98AySc+gBXMqlarj0kfSqMCX5zXCvNHJqGo1OoCATGbuI/y2DtNcnSXp6G2+7ZOXdUuxMCvq39RwdSadfEdYYjX51JDXQ7kUAfnWs2BiJapQWXGxix8rClkw2ByfOvSdo7yMQaWgDo0a6Ey9mm4Q0Rt3lRHtE8rBEr+Q4lgQWF1WAXN/DikMO5V8HSBEHLB8gRhVP/0CpJKkXurKfhA+oeFjUBKafHwUydQsVqD37cIkDSkbOfXxGlYZl49Iq+3+L1GIXaStFt54PXUeJj4oUikRkZqipxO5P9m8Zg7xxSO/kSFf6EyRbkKuoYyv7xRGlmfVuMSjJ17WN/CQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(2616005)(6666004)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8a4POQWROvwPHR66S5BgvLXQZatAkI5Qix7TU2W9F/6K3LjFq6zndx8rypqCms1E+tmL+DoTGoxZiRSTVFqbxN7ZSnx2272Kf5dBRBHlHo4GHsb3SmYq15qsvDfiRHW/Qb1xLiqLKnSM9sUaFlLgTmxw2jZj3df6VRKh93zrjWFi+2X9qNVT7DgJBiqYXbO9eSRA7W0K2xM1DXEtyvqAC2A+Q3JeBoCrTSPtkHzsaHx0o7aWLVUB9vwLad1IFB/nbdUxmJrk6ugXUakDuEHbw+ToPc6O+eC8klujDD/FutnXOymcFYvpGUHw3s242eNm+ZxWT5Ct2y1rNaUYPQkVi7UPqInQ9O5Cg/vQO3NAnvE18iv7TAkpan/TyIGth6U4s1FhLb6UC2L8gl85chh8EKH1+zY5WPexDuXV+qOJenxPd7TL2+E0C8Efnn8mdd8rGLMdPclGihv0g1VlbgQ7vVsQgChiLaXZe6SBIxhXpSdB/0Et4n/7BnWje8Z09d/2p4RoXtDF+swmg6lJ8cCho+IPmfSgQSlhvPErVpBNGZHf32hxnQIYCytdAVdu4gHvSqhI0h6MwrAslaxk1DBZXoLR9gPTTwv9/Hsg6/TaEEI0v4WtgbvYnxi5z1NBtfRcHHZFgo83VDkQO3ldANl8vDwPXgrTw1ixNVaf2ElgChosz7f2M6CSI5IMK5uJqKi8K0PFM5lJf4H9Dau2/C/WqTf1iCbOkSK33WhHv976hKUjjHikoT4BXGazM6dxY3lJRdkhXN2vRcy5j8RDkkOUrJwKfW6OSF84kgiNzipIbI7ZLwRlUJw87XVd6kEbBm4VwonalqwHn68tRpvbiIABKBieYtJau1uFWzdb1nSPhbTWmdEG34aDzQGTzjY+z5l9MyN6/W6c0PeIe1+aPTaPzxfLlUHPcU8jRw65MUKdLKYqvlMYGsBSaf5zbiFWqMEq2ZQIfbHQz4h7eUmxkWdRDlSLMbiTzNMbvvHJq1VKUkHtv4UyhsS6aLQ+THDJK6qhVJ9DKNxhIRwFZucLhuHYQsdjW+qdl9J1X8i10du4KNgA/EuK6ozRhAn/McnpqaGJ/sHhmTSyJqQbARkPjhCFxFcHNl3Mnc5MziVhHSWDf7csWimuaGV8ZRsCCBCMINKOIoE1iZT8+sU+S/kIF7YPU6Ly3XHZAFcT4FeOjckSiRV2kV9arSXdrw57h1GgY9QcEd6uB/NLGuFIFRqC2HpuRKTMwrPGhAKXTV2irCqavnrR6ZktEynAdc/WC13mGLBULfNNhhIQN4DddAXqHF1uxaurvDqx4n7aWyd3yYhajpC+HTw/4jRDv8VQETbQXUb8FdyL1eZml+LG7krSdj0ELRIefoIO3yG3KhIRKMHcalO6Q8u4bpwqiNkTkE0y5CaNPJiAr5tzFPsI2dGUkSW0qP1Aaz7eB+oUzZiszvPqt4pjz46AXSCBsElufzjq9P+WzwIKBBPCgiY1e+RoztQdmjDNPju9b/2W774piu126iDVtM6Jlw+bQYQNPH5PC4G9kcBi9q50O9HXrVhGs3MKLHirNx+vjAlfAtRru+IQLWdjN8V0aKmAWK+kblCopuMXlXF8+nKT9XL9fTyXg7h9Hw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61534432-ed8e-4701-a47b-08db0912f587 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:24.0175 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aKYW4eNbBQf2hAynvO61MegsDnGtr6FylIBM8XpEBHzzLxS8lQQeHsLMitpwYvRiE/9jusCduKWMy+bhfHwCTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757181005830054793?= X-GMAIL-MSGID: =?utf-8?q?1757181005830054793?= Some qdiscs like taprio turn out to be actually pretty reliant on a well configured stab, to not underestimate the skb transmission time (by properly accounting for L1 overhead). In a future change, taprio will need the stab, if configured by the user, to be available at ops->init() time. It will become even more important in upcoming work, when the overhead will be used for the queueMaxSDU calculation that is passed to an offloading driver. However, rcu_assign_pointer(sch->stab, stab) is called right after ops->init(), making it unavailable, and I don't really see a good reason for that. Move it earlier, which nicely seems to simplify the error handling path as well. Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: none net/sched/sch_api.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index c14018a8052c..e9780631b5b5 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1282,12 +1282,6 @@ static struct Qdisc *qdisc_create(struct net_device *dev, if (err) goto err_out3; - if (ops->init) { - err = ops->init(sch, tca[TCA_OPTIONS], extack); - if (err != 0) - goto err_out5; - } - if (tca[TCA_STAB]) { stab = qdisc_get_stab(tca[TCA_STAB], extack); if (IS_ERR(stab)) { @@ -1296,11 +1290,18 @@ static struct Qdisc *qdisc_create(struct net_device *dev, } rcu_assign_pointer(sch->stab, stab); } + + if (ops->init) { + err = ops->init(sch, tca[TCA_OPTIONS], extack); + if (err != 0) + goto err_out5; + } + if (tca[TCA_RATE]) { err = -EOPNOTSUPP; if (sch->flags & TCQ_F_MQROOT) { NL_SET_ERR_MSG(extack, "Cannot attach rate estimator to a multi-queue root qdisc"); - goto err_out4; + goto err_out5; } err = gen_new_estimator(&sch->bstats, @@ -1311,7 +1312,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev, tca[TCA_RATE]); if (err) { NL_SET_ERR_MSG(extack, "Failed to generate new estimator"); - goto err_out4; + goto err_out5; } } @@ -1321,6 +1322,8 @@ static struct Qdisc *qdisc_create(struct net_device *dev, return sch; err_out5: + qdisc_put_stab(rtnl_dereference(sch->stab)); +err_out4: /* ops->init() failed, we call ->destroy() like qdisc_create_dflt() */ if (ops->destroy) ops->destroy(sch); @@ -1332,16 +1335,6 @@ static struct Qdisc *qdisc_create(struct net_device *dev, err_out: *errp = err; return NULL; - -err_out4: - /* - * Any broken qdiscs that would require a ops->reset() here? - * The qdisc was never in action so it shouldn't be necessary. - */ - qdisc_put_stab(rtnl_dereference(sch->stab)); - if (ops->destroy) - ops->destroy(sch); - goto err_out3; } static int qdisc_change(struct Qdisc *sch, struct nlattr **tca, From patchwork Tue Feb 7 13:54:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2863617wrn; Tue, 7 Feb 2023 06:00:41 -0800 (PST) X-Google-Smtp-Source: AK7set9qHBbqW7hyDftTdyl1LTkUjAeKm+1lJb5R68eyYPMX/H1shgwBHiD4kkWLNZfZ6ZSZmYEH X-Received: by 2002:a17:906:81c9:b0:88d:ba89:1840 with SMTP id e9-20020a17090681c900b0088dba891840mr17341738ejx.17.1675778441372; Tue, 07 Feb 2023 06:00:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778441; cv=pass; d=google.com; s=arc-20160816; b=pMsux8KNF1ArBpu9NxY+8dKiC/CZg7aDknYYXb6y7Ff2zYvwNAaOjS1RQZXmyCy3BO lrNXXvoAi3kNnKzKygc+YorL5oCutZvN6wjzUjNlIWikI638dkP5SrgjVXyS15oFbEfM Jspj9ImJ8gowbPl+sI7ZYs1kFdVnZPAWJT06w2XCzuR76tSlydWoeuYmOI5430X8jq9e 6kdbgX/mOZcp7xk2ySk9HytUlBo2SEu6bE9S/eu7Zmgs6zwQ0nofJL9kN2QTe32m6bWX AoH9FsTCG0H+4vEthQf/tWWNszgbWG2zgc3Mb4Gq6PBqiOLwbkcIur1xMPNbL8+XfHwE 7xbg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yS3NFUx8nuK7XC2Esse+57Ko9xwMEbc4qNSXxpQsgDM=; b=KVv9poASyNfouLLgRINuxoOLJEnEioGwScv7hW+3BUHab5JKtI1LEOWOlWtY4KyruJ W1fY8fIS/XiGMO1rcCjTNhSn7iBF3kiZdXSwurPrfVo95GZgo947MDW/idXX/nH+s29n 0KQ991wJdF9UDvdmuX5uQXT+L/DEN3ztuI3IskdlSs3iJZZHh2s5xDriHfF6ELpKwUy9 ZDsyUfYRskwyVQLzVi3qogVfQSZkBzL5xl3HyiQqW7MM7OBEFDt2IEra/y6mT4+G1VOD Y5pGpxg5UlyEIkyVwezL9I5X7Yk9LLvUBnvNSPqLIdhBeaem5CwPttY6EJaLVs4yi/LD PG1A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=B9u4CiZJ; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f30-20020a170906739e00b0087329ff5934si19637875ejl.0.2023.02.07.06.00.17; Tue, 07 Feb 2023 06:00:41 -0800 (PST) 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=@nxp.com header.s=selector2 header.b=B9u4CiZJ; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232299AbjBGN5o (ORCPT + 99 others); Tue, 7 Feb 2023 08:57:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232442AbjBGN50 (ORCPT ); Tue, 7 Feb 2023 08:57:26 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2058.outbound.protection.outlook.com [40.107.7.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7292638B58; Tue, 7 Feb 2023 05:56:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DKDzYRhs138UqZmNCLASGdPWI8miSkb5UBae6xJeuOD/8MLVlg/9yKRp6f044SIp/qhuJWGv+1kZYPtiMQdxr9eH7gYDHOPY3p4pdqxUyZVdePH+9acNWRGHcNsfz83frVRfBVzJ0YsgMHsb5qJCBtEL4NNw0N1uk+Q4cGUNW9R2EQLYKFKcPoELWxqqdnlR+LmE4zO9G42++orgb6yX96LL6VWROyYXtjwkvyLdlQZustzRJL7Gt/ZacvZPOGl8Ax+Dm4NX1jAUf9tksd/11dLLLRUQdPPReldTXPhbpHzPk9GSucNwRYCZjsQ2ypBqZzS4Nqre9nqgk+r6DH6gfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yS3NFUx8nuK7XC2Esse+57Ko9xwMEbc4qNSXxpQsgDM=; b=gIicsbrE2UGj1O6YdaHxu2anyvzLxYjHB626rW7tsogKpEhNlXKMp+Cg/fclkcju5EZKaz2rSIKsloj/ha6wlBjst0nzIVfFUtLiRUvdt0c4J3AVeOpyRwkD9S2llDZGlsCugnHSnXsEPZVpMNIIWEUfZjOa/9dXytQJjjgeBzJ3at+ECCiRr1crDtdI/+cS628xPSR60r861GunEVdDyjlRMJnj6GYOXpRDNgrzHPaso6RkIcYIDHSBKNmhSWFwRjHi/P8bDnB8iKkkTWQQ1mW1/juf7pI954ysSh2M8vopTzRVoLhXjDJzFwv6GhAyMYlU6MLUIYFEQH4dbRmCJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yS3NFUx8nuK7XC2Esse+57Ko9xwMEbc4qNSXxpQsgDM=; b=B9u4CiZJwOisqRkT9iq6GpSdM0LrTzLL1y68cRxjJ/82BgGj94W+lgMSitGvUhqDJTIurqRTnsmtF9z4oJDvoTUKcbXFqOS2c136XkhzmOk8+IUQX91LVXr6mRShb9Wwd4yAYsHs7ReJoI2yKNp9wBIyw1Zwe7rrPdMpwSDUpWQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:26 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:26 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 11/15] net/sched: taprio: warn about missing size table Date: Tue, 7 Feb 2023 15:54:36 +0200 Message-Id: <20230207135440.1482856-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c9799bc-f1a5-4394-a507-08db0912f6b1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YhnU4zjHr0M9YJCFN86hgEWdIQ5AeK0ftZlkKq/qzbh6dedpoJO8s+OrXTbHaEzklqMji0dYgmbaG7UhtH3p1gSNO9BEDJu/c6oLIkoQ6EkKMn6XpHvG4pwGU46s/29f5u5ID9zol2s5QK52ubCN7D+DRgzpRTw0rsrLOV2oTnKHHxN+4iaMx8s/P6uRRj+r4TpqI/rGF9zULXSRHkiWbxA2NUKNg2W3BdvAZx/ZVxuuEoQsmT7TOl04H3l8eLAJSFLs/glpO1iHP8XWcs/HS31B5HLN0fRkd+UysumFY2594jOgIfUgZBS5R7/6iiPPDf/yOt92biy0bO59JV01dEE7Y1Zp90ASPrervIDdyaOJAuaO/RZtXuV4wxqnh1KGgoIV0SsQlLf6oUR97MP3Q4wxr5y+zk40R3jpK9f6Vxvx2/lA4vgC//UwxB8SzTBTuYQDcJ5D6OzpaHZlJHHbS5uobXKdOAPV+PHbLgXKak8Aqz1/vWM8R0DfSW2Vqhpm01VEeMKHKPTWWOiAmB/bMnSLMe/Awbcrc6xW5Tx7/T46wabHq036UK145R8VfbOPRaPs38WbcqYBMKB6fGLIrGSzG2PRqlmk1bSz5vqq0kyZqZ9Weh6bLeaJ3OE5z6QcTF4whDRs6ddOQXH9s40fubg7ta9Lfo3MZcuzk3kBjlhf+Ui30JtnsZipgOCNB0YABZ9l+bgAb/y2ll6YBtx1LXJyH7lhXAzfVmih6/E04mE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(966005)(2616005)(6666004)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VJpVjM60XDJhUiuw72BZsmk7KZ/LJeMt0kklj/8TehzFRbyq1XPdQ90V22FT+NHvM6XEI4120r86EmoT3OzeT/3Iq036etGHtX8hJneNQSNtzUfzMJ24wv+n62OIk6uYnSDarJDTY/vZjImRORqe+BYVDtNLKubFXYapX+SNn9LH3MoWyNQXfY9RYYDXni1SuwCtOVT8w7oJro70D1WpinMAqvxTtFZU/My/ivRNnkzfyV940eyJiLCIRCQooefM8BTKKtgVAJIJ6VqsrhTF9esT4y36YyWpcZU64ZxjyQoSFqNZ208Oh9bHYXGZet7AwJLp2nzIuIoVb1R7HYB9/sdxhUb64WJMUanMQnrSZdgBL477VJJZjxK2sDjeFlQFPGzn0cYoaWh2nTBHJkQxRmw5MkUZxqrvqTYesYTUFRwyOAe/bl3VDJ8B6KPic25doLPLLvW7cRMfuyOTkdwZozyop5zQsGVPoPNq5/RbFpyecS3e980uojS/+NJNVXj5NYKGIFZ3OpNWRRBEOuQk7CUGEJEnF9wfOD2I7VrNFDhZm3x6BK6OABDlb0DUFwbhnyszZCB+LL4f5mtz6Eif556UEmx9a5gFJ09TVNfE7tQNn1yobx2yufW0oB/myqjUb2icJxzipWYlohqK/pf6rUxrGuKivzo+RZv65bmkrJTuy3iuNTx0yIS2LR76hkSThmQ5D1Pe4G5/ujH3eVZCL7ec1F5Xs3mQoYA2hgYr5P6pspKrufOzlGjcVXhoVYnZaYswP4p/MEFbFQwsC6EVI9QXhs+mD21CzUG770ivnEd5TjHUSWQtYXUh/zUu/MqHSgZ9OIDMwKIFkexHsE4F0/UoxFegbSF2JK+uNItFiE7dqReHkhiPYm6EgSAEd53QgGHsTQ4uw+J1GFMId05qQWNogHVogwtPySDnCPZbPbtOz1veoHRQo9o97U1OlrywP10YbAJ8/5ae2aCqCFwNHk65LbXEjEbO15bFUk7WQpMxscaDUM1Y3fKJiKibxkuMH9vunBcAlp/3FfWUp1TMw7XJoS1CEhSsT8Wdm0Ro3wZGvtxz+Vujd2Sn9JA5aomtBDPhs79k65id/LcIN5z4LFJBWP1EoLi3ZvZyUv98JR6IwrGn9eBUk8P8wdx62rlH5q84ctCaLWxnok86eFF74ko/dZTl712wOC5ARO/sj4o6Veoryf43b1R5qSbXrwfDSKCKIuAW2bMTfO5L2N5NBupD+u6dl66S0Nj0ubkxKbR0mgnIXmV+mNE4q7dGYPOBJHB8iHQxfqgpq2tTQAXneZkXZeEntvl6BYTWSV1QPQ3bcjM3SVjT96Cwds6WR0VZ5owutcEvcg6uYq1dqMDprF3GfLDla1NHjk8CIexb4crhIobpSONU4SUfqTOaKgWy5fdGRVpmZERTFdx61kUnVJ+L+ZIxvvvh/ufVspx2DmmFh8eaYnXxkR/9wi1urO97T8GKd4K04yF2L4Ahgay2bxJPKv7YAHSgJNkJCS2J+XmdOer4o48aGKbUG3mvzRKFcEMfvnSPWcdu/a5JHdORAppt7+M9LaChrrQw3WShtcjK3FiWAFD5oMaWbCZMG60G5o0edNoZK+YuAci7lobLTQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c9799bc-f1a5-4394-a507-08db0912f6b1 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:26.1736 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6TbebOIv0mmTesOxDlM3rMW2NwwlCmiFRkkEmXUDxGQIUV45RPquIqAiolsEFq0KkKqKRZdUutpTq5qLADlY0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757181055074486377?= X-GMAIL-MSGID: =?utf-8?q?1757181055074486377?= Vinicius intended taprio to take the L1 overhead into account when estimating packet transmission time through user input, specifically through the qdisc size table (man tc-stab). Something like this: tc qdisc replace dev $eth root stab overhead 24 taprio \ num_tc 8 \ map 0 1 2 3 4 5 6 7 \ queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \ base-time 0 \ sched-entry S 0x7e 9000000 \ sched-entry S 0x82 1000000 \ max-sdu 0 0 0 0 0 0 0 200 \ flags 0x0 clockid CLOCK_TAI Without the overhead being specified, transmission times will be underestimated and will cause late transmissions. For an offloading driver, it might even cause TX hangs if there is no open gate large enough to send the maximum sized packets for that TC (including L1 overhead). Properly knowing the L1 overhead will ensure that we are able to auto-calculate the queueMaxSDU per traffic class just right, and avoid these hangs due to head-of-line blocking. We can't make the stab mandatory due to existing setups, but we can warn the user that it's important with a warning netlink extack. Link: https://patchwork.kernel.org/project/netdevbpf/patch/20220505160357.298794-1-vladimir.oltean@nxp.com/ Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: none net/sched/sch_taprio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index e625f8f8704f..7553bc82cf6f 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1690,6 +1690,7 @@ static int taprio_new_flags(const struct nlattr *attr, u32 old, static int taprio_change(struct Qdisc *sch, struct nlattr *opt, struct netlink_ext_ack *extack) { + struct qdisc_size_table *stab = rtnl_dereference(sch->stab); struct nlattr *tb[TCA_TAPRIO_ATTR_MAX + 1] = { }; struct sched_gate_list *oper, *admin, *new_admin; struct taprio_sched *q = qdisc_priv(sch); @@ -1842,6 +1843,10 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, new_admin = NULL; err = 0; + if (!stab) + NL_SET_ERR_MSG_MOD(extack, + "Size table not specified, frame length estimations may be inaccurate"); + unlock: spin_unlock_bh(qdisc_lock(sch)); From patchwork Tue Feb 7 13:54:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53917 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2865483wrn; Tue, 7 Feb 2023 06:03:08 -0800 (PST) X-Google-Smtp-Source: AK7set+ZgMSKlakRWIekatz4uvfbZQ8lArpcCb7uNckXUUVS6d39t063WqEtHCiCh3X2i+YyC0Q8 X-Received: by 2002:a17:906:8557:b0:8a4:7806:6eed with SMTP id h23-20020a170906855700b008a478066eedmr3609646ejy.63.1675778588086; Tue, 07 Feb 2023 06:03:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778588; cv=pass; d=google.com; s=arc-20160816; b=w9RoNLVr78znyipNWjfczmaU64Wlaarkv14ptn3viOtJW2J4ZJBvZdp8UXH7M0RNI9 kNSWVOOoygZLW3nHqZsRDy2DlfysWVv9hpf4PJwQ0GJH/hDIhvisMiIgz/kTwxeF18o/ 3PmFHhnf1PJMMrBtxfiJ6vXnNkWt4YGnFlTNhs5kqYVyoMGztasuvplYsflIQpWNRABN tNLCBkOn6uzTPx+myRtK8OK+iXMfMsudIrNb8w0++/nI3UGXJz5zkCJyWZigWvODgPhx cC8U4mYQ/cdzWK/+Qt87XgkWx0CPUpUqNUTH6iApbp2PoLPDxb1W/7wwVSSwAQbarsOQ GZag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dyvBdeO4lzfn6LZwQegbDSoHEdK00RUbNjAp8gCQn1E=; b=NtKndKim99wsdYMYN++ECh574RJOAIMph4c56GTQF/oE01v9IUAjlRjFDEuQJPGUpJ xkeMxvwXihPWFC/O363U6jyw+E3rPMniVAwhl60h9WvivCOW65j9apdEUYK8fi+46c9G uKnjEAA7ukVZxhL5tRzcZltb56Hc4p+VijdumGs0+HeKshbegGDOJtTBZhPNAY72vGOR wjOYOhG6aOyIdWxF/Fkxjkwjs0pMARQjWUWKRdYmdJFQ5amVj/ZpL7XDt/3I7c1t2ckJ AV6w6ac9nwWzbnxnD+TIuQTmrjpwU7vt2dPZZMqXI9F8u1flBRfFJ3/kLMtZoMnBh7Un VN+Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Xi5ugnyY; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 15-20020a17090602cf00b0088b3b09e143si21720250ejk.593.2023.02.07.06.02.30; Tue, 07 Feb 2023 06:03:08 -0800 (PST) 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=@nxp.com header.s=selector2 header.b=Xi5ugnyY; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232450AbjBGN5s (ORCPT + 99 others); Tue, 7 Feb 2023 08:57:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232296AbjBGN51 (ORCPT ); Tue, 7 Feb 2023 08:57:27 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2081.outbound.protection.outlook.com [40.107.7.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4C9A4C3F; Tue, 7 Feb 2023 05:56:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=idXzKj1gfnA3KDyyRQBg3Jq50YQe26YGL7iaa0+EbU4PjwaEdVrCb+0CCjtuopIROYZqIG1TNTsJs++t7n+sbAN7hM3hC6qqiFCxpNGfk4QJUkH2E/8K8UK9Jfn8lrxJLjDeDGZ0flsHPz4xPu+cmo1ebImnflJ4AJnlNhRosb5+FkG4ffwkr/EPmRhsKLHgF4rs7k5yh7ZH1MZ4nfe/vvoviz2b+UUwe17rU0u6Veu92PmR0o5IZvARL6385LAGgKivHedteL9lWHpXJRofD/OUQwcJRRLA676Uh5T/2ZAoxI3UTdkRWeril4iWVTG7GQhGUqXmsz7mFVttNqBv+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dyvBdeO4lzfn6LZwQegbDSoHEdK00RUbNjAp8gCQn1E=; b=jak3ynTCwAVu09d2Je9bSWEDJlPhOjGY3TB/9E7Nvtx9I+WK7m1/kh8umcc088Y5KA8tUERgu8pVWVcl95+Cj9jyExvE4Bt91pFgMnyNZRKXbGU4HGuM7uAz0MdsfohsYefz8PsWFZAH1iu1lT0oU6BKP6KwSDvXIFsNj/mLGkqHD++7azRAC95Z7cmZDpe9blonY0MLMh55Az8yRZZBJvnI3yKyBhI7WHwAt2NqYJODVQa0hvcKuF7hJFD1BuTa4MAgf5iv05F/IeK6nu4r0qT70TiXATiW5v9N8YFfx4wBs/ThYfu9ekGtiwMdP3Tkuu4oBPvIaKcWSoQ8fm4Cug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dyvBdeO4lzfn6LZwQegbDSoHEdK00RUbNjAp8gCQn1E=; b=Xi5ugnyYR/O/bwAAeP6zZ6crxvknaU+GY2X/kx38sY850/L80IRAKSZ73/397F3Gf3ZWg3A4kAkNSVUvcOqSepbUoqxEBtoGSWV0JAlO1IuFU4zHkup1M+IrJsxDtepTsxDqIJ2wzQhkpEaSdl3x122zPrpQfMgrNa+/hEQQg+U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:28 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:28 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 12/15] net/sched: keep the max_frm_len information inside struct sched_gate_list Date: Tue, 7 Feb 2023 15:54:37 +0200 Message-Id: <20230207135440.1482856-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 272ba18f-0ef3-4187-ef79-08db0912f827 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9IrKekyZ/BHeCtE4ID9m8SOa4I8EXHHb8EQ0f3Y6NSndjwx+5knxjzcn+e2i2eEKgKMHqpJkporb3EF8hYOFi8l4kvL7QaEYwvABvwZq7HgH/uHIJN+OYBgjEPmgxv7RLMSvO9YPDZWFbvm6zoRC041KbHCsDK10jNCk+T0fNFOI+A9FPKVrCNHPkPh326OflgQTFiZQvp130YkJ6ANJ2utV9TgyI7PfFTMpWrW6vh+LHw4bodXPWH+lTgcTXlU2xU34SvkEhUS9Qs0wKJ1dWQvN7dmS7MeRXVkOm7fZeIbd2dGOKHsX0SYZzIH0oJRkEd4MTGwXSf0EmBtqCCxXzYHayE1oUBz5z9lSfoV2Rs7NXFulW09+lSWXqfHpMtHvyZoBgOFZnxeiWyuYmB0nBwiz7qMqMQZ5EQvbgBtFetre9ba9mMDPenWsC93mZ6S9Gw+BPh+ZqeAG8O0geRhl+nJWpExYhSB48nN6A0eMvy6mMXb2ZwCMc4lxdeF0RFMS7ns911xKP475qYPLcWGFRrK4qhjxhqfpCdJKkvFkBT61OyzxHm3PvDsp8YuV5GazDLaKbRV1xe32FPzwOEiFR8aDwpPrlscPHkdwiC7yR3QT2AiHCc/PEGNJwr9EgHp4gMa8L+La/xq/JtE+xSRPEPmKjxv3vowKicRLfC/Sww345dzGJqMwNmq3PX/jeJpkZDNex8pm6sc/H7kBVD4/Vg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(2616005)(6666004)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gcpKVbEYXzaWbaPv8iNrOPz18JAlQTtncKGsyiods0FQRScwtyijPB/QuJViwUoJFS/53UB37pGSvPiR9fJYOnRGKtEN0gS0WULCSV2bX1EgbK0zj5Ros/G36CGH2hOjtT/ZVZ45D51+DVSZl9319tleKi8GSu2SQEEUl0v7sf1XCdeDmXLz+j36/EAn06XsNkQH6X1lHY7tH/57ddkbn6oPhxyf3MmnRsucx65acNNe/mqUGCkFo0rTvDqv3c2iLsV05I6fINlLwu3ByMcyIzvIMU4LOOs7Zfiqqd9DlcsO/TJHr/h0LhiZV4xwP+nG7eV20NP6ZHhOY18u7wXQIhKKu6e0oCf+mtVdp+NwWmfkRs6UGrQ5EpBjTGrRrCQr6H5pK0KAy+VVT3bU1JI35xdf8dt+C2lQjeMeaSP6p9Gydy7in6nocoyDIXxwFqH8l5IoBE4MoLoAqS7gx5mUddfpY9PdftJa+4eg/GkWjcYXH3gRLJ5eH5M126PnULkaowveCUf0Fs9YsPnWXcs6fz+EQGt6bNp9ypgVPqhp4wB3V26v1r3q6Bj+FBA+unRC+aydLa4XdNGbYhHdqj5nLIp7vOxnYvIa2G9hBUWi2htZIm2df5BkFy9UR58Q35l4V/ayOrJeLYH0rn6kI7sda58Io0sOnHMroYPoZT3RXsu51d4NeSOruhtUG4m6XtYaZrpoJxZDcF0yo3JYAng/Dz0aFIrKRAjDD1C668E7Ql8ttaPqX7VWyc9qwwM/sqLsyJSloB7AYiVyjE5jc/P+jEdjQS0sgxzqCB48m6A8Xxm2sHIyd/1IUaipV8hNYNunYOlleuZFwe2kfDrXszMXH9vhtySdiuuN8Aa+8kb4E6eUEk5TctA0xaifXu1QtpMFqWB/3J46IU9s0jeYZIDUtzO7cbMEydqKVolzHjQl+YLoJeFym71M35LnkUV+uG8h+V8AiVusYYuPXyHkZoaWmLqaxUPqK+3+z27ZUaVQJZHpS6ky5GYuMBVTwYWaJwZADy0jt8oV7pOavT8NuZy1KDA0nVo62L+s3YFws/bS+6br1FHrK7BYhvbsWU2M00PVitD/TCwpEPvRE+qb52Nfg1a/99/fkW3B+qEAyAUMHIKP0TvAvTzbtxyU601kCHkFnLhPJc2l4v4lFpkJFf6zTmqDre7wJ4RV5he72UDAn1mKm2vFmFrBh9SmTDV27MGKocCfui5MPn25JU685kr7pQ96M1r929840eKLnwvOdRziBaFwY+90dqOaocDwcPTk8iM9XDc4LmNx5bnIjpicxLME1ZmkaBMCBnQElZpubZ5vlgLDS8Wcks6qXvQpY4aI1ETbj7WpepRdBkpCxmBDDupW090caqM1UrnE8qk+3JIGTC2mgWEOY/SyDExEsMnj4VT5ophRHTcJE0kLtc21oQY15hu+q7GHE3N8WrEaacLIGDgNFHZE1e/65JEyB0wdNGGNHOxL0/AIp7iwT83vyNHZsNEpQDXqBndTmCKdqh0CLEFS0rbJ0gc6CshFnIsmlzmotQcU3OoFYo3JNSyRij0e1EtmlPe6yh6ExRV3U7OYvqaK+ET8imOJGRv3uRw1qJuORkSCjyD2pQEU7e1Uug== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 272ba18f-0ef3-4187-ef79-08db0912f827 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:28.7984 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DAxIcgdUt2eTQgeFI+B6UYjistp+GWyT8gMLTpFVg8kXVPObyjWM/9GTRXFpYNxWw3SQtjHV75b5V5bAk5yyEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757181208347535408?= X-GMAIL-MSGID: =?utf-8?q?1757181208347535408?= I have one practical reason for doing this and one concerning correctness. The practical reason has to do with a follow-up patch, which aims to mix 2 sources of max_sdu (one coming from the user and the other automatically calculated based on TC gate durations @current link speed). Among those 2 sources of input, we must always select the smaller max_sdu value, but this can change at various link speeds. So the max_sdu coming from the user must be kept separated from the value that is operationally used (the minimum of the 2), because otherwise we overwrite it and forget what the user asked us to do. To solve that, this patch proposes that struct sched_gate_list contains the operationally active max_frm_len, and q->max_sdu contains just what was requested by the user. The reason having to do with correctness is based on the following observation: the admin sched_gate_list becomes operational at a given base_time in the future. Until then, it is inactive and applies no shaping, all gates are open, etc. So the queueMaxSDU dropping shouldn't apply either (this is a mechanism to ensure that packets smaller than the largest gate duration for that TC don't hang the port; clearly it makes little sense if the gates are always open). Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: create a taprio_skb_exceeds_queue_max_sdu() helper function net/sched/sch_taprio.c | 53 +++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 7553bc82cf6f..d3e3be543fae 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -63,6 +63,7 @@ struct sched_gate_list { * or 0 if a traffic class gate never opens during the schedule. */ u64 max_open_gate_duration[TC_MAX_QUEUE]; + u32 max_frm_len[TC_MAX_QUEUE]; /* for the fast path */ struct rcu_head rcu; struct list_head entries; size_t num_entries; @@ -93,7 +94,6 @@ struct taprio_sched { struct hrtimer advance_timer; struct list_head taprio_list; int cur_txq[TC_MAX_QUEUE]; - u32 max_frm_len[TC_MAX_QUEUE]; /* for the fast path */ u32 max_sdu[TC_MAX_QUEUE]; /* for dump and offloading */ u32 txtime_delay; }; @@ -246,6 +246,21 @@ static int length_to_duration(struct taprio_sched *q, int len) return div_u64(len * atomic64_read(&q->picos_per_byte), PSEC_PER_NSEC); } +static void taprio_update_queue_max_sdu(struct taprio_sched *q, + struct sched_gate_list *sched) +{ + struct net_device *dev = qdisc_dev(q->root); + int num_tc = netdev_get_num_tc(dev); + int tc; + + for (tc = 0; tc < num_tc; tc++) { + if (q->max_sdu[tc]) + sched->max_frm_len[tc] = q->max_sdu[tc] + dev->hard_header_len; + else + sched->max_frm_len[tc] = U32_MAX; /* never oversized */ + } +} + /* Returns the entry corresponding to next available interval. If * validate_interval is set, it only validates whether the timestamp occurs * when the gate corresponding to the skb's traffic class is open. @@ -479,14 +494,33 @@ static long get_packet_txtime(struct sk_buff *skb, struct Qdisc *sch) return txtime; } -static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch, - struct Qdisc *child, struct sk_buff **to_free) +/* Devices with full offload are expected to honor this in hardware */ +static bool taprio_skb_exceeds_queue_max_sdu(struct Qdisc *sch, + struct sk_buff *skb) { struct taprio_sched *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); + struct sched_gate_list *sched; int prio = skb->priority; + bool exceeds = false; u8 tc; + tc = netdev_get_prio_tc_map(dev, prio); + + rcu_read_lock(); + sched = rcu_dereference(q->oper_sched); + if (sched && skb->len > sched->max_frm_len[tc]) + exceeds = true; + rcu_read_unlock(); + + return exceeds; +} + +static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch, + struct Qdisc *child, struct sk_buff **to_free) +{ + struct taprio_sched *q = qdisc_priv(sch); + /* sk_flags are only safe to use on full sockets. */ if (skb->sk && sk_fullsock(skb->sk) && sock_flag(skb->sk, SOCK_TXTIME)) { if (!is_valid_interval(skb, sch)) @@ -497,9 +531,7 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch, return qdisc_drop(skb, sch, to_free); } - /* Devices with full offload are expected to honor this in hardware */ - tc = netdev_get_prio_tc_map(dev, prio); - if (skb->len > q->max_frm_len[tc]) + if (taprio_skb_exceeds_queue_max_sdu(sch, skb)) return qdisc_drop(skb, sch, to_free); qdisc_qstats_backlog_inc(sch, skb); @@ -1609,7 +1641,6 @@ static int taprio_parse_tc_entries(struct Qdisc *sch, struct netlink_ext_ack *extack) { struct taprio_sched *q = qdisc_priv(sch); - struct net_device *dev = qdisc_dev(sch); u32 max_sdu[TC_QOPT_MAX_QUEUE]; unsigned long seen_tcs = 0; struct nlattr *n; @@ -1628,13 +1659,8 @@ static int taprio_parse_tc_entries(struct Qdisc *sch, goto out; } - for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) { + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) q->max_sdu[tc] = max_sdu[tc]; - if (max_sdu[tc]) - q->max_frm_len[tc] = max_sdu[tc] + dev->hard_header_len; - else - q->max_frm_len[tc] = U32_MAX; /* never oversized */ - } out: return err; @@ -1758,6 +1784,7 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, goto free_sched; taprio_set_picos_per_byte(dev, q); + taprio_update_queue_max_sdu(q, new_admin); if (mqprio) { err = netdev_set_num_tc(dev, mqprio->num_tc); From patchwork Tue Feb 7 13:54:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2863769wrn; Tue, 7 Feb 2023 06:00:53 -0800 (PST) X-Google-Smtp-Source: AK7set+asxv3Mn971A/NdENtoKxlgpKP2orNghiaIVeC0Q57momeA7nS98QU272H58+c+gvBzH8u X-Received: by 2002:a50:8a9e:0:b0:49c:a7c8:527 with SMTP id j30-20020a508a9e000000b0049ca7c80527mr3442015edj.3.1675778453010; Tue, 07 Feb 2023 06:00:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778452; cv=pass; d=google.com; s=arc-20160816; b=EOkFiErqgzvt6hzFSX5l/pbcHWLCGgacANFle9CN+3PMsDYSzkP8lmQATq+QkFFbbt K5is3U5kpJU+VR6nKLygAgY7stY72fW6I57RZym6EATiIVC/JDS9CY6nq7I9/j4X0A0V 2vLLkOlwBxU1tYpDOLaGFdeYkipc4Qvl+pLtZe3EFcqVJ5EYXKx8CsvIw/MMbH6i3EGW 6ihAy6UI/qkLo1JKHOSP61fu7uoOu2I/hrR1ai+smv4FG/12YvWtlTJOkosg+4qDbDyA bx1rEvb+kZcSdbOtJ+FpAKdKJkC9sMr5bhlj9DGQrpBj0rLMnQYM7yY0mcJDtJv9Hu5U kY5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nuPLRJ7SNyyCiyR9jFu+ruSdL2kWjmKTnlGihV9wK+U=; b=gfETCLH+7V31cc3YAW9KidaNxG3dzCxhgW1U7upPMmNeH5JDe89r7L0zJQXdvJ89M6 rJhXnyxNwNfDRq4V2Gv7RKWk92nAHPXda+tgDKud91VRE3La9tLDv+Oadj6fZnmJ2SPe t4gIZJ2o0wLZCOiRqmgsN5Ti3h8bdCg17Yd4Il/cKazJRPRAD79DBk2p4PwsW86F3DVs m/qM3PdeowmzD2G4l9AyUV/2A7NH1+MfVJHHmvqONdET+ZKemeCGFMD42E4VtFRBOwtg sOr82hvb6/mQClF8ueeQp2D5Ydt86vRoMgcl54TXHHzcUaF0xCl8LmbPH+Y5/HKe4aFI dUPw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="o4UQ/xy2"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a056402240700b004a2687900absi18627411eda.351.2023.02.07.06.00.29; Tue, 07 Feb 2023 06:00:52 -0800 (PST) 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=@nxp.com header.s=selector2 header.b="o4UQ/xy2"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232486AbjBGN6W (ORCPT + 99 others); Tue, 7 Feb 2023 08:58:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232058AbjBGN6E (ORCPT ); Tue, 7 Feb 2023 08:58:04 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2058.outbound.protection.outlook.com [40.107.7.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70B442E0FA; Tue, 7 Feb 2023 05:57:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NvEjdkoPTcBYhb5IEGmK+YTqtNyz4VGt+cheWFpVlqZFZm/DBmMVU1y2Wxzt7wrgoQyOF6XzY0iJk0/XyG3tAMTzHFJXdEMzJNPgxIUqU81PnZ3mfnPWJ7MjOUKutoBCrISlahjYR7C/yhFzYHtYOaTwReBQYfZNgT/hnXUES7wl9hgej0TjVU3G0jS98AqTq/FGuvGGSVjjomcR6/nMjmrlJ0V82iFmX0mv75UUzYZceRubFBI/IWUQ/gCJ1p2qKi8fpPTiPIvd02EyWWuLAIi0pI+RoV60TyBummMO9q2jaJFzgFQ1erQ1ww9qNHwTj1EG1dvxo7E2t/Eqg5J2cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nuPLRJ7SNyyCiyR9jFu+ruSdL2kWjmKTnlGihV9wK+U=; b=Bc9v7+csCg3VwTtKvtWoUjIqUOSqnOH0AVtriTs0/EJNLmHqL9sA5FgK0/yIV3j+dOPq3dx1v7I6Sy8b0ng9bmT1JxN10rzSNtv+GpLaTrV+0Ktx6XRweWk03+E/aZMCLv1J73PLABfJmCrhHIfVJ44mNci9FihCgUGmcEEUiBcIkatu4RhF7T0hif7QEm+dk1smx0MdQUKNPJz4rqHeBfuHes4PeEZJHik6Majcf/YQzYooSp62CyyMPOJ4IGkFt2ScAb8BOO1LDcd/Nlb4caFoHWE4CJ9kzdf9Bik6n2enFoqswwgMRLBzrgvG1QfPkDjhvF0LOuarti50bwZPuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nuPLRJ7SNyyCiyR9jFu+ruSdL2kWjmKTnlGihV9wK+U=; b=o4UQ/xy2HhZ1Mct7Mdo8KyKf4sl76D4hwpK+RP1luau0OxRj5jJp29SYlORiHrI8N9PZqpm+WW92ujYwBTQ7dHfrZOFZ6TXZkCTWtBjShbw4KqrDUa/Hop0800F/2Ko6MeBRQA3SHx8ybfyNbvSy6sGya5yKWhbpaR/p5B0Fi9I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:31 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:31 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 13/15] net/sched: taprio: automatically calculate queueMaxSDU based on TC gate durations Date: Tue, 7 Feb 2023 15:54:38 +0200 Message-Id: <20230207135440.1482856-14-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 11b7ae1c-f9dc-423f-fe88-08db0912f9a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IFp7RQiQHNycD5T6RFxGF1AdmZ4AjDd0mWTaSCkZIXgDzSgYD9NxRdl/RiSNe7jMTqonMCnRzRHuEfbH0RkHUFECamHDpPrKT0RhMXubEOrF7En95RG6Q+Zd6SifVIYCW4LoGvdeZ9sZGeEZaJr2nfm/FGHnJAnygGgxuagtwxWFtEKdOivk5gKSzkl3/lC0zbwWqD3Qot47YIVXBe63jAzUa8/QK3FjT0yW/3KetuOu8cbPtAr4qYBqjRg7nrKRFojTcBEuWAJtnLhi/H9jz9uzt6/itrrxnH5ORB5+SL6ctUO6Aj5ev0qTDFs/6SSjEvbk1A3OK6TAFj3CnArngIpbSshnG8jKtdVKJxPRMvsDshXOYP9wcAuTDSeSkOtZo/FW6LLldTjqAg22djdlUeXwMmWja/nFXs2A5OMknKfuiLgHGqcZ7/kcT0kUoI0QD/taoEpHUrZuATm/P47VUqydXYqYMdtmNVW1EgjZ7VZ0ux+x6++NCToC7ykPB0PQ+6tT4obNsNj4AIXDQEZO3+jeNuJjDaygPKP7uJGPm7JXHAvZ7GV0dexPKnPVojWcXdu15GxUJlfpr7n50UXbwfS1PH095QqKsuz3uJKNfnwS6ubhoiXy7ZkLCcO3DgRryh0CcMGFkaK/XINy7YHnYCYOGPoe5rK0qolQe9AUIGW5I/p4Ob5exPPg2/Umrjt+9ne+LxqkXMRAevACk9L1lg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(2616005)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G37AU/hUAV2bBRRFwti/eXmOl6Zk206s7a8qXxXbIE7ZJ7RMIzoDFsi3AMflJi8hIXZs9Wi1a2L1/gOgCZCvqoNHA0MbTFJ4QwcxMwJVTKqc0juArltLXMIMzEVHt3LDpkvhsigb1ePuz5VPcLKqqN6AxSCtqhbDL1TKERBVBxwulhRuHgoBl84id/1pPt/QEVuf2X++YqfoEnqddfDqqQOvO9V6cY21yxsG02yqikNt2AivmJgiX6QwtqQzC+ZWvYY0hnAqzoxG1pSMiaAgVBp4vmH17wRvnlYYOpL3dghYo8H0jYi29MClmOoBXWHLKof4pnt6svPP1cStnjmNYv/b6A8ehuabb1/K3PvIODqFCrC+civb+Fo0xSD0DUBKI/P7aB3l6NuRxni5ZIp9PWOLF8rWvDDHa65DPnXAnphDVyY0+Ftb3arCuEkEMfKn9V5Kyka/YugofUcZwT3YkGumJNFZRBZ8XgLeaPmrSSTybYKs0+Esd/cqkgecAClmLat65QwMkMH123UCzxvZd4PehRGqD08stVyZaklQP8y2UA2T6d3sP7/0hnd7YdAvr63Fc8HlYxdcLwjIPCYT82eewdD02tMT0x09b4Il0B+UO7kcM60yuJqOTpC+ZfiKC0iel5MBM7lGU8o2f6aZA4nkRCZg3ORRhEnccWo6+M2cYrVkmBCzUrwbaq5jASs8zz0qbO9AvhqA5RLs/bZdlELmFnUAfAGNDg9N1+6xHFhtN043z/sim4+uaBoYcdiSCqGYiWgzLBwykKplccCJxiGE6Opbh4Y5hifhKs4v/31eKUnZu6BheFrZEmb+mQS6742V16+2GN1WzmQyiSeY6LmKxSxdN57sL8eoTHGsIgBjlG0EaUVufWXRJJX0yUS/opzTetUxAn+FQFxXdxaaH6tedU89WGxf5K2/Hq1af0WRVISl811Bb9kgf8Y7qantpiRFoQY5Nri9T+MsP5Wp5i9I+qn4QT+lBmsa7QVXCWxKeDJrKGvWnmOd/OQvESId0uUeAqEWY5OS1NLClECznO6OEyzd3smayGQkcLH8bDUXstXNVIQnAx824ylIgPohaUEaRBQ3bqbO13l+Q8/WZYHc+3bviLTWWS7aa4yXUaqA8JprREd97eAxMrKe5P6wrWSYGB86UZQ5CYGmlsRTqMt9rRjX5CV36TJT6U0vzoDyozq+hPvZNcDYZoOvcNhM4R1//kpLEMK1pt1NeQJChKbVZIB5obHeTxdZ8e2wz37qLtQkH0UL6TzWFWCgeNcvexaYXrSebE65nEzv2nuUA3Z7Vni3M3+w1z7A9Z4ROQSPchlMf44iNJfwOnG4KtuHZ5e9/VNsJi+C0CzBs5uIIFduagg0Mg20EQfYokD+JqclNFHKWFkA31WUJNc0lzmcoz/i8lry9esPluPqbkEnCmNXAcfgt3Idrnn96gcnrkbYM+k5o9bp0mo8ioCFzO1xyvvk74tsmrCVtrtpWbjjQUYibCyfZdYTPJzmpa5ZcumDq8egdoCmIMmZetX9n3tL2z088bu+QJ7tzPaFjHCzI16cgovFFfSFua3aZUDuTZLhkeTaW1Uu3zYu3j3LwD2bo1THmyZO1++LJvfklJcGgw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11b7ae1c-f9dc-423f-fe88-08db0912f9a2 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:30.9701 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1IJtZNyo3eW6YOHTN7tYSvfqDXNVPM+fxsHK+Fpj0eLeY5HuPLRfeSDDF7fqaItItS3EI1V6l9VIJsfNKrvNPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757181067530318961?= X-GMAIL-MSGID: =?utf-8?q?1757181067530318961?= taprio today has a huge problem with small TC gate durations, because it might accept packets in taprio_enqueue() which will never be sent by taprio_dequeue(). Since not much infrastructure was available, a kludge was added in commit 497cc00224cf ("taprio: Handle short intervals and large packets"), which segmented large TCP segments, but the fact of the matter is that the issue isn't specific to large TCP segments (and even worse, the performance penalty in segmenting those is absolutely huge). In commit a54fc09e4cba ("net/sched: taprio: allow user input of per-tc max SDU"), taprio gained support for queueMaxSDU, which is precisely the mechanism through which packets should be dropped at qdisc_enqueue() if they cannot be sent. After that patch, it was necessary for the user to manually limit the maximum MTU per TC. This change adds the necessary logic for taprio to further limit the values specified (or not specified) by the user to some minimum values which never allow oversized packets to be sent. Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: max_open_tc_gate_duration got renamed to max_open_gate_duration net/sched/sch_taprio.c | 70 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 60 insertions(+), 10 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index d3e3be543fae..e7163d6fab77 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -64,6 +64,7 @@ struct sched_gate_list { */ u64 max_open_gate_duration[TC_MAX_QUEUE]; u32 max_frm_len[TC_MAX_QUEUE]; /* for the fast path */ + u32 max_sdu[TC_MAX_QUEUE]; /* for dump */ struct rcu_head rcu; struct list_head entries; size_t num_entries; @@ -94,7 +95,7 @@ struct taprio_sched { struct hrtimer advance_timer; struct list_head taprio_list; int cur_txq[TC_MAX_QUEUE]; - u32 max_sdu[TC_MAX_QUEUE]; /* for dump and offloading */ + u32 max_sdu[TC_MAX_QUEUE]; /* save info from the user */ u32 txtime_delay; }; @@ -246,18 +247,52 @@ static int length_to_duration(struct taprio_sched *q, int len) return div_u64(len * atomic64_read(&q->picos_per_byte), PSEC_PER_NSEC); } +static int duration_to_length(struct taprio_sched *q, u64 duration) +{ + return div_u64(duration * PSEC_PER_NSEC, atomic64_read(&q->picos_per_byte)); +} + +/* Sets sched->max_sdu[] and sched->max_frm_len[] to the minimum between the + * q->max_sdu[] requested by the user and the max_sdu dynamically determined by + * the maximum open gate durations at the given link speed. + */ static void taprio_update_queue_max_sdu(struct taprio_sched *q, - struct sched_gate_list *sched) + struct sched_gate_list *sched, + struct qdisc_size_table *stab) { struct net_device *dev = qdisc_dev(q->root); int num_tc = netdev_get_num_tc(dev); + u32 max_sdu_from_user; + u32 max_sdu_dynamic; + u32 max_sdu; int tc; for (tc = 0; tc < num_tc; tc++) { - if (q->max_sdu[tc]) - sched->max_frm_len[tc] = q->max_sdu[tc] + dev->hard_header_len; - else + max_sdu_from_user = q->max_sdu[tc] ?: U32_MAX; + + /* TC gate never closes => keep the queueMaxSDU + * selected by the user + */ + if (sched->max_open_gate_duration[tc] == sched->cycle_time) { + max_sdu_dynamic = U32_MAX; + } else { + u32 max_frm_len; + + max_frm_len = duration_to_length(q, sched->max_open_gate_duration[tc]); + if (stab) + max_frm_len -= stab->szopts.overhead; + max_sdu_dynamic = max_frm_len - dev->hard_header_len; + } + + max_sdu = min(max_sdu_dynamic, max_sdu_from_user); + + if (max_sdu != U32_MAX) { + sched->max_frm_len[tc] = max_sdu + dev->hard_header_len; + sched->max_sdu[tc] = max_sdu; + } else { sched->max_frm_len[tc] = U32_MAX; /* never oversized */ + sched->max_sdu[tc] = 0; + } } } @@ -1243,6 +1278,8 @@ static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event, void *ptr) { struct net_device *dev = netdev_notifier_info_to_dev(ptr); + struct sched_gate_list *oper, *admin; + struct qdisc_size_table *stab; struct taprio_sched *q; ASSERT_RTNL(); @@ -1255,6 +1292,17 @@ static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event, continue; taprio_set_picos_per_byte(dev, q); + + stab = rtnl_dereference(q->root->stab); + + oper = rtnl_dereference(q->oper_sched); + if (oper) + taprio_update_queue_max_sdu(q, oper, stab); + + admin = rtnl_dereference(q->admin_sched); + if (admin) + taprio_update_queue_max_sdu(q, admin, stab); + break; } @@ -1654,7 +1702,8 @@ static int taprio_parse_tc_entries(struct Qdisc *sch, if (nla_type(n) != TCA_TAPRIO_ATTR_TC_ENTRY) continue; - err = taprio_parse_tc_entry(sch, n, max_sdu, &seen_tcs, extack); + err = taprio_parse_tc_entry(sch, n, max_sdu, &seen_tcs, + extack); if (err) goto out; } @@ -1784,7 +1833,7 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, goto free_sched; taprio_set_picos_per_byte(dev, q); - taprio_update_queue_max_sdu(q, new_admin); + taprio_update_queue_max_sdu(q, new_admin, stab); if (mqprio) { err = netdev_set_num_tc(dev, mqprio->num_tc); @@ -2142,7 +2191,8 @@ static int dump_schedule(struct sk_buff *msg, return -1; } -static int taprio_dump_tc_entries(struct taprio_sched *q, struct sk_buff *skb) +static int taprio_dump_tc_entries(struct sk_buff *skb, + struct sched_gate_list *sched) { struct nlattr *n; int tc; @@ -2156,7 +2206,7 @@ static int taprio_dump_tc_entries(struct taprio_sched *q, struct sk_buff *skb) goto nla_put_failure; if (nla_put_u32(skb, TCA_TAPRIO_TC_ENTRY_MAX_SDU, - q->max_sdu[tc])) + sched->max_sdu[tc])) goto nla_put_failure; nla_nest_end(skb, n); @@ -2200,7 +2250,7 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb) nla_put_u32(skb, TCA_TAPRIO_ATTR_TXTIME_DELAY, q->txtime_delay)) goto options_error; - if (taprio_dump_tc_entries(q, skb)) + if (oper && taprio_dump_tc_entries(skb, oper)) goto options_error; if (oper && dump_schedule(skb, oper)) From patchwork Tue Feb 7 13:54:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2864170wrn; Tue, 7 Feb 2023 06:01:25 -0800 (PST) X-Google-Smtp-Source: AK7set/JxS9pl8K7DNR65XEix3L+ThKu2Ode4Z176OFJkn0EeRBo+mLXZMgdopwRtCSkO8jCV0zl X-Received: by 2002:a17:906:2a0b:b0:887:d0e6:fa24 with SMTP id j11-20020a1709062a0b00b00887d0e6fa24mr3286569eje.76.1675778485526; Tue, 07 Feb 2023 06:01:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778485; cv=pass; d=google.com; s=arc-20160816; b=IbOceduHUXivt+J3YreuM1xQdpi+4nnmsA9XE58C+aX6SWj1AAA5MYzdm3LJsThyno UE2ZID6ns6XqrLNR1jE/OBCewIExrkWg6X6afS9GtKRr/4M2+eMEanTTiB6NkwA7Dwo3 H3FKKhTERzM3svShhjAByNoqxtCMVZ68NmVgoL3kgtAIcZz6jemR9R8c7/ov1zixQlHf N67CjExnQBSK/SbMBJJYjbDMTZv43MF3WICyqwc8hkdd6MO6zsvVjDOn/wd7bBhKoAfV XOmZZGNu5x2AWHzGhrVR8j48vGDTZHQNUDZmf2S5qZy3J3oAHRHo4r5yjfBzzkbtGnPj W3hg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EeDbZNGeWgvML5Hp8qKyu92dq/8PagPxjbc5NDdh5jw=; b=Q2jI/j+AajS/3IYq32l6zJTPhqB6duNjRJfeyD2gCfy7mB3IiaBwRa9ahKXhtCKQj2 e/ZUtOx5H/RFP1fgf/TKsKRG3qSV3ee1XL8VYboV/bvz2Jm/BIcHldOxdFEeCnJhzNQG DR6/7jVcEL/lBWcLz4kQhSrWHcX2k6J+NmUUTQ8sfiyL4SAWvPPbdy2ZFJ8isOV+G4Du 9vLch3QFoSt/1tCV5uSAUCxsRsy0T6Zvn7L43ayScmCi0XHw0AEVFaPeelWZu4CmA9s3 IQwBr7Uqu4h85HVkpQDtkLEGPfwPuTo2Q4Zsa6nstJDIBSjXGUtGitVNtOSQxwrfbPIM a6LA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=KvA+bv4O; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 17-20020a17090601d100b0088b9c1de4f9si21827054ejj.9.2023.02.07.06.01.00; Tue, 07 Feb 2023 06:01:25 -0800 (PST) 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=@nxp.com header.s=selector2 header.b=KvA+bv4O; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbjBGN60 (ORCPT + 99 others); Tue, 7 Feb 2023 08:58:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbjBGN6E (ORCPT ); Tue, 7 Feb 2023 08:58:04 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2081.outbound.protection.outlook.com [40.107.7.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B92F0CA27; Tue, 7 Feb 2023 05:57:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IGjGcAkTY8vDIWgQr9AVlpv1j/vRHM2vtJInp5aSrKBuZ3guxl6ioGNBQW/zhuteKuzz+MWEAbsjcZj76z6qNbP3E6M/844l3dIpBiJd2DOnFFEWqGAfYhkB85bokl6OFyYblC9HVLe562UiQOUiqcd9N6svhEgLvtAC8qqHacXu1uY9Yvr/Rh8XxzduZI4oLP3/JXtQHzcvpce63xb8ZmDPAcn3nndLxhrpg0Rw6KbHuovAX44OtV+8EucbH74rOrCZgGEI5Dtd+sMhN4divu/LfFXqws053+AGD0+LrcHbn0Ygy9v8AVu7Z/zcT5tSRc79AMWyyB4K0HN9MRXihA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EeDbZNGeWgvML5Hp8qKyu92dq/8PagPxjbc5NDdh5jw=; b=jq9+EqSiv/mIt/LG6xIjp6uviFbU74oaPWqRc8fe7PFMcm19xPR3gv//nFBsOKCsiH+paZX3R8YDWssWW9zHuZbLO3G5mpZIHd3OnSdFFNI/VkG4lsp4Jt4smMryDCSGul2Gll27Yo6iXRi2P6PyLekJ1Jl9cdQ+ykAldMCTGpcmoLEmE5g17RepFO3PuI2DgNRrJTkTFUzE9Jy7IxL1ol8PMd4oIe3BhmB3wFq/rNJI9Yd13UffbRG8fQnx+63KPLwjo7bQ7k9VIZhDTSQa6XVk1YiRdoAtM+aFevFl21RJppegnhd4Ia4HT/GitnEg5JzpC6kiOEmw9X+td+V3WA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EeDbZNGeWgvML5Hp8qKyu92dq/8PagPxjbc5NDdh5jw=; b=KvA+bv4OOmmIcTjiFR+S8BJxM2IjU3nqQ8lG1ODT7OvsLJvYHMF8lQ/zXKIYRKeERXcXco0uJU471NwldyvuLtSZtBUkoABCqe41nL/2M61l0BYXv+xqmDCLj+vvTbNych058w7o0T3oW95xl5LqVOdpcdiUHyqkMECD+IGfMAM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:33 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:32 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 14/15] net/sched: taprio: split segmentation logic from qdisc_enqueue() Date: Tue, 7 Feb 2023 15:54:39 +0200 Message-Id: <20230207135440.1482856-15-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 90aec37d-a53d-4815-6164-08db0912facf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DIiH2Vq3XrhK+JB7Lfb8N4DE2RuCBgvhl7AMH3WmI6F9BtQxOlIO6vCExrDKxA2dt+mX0sOtORJr3lhNr+N1QAoBbaVg9H5vK72LTZT/DNGiTVKaVqB/EwFJ9BlwcmSC2Qig7TriHIckAWaxtq4lg/OQCchvUTYFd4FdVXRiRLTwhe7OVnuesCQ19qSF6QEmiIF0rYh2VJRugztAaUhdS+jVLhKniQqMnzrFNjla3TsNuXjgomu/UqK36qEG0A20hQegGlsG8JCxurH+sPtnuGvY3RjsJYRCj7oETIRjrzAK+Lv4z8e3cEJEYHVAvaDyTsX78T0H9DPorEmyc7gbkTNqmIf/z1Qo7YRTQYdaCAvk51Jq1NIBf4qGK1n2DuPEfC8fezG+ycCr3gKbFXTly3PXLndwXFYctroyIFhQNu7HWwKZkm+vmPZwYen/cBktWexzneF2/Q8fmimrXoVILfDFxcceufRC3FkIOlAn1Px5BvEIctj+Paq/P3dL7d2CmfLBdtRvP7jRWzuPT/cCX+jEv+aF1RbB1EQ/jmoh7weqRf43dpOchCh52w7ZGX9GKGzGB6XdHCIV/yl8/6+T3KQD91sSTF+Fh92ZEaQEnf0uqVixMvpY8aINA7JPehLFmJppA37t8xRbXoo5Ye14uqybV0qeuhgGX3sdKXON85hrWJVtsHv376v8ZF2dXN984Ra+srRhQEd4DcR8VkuH5w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(2616005)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hsSHk5V4Hcpd35RXkW9iux5IaR3caKsEzf7+ancpMhUCQtOCv10htbQahbXzPaA0P1urI1HBl8nVVCDyfuih3jH3E6qZ5TevdfLS+AJJR5XuxXjwrLOoqEZTJD5Exf67KeJgV3Ztau+OTaswajR5W1Z6O29pYSpwPMhDqlbR7gMeEzg/0xABERXxFC+RIl6YfZ2TnN8nR2QWs6qcZQ/UpSBPdYcclTSLb/gH9mX35dFQp1orVP2pspeF/A+/NNJBKQw929OjzbXPK4kBFdMYL7+y2gapAARoUjd6zV+6GpV7nI6vAJDfJTBxWGpiijGPY6GdnF6Pbrilf9kzxD0gdwn+oUQXHT2J+Ps9MgqR1jcdxsC1L0GxbBAnFDH9+hje1ORYOBUbeoC0lWs3zNptYWKIp3RhLPS5Hv1h3iUPsfChpVFEKhhbpqlmDX9ReGsmV/pNDKYgk0sREXSxCilkpIgnUk8vo+x/NmMbr5vjt5R5F0WcN3x4gBgoIGJBtsIFhJ3hMhV5hfvBNX6n4EExcgxELP5U/GgO/BK7XuQqs9okOhIfMy23UBAzAUH95ZjlEx/4D+UdNtAnOJ5oXIF+amNIkflW+FMVkMy8R7yxMKDgIxl43eo1k9EPOuYWCWjgpvsiLrL1yAL83Za3uH0xwa1HJo9Yh0GJ+cjsS2gwBSBy09CGdaAFcsUXTxj1smj31Y+h0h10ASkxJzMW27/vuvBI17yZc3JlgSLIpvMwvmGFbbws3tBfXhb4SzKSH5FsRHYRr6VIt5NoIpvU/phu4jkJwQBSLBqWi8ycPHKNnmbsUPOSiDQ7qgRBJf5zsrmLOWqP/0zEWc5hbHPCNDzv+UsS90FfNm6DkKiZbBT7xTQuo64K08FolXcxNB9vzlc+TUvJ4hDQJUWZ4BVwkW2dkplc3zId2AXXayqW9peTlPvOSZp0o7e1Zxi1kWgtHnsHmmAS6/9Guw9cDumlc58nmUBHNuHmRlfaraWgIVUyPTOQOpbMGhfC4CJA2P9N1cpOdjMJuXGO54g1b2lTpTAT3QXSKQddUSVoFuiQX7Y87LIXp7aUIDlIMKCJOiS9f0Ly81YaHXVq3KGKCuZcSLVSEP7LDPE1zvqgUcoLIPwXQLC8uiga0vVTRNRO1lt+oae0AfJ5lf07ZVNpOH93h/eaj2EUK1hiEG0VPD/lf1XAIUPuaK1uRZLRxhvXD4lb6o6vYA5oS6BeZzwIn4LDGGRf95hq2Yn6yuxJYNWGHtUGNGjbCWEiDSUtup8IRa31yuKuY2ymSyo7QcoxD8hYft1jVfb+9a9ustPr67b9kKtrM1Kk6dPs/KsDdQuy4VG6hRovlJWQD1LmtyvEQy1gg5iz9/V0i8R5Dw7Q8zYaFLM2GhytyjdbSIXufreeqC1IXIfHiXLaCf25UFIuvpvU+HAzhJ8xM7u1vwY7j+nXVfwQhH1IuTrnq91ro1KsU9unMXDqd9L+PSAKj0NpkPQ5GMp5JxrZ9Ee9phBFIEa9FTcAFexhMbGpxGbotxPRkZr+1W6/VsDUIYOwoH4p9MNLD9DrgJ+7UKPDLLDzffMEAiwC4xybOruEFZ4pWafpvLu+Ls6UkwEA952VRb5pAykAWioFew== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90aec37d-a53d-4815-6164-08db0912facf X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:32.8606 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jxU7qpqsV/8X1tMDWJN4NoTPOOCdTOYZ2UfwPdMl201UwDULUbOfbW1cc2JPU4BzKczYy9kVn7+DQhnQ2yvm9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757181101024137085?= X-GMAIL-MSGID: =?utf-8?q?1757181101024137085?= The majority of the taprio_enqueue()'s function is spent doing TCP segmentation, which doesn't look right to me. Compilers shouldn't have a problem in inlining code no matter how we write it, so move the segmentation logic to a separate function. Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: none net/sched/sch_taprio.c | 66 +++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index e7163d6fab77..839beb599f55 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -575,6 +575,40 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch, return qdisc_enqueue(skb, child, to_free); } +static int taprio_enqueue_segmented(struct sk_buff *skb, struct Qdisc *sch, + struct Qdisc *child, + struct sk_buff **to_free) +{ + unsigned int slen = 0, numsegs = 0, len = qdisc_pkt_len(skb); + netdev_features_t features = netif_skb_features(skb); + struct sk_buff *segs, *nskb; + int ret; + + segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); + if (IS_ERR_OR_NULL(segs)) + return qdisc_drop(skb, sch, to_free); + + skb_list_walk_safe(segs, segs, nskb) { + skb_mark_not_on_list(segs); + qdisc_skb_cb(segs)->pkt_len = segs->len; + slen += segs->len; + + ret = taprio_enqueue_one(segs, sch, child, to_free); + if (ret != NET_XMIT_SUCCESS) { + if (net_xmit_drop_count(ret)) + qdisc_qstats_drop(sch); + } else { + numsegs++; + } + } + + if (numsegs > 1) + qdisc_tree_reduce_backlog(sch, 1 - numsegs, len - slen); + consume_skb(skb); + + return numsegs > 0 ? NET_XMIT_SUCCESS : NET_XMIT_DROP; +} + /* Will not be called in the full offload case, since the TX queues are * attached to the Qdisc created using qdisc_create_dflt() */ @@ -596,36 +630,8 @@ static int taprio_enqueue(struct sk_buff *skb, struct Qdisc *sch, * smaller chunks. Drivers with full offload are expected to handle * this in hardware. */ - if (skb_is_gso(skb)) { - unsigned int slen = 0, numsegs = 0, len = qdisc_pkt_len(skb); - netdev_features_t features = netif_skb_features(skb); - struct sk_buff *segs, *nskb; - int ret; - - segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); - if (IS_ERR_OR_NULL(segs)) - return qdisc_drop(skb, sch, to_free); - - skb_list_walk_safe(segs, segs, nskb) { - skb_mark_not_on_list(segs); - qdisc_skb_cb(segs)->pkt_len = segs->len; - slen += segs->len; - - ret = taprio_enqueue_one(segs, sch, child, to_free); - if (ret != NET_XMIT_SUCCESS) { - if (net_xmit_drop_count(ret)) - qdisc_qstats_drop(sch); - } else { - numsegs++; - } - } - - if (numsegs > 1) - qdisc_tree_reduce_backlog(sch, 1 - numsegs, len - slen); - consume_skb(skb); - - return numsegs > 0 ? NET_XMIT_SUCCESS : NET_XMIT_DROP; - } + if (skb_is_gso(skb)) + return taprio_enqueue_segmented(skb, sch, child, to_free); return taprio_enqueue_one(skb, sch, child, to_free); } From patchwork Tue Feb 7 13:54:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 53914 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2864581wrn; Tue, 7 Feb 2023 06:01:56 -0800 (PST) X-Google-Smtp-Source: AK7set/1T+lm/BwcVkDnd755x2jX/oSsKY7tzUskyiOuDKRT7FgO8+4ON+qYAWGoD40vCjgV/60y X-Received: by 2002:a17:906:d0c8:b0:878:5f7a:7aab with SMTP id bq8-20020a170906d0c800b008785f7a7aabmr3588470ejb.39.1675778516035; Tue, 07 Feb 2023 06:01:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675778516; cv=pass; d=google.com; s=arc-20160816; b=OoF4OU+Pe7uf0IcLQZswE6gNFomx8wQnOkWAZWonzsX2TPJYlPUNLI/Uy2H1tQLHcL oQGJQJvsFl8/oGc9buSxG/d94GeCUksjm6IrEUOOFtCIubWVVqV6fqQkT+lm2NwIlFzW 2g3+WMJZKNmkBSsRxaPVoGiAkVAVJm1ri7OVAlrRNcqN0TRV4Pnwnl1v2u6TQ3qMzAcO eZBTJznPBaEnJ7WpU2hVPx00jXhjA1urTGJaWdMLE09EA+uXS4OkzEZ/zuVPn7LtEHo3 ZFAIReVMmJXklRf5HfJGPDb0c3t5ajjoxKvmD2LvOlViEEVrwkrYZQYqb/l9a/TYdOxb tgwQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UYmIk7rENYdzMcDEaZURe/aJbzqRvZhq4vacexnvWmA=; b=NqhysUztGerqrM0GNs+uOxoRQo+sH7lUH5PyrCAl7186e4nNFar4tAiUS68Kbc1qet m4RdEHD3VJDmjxVvnw7grUlgM78Ki37whfRA789Z/N7w2TarqZcodsBY3Frp6YS3l/al YrSqOEO/V2TGQQhaoM0MoS4JlRR4rdvy2glb8qPfJPY222pYOlqH7KhsvfmzCAolFU9n kOQbWW2Lp96/oalN/Tsyl4Rw6gPjKQ4Q7D4YzCa2ynFm03adomOAaCtywbir/QBOIQuh KIsR/M5u2csXgmRy8yPwpIWFw5u6jgzdm49P50+onbL1ehadxvSn0QE5xboMGogSULAN 0l/A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=pekwINkQ; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf7-20020a170906c50700b008845c66840esi14236541ejb.185.2023.02.07.06.01.32; Tue, 07 Feb 2023 06:01:56 -0800 (PST) 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=@nxp.com header.s=selector2 header.b=pekwINkQ; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232330AbjBGN6z (ORCPT + 99 others); Tue, 7 Feb 2023 08:58:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232490AbjBGN6X (ORCPT ); Tue, 7 Feb 2023 08:58:23 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2058.outbound.protection.outlook.com [40.107.7.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5870F39282; Tue, 7 Feb 2023 05:57:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P76rZqtAnI2eld5HxlQQpBkdmTI0vmSuMsqz4s/jquIkPUE+5Ke1EiHrNu8OL0QK7WckoiyYUEZwieGXwr1qMgPlB1zT31yevU3cx84CsIjz8XV2Y5OunF8kWQdR8oVL9TkyLyZp/Ng9gcKTy2KmlcT1ejwJHMAiFGu7I4oNo9omJshC77a9Qcy5gDoX3PEZ0cJainVVMt7rWqfmwDBGbZ+hwVfzbxZFrfxq/0BxzIDT3sFDV/dqej5qIytEq1bYEQQ9+KdNiy/bAbx4v/tNMy7EG3tMW6i0QzJWiWhNzXIFmt4gcy4SqpzaJg4vU5bfzSMHkHZeVgfhoyEoTOvPEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UYmIk7rENYdzMcDEaZURe/aJbzqRvZhq4vacexnvWmA=; b=F6FzaIlTeLlH/+ub70/gGNN0R8SV4elQZ4d1vU324Ib7ZwMw8UagYXSluSXpXpzK0F/5uBVnGKv5vodHCUKHdh11bE5eA4vBjXKEiFyk+qcK8+g1zf0EkNRlHt9UPJkevyfwHFfiiJg9RhRM6QTseUYWUnjcozz0axRERKcRsg7P3LF746QakXQmP2d2T4gAI/mrpiBWAHrol9yV0FwXGB8rwQNdWgMkoib7TosCfViQYHJnD6gnxcsXIIGjPxiTcQ3PzmLCh+8EVS01LCnxG1YK2KRhZWEvrKWjNdK2/f+P8frBNWx82WYgSBio5+O7YIZjmaO2frwy8SgrvqXAjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UYmIk7rENYdzMcDEaZURe/aJbzqRvZhq4vacexnvWmA=; b=pekwINkQ9EjqfDczBsSX4vEKq66KhnbnTEYnarTRQXt4/StI+w4kMWIQXqj30suOZqbDasgPlnlGQUd3c9iMKv7tE0i+nJQWtQcEXtNqQDL9EXHkkmOKuRqp6AmqCGqWPZ9wN11J6s7h4x2JWBuOZquix9/w2iSz6X8mXuslxSI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AM9PR04MB8115.eurprd04.prod.outlook.com (2603:10a6:20b:3e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.36; Tue, 7 Feb 2023 13:55:34 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Tue, 7 Feb 2023 13:55:34 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Gerhard Engleder , Jesse Brandeburg , Tony Nguyen , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 15/15] net/sched: taprio: don't segment unnecessarily Date: Tue, 7 Feb 2023 15:54:40 +0200 Message-Id: <20230207135440.1482856-16-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> References: <20230207135440.1482856-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0023.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::15) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8115:EE_ X-MS-Office365-Filtering-Correlation-Id: 792a76c1-941c-4fa8-b1d8-08db0912fbe8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9jSPNVlBW7aCM8YmvmKU9eI/MeQv9oOkieRK+Dx1XqCGzWrWHBW2M8ANnFvbGmrVZ9U1ExYjWwmLCqq9vAdvLovumaNar4uX3z1TUWqSmDK0vfrTo5XYPX5nlUWfe0v2Yg8DIR43aCrEQxDWJ4GN+h9p+OzWgC2f2gCb+GgqU7OBmAxVHP+jzfdWookZE1Ku7ggG29ZfHGk+mBjy7qEHKoVXYntDOhDknKxjkkjmoQZTAfYaecu9umQtSsqd8SyKvz0esRGB4QTm5b+t9RYwNn1yVRaC2e78hEIWguFwsxaQOO2VmJ2md/2nF0dGYyJFM+dbAZs0ok5ior5E2OqLELUgXLjTwsek71iVwAtflzl858rsRYl9RmDvNSLYUH47HQl0YQrCy413Uo6hLui2flmTqjQavEOprtBVwxV2ghYNjQsSRF0P/xNxsBmayNjpZqXb2JByrckRYIfspiGH0m1fZuA79sgiF9xcHOq3gqICyuW92KR7G1fPaZfNdJWjgDm30b6da8Oz/JItB+NXXPvTz5zLLkcKb6UoR947qG/LDnsi0MTGAQJIBADhOD/uGp9uDG2ahYHRw9BqqaT6I3nnqOlYWk1zh1vuV/3q36ZDkRkTAH2oMtGOaBWxpzR6wRNjcJReLQ65zJhGgw0o6FgU0mRpXTS374VshAAXUR1iGgHgnaOF7lzwcvfXU3/O8ieTKzC80LjUgaMoRq2asw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(346002)(366004)(136003)(376002)(451199018)(2906002)(8676002)(38350700002)(38100700002)(316002)(83380400001)(6916009)(66556008)(66476007)(8936002)(4326008)(41300700001)(44832011)(5660300002)(7416002)(66946007)(2616005)(6666004)(1076003)(6506007)(478600001)(6486002)(186003)(26005)(6512007)(86362001)(54906003)(52116002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rALJWC5CDNAmjOKhT8RVgdnv5wq79rfbpDBfT6TXVNGRa55hOKfzKNlNAV+00CS9twwQscD/amWS/SK5bOwZ0o3Od/bjWs3e5da8/E5nkNJtN1Fi4BqKTehyfqZPdKnkN3Ka7uDyvUn9mbcrqmwRcntC+QonsUjOGA97XPUBa+BANDqz969oUeBv9lo+HN2zbnK8+5KZ926tFDk640ZEblR3RdMMIw+Hg+qj8dmRT2+w1CRv7oyUhObJSDPx7nR7KR73j4ili+eSvBVK4a6m8NYYWXj/b96wZ36Mi6ScjYVtQhYrbj970fI4jphz+sc4q1wX5+47ZIxh6jjtxY/6fQINhs+6Lkos3EANKSJm7U9/OXsvfqvVGfxXV+1eeITobcVXa/oIcoxgQzv1dCxnOwKpWrtdxJbej/0qpxVP6+IRP9fGzQ687hmrF6goz6FbhjuaShHtsBTN4ODJ1rnKDUR9rk6jeX99toVcmB1j4kK3lmt8QeA54RdGQU1fZHZgcxsOoxjgDoEI/9QT86FctvBeJFOYiZa1tB1YJbH5oSB+9AJrr56BO69K+9cclRSFXb5qgdWCYYSEe8vBwumEEwt8Kf+i0cvc3rAHJbAdDdwef2ZFX5NJRQQoCRgEVEngLkSqzP6pY4iU65J3wneXCEG8P3DkyKqUsMBmL7grvRaw0P3Avz6X/YlPbKSkDKv2tHQHXl/zKigCVgO/BpwvanH3tuGgfIhRh/ypUwngt6SQaeD9d7XAj8bW4GWqd591qQ5VVjJcx9Lx/axFZptYOkS4cGmUCf0T0fVAnqvZ/saWADNeet5cXquQvwDUMHmku96Xjjlta+3iF7Im1GQVQkSf7ZdrJ8XMQrSq2QIHtclQzgNn07bPzjY1wmVf24geAeKYuly5CZP7CkKxerMRHIwlcrrZBjTBkitLBRsBsQoYB5B50/GCKaeyvx1QNOmTRAFS5oaOGqL3+gacUvaF0Fjlk0EIXVN4sHfjCjwc30vVjYHMAC/RCXaWcoKWLcO4bwqZ9e0ttVkIjbcLHcaD7yPlEyJb5cVklNAFgccB8MLr7wzrtCgfVWKEkbtMQcFBzBET6wtxqn1C24yYoTSwzlgnzGy8n+1WWqe3Cb/1Qj2F8571jnbJaUZFo52xSt2lHLOybc6k9xVBhMePb34RS4ftVRamL3vQhW6CoXnUbUUvPdt3l86M7d83FZxaD+uFSVbl52emKD/SNvJDq+XMQCH17IyFqVHatnHXOeb0+KIq8/6ftnBXxa4plzQ/mzNGiTqu9XeVtfB1SskDt8mj+qO4WbjJh6vRMCyI7XZjO/198ak53i5rPvuhM14T/Ud0USSj1WO0PtgOv0a8pXVT4DJjDn1Yzfy7nqPAbQCZa9Uf53lPVQsj5JTqNAQFBABde2LC98+BbonclLhGoTDtTOCiP2/wt7+LFBQEWHlxMNJ617ZT1Qq3h/px5wJlxKXXMOE16u0iReeo/UGAURVWCii+o2XV7m81psHTSNiibBYuod4ajLfxsJUuVwIuRfUaHTDlj4ouKq2Cg8DAqMKSZVKdG+cfuqHfBCXy5jXhjEjl3onUs0CRHcu2Q7iV3mItjY1RyW4s3+PIqs88rrKeSQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 792a76c1-941c-4fa8-b1d8-08db0912fbe8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 13:55:34.7668 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: plxzQm1YpCAVFFtSxrnA79KLNJovioQ6CH4Wpgfr6utjtLateSLU29PZIuBtDnmagvbcZ4EZh6360ESxKgdLBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8115 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757181133377763576?= X-GMAIL-MSGID: =?utf-8?q?1757181133377763576?= Improve commit 497cc00224cf ("taprio: Handle short intervals and large packets") to only perform segmentation when skb->len exceeds what taprio_dequeue() expects. In practice, this will make the biggest difference when a traffic class gate is always open in the schedule. This is because the max_frm_len will be U32_MAX, and such large skb->len values as Kurt reported will be sent just fine unsegmented. What I don't seem to know how to handle is how to make sure that the segmented skbs themselves are smaller than the maximum frame size given by the current queueMaxSDU[tc]. Nonetheless, we still need to drop those, otherwise the Qdisc will hang. Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- v1->v2: use the new taprio_skb_exceeds_queue_max_sdu() helper net/sched/sch_taprio.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 839beb599f55..9781b47962bb 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -566,9 +566,6 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch, return qdisc_drop(skb, sch, to_free); } - if (taprio_skb_exceeds_queue_max_sdu(sch, skb)) - return qdisc_drop(skb, sch, to_free); - qdisc_qstats_backlog_inc(sch, skb); sch->q.qlen++; @@ -593,7 +590,14 @@ static int taprio_enqueue_segmented(struct sk_buff *skb, struct Qdisc *sch, qdisc_skb_cb(segs)->pkt_len = segs->len; slen += segs->len; - ret = taprio_enqueue_one(segs, sch, child, to_free); + /* FIXME: we should be segmenting to a smaller size + * rather than dropping these + */ + if (taprio_skb_exceeds_queue_max_sdu(sch, segs)) + ret = qdisc_drop(segs, sch, to_free); + else + ret = taprio_enqueue_one(segs, sch, child, to_free); + if (ret != NET_XMIT_SUCCESS) { if (net_xmit_drop_count(ret)) qdisc_qstats_drop(sch); @@ -625,13 +629,18 @@ static int taprio_enqueue(struct sk_buff *skb, struct Qdisc *sch, if (unlikely(!child)) return qdisc_drop(skb, sch, to_free); - /* Large packets might not be transmitted when the transmission duration - * exceeds any configured interval. Therefore, segment the skb into - * smaller chunks. Drivers with full offload are expected to handle - * this in hardware. - */ - if (skb_is_gso(skb)) - return taprio_enqueue_segmented(skb, sch, child, to_free); + if (taprio_skb_exceeds_queue_max_sdu(sch, skb)) { + /* Large packets might not be transmitted when the transmission + * duration exceeds any configured interval. Therefore, segment + * the skb into smaller chunks. Drivers with full offload are + * expected to handle this in hardware. + */ + if (skb_is_gso(skb)) + return taprio_enqueue_segmented(skb, sch, child, + to_free); + + return qdisc_drop(skb, sch, to_free); + } return taprio_enqueue_one(skb, sch, child, to_free); }