From patchwork Sat Jan 28 01:07:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119601 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80DA2C38142 for ; Sat, 28 Jan 2023 01:08:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233643AbjA1BID (ORCPT ); Fri, 27 Jan 2023 20:08:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232356AbjA1BH4 (ORCPT ); Fri, 27 Jan 2023 20:07:56 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B2271ADCE for ; Fri, 27 Jan 2023 17:07:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MbyWghYKzoahm07iE77nuAEEx3FUgjsfcOw4ImX0fchbXCnuQOQM5mmVWtFsryrl9gC3+Dhn8aKXkUFrVGgOaL8LJlii1ujUD8hoZJ7hrhfwiJ5SGAr0XqQnoHXfYs9ktEU4p50PcmQW3pCczbdb1gVNajd4pRz3Lc0tk3Mt9ZVNvMu+12EJzEtlV3VLUBPl3y4X9qSyUDWl1UAn+SOX9oGIKjFf2Bms5shAHegJYJ0X+YWuE160Xhi9OG8oL/eWQQgypjNSqWp4wNM0Ie+kyMK+iEjEkVr11WMqR5edOHqI56xi6ReiOiBtNiZYOYMMFFzhQDjeKpP7riaNXQLqHw== 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=eUssSdJtzUQfQiYK0BDmZMG7q2MKAhBmvgYvaTeg8us=; b=e7ycrKpjoeTIZA2miVDSokDVOe+J2ol57xcPxSzOxeeA4QRN2sdaOVy7eC8QsNg06zsFVnAL7K56Sm7qOHDqEBz/hyYi3nRLadx3B4HNT0TkeBkaui6exCroxiYC3Nh5k38SmXjdznJzcT1mS8orA3Mf9pKjQyPjaKo7HQ7tX32mbbtkZHY436hLk5zkZBygG1ucPjZ1ERviIfiuXpYvJu1BmZjgVRKoRE+L5i3UPYkGdm1Xi+tST8clqBhRoNQGFSi/cnPw4Kz2atPU612rQ7ahr+Qan9asJwBr8YSz5/RF1bIc5IxXmQ3Is+VLgUbedXZUYOtdqoEx0e1M3yjc0g== 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=eUssSdJtzUQfQiYK0BDmZMG7q2MKAhBmvgYvaTeg8us=; b=AXmu25YiEvR/C4kmcDhMiJF/7nAIu4aE6gyHED3W85s06fVOAlTVKyDOi+fzE0XposjlGy6pjG9KUzSr1P8sUvSvw8mfQANpk3dUkA+5UYbjAu0fnZZbWYnj8qm1vtPnWktEs9dcqawhec+Dl8+O7wZg21Yd44hQFlgoaOohrcI= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:50 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:50 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 01/15] net/sched: taprio: delete peek() implementation Date: Sat, 28 Jan 2023 03:07:05 +0200 Message-Id: <20230128010719.2182346-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: d14b9fd2-b4bf-4202-a0c5-08db00cc130d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AfkyZeG6UGVUAKlw7G5Ll/x5x+rzKZrHd4uZN+04VfZ16e+7rbmjaiYFjaHHkKshdZRgIkuJi9IfqpMazPW/ZfYtAIyFkG7msA+Z+ilxysTLzNJ6bRkPQdTeU2VdCYARyB2Z4NXu1LJ5ULZfX0QG2jHIDFN2SrmqGSGIaCjig/AWBvgUstTnUjEz7deYJCs+re4S9GIqHTLWL3i7eRzrrCwwZd7GdWIPy6Wy2E98v9AGvWKUgU2coLAyaus3jSFSa8U4AnQ+3Kl7MOHArqtskgm+ZUd4/5qTg3QrlO0hczTuV4kFdbG6wMFehhUb54E48r5rGUnzmtMrnokpwJYISws1XBXoVgxgmkke1LxKTck5rdi4EJ7r3ckOv/bCF4P0Tfz0RtIX8zc3Mbo7E7z/yjh8R7L4sJDZeYXPsobUKTGFt5pjRotLlkaX7fSmV2W3Iv9iE9UlllzdcOym9u8Yltc92gFVV7HySWY1EXOFOYWW5dHBVja49BpvUUy+8w531eb+KQY56tFAlL98W3nZjsZ/U/2OUSch4bF0D2imqWNgAP40iIn+e/hJwdKWALPBStPmf4nSImBIkQbIFvWre2XQj9VVnwDy3/QX8XdRlgzncBHCrUIM/pICN37cm+NyyscdCnAffw4xxKWZH7t4tj7t+IWuBKhi8DseiRJTfPcQ/oMJ2YWqWgkemt6nmUDCj6GKkC2Q/oZIvGZDvtcz9g== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vo2CW/IPdYtcqx9+cL0MLuUBo0+qmVmY2kw5YOSEtz2Np/Y4MpWauWl+v/N8+iiEnMRpwuJCBAl496jLfDuaAxVmMGM4ii0ieg2DpJoQwqyTYmdy2ykA7RHusKm9pjFpxEfLVKZTJguIICCGWJkShr5Lm+HngJvpDHJBP4xiAvGEzGJw1psFjgVkSOEsZ1nQzunEwIVhepRfX4hI1rWONlsp9kPsN8Yg60hrfj4JUaeWJkx1RL+xDoNwK4mHRgaUH2f2Uar3Mskre3u2xobh//yjda3iajhwRs/D9PhKYPIzllzhYHTqEQai+ZcUgKP0sA76eRYtyPFg6/y5VO9byphq/4coS/S6KNZmYbm89tPGDrItVO8RUpn7UnnYWbUWxw/v+IlD2/R31Mb90e+wDU4zlWAGORIgAilJhuxDS+6z3ryhFag6sKoD7uTpcXogDbIawmqcNlUc+419qVJi1qNJF1uWEKBAs0o/ntgqMpQ747qEzx5Qj5zLYzEu2ceRt9Q4uJrlqidWHERd4sP/Hwzqx25QpIJhnSWXVE+aSf41Vx/EzBAIVBvfyAFPGa6sqSam/WJ/Wxy/1nK8xa2f8L8f/kuxAc2zDIo+4J0e97O4aLVREHIyiHijDGzuyo4DeNXULs2qMgOOkWS8Pu8JfcYXjAuq1KHeaISArmOANdbBZ4GXBL2A2W5Wmg1HLUSZW+8Pj2hUzBF3eAngWifY5teUSpmJvv3jTPL1aXJr2Qz69dA+4KrUAr8dZiHSuvXMVqVl74aNi1DoEnyH2oV+/tx9lg8H1FAcibX9v3xiGCGpe6shUN8t0d4R178IFRVvpLifzrRy3c0TuEa/3+cs3lIiAFZE4XZQpjaq2LeJfcKA9Ygq/oQduL4VdJLLX218+j6/i4sgTn0uYkpdSA6q17QhYZo/vbYLl68SKmcwRPjwAf+BPPtzUwCI5dHhEwzdZ+7uZ+qMal8sfs80lv2aSiBXRhwG2zEDbnaZEVHc/VA1xOmhimovrThCb1tmDdCpUdP71GyikPW3hI6sqW8u86AjZUFNPYvH2FTdty6TFeBwhF6dIttH8UCyQ3fV1ACw5HCuy1ujVAKIZNoN5a/S7hs9GfzK99FBKMFtiXwHD2TqSxBNNVDqN5GTh0bg+seXM/toqRcOhsiqrnZgwgMG7YSHMkrOu351adIs4DUyGu7Nsdx4InvCxzMuU26YQfn66nGKoWXmp6+W9BjABfIt9MJnF9+Zo2rtQJiW+fj3WPXvyqaFygnpeWVeg2vTbRdR5/FlTh1nMZ819sQTff1oaB6JU52FuHOL6kYnLUAWP5QcXMt0e1HM9t0U7SirzL5PHBDtwhHM690r5Br5thBYT9MsGl7UICtEvrdIMkCK+d0zhzLDPSlcyQxoD3/zzoW1bjRr/bcwZ+1Uk+f7F598G7yq5/yUo+Vhv7CGvK8RhmGdZbsOm9adeFSBv3NklBJ3+kX3ZQZbnSC4yfQmFS68vQH1kXt2+tSSNaOgU2PrxULePhRa3QAEy6DxJMPcpYf1tWaRF4YpmSWzegYWGJfhHjz/qpZaT7+0sJqmnSu0lIM5Agfe/XVD5gqtIyGJArArkcs7vNrls2lqWSnuv+DXNw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d14b9fd2-b4bf-4202-a0c5-08db00cc130d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:49.7920 (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: M6ItDhSPM81VoeO6JslE4yOa76+sq2CrHtP5NdQQA1tX/R2Nw2ceVXo/oM4pNBg/nPdNOztwOGuiNn1CAh+oqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- 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 f2c585bb0519..375f445c1cfb 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -497,50 +497,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 Sat Jan 28 01:07:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119600 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FBA9C54EAA for ; Sat, 28 Jan 2023 01:08:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233151AbjA1BH5 (ORCPT ); Fri, 27 Jan 2023 20:07:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231953AbjA1BHz (ORCPT ); Fri, 27 Jan 2023 20:07:55 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2089.outbound.protection.outlook.com [40.107.8.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 180DA1ADCC for ; Fri, 27 Jan 2023 17:07:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WDy/FGOJI43FQk96MquuuqrBPv3iFIiVhzsLInxsRM66QmKBQOCLcoHGVfa+xGNKyLMxCAzGeCYr01w0L+u+MXrJfxwzufj08uPDfvLHXF2hQ3d7G25tR/b1WGbndDmxWLDap3rKe1mo7vcEEM1k15p3XE3ywM2Hyhobhzg1BmJSELHkzKhOmAhnkHZQp7gQnafZD5kmXdzNvj28rcqLsO17jLCWzPybUAK1VKRIQVY3O5stbus9NEicRTIyJgTaEIo/ec+V7+YMw4yEYq6pXERDl6oVlJHWhEMRE3S+XOKJAtqirsU/uuC7162144EQVnGcM2lku6ZefdQ21oXT3A== 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=F/cwxpkDFqYRd0KtlBJqEIpYgzWS9S4gs3XH5G7eF/Y=; b=jzVm5pdljsNLoXlTcbSdaWlPNHamRI6nIWe3xJug/RX+sSTpO6254KDJ2aTAoz71OvTp0r9z8hhsCjAVn7qFpzMrqL3j9o+bgaS2gA/pLOQ07Mvkdgvna2Vhgfiki+DO31/244hNzqduTqJ8mLW/Jm/Mmym8IZJ0kuwVsuvyriyAqe3ON7YsLglx7rWiJ4IpsHuD5gbWf+HCDKHeHpE/gqsiDVsNNONLwDCLKa7GGfJAxSNrv72FZ6jf/iOSpU6828L/of3mr5FBz9n4LcrJYJgx1AnW9lKcxgSLZKNzyvUycYbmfB57GWnKkBnFp1qV34TCGrk2gMAZsp4QIQUpGA== 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=F/cwxpkDFqYRd0KtlBJqEIpYgzWS9S4gs3XH5G7eF/Y=; b=kAB/OwOGyRxDnRwDYxrRd0BoiGrJlcWCJOTOcXp0DLP3XqZF0146AAf0ZDsjEVL5M/9sIj/tgbdnsKtRKOVgJFJ1tl9tzcMAjupWL/am1BeI2hvwLRIcmnBqLI04A9jJopu0glNldVrpX2GO4haU2OogMgrMikdu/t/x11VokQA= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:50 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:50 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 02/15] net/sched: taprio: continue with other TXQs if one dequeue() failed Date: Sat, 28 Jan 2023 03:07:06 +0200 Message-Id: <20230128010719.2182346-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: e29e73b5-d047-487c-1181-08db00cc1361 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g+PBmDfmpsUyZSomwOyPacwm8XXiwxDq9u120qpx72/g6G6quDfkDAAf38JtcGk/tOwUUDjGCiBsVPxOem3c4fASqhHbH5b0Mv3o4wpUHa9VMRAkQorddIMn160UigXqWeg2DKp/+A8rIqtxxhG/vwk2ESnTQ2EpaKBhaPcCu6EO9sWZ3LOJ6EVja+0Jv+TACaMksatgFfmx69mVRoaBmfS5D55T3oYugI9mrCgLgVOpIJ8OxgyDkHoZ+pCx+952ID3tlngUaYuGE9V5gG4AIUHt+abtkSmJLe7H8S+bOdftRGc9UnBX96h0LtBG+C5vNd0h/2ti9t4zVGXBsWBPzIBwRSUl/nLA3Mj8OjpA9FRAZBDWBRglmEYyMXsekKbATJrwTWIEIsuD+RkbpiB2gku1HdCDHIUxbKPCWlY8wibPubWOjr/bWPM327gD1asOdR1/LOCxINGVv68tKy1uFMNK6VZbXWWSECWIIEXoI7OOs2RvkR33xdzsGWMTrQLT2ZvzQ7XsdEqQUfG/2Td//4GXrAxmVQjrpII/KuJV9qJij7qkTcp41KiCqWWatwKPrXa2cSa06kINbtiYW6bcb4HAETJveE5vzx8aa6n7nOtWfOH8zDK696hwwERPqSXOC3OxYeiZdhX5w5ErUu5kyBqK3JwGm4VWJ183X0pZkj1cDuztYUtGFsY8xAXgVt6fm115T/Wwomw4DUroA7670w== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(66899018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1H75koATdtYicWa1la7SqljDcwc443ekPAd6fi+RopjYrwKtsCMTe21slrmBVp4zfe3AkJ7guPDfyH91eTbQy0oG0LHu48v1lk65o8ZaULkeFJguNBNtGVwmTJuvEPfgCaIxoyi6pRSOMR1wPozeIEvvz7rnnFFR5GIu3eCSpqjOOmvR/9XsrZ5ZBm0pANNahuzE415Rac1tzKD3zHYcUbnPMo60VSZuYnO4HhDSeL7LgVV7vc1vbe0wwKZwSlw4GGFBSsFN0zWX99fPViZaldLmJ0ep2MIe3yMO4onXR7G41veV9rWuoS7ZPO16ryFCHi09uf5QAAmLUosiI2JRAX0yoa4mvET/SAe9pFg92KKdRwtCCdDCrprXE+dPbvUVnKl4rutk7je0dHYGx9uszYyR4gPv6MA+AHZYWhlsI5rQxsjmBk9OdnvJ8CtFuqXzw3h4O5Hme/LEhasreYRHPENFWAE2/G+qqh4kNsDTBe4t/Tpr5w5f415o9tGV4ZRHS2KoTY2CggPCwlOZXr37unEzlCVrNIL663K03J5vSzivmWIUxKiy1o5T5xyv7xp+BxiCJoEStHJJF5O1AYmSSXCYjv+Z8Gt2lrZ0epVSz6husqaKT6ylm4H26NQ/+BS8jlMMBNoexEdGrrhgdttZUS+hyiRWGg5ho5cAdNX79IyXGtlwUntmLPolqRFaG9hcMaaFoTIk8Uj7ixzajlWfywbnoEpKPcnt+vBZnpS/0bh/XkO7q/TDDIw+lamVLVb9p1RnRU+ava90QOcZze9wXGZ99u4zX4PIV3KPC2lWlAckDoZGfrNtjQxgzCJV7tkW7kE78gHa6YUQMiI20uK8ZcXhbW0V+iXtb/nzMS44Ox0/hfkrdiN7aEbeQrlRiHuURg5uJQYOu+C+npH1SU6GB5AcXHOekRTKMLvi9yjT3OM0XGnOPsfdE6Ap8pJi+k8KujtUELVM0D0yrNDe+I2MxgzIejGPWPA/J/2noAukq0NW6Fk/CY2+uceU4GRB9fV09h33dOS4OA4nHQ0N4BIAnQ85TpbNq2y232XLx29pcIw0y6cvqqLBtjMN89MYUe0+v6mD0Tc407l1rjkgw432NCKCxWN/4nnT/4oeszADt6JuheFUWfRfSma3JgUyMYGX4Jc6Mj8lc9AlSKnHj/dk+S3+JD9tMroPJrtQtQ5QMpl6GJWyu/xul1CNpiw3WkkQB4KdXRIWGZQGubN860pOpaC44hwp1/lKv03ERhXTLQ0vgtuxjxaOHBamUSjCDRY9sZB+yXJMvj/BROyGdku1z34jtszT4sNB83bb26/49eg92HE5eNG5pj9gKzNmU4gFGR61jshOJUlFKFaWC/T3DjtkFBGLyq4VacIJfvWdRvgMxwN6L75jA1JJCoN7OHja8d7W2GcF5RjAngQuUwFvxiLdpD7CBOUioQHnbJEv9imS2zkQnd3HkmlNuLcXqX8wrW1mcwjzQ2lTXvkGRkp+e+3gfPyJJ8yKFOv61mRKDAluRZv12jRpP2LzhtcuSpZyloxNwlOZlDBcVSbDVEPM7kEWeml9lUg9oZ2W0apCloncVb8Kw0FVr3MwrbQ8tCOcfNHEJAjOVTtv2CDuDyAi0w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e29e73b5-d047-487c-1181-08db00cc1361 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:50.3076 (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: pMsSVmwT8Tdj3dUk2zi4aUY/R6s0kI2rnOaOX1xgDvAdbVtPiZQy9/M+3YmN27PaW2cAjBNxKUPOHUEYUaap+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- 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 375f445c1cfb..1504fdae723f 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -585,7 +585,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 Sat Jan 28 01:07:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119602 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EA2FC61DA7 for ; Sat, 28 Jan 2023 01:08:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233604AbjA1BID (ORCPT ); Fri, 27 Jan 2023 20:08:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232709AbjA1BH4 (ORCPT ); Fri, 27 Jan 2023 20:07:56 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2089.outbound.protection.outlook.com [40.107.8.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D61F1F929 for ; Fri, 27 Jan 2023 17:07:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nVew+vsGcO2XIWGCuVswNguX3S9GUEzwA7JNTs66AyH8qQqzTigxNoAmaVOhIkAPCVx8zKHEO7b4sbtYxdRLw/4QlQHzyQgW22KUQT0+GfgvrZxutQ3qgHwxMf+wM+0mIn4V1cg0HDwNaHJ8benVKZvee2xwcbxhgS7vHO4j03+yGhWrhkulgw3u/iL0mx4sadT5F/JasSv1nGDa0CO5kVxC3NAm+fizgtPsGlGMcjais4zUGBeoyifPVeDVqY4oJFpQZ1bgALt+WmimRONyBUIgXk67iUFjrY2wQU1u24Xgg9ULy7Bnp4V9+q0feO2zl/GAFN884oyC8dipjx0h5w== 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=3IKFiU2X46zL5lnXxF3I+Af7Rh8KVaWY7k4fcGTg6qI=; b=awoC/r47Wa/GK+u0X0i3/wY2iDzRAMSWQgsHl70gItQW302J8EeWRBZri6TJletH28HOv6A5jlcb6kSd2qKaFL8XDwo09Cn7TZvcgmGigyCYhHmJ+B8s/haNZH+mWiHl7CrJwv813m/6R+oopto5DVkRTnld/bx0A5EEWdlqAFA3aannsGBMzQwTRZxcO3oTPG3yhXlaTLPacYlPuK3GtfqWDIXCU2vAUQDQ/M8OA+dENDl9TOzXg1ez29eqjs3a8grxYASoqlbk2hWJFq0lCxKfU1kzTui70MIH0fqeu9UNAzwrnjpC0bNHIOnzqMjIdWzZjkUJhFFzAY/gO3u4RQ== 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=3IKFiU2X46zL5lnXxF3I+Af7Rh8KVaWY7k4fcGTg6qI=; b=J2vtOFHVoimVLKI0b23m2df4h4PZ6m5JR7eahBkt64/sTPBPhOHl3lgsCAbAzBFBMSDY33Xt9fa07xdp5lHDrJyrcLLoYb4fTC6lVBF6W1YgILtPp8L0yd0qqULr7+nzLtZqgc4J0B6ByFxH/kCdwsvoe7QkG35z1xjslo7yS70= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:50 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:50 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 03/15] net/sched: taprio: refactor one skb dequeue from TXQ to separate function Date: Sat, 28 Jan 2023 03:07:07 +0200 Message-Id: <20230128010719.2182346-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: e204eced-9992-4fb0-bda9-08db00cc13af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pQJH3AS0MAiGZ6KnZbmy1ke+9ml7/uCn05gf1+IfCkj62/kATuruPtxo4lePHMPeS08ZXau47AkwG8TG817hX/3w0axjhfGg2gRByEsg/P79k68k0NuKof1xGWAKv8n8CNTCoXHH3tdH29OPddW/c13Ryb1RKCr/dmkez1sKrLKgMjv5anlt2m6DLDwZy1jkMRMsaOYakj78+uGZaXXk/4vlzYeQiEe/HXsLtZuth/UtafNByyRW2jbAtUxRqRy81SDPse/Z/wFXCGClyvloN6EG3VuiLInonwLhg4T4yuK/ywI2+rLxXPS+sN4B9qzCOOroTAZ8fidGV6SQi4xGnoaZILWtX9I+hXfLKac2IAz31twZJZ4mvrdF76PU35izxQ94Ry4H8ykfIDkRf3zgWIF4UzZgOecjaC3UfKhFQ6aeaffpg84SZfRUi9Mlhh6TYBcuThZFsgmnC89W05dvn0Qu7E+IwH6iXaIbT9vgbHEnqVLrZPRn3NMOh8pplFH/aybjmDrfzub5ItzWY02II6UT/cDzHkBuOtD2hBzjt1/s6UdqC9FWxo1IcxAdL3TtzEPvETKK0CPQDPU0Tsi8lmXgTJGSnRebBe/3BphyPAMq4O0DNEL5Fj/rZ2yEJ9vEv/GDJVnu0v/EtpVayKCj+3mmyqrU606qxcpigUNiKcSKO1Ml1ApiiSaqOYaa7UF31RLqjf9mTNueYr6s3sLcOg== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ya8hVuXxr5Q4YiWHpL78WK3vCQQYXi/93X2IGEuFHzOM2qL+pY2QrMUhlyj6LoaFB/38mte7s6ov/i0/Xwem0lj0tBjrwDvXHpggkPc5gd0b58NfrplBBfXkcArjagZL/rcrtTeOLDmIs0nDHVV8rD0DdDKmK8yiZ1dmYjFRPCRzemtAz+x/hLIKTV4DQEMV4ttaiL9MNhmHORIQsUNv5IpSpKvL9XknM84r/xkj1zhwDQwJY3aCJzX4uEGZ1cZlfLnJNL38b1UQuWlTzt65I6lUfHbT+iKlJRhEPnkti1G59gFOYDEZBf3dhDRyRl942qXg37F2Dn02XoPytmZBEiFgIQFBapzzE6uspgKjvovboH1soQomDuJCTstiS7SIJ/nw4nFrqjUUy2zd9fccVKjKUzlHsKnF6IZPqe1cFhGbq2mhqvvYcpBSUYs7l6xQTxUNkeWF0unKIwQg0flBmepcb4Skvr7d+LSpi+/cfsAdu6YcsMChjAHQgPJoHqKPeqgsv4357+BotDKALDZv4mh5WnkTKff/th1J6niMhidXqfJsMWCsTHPdoElA9WEezYoxXPTL87QqvcYXvCS0viifovBld+n4bmoUfRTT+HeWPsKnagdhPhjIXl1MRNfPA0YcflQUBuNWHynaYIv5xDOFL7U8gcicu+b++bzM9Qf9mFT3VvrbOTonRqNY8s2n0oc2txn050VQ0x5pww5BSEE266xQ4vb3QSqt3nBps6lT821IdRmN7J+XmSBFhMjme811QgKD3KsshxyVICJ4UXLNV5orMCzyt9TnHjtW7wpcfWiwOqoluE3SmQcAqKT+QaBq6P8zQGIqpJuVdK48wDJbOlShHoUvywoOMx4dJqnlrBd5vFAPEiYqY6Dd8XqW6mxjWsiup8q+KgdgYcMvM1YgRgxRGyItvtt+hVWIvPf5ib5upMmMHhA+IbW4pEZ44q8IDnoQdPH4uGs+vszsqR7mGIckktOicwfK4j1iqLQm6/zCMVkDDrsjCqFr/NyUbinXGpPBvEo4mptJrbEZzo/tHOUdzbi9CQHHxx7n/dP2ky5La3MyE31p+CNo8kdlSqjp7MN8pgeYXNyS+DmRvSJ16/HzxZ7hcVnsaqmpeVk1Bg6pX/P72yECacWbaTwZ99AhyjqQeudFhUaA53YbXNIqRYQa7YxEZ47quiJ9wcsYiqL02WYrw9szLkJgI3CdVo95dFKJs3d/1MoZXip9vMSKFLP78JBuIXefFdo/nrqkgtl6o341tiWwPoDNuhBMDvdqxPP+2awMUoODi79HTYOhGc/SqTObvzJ48ZvO+ZLZ5LZbqrNr7kMdSp3TP5tuH+tamuszRd2aaOfwQOBR4J+7HTLHb3jyfnr/rCdGOqhl4PxtccErs7F/ojRiGUFnnVOJ2LRbLJjIJsF9amG6URCfdfCcOz8WoEICkIOnXGUut/pouMudZIWOLVqzR2p/AttkE5Wpnggz0mMWUvHUSCfpZa3Y0LlVWuxGFiTS3IGgDRLen99Utbmoc769ln6VFrIqykB7dF8HQoSJhH8boW6elcXKtZJgZQ3Qrd3eDDbWapjlG92qsS93l/I5y4+cM2P1AbF5doKv8AJ8/IInfA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e204eced-9992-4fb0-bda9-08db00cc13af X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:50.8232 (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: A2tDi7DnNxgfq7e3dyUHCg32riKNX8wc0LEZ4duyv+jFvcjjtlZrb7oJb3Jfhz4gUlFq+VqxHpsdAjZZTduo3w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- 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 1504fdae723f..fed8ccc000dc 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -510,6 +510,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() */ @@ -535,64 +595,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 Sat Jan 28 01:07:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119604 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EAE5C61DA7 for ; Sat, 28 Jan 2023 01:08:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233656AbjA1BIH (ORCPT ); Fri, 27 Jan 2023 20:08:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231953AbjA1BH6 (ORCPT ); Fri, 27 Jan 2023 20:07:58 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD0BD22DF2 for ; Fri, 27 Jan 2023 17:07:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eJddFpxMyfkTTm+LQCBth1DfqOmzPMGqMYFhTKS/uou8B6ajedAC/C5EOpImYP13N8Tk3pSNusdSezlPcPq1yL6TZtfP/YY0z+l+9mHEXUNuCjoC/JntNvSs+2RLKZD+G7A7rO0goKjLhgTePbeZaWuqoaK5hqa7hWPuJDmM+A5ipP8NAcPUTNALam0wlz72TyX4/9/dnCwN1R0ZwKUhDxdNSA0Fdyz2i/5THK8SvZcSrwAbB78HNAmN1RaEKeozW/dI+zfZ+wtdFl+W3+AHPDKkEOmlRt7Bs81eP/tCuH4L2t7SvR/3JdPZV+auE1P4+Oejn4JIzgv05cGYypBF+Q== 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=SQ/HRhSTUPAJcny8iglQSqomH26sDv1dVC2Lmj4hbqc=; b=WEzQw0+Pg8dmESRl10P0A/f85KrdvUta/noBdWIeYJ99LANHl0JSK+uQcLlM4jrRPG7eB0TP69tPAPlbkdCSuIp12PsiXYq9YA/HOqxU91E7an/EtQbfwSYoFugfXDkkhjfUQvqyNF64cW2QbzzCefR5SF4EyCwtO/UwbgW1OnOJEOyRvghMwr0J1eTQNq4WRFODMolL2PkLmzALR97+FpDEyfFGgtnNOLz2VEXul5F5MrbrrM6Nf+/e9wq+SLHubX/S3wgc0Y43DLn105TFtmoFSRVOL/G7QcIzWOp1RVO6Ap1o0n0YS4eF8aT6MQ0y3R1O5T/6A6vEKh3TWAYsfg== 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=SQ/HRhSTUPAJcny8iglQSqomH26sDv1dVC2Lmj4hbqc=; b=PF6mWwEvanGJx6m//LjdEaAzGS2frBA4YtoI/HcvvVFz7OLp8VCPf8kehdRJ8y2yqSnuP49SODx27o4nZflL9+sGxsMgpqoFOL63BqI5h9G4ndvF2DojgCm+U+fG8WOgtMmtvSUDQ+3QCBRRoiWm33aHbeVcfjCcJkR23UhE0Ss= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:51 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:51 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 04/15] net/sched: taprio: avoid calling child->ops->dequeue(child) twice Date: Sat, 28 Jan 2023 03:07:08 +0200 Message-Id: <20230128010719.2182346-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: 7542fb23-7ea4-4f9d-f302-08db00cc1407 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M5JXpK18+WviQu7zIAfYg++n50k2UHKbAv1k/RO8wFO6+EcuFboulUGe55EguyJFmITXDuQKKW9JqsYM+a+yTfzfVrW503j/+KSUJEy339q1p29Z2BZb5AILYBOjrEcuLVXh1lbdXG75p2d+/ZlBQiVsZpYu6zQHnCeFxbyijbe41YIBgfP2Xr83Zdz5x/CAYE8YVwSVHIc90fMj0FXkqLJQyh48DokvDx1dwUt3JGvTHuj5L0XX+IkPSFYYtUyVjZ/zg84geFuOpi7xDkrooIzLejSd1QybZXLc45JmFOOhdiZeTBIoSVCTMgUWhaWTF0a8wGR/E00kfnN/gfw5i/GlNVhXyAzHPo3UDtycWKbusdluXeN3tJRG2mMmV7WvvcprgMoOmLjqkSOrpSQtxHC5CrkXyiAmL7hQBFK1VsEpPNAuugpA6eDj6qj+si8Jhe7WgxuTlq2uT/zfu/xylvrAoKyQc/XzB1A/P4Ct34qWJUrpq0kRyKm+ewptnYkrOKMsZOpATSSU8hGT6DmO019vMIUYOOKdE8fdV8efbfmoqRvYps/5vjka7CaXX/hBWTCfhs9LCOsXmNr6F71meNL0vhxn9ZiglSGWZIjLHRljb/7VzH+MNr4hdrvViAcOQlMFCqLvQGFm8JAiUgPzWWtYlFQ62ntG8k6jN6NB2YbGsy7F1nj6v7OyiXS00s8F9Sr382A6ZUvnJbxI+C1/Xg== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1P7Bu/8XM5XPkS7oCIZyskwW4NiKUCOVgRPb6jPPwCqUxfNPe9TZhZHWssXFD9b2PsaDuJqW3fkSfGRmU3rzZUbASTG0ueGGMl6z9AtEt2AY3qI58HBgSDUxGOnWQkVOtYFqwiyNhZ3SnhAVi4j1h4iVXVVXohbvepBrTtgORHQ/vAHK02gz4YOf8p4KdGn3CMTLYBDM1VxoD2LxmVXYcpu4NDJeINuYjhk9k//q9k8CP19XtMb7LJEryF+cYmrbykqsaR2O664gHKaYXDfkgI7dw5EkwtRdwJLuCrbU2AFPBH42OpVMlyVHNVGk0Rk8bxlLufuvllp1BDP58/OChAB29feqZuNVeiw5kGD6iMt2z8OlByeysOVzrU58SS5nNXG2lIcYGv/v+pLU0Nw02EZODLa9KFhUT87fYWTygJPIOtgTf7bI/p4huic+th0kL4sPu+Q4Ps8mPLisxief22Rv1mV5fjMeOK76WxnLz5b3Y4p1/RvOReP5gDDVb+pA5t4vilNcgJuCffKO+FIKucZf7E12B6DL6uid44eeIS4hxN9+Be/+XnOkCzPbM9TfVmKUx+pF1wg9fBEicEsziBJfgWzRdu4HGTS8J987WpURVuqXQyGeZ24+6pqSj5yoJo0Uo1r21AIGunBSDzVTXNXU1iX8sYxk9sA6z4oD4gDMopIIljS0r5e4Tjm55FzbRl2ume9uJiJ2nJwk0614Vp9r8xBGHlX52vgQDX8Fqvmycj8xq5c4of2SLJ4PBF2fn0Zij70CdDNWpYAeLhE/8gv/cYg90Tz3348+i7KCqNsDAqcm4prxv8oRBHCmtLP91FAQMWyxrxpgLeMoXAETH3RjkGzGggAGe8qzKWnz6II4awzpoQhwiuMHwx5hEM7sz1pxIqn+RsmCY8X5lnMOy0OQ1NBEIHZiRDbD7sITDgMLKZ/f8CICtG/Cx5RoO6b1XaJsYkzt0n1JyffziT9wGRBmRIvtB/K+i2oHa1yoRUuiLojWUGV4Nfm0q0gJ61KfLNlmBVU+hYnelfC+kgoOCvjnlJuLC6o71yT6omFKSMiCqshtiT5mYj7RQwaMfqRq2XlzwMCA1qmvPZ+VBNnToTsLnNTHlBply1tSvjmf5oxAcMlmcYgCY9G5jzmL0ORNV4tUP0WVCMdC2MZvd65o4fNAnJARQQFMFMx/Yvmg9ySgavOVleuawUTjtGk0u0VIGiB/nYNdudPVkNdrYUYxY5djWrzvViZDG8BUQ/Txbfuxcn1/cY4jxlOBmHHiuknYHTXzgXWiPhpGNc2O9KMvCHHZoHyYanxj0lUJwwh3NUtkWCXQU85IQUPaIufYyWktN8+vOgk8LdmE6P/Ty3JHTA+NWIpkR5LT6Xbhoaxvyx+gQ+L+TeD87a99kUvLrf2QEWl48QW9tc5OZVFE8YkSO6S9IV/8GiogCgANndsb2loDdnAErjDCPRLbzUdDywRyexycoECtVcLUt9gQk7EmcyzxmM+x11LKZoQl7iMGiSqr4wyDijO6wahep2opBgN4KDXNDDz8VK60xNiGESeeZqdtkFwuxqYnSpD8mUTjGVyuo10RuusFQAnj2ijZU5l00XVNhChh9jahBjslrI0zVA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7542fb23-7ea4-4f9d-f302-08db00cc1407 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:51.4169 (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: S8vb4flHqhtnq/hyNDsIIK0xfbpLKy1Ba6ONtlVdNU4MN0404Ysgvq2sSR3nKP65SOkG00en0WnPjSexPUxeVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- 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 fed8ccc000dc..30741b950b46 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -526,12 +526,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) @@ -558,11 +554,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 Sat Jan 28 01:07:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119603 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 154F5C54EAA for ; Sat, 28 Jan 2023 01:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232356AbjA1BIF (ORCPT ); Fri, 27 Jan 2023 20:08:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233306AbjA1BH6 (ORCPT ); Fri, 27 Jan 2023 20:07:58 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2089.outbound.protection.outlook.com [40.107.8.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1974623640 for ; Fri, 27 Jan 2023 17:07:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q3HXbagZ4elzRiIEzlG10vB/UNRW0nbG48R0yL3C/6apO5iz6x5eUi6ggkRL1FRmRxr1W1PPb0kxRlCX93l2pbWf37No6rHKTCv4sqwdFujdlIhtIieIwuIb/CdlEDeU5jQaLUp0cnMuELs3Y1TRGMtfE7Q8zcDi+JwlHhVqupPtNjQ8lB7zh73n/0+Shu2EeQ0z6C3bMec3AhQbDq10vwQkU4Fn73SzyZ2gftgy7dM2D5gdxU9tXm5Y0N6yG5pJwhBse5li7CF5b73dVCYls+2I6sApMe8yOTCj9yyViaSVE95MQxqj+c+sCVOxtPNIcsrdwHz6XT3P3kaYrySIsQ== 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=c9op/AhMplJj9e5Vzos73yAvRTc2/6szWqr/UptpKPs=; b=QHKAl6NkUTxZui8mG9Dw09xvuS7ZQ4ewZz0WC1Vm70QuNcBAfJv3sl7ovecgyr2cUiH1/I6nalx52GfZPpvVeskxKhU/8nrQ3t5v5yHB84HkviqfhZAjjuZZDflZJk9/2d5XPL1Ey3szR1WzruIpqw9d694lZoxPVZnTfptV7qXiCTnbECD/8OuyoDsEImCX1BSJnlwvSqFlvrCQSIitU7sPQAOQ+cJQzXf+Z8+as2tl+RNpKX83G5NYmCPtt4kM1Y06s3JmWHhXW8d9njWVCXHoBy4EK1hi1JTxZiLVTK6fqo5gN5eCTJiaZ59Po1BlD+E2QeAJyV6LQcsB1NhlTA== 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=c9op/AhMplJj9e5Vzos73yAvRTc2/6szWqr/UptpKPs=; b=nK0McIA4I48BdsDj56TmIRAI5cXwVkc9Jrg9pPLq7UZKKU7CrQUgKMvSyUwPgq5/vH89bLYK0lxleSwJGpxg325aCZ5/G0RuLpi39wifF4toJq/CDvU2uJOogpP69IafumDzzPPzXRQJA0d3fZxwv8t4zax+sOJM32PclCPVULc= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:52 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:52 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 05/15] net/sched: taprio: give higher priority to higher TCs in software dequeue mode Date: Sat, 28 Jan 2023 03:07:09 +0200 Message-Id: <20230128010719.2182346-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: 564e4396-981f-4a7c-c613-08db00cc145d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6kBLU0qV4UXqYF0uyieHyP/dfZPjcbDmk4C9ir67ugAZ63Hj86N5MgmpaFg8ZNzzY5nghj6W99WYKXZLOJ7ZwIRv0GMoFlPyDIAolZ/FAA0USsJxSTTHA+AilCQRaCwso1weLVzGOj9jytgNATIeV08tD9iojtRbnSH9xoPKkblCzbYTd5H87cYYNtKIJpffQq9rHcnyrBX+DdDOsmOlHDUEU5wFRGZw78kr+Zs5GTU9+Z5CyQhCqDNe3MK0VtWBA7xpDCcB+RXXBemxXFQ2M9MPWs4rzLTay4UvLN6B9qQCGAcJTWCAe3q8ZQRh/pdDJKHBr9LV9k7HS7i6N5Af2PlsYhM9QRiJxBx646ILh43Vx8UgHbZidH4yzVy7uy0JQxYhPE5iFV4qmHiElPGxP3cIiW405sNJT3ZV3mO/k2qpDPV9U/UwvRPhhRmJ9JaK4tGUKjCUjFzEePTstvP5MlQit59745KNO4roEtEMUgD9PkQC2wnmiMCqparqEI1me21cWWL2xAA48OEPToT0OBUToDoAfdUKLQFbqpy7i+xh8SywVMbX/kljF+XIXoaaNMPS8tBZRdS1nOWMXAy2Q3VI8P5dEBk8ymOLSlrQCPiMwHhumVqIZr02YFJtKpiYPdF7EXf4W5PKP5lJrppFhLgsshihAK58QycPGKQTznY3Kl6PrtDHlb6jbUgneNu6PzK4FxqYNQ3XVc216OkKAw== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TT0VNp2ilhRPZ2l5GyYv1OwYkaWqM+JDd48jMlbIB/11cF+7pVzijZE35E2xEkOOJnaE8Q5DOPyCNJZasNZDS7s88vpT5OyGV8NBKKm/VSjt4N8Za+NSMpovzWdlF6065bVv/2pwBchlcm/LiyO+xZ4+G96NJWg/5BWwxYEx693sbwChZFEhDip9Mby4Wow62VVAyaFtWXegOaHl6cgFcsJaI3Kh0E7w3QB4wA/F8CbVtaFoJq2tu1Zy9bP0ChIvjoGEJKv1oCbVdemooXLk5AEiFDdVlNJU1htIUvr9sFnW5m31F/4m1IOIkUoHgumwD/7+Gljmy2K2keJHr3XLunPLK0HwuPi7kg4jBL49x6eIRLhJfn2Ds88ByWVszzgaMtfxZMyGDKOMD/E3+RCYjdTA8KefyhVmcc8DwyXTXFCjJiRrekH9xAJlkabvICWs0kwe6vNgalQ0UZGJd9mOEL4ydn7ecMX0wr36mCXiHXYn4f6ebnHtsMYj2m9+YxU/IgtQTws2up+4yO9C1yyAmJmSNieTlf4R9cWpQT95j+PZ8j/qNy3rV8Md6gMS4/S13RULgfHMaQVZQQtP0zRz9mseYeocrP/0ioUgMSyDA+2ELXsc0+JMGJYznc4cfQD74gmrRDa0BKOYrPXqfUuvLG1M4yVq1eK1ZUkyftr1fXZPybPjj76I08+NabYZ/3aBAvs12HQVseu3MotRY8p200sfPcDi/FKaEH0tEi0Z+tSqCSBeOmVHtE112rfkstpfrYUNqTxmyd8msmozUTk+1/KLjR6y6kLviKoTXmcci9RF9PmdGiav6WZp1GbRqhgzec/W56R3mkPWZ+BZsL1edf0f3pBj3hELvVYNKjlJvmFEK57V0/pTPSnPTQvCNjNwtgp6z2btE0Hku/Dv9mRm2nQPkATb0oC2409YeqCpN0REtaxFQ0KusK0L78KtY7Q+2nYFfqu0ZFuz1zVaAWpXj+JPM+lZA7KoSIDoPKGaPx8cgLqWA5Xgtv19syrj7HG1uJfaH3GOS1SqqSUJ+uZ4mLn1mD/MtvHsvdNZmAxm/TRMws3SVGU4YY6J4+cPYNmfqsorIV/aRK9ORSIxypXulxeMns+CVWHRgx+EMj/YP9DLGxyHE9Vfq3rO8HvOUPKsMxas52R4LonOjzzIYRIj5kpZcUAfY9YzJxaTSrHE7S9AR0lXh18Z7WCUVNkwM8hs94PT6YWFdMJTFJSdLdT5rFwgRLK1QdZJUKA8YWA/WdmqiEDdzIkhxWRAN/mp9BlmeYrngH8sH9Oo+q8XbmjJ+rH+cWpwuotx6CDkeaQRUDj709OkVtZoCL40wynrJv+Vg8JfGRMGiRoYsoMrQ6QDFU72lv32Y5XwSXQ+/zB/V2gVbqZlUlFr+KDtNuxKMZENxPN6CpiaWxJAJzleVAilNQhQXmOkboXbVV+mD0GDVxDwjOUF5tZFsqhing5wkwqhnoKLPY9RbEDtFWK0Shmqu7OHiAOpHyp3Rd6ApgexxfiB7t5fzOW6WO1eJKzyShSIEBiAtLm5lyH70Z05Gv599K1XQrUYWhEin5KFJ/YUJL33ODWjDtIj8dp+aiCXHrIb/AmlOMqMDeyUJ5FU+W4jwg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 564e4396-981f-4a7c-c613-08db00cc145d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:51.9481 (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: +qOH4NXacALzAoDJfYoXCNHk2HawmGFo55NaAjGDgOKlnQPzEjZXVKi1FBhX5X6jJHiNguY/ahBfs4XamHtrHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Currently taprio iterates over child qdiscs in increasing order of TXQ index, therefore giving higher xmit priority to TXQ 0 and lower to TXQ N. However, to the best of my understanding, we should prioritize based on the traffic class, so we 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. Implement something very similar to q->curband from multiq_dequeue(). Something tells me Vinicius won't like the way in which this patch interacts with TXTIME_ASSIST_IS_ENABLED(q->flags) and NICs where TXQ 0 really has higher priority than TXQ 1.... Signed-off-by: Vladimir Oltean Signed-off-by: Vladimir Oltean --- net/sched/sch_taprio.c | 49 +++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 30741b950b46..7dbb09b87bc5 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -78,6 +78,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; @@ -515,13 +516,10 @@ static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, 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; @@ -533,12 +531,6 @@ static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, 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)); @@ -566,6 +558,16 @@ 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; +} + /* Will not be called in the full offload case, since the TX queues are * attached to the Qdisc created using qdisc_create_dflt() */ @@ -573,10 +575,11 @@ static struct sk_buff *taprio_dequeue(struct Qdisc *sch) { 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 = NULL; struct sched_entry *entry; u32 gate_mask; - int i; + int tc; rcu_read_lock(); entry = rcu_dereference(q->current_entry); @@ -590,10 +593,24 @@ static struct sk_buff *taprio_dequeue(struct Qdisc *sch) 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; + for (tc = num_tc - 1; tc >= 0; tc--) { + int first_txq = q->cur_txq[tc]; + + if (!(gate_mask & BIT(tc))) + continue; + + /* Select among TXQs belonging to the same TC + * using round robin + */ + 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) + goto done; + } while (q->cur_txq[tc] != first_txq); } done: @@ -1588,10 +1605,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++) From patchwork Sat Jan 28 01:07:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119606 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C7C7C61DB3 for ; Sat, 28 Jan 2023 01:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233659AbjA1BII (ORCPT ); Fri, 27 Jan 2023 20:08:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233628AbjA1BIC (ORCPT ); Fri, 27 Jan 2023 20:08:02 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2073.outbound.protection.outlook.com [40.107.7.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 827E14E530 for ; Fri, 27 Jan 2023 17:08:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bKFjtRltkobpjjFm0Wz5DDOpCfnCvDo+hNAxT79YRLos/uXlNRGm3Z1JO0loVsBWAtHYdN+jrI9Q5uOeT63f7iNvcnEDWMQAo5bSInXHDJ96lSEUW21JtnRRh18Igj1t4MQTnhfvT4PsDZGn0cDF504ju7uaUMmL9TxXmQ9g5L4oIQPez3B5G+8F1gCSyAbxSPct6S9hIdy60QnFB3TD98Qun8bz46QtDeeivYJSVZM+Jv00vF1iTa7f4yhh8ZOd5EUmurpbdeqPPNfSMnFpLgqopdigCXFx1uQXZU2W/RUxkZrgD4AAce/s6cPI/b8WZX+rf1imoAQ4FO/2b/DO9w== 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=TOqYcKIvUO2REZekzAq5XFnQe1lhVmnCay507mskTDA=; b=f+k69YvEWEUM0nV06v0s9RlmsdFqRe1VcRFxdGrDJjJ5zdHe7M5rq2KhcqQ6zT9WB3jI70OfQgP/0G+cZAvRwhBfVhLFPGzhzhDaRkt+fiyAhLO4WRa+qYdRKJKv2u6xR6WOjG/JeAW+Q3VQAaWlL7CupAX87LAaOjWxAq9221L7mY6iKzLeCLJ2WW/VsWav8Qg0pist4dKw1nqcMSNZtbt8quWDSMhq+qXY3wA0wc9a3SSg/HenyYnT+iQTKeoafxSRspSigTN8PcN43q180IszLQbxC1u6MuXI8hNnUEXTlPyY7brOBhrJ6lRCI/DbcKBmDhpCTyn2eSDmBTY3yw== 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=TOqYcKIvUO2REZekzAq5XFnQe1lhVmnCay507mskTDA=; b=Ng0ur42a35wQu/vW4elTFCDXEc3ULeSDurA3GCgdFVuwT5x5r/kCFvpbwEEN1G4dP8TlkQfkJbQXNg2trRM95BZJtUChCPzbajVtwvzqn+M8DLP5ndubYOqW7drGXbTbU7n9DykVFIiIKPubWJkDP1nkhQRvNlaohfNcTMmiz8k= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:52 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:52 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 06/15] net/sched: taprio: calculate tc gate durations Date: Sat, 28 Jan 2023 03:07:10 +0200 Message-Id: <20230128010719.2182346-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: 99a39277-07a2-4573-d48e-08db00cc14ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oCUTo6K5th1yNPc2BIkYmU133UQ/W8f1W749IIRPOFr2a1q3SQyuDUH2xxJKD/W7GM4Rv74sP5srseOcwJK5MRsQ8B5RBf+n9VL2Ij2um5YpnOLADNYaXU8F+Q25m8Moz2esxocx4osW5e6hrSThRE+jRmuKGu71fXf+g8g+iO42SbRcRzADbQUaMv6xKFnJLeRX/YKfk4dZPNRAE0MWIz8xbJQm0RptJdwl8sF6huDoS7EFK/5xMu2At8iD2ZxNHqbhn0I9+LMBg5e+L1rriRpeYdOCOaXu/ucqKzL+nbAb21wmg+OH6dwNXZixGfCgW6jmlsg1OlnwOUSYEyBRpf9caSMDtPjS1YjF5luEAE9V55oYscN5FDh6Fg930Rkey1BCuXqSTdv2S5gJRLPHn4bIFx+2H71Bhykykh+kEKoBUX+eppZlBkLmd8MFEyAgbYRiCK9jcYT9+h78vaXhmoKHVHJulh3l1nwNOwyPrhsiuloCMJEXDqNxcEvVu/vdU4aOOjsURkDmmtIUtLrJEgMO6FkdO4VjN3Mx+9sdJC4eUYcZNh1xByxxpL/dVpb7OoJWEc4BxEaGlWKSC2tDx3ZMH9wOwEBg2PpNxd+5Jd16GiFRbXiNLqeQuTaMOyuEF6SsoWMltcwVrcbl3AKrvdILB+5vCia9nnBFXyV9Jl2Or17ha4r+rzgRtYCzoQ+XMqKO451RSAogWKkaOSBWTw== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Vjg1wq14o/NxSrzbOQKixayjhr4RxPQ4kYkgpfyQX4iiJoO/lYhxOaNti9i1AntWU7dU69Foh/joSWAJnOA7FwdrQIp+3z+mgOQTYHFk9vwSmbgSW4xJlPj/RYJFp0+HKVBLtl89VVs9SAycxTAcTFys0oLHZydap4ktQ01CFXCZKlabvo11QBbWrX35hA9Qv9qadTxJt0uBiKOL5CAO42NdBF3BQ4HZ7fxh1oEA0DuSqbsfsEhodSjoWkD0do+3Q4tqV/k41HVdhUasHDPDeRP+VAuk/rPwbGfEMkjZ8zBZIJY4BTboCrDElLYwY2LdV0M5W94NjxkYPjNiPv3TV5YQZV9icNKS+Sa2jSm+fcqrwydvj8zL95XGOJB9j3OU1PVX/7H9AckJfXibO0C0dqWr8UAGS5AMPLEsIT5sVqmxajyYIune8pVZFF2mtXAsiYOIsb3OSXzQ08562pehMHqIWcrV8ddH+JGL48thxx+Hw5JDoDPUsl2/5I9xvVV7DojK2isymOyVKgCy/M+rvh/D31YiJF/BfBKSmouzKKCrI5D1Sy+Mhx6NeDw+qp4EDbhDDpLQcFJEHdQ2/oYMx4B3XMqQu0E+uROo3MhSpMXFrugQGwK+z5yFhhWHvIfOIp/Yib0uRSOU3oYZz0AQu1ErmhOJlyK3tWY7QNX6ODivxTXJiNqDdXQ2FlPvN7XPet9TRnLDrSTBpSm9goJOBzpGHx6VUBntz5G/6s5w7u5mVG8Q7IoGu++yCWaJST9uoW5AH71/VKkj200zup+Ep8tlK9OUPT9wAX8yXHZLkSFyuXbjItLYFbIgOHOcZd6E8Ffw7LR9eWWLfr+KoenSyWbZDVVnTfJ1P/m6Zj9xSdL3INpX01qUUFsMmCWAxHg3UWg4yQR+YttHHZSI6Z/IIicD+vrNUnn1BQ90EqTBF1K3ue40Ul8H23hZzDOhOrr5POXnLggz64qgsyj6OUitxwFovfw0+3QHUTBUeGvKpLOLacBSyDa240LKXSYunnbIcJEFnUsFA5jVec4Wj4chnE1ZiP2k9O0YE7ZFilWMCXf2xnGh1aNJaLRqzoWWdWEpXFJ6mewxaGuSq0rMOdB8qw70Ip196ODnCddbasXDW57LflZGNtl9n+kvgpup1Ykw33/Ul9ajuK6BxhN1rTBCnH1bb3mkIA0mZIJOoc78ziiHmHgYuW+fbvoe5ZPPGNYozga58s+g3qscGN+UkDNODAYvWuk0JiYL93fiaiiJZsyLiZnoxqDxV7tuw/1joJsAC92J64CgYfIFoiBBPUuvuKf+CrdI6V3uDvmO3MWFkZgtwQZ91d1zMxMi3TLIZ7FK7vYKWFejTxaqSXH61uu9XKFP4LbdhWtt9qxE0qoSJvgPmzQLpzoIyFe/TKU9fP3nhMmTERkpdCLTdHIVxssWJME6OT29X6suPv5ncMxwfxzUMeBW1EDABvF+P8ga6V/INOq6JXP4Ao6gG4E2O2ZP8lYyom73+T7ECzcCR8xAudrbXzBAziNXHBl1jXlD4+AT2InRUn892jxPnZXEEdlrb80q9czr/6FNm7S73orJfgqSY154vnFIm2OB+Kb11qWj9HqAwMGZT8XdLCzL9jFORQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99a39277-07a2-4573-d48e-08db00cc14ae X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:52.5262 (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: HPwe86+6EVHh3onFHpmrC0iljaVG1SjNDv2+s+5JETYz+B6oyb9NagmOQ/xRqVb9op1LySs56Afmh5vjTKsQWQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- 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 7dbb09b87bc5..fe92a75701bd 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -35,6 +35,10 @@ static LIST_HEAD(taprio_list); #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 tc_gate_duration[TC_MAX_QUEUE]; struct list_head list; /* The instant that this entry "closes" and the next one @@ -51,6 +55,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_tc_gate_duration[TC_MAX_QUEUE]; struct rcu_head rcu; struct list_head entries; size_t num_entries; @@ -89,6 +97,51 @@ struct __tc_taprio_qopt_offload { struct tc_taprio_qopt_offload offload; }; +static void taprio_calculate_tc_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->tc_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->tc_gate_duration[tc] && + sched->max_open_tc_gate_duration[tc] < entry->tc_gate_duration[tc]) + sched->max_open_tc_gate_duration[tc] = entry->tc_gate_duration[tc]; + } +} + static ktime_t sched_base_time(const struct sched_gate_list *sched) { if (!sched) @@ -907,6 +960,8 @@ static int parse_taprio_schedule(struct taprio_sched *q, struct nlattr **tb, new->cycle_time = cycle; } + taprio_calculate_tc_gate_durations(q, new); + return 0; } From patchwork Sat Jan 28 01:07:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119605 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 996ACC38142 for ; Sat, 28 Jan 2023 01:08:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233306AbjA1BIG (ORCPT ); Fri, 27 Jan 2023 20:08:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233602AbjA1BIC (ORCPT ); Fri, 27 Jan 2023 20:08:02 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E36E443461 for ; Fri, 27 Jan 2023 17:07:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IIt5Lhlgx1gFGXWQBWs/QJ7TY8yA2ETGPL8w3LHgGIbei215AyPYlT3oE/VDJYKmll/OmWberwHs7LG30OIVvRzipG4nDcGJZ4E3eEZfhC5urgrCHTRotAXMDOsLw4wemxqqimZJCylJOOJkVaou23LNICidgCpLV82rKQbNA4oZbtd1N9hQE52wxx9unigr3pg/zsDCUFUE+OHgOn7jPT+IU5JjChYCYPsG+030LkFSmui3p6kW0l73hHSUcHrbH1tR7puCaElxK7m50tp+hKJq0POlWZ8pcTmenjYzGfVR9wqJodULijvgyEPLRtcM33tatMPpLncVsvu9NaP3tw== 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=LjHenr29awFekdslInYr5BdHf0tzqpNTiLJICSzaUjQ=; b=ftu51/ONM36TnZOfewPStv/iNTTBoDeUwTByvyZpMWjBJejIukyb3xPwMIynD9eV0ciQvapJmR4NAIMkVYora136IznVYPgc2FGI1wLoxCsvfxLBYRxZq/GadIWOCuWf7/v4ebbs5uj2bNJEARea/L39WDGlQTaxwsHb4h9Ru8xYw8Mdy4rmo+mzEENgb4RIv5e8O0oNGlfJUwYFILafIJgkJvejsQFHkONdUkEHFygJ6ekNYYLOswmvg4AR8SFAIfOXV5QU0K0Afv2Z/V3Ep8cRpKzxL+UH5c7/j3FwMMM2sDqz6376TndPueCc68vqCeep/BOySt64pLoRK4HgAg== 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=LjHenr29awFekdslInYr5BdHf0tzqpNTiLJICSzaUjQ=; b=m4y8lIj3XtwYF/WwMBXZGebBp0jRD3uN4NJzJ7U1jksMThBvIST1fRn24MnVe2E21I4Mv5/rBMTOP6GeyLDuVZAh6wjHMs73eKU7VZqCyFgbFq7J2MWyd6Z27D1Bd4E3nqCvfgNdpSPrngSN8nm7x9oHP/wekxzYZzfzNGrxvdE= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:53 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:53 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 07/15] net/sched: taprio: rename close_time to end_time Date: Sat, 28 Jan 2023 03:07:11 +0200 Message-Id: <20230128010719.2182346-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: e05c38d8-bb4e-4c6e-a78a-08db00cc1504 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /vA0+Ks1lIn8sNtLebUy9nqvbRaXgERZ8wDAo356sOz9rQSMXKf+2sY8DkVzw36ru8NmAKFrrM+JH/Bh+8rDhpxMDIbEIx+Y3PZWZJvB2B+LryMbkCiWmNzLhV4KorDyYmDgl4EsYazg+6ie82EjEtSsauIhxSiYb7Uur0V1kmUlkmNs6kU0xD00DfyPSeydtevfrdlNsOyLVjAH2gCLoKd9wCby8Wue6YXp5XCO/J1WVV8qusEDM3ExgzuEBYh1Vo24XWCbVveoSniEpLwrw3WgE85UgjITLHYg2vV6wLtO6WsJ4EbXkGcqXv02teBWYZIx2iHGDfbvzXiiYDTAheZIt1VhBlviYexgjsEckBSo6q3oo4jXF/ZE2hWdHZ7Qw1uJWNkpUQiIFbRyO5yJP/9lYfLid/n9gnD2HCZdGD/7tVh0DNoMJeFVM66DHS93Vnn1uBhymjILd+EuCfdWtK2ZpbNBgFd95GhcrDbzvWdWV3ybWocgd9mK7yrAJBCtvLNd23N6QuWH8wwWDoX4AVCUuh6UnlA3Ov21MhpQ59DkJcfKo2kxpXm0hJOy59vtx/svmMRL4mGJhT85AGlmvirU0E1B72seZ5Rf16cPxFauZ+4KQQVG1N16j6cogSQ0HOuRfust6fT6ZuuBwPQxA9sa2o+SO7H1P6oKczoRyZeItB9T4IHsmWfHsEre8wGDGfYWzFstMJOUFbpMka4Xgg== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: if+dwK8R2Sfmc2l+wlP3rMRP3/l2Jr+yfqSBWQgS18PdKGoir+nTMXz1r7u7gLxsMg1AuB2KVlFVN7uoG9A2mymwxI4yxGLHyISeEgEHuTHAZqkQ6QWlLsgUiW1BhcU77JGlu5xLnxt2PXpD3H9xnbpT7J6GQR/jh+4UC3qoYuoeq79RjS2ZvDKXY+YUaBqW66RgFQ/AcWZWclkCiKaUgMvAZpji1jzRY4WKECHIFz/zy2mYkXkcZjjgOE0irOyyKXFujBnxALcmGgDJt4oOIEg6FFkpoeyIXbRBhSHVaOtVbphXuLZERfkdp1olsKEtdmuYWX3AZov/uCx1YvzFoZlzLpHfKpYTLDiHPaNFCR59nBu90A9/vCtnAAoB3U8YJg4gzh1N9SCIRXypuj7rSTWoW+dK3ZuMOMjVXxlg+hxZvWNpWtqABwpg4plZFpCuP9qmOupRkXojVeRU/9EKCIHbHWzAGktTDnQgZehFOTHzIVXvfysQD8N7VrHiR8A7R+ZJs37RpPJgNckywafxR1ICwDzzp8QHk1H1RD4la8OrZEnhQQn+Fuf1rv0wA/cAIyUwbq8h9XxZFw5lhAiP993nLYuHcUCatV7GlnWjeLHlu2cRuox8IW299cT7qxBoNkC3asaPjhxMGInUmW7ps6yf/kK5OY7wSJRffUlhBKbIVAcNTZntRa1zxcZwk2Eog1rOKbRUOWfWXlzr5EOqMCYMVtW0ripWGCxZ2TPWPpM/CirBahuAZOGTmrHR1Zim3raXX/dGXM7NSHuE7oj5gs65Ryw3do8BgGKiMYQESyAL5CEZARYbQYGirzaC5ZBqqJ2oG/f/o/hZyJsCKZNCCMx+yVABunGYT+GAEfIx3IGxsbW1e19hiyZfMj5dse/AsiFOcUY+7N5Ec6WGGfUeQ121+/TvEp559QhoWr3Dc+X1/snsSMFyEZ2N7Hybhviso32sCevWYHCqub7ymGe+acqM13MpdSQ9NeOMEAMKVZHuAlTfVROZr0TR7WG4jUVF/gOKOGwBQR0vAXyCTME7FiRMVuSOvGL8zTd977DmaSbuolnlpmJu6bLUWNrB6vC5r0XvVvsTB7iqmLVRSsFvdkzCDTj18FxeImUdZNp5j/HBCeii3yk6sr1RagQRDVcnM/cLkLbXFOapMp9H5Jm0Bek3kRoqmNSvO21zWUu2QdJAVklPvXTCWvhQw+hbP8CibpPrhIEFS7xH8Ijxx4AAm/jnHvjMo1WF2xk7Wdv37znQ6oRTFw4BZoUXCHNzeKjDXZ44A/ssFfJm2W0oEFJEiKzz8lj2bPcgf0R+QgwIrKtoFSDcWWZs8I2PANK4fdBbXamrOgzQcoYdu3Kp20qpd9Q4xb5aIPgXPI81RLTq/CRCW2aLNlSt4qxCr3niZOj70ugtdLDnjAwEzExVrF/leeHS+KTOcRd+VJfPV/mElcUp2xumWBhY8YAjf13BrleMZGJvyC9sOoQMTRBivTbuH+xesAEfA+hgewXVmMy8jEAUvluR9z2WgGQy4/EXZ0hS/Zr4SMuHmj1/TeuJA45ofwtvYG2c4veV4y+b4Fza57ma5PQNKKzF9FSAyKearPAPMX815IDJVfZg/Vw9cC9vHQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e05c38d8-bb4e-4c6e-a78a-08db00cc1504 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:53.0574 (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: 5XO0NMtwO3CKzD4JWpv9+1cMBJdDF9L9w4mLPjKAYcCSH/R7UFJT3mdiRS8af43fzeCSVLU0QptXPrut/Qlx+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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". Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- 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 fe92a75701bd..d5d284eaab66 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -41,11 +41,11 @@ struct sched_entry { u64 tc_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; @@ -62,7 +62,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; @@ -591,7 +591,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. */ @@ -678,7 +678,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; @@ -686,7 +686,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; @@ -695,18 +695,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 @@ -725,7 +725,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, @@ -744,41 +744,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); @@ -1065,8 +1065,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; @@ -1077,9 +1077,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); } @@ -1736,7 +1736,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 Sat Jan 28 01:07:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119607 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E0BEC54EAA for ; Sat, 28 Jan 2023 01:08:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233671AbjA1BIK (ORCPT ); Fri, 27 Jan 2023 20:08:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233631AbjA1BIC (ORCPT ); Fri, 27 Jan 2023 20:08:02 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2089.outbound.protection.outlook.com [40.107.8.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DDF546727 for ; Fri, 27 Jan 2023 17:07:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aT4D8l7LN9mP1RPj2Mql6tqcAuFTK7E/IdRFaKQbXYqCHOOsn8MzqmK8DLPr1mKvf7ZX1d++6eGgKQmMIg4zt5a1zhU+6sbUuv2PnOc5dClZ1yWFpwbDkQfJ6dsvf3/UbTZOY+IjwPxLOsOfn06sqNYFUAFItuaKktEOw3Yg/2wtAcu65cACRtIq4bvZS3n/yxAXD5H/8dMJQqoVwWjeROxc8ibIQUF87sNWmG+NqPyqdMzCE5YWj+6FIp7lNaGxIVys5yK9375KOyCU0/wJu79vywv2+GBQjDEeViuMfhPEWNp9wPvC5TVo2wGcqJzdIe6J5Neyuv+7xk7nHHhOTw== 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=16S+S9Z6o+eA4XI0GV+EggXpp+GI9KS+VLnfKQaSpgE=; b=EcC1s5PVnpRmQXmVzsL54HHuqH9mU9oly6W6YwTWS/3JWSTYrdcybCrPBj9MbxPvgjZLpufn1qlaRjbQWG6YKeaPKfzTnnWHuw3tC0vqiT2MAt1SL25awWyhQFtBq109vLQZG9fYzQfQkn7FLuEGhcXEBblE/MXJNAB60yyCau0m2qqaYhd1J0sudA2Becxxa7WIaA8jfRZTThHsiHzCFXaWYKWyaTm7DrswkA61VQeM0fjaqZyA/juKpSCxlVv7s57dws+XaFIViGIdyJbaqyoVvCUNia6zWNmKVxZ1IN5cBHhjQg92as+ExKKM3UGYa1e3oybHkeSILB9J/IGFFQ== 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=16S+S9Z6o+eA4XI0GV+EggXpp+GI9KS+VLnfKQaSpgE=; b=U0247Vvx3bo5zJOiN6LbTNnWlfh+EWp13HQQiYBB9GT3VzCwO+RW48FRXY8Thet/CbgILWjwvQNwPuCe2wafGhSxKkGAKisRZq4NEeSFvUQgGYDx17PC/X+B6T/rPk5Zmv1XhK9ius17ssZKzf1zK50XNw7T/489o4ghHxTzITY= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:53 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:53 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 08/15] net/sched: taprio: calculate budgets per traffic class Date: Sat, 28 Jan 2023 03:07:12 +0200 Message-Id: <20230128010719.2182346-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: 9212e8e0-814c-4676-7a92-08db00cc155a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p/WdyOSD5fYHP49mI4RhSjOyrpwlI+Obzi00i7Z0OCj29c99WJwug66bxzyayDXKwPsAqE7CkfoptsPeGRUUtceOBZ1TNclU9KAmdg+B9pVgHSsWV0ZGsJidZF4tHfwgSLmgz2CFz56TaI4BuIom8f9r6stiHVeAXbLmFmwr5HdOVRuDDfSjSktx8xRHYp10Ig/QbsfdRLnWJ8RfYoTm7GrBZWyxwMa27Qf3TCwpE9fSw8iEfQH3ryf15Wmrn/WWii0h8esRilhpzOdoNlWTdtYWowKwND7vk77LTGouJ6ByTOO+I8Bq2QUs5bVmMLlaMSy6J8fV11A1AE0MF82kOlXkTuOrcAbGz29RSa9ur1xlhoTTLIE6bQ7sOhxm9U2XMnP57Dubx26ifbwuOV76R2odNada/5HqjYEVdtF2JpXcqq6dvExPSGVh5DV4ESAI5TFs3g7QOLXmACMTIbZQ8FsOpCPM3bzu5igR8m5nZs/MHfiDj/v41qI2JtOihUuylLiDf4Kya7S8polekUkeQfiQtyF4KeGwguLd+HHqtvHkis8Qogu+q7PJP83hx5eI2UUDIP4ACcfH7gPkVLyCslzG5OkJyBFGGIbOZG7I8WEUR/VTmGKiP0tk+1yQ4GYN+dlMrnM2O42+fKV6PCUnXUcx7klN4GCJN6qANOl3pEB+NNopdNvryf7tzb/A3L3ztwvhfSswiMKpqnypFMyDLQ== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yzjVt/8OoR9B21+r5ioinZq3xo6ETaeQV0LZayUWfERALWfNGzNdYvSyICTJdzzthbghywA7XiwYxN8j4+7vT8OSX7W34pO0AV5c6cnSE4HAtCdo6ukKcarDiJN77OKaV7vOuIegTg7zE61CGwjlP9nekV2u0yhilXl6eip3qMqS11SxUPEHrNt6/7Wp1cQOaQxTQ0/usUCJH/ZBGsNwcgGhaTj2Jtp4lpNRYSh6dFWynEwHgXz1CXb5ohGx0Q1wLWbyaeXX4/6MuAf9p3xdQUMvyrReOIdV3/WPQxVnkWGf0TLC4qgNWyKgXAtunBOjzqZFIh1NH2l+O2k2OBKCtsZyoZ6qDhhsDvgy/SieJx17PLvb7rNtwWp2EWrWQ2ThM7DNljQXlSOlIgMPfj8Pfk4A4POva33bQ8WYsWGDF6QX7N8sRYvHiGSn59QE/xdb+L2A2Ua2Zg1hio1LtChC3nwgH2aU8FsDB/NPDqCaB3xFYP/z1MqvHMWoQZ3KHwI3Q71bodx/2GxVDV+EbxIrHw+8LZmoBimUlUdcHgYKmb1jcdpjRAYJ/Z8USjaUyxXfB+7Y8aRyIxgVDQXXOx9Mt/l16MqW2li8uP4zUu8pOV7ylNDFAoHHWzoBL2jdRtvwEVXuTrTT/d+mx9CNQy2/aFEgSeFUYtLdlMTwjEJY4dvdfF8xO+IRVqcKlx6CEjtvVn/YtBxb6BtcA3TkQdXWzKpINov1JPFAbdQ1lKcJHARb1jm4nvVtu+yQcTjpdkNnHpV9mGbSiDoiDy3GXzx1XbqDKpSbEbD34sTyqk3PH4twUVoZPZlEti7b2sDRL409JZOFsV8p/wDvBl5Cy/6MvCNqePcTVSywfSNWHD4r79Hbxrmb2PK9nnlgCP73twr9WbLnInrxC74eZ1WC61PY0T2q6Ds06NK3EJ3Eq6Uf7KQzpROljteQ1obt1Aa3Q63tUUTC+kpTeQ2vPn1odHXz7jkysKOp0pVh0ODy3LzvZWtrdp4qT0UjmSpN1nE84n1rSNsyXGDcJWxUQ/mKMgDBmuh2KKGi7jBICHBB39hfiKFgFgx7VU7FUHMJ5/uutiZyUEOLgf+QCYNtJfTsy+wp8jRxlItuVE2tccc6lPYMzQvKcQZhkz9uhJk9KwAMB06lZW/MVzRXHxZhrgsL5MCNOS5AXbFmyzMHFu9Ks6X9Q+fjt1TCZk67J25hCtkqS98bcwg0Y2WIpTOkszmnelpbVbwphuEPAI5RPQ6hZcjayQBS5WWx+GpwKRu/9XJ7nm3WRTc9BKxRDwILLt9Mnm7k2A6xZ9nS1tX75oHQAjZzlT0jvKU5yuts2zjsLzoAaEZX9ThirXKa/vtNwgnzAt5kho5bfxtPqpxcI9ZpC3XVfAMAiabqQUXrWYsQZGt57TLnsUwJJHyp56gNYSqgwhAMgCSViPQG1A6CQ1bgKsxS7oSWvvmjVh6weD0B5I9OwDMSzq3V3LE1qe6odPguIT3H5HP45CuL7P8nE92Xa/9gmXliJCtoZRTpmh0szed6N76Ko3Q5I/KPykmfVawxV5Sv1erBmUvMXD6HDcZWGviICbNpP1zSeqZvgJQUYOSeQNwRQZvdNnqfTVO3Sbpf/VQDXg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9212e8e0-814c-4676-7a92-08db00cc155a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:53.6199 (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: pf+q+PLU3ssXtMUWNe35E/R4V57xFZNgmpiaXFanlGv6WCKbDabFUVjHzQir20n4HXwv4n1bkWg/LWkkjNIdgQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- net/sched/sch_taprio.c | 57 +++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index d5d284eaab66..b3c25ab6a559 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -39,6 +39,7 @@ struct sched_entry { * respective traffic class gate closes */ u64 tc_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 @@ -47,7 +48,6 @@ struct sched_entry { */ ktime_t end_time; ktime_t next_txtime; - atomic_t budget; int index; u32 gate_mask; u32 interval; @@ -557,14 +557,52 @@ 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->tc_gate_duration[tc] == sched->cycle_time) + budget = INT_MAX; + else + budget = div64_u64((u64)entry->tc_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, + int tc, int num_tc, struct sched_entry *entry, u32 gate_mask) { @@ -596,7 +634,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: @@ -657,7 +695,8 @@ static struct sk_buff *taprio_dequeue(struct Qdisc *sch) */ do { skb = taprio_dequeue_from_txq(sch, q->cur_txq[tc], - entry, gate_mask); + tc, num_tc, entry, + gate_mask); taprio_next_tc_txq(dev, tc, &q->cur_txq[tc]); @@ -772,7 +811,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); @@ -1080,7 +1119,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 Sat Jan 28 01:07:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119608 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD3FBC38142 for ; Sat, 28 Jan 2023 01:08:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233682AbjA1BIM (ORCPT ); Fri, 27 Jan 2023 20:08:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233641AbjA1BIC (ORCPT ); Fri, 27 Jan 2023 20:08:02 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8230A22018 for ; Fri, 27 Jan 2023 17:08:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NWqoqKgLDNjm2Hd9sJdqk/37c7MLBqcVNnJwAPLlSBZwA63qBCOodiCeK9JpgJlXb+XdIsCNHYLveG+5cUJVUFRdMC+GEBXHekfLc8KFLyk15sh2q51LOw0GAMRyX9CVeyWpCkgoP952ULj1hETHUkuEM5OCGghI5f5M7cfrF6jNWZ9vOj2GAlDQlf5FAz/Jisl7xG2mkLu58OdYvOd0mJiZwm0JSJPFU/pDyrq0C60ehQ0sWx1vgbRredFfU/I6/gh7RQimP+20No0iKEc83vGbVRthovAdH5Gm+1rU27uRNGpRZR2A7pXfq2XYzl8Ymct5PjoONCcQYQr35VGNcQ== 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=VmrMhPAVzjmifYxrAjsuA9hOXQvl2+vnEVVjevd0ijA=; b=gKMjMeEpFvYGZCzbpHE4aVPnAc7c6GLdK4pq72BL7qxaQMRQ/wk2JH0DPY6uV9lb+6SRT7d/6lr0fmtHYoqlzgMBKxsss9fCi/GRVO3tT4nCKHnJZQ/5nX3umRs0478d980TVPcnJ8J0MLI2PdS/i+KrtFPlSOlCspp8eTUqEwXoyeogMAhbCSLWH11FaI552FqPjinAfHRZZ696ddrs3fiBNQi72ECZMpQTREP40+Vei8byHWgvjl5TvSbddq5MUBCCZFDBxw2SaGtaZ0c8SJEV4iaS9uGki60sSBlUMUfB8xCJuUTqDanCbse8hiNvbf4RPOVvu8vsPW619y3A3Q== 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=VmrMhPAVzjmifYxrAjsuA9hOXQvl2+vnEVVjevd0ijA=; b=KKZakOjA0lHEyJlv9/2gFPWFj+8dHKeS5R86OYmbJ9cs14oFMNNFMK1YDfJZKvGLbckUzxKN+515OxaS+HOn5bORk+Ig7xqz5BsSR1lUjhuNZYNC5mzHXDb3Z4qidbLA/9rcVFX+Ret1F0wEAEaSvU1nSwIk8S+ppTpta/va+ws= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:54 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:54 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 09/15] net/sched: taprio: calculate guard band against actual TC gate close time Date: Sat, 28 Jan 2023 03:07:13 +0200 Message-Id: <20230128010719.2182346-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: c4a742e7-03e1-40ee-88fe-08db00cc15ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sS9atxsaG8qUTKlRuVdswRCQmDMbVy/z15doWSccSJfq0SmUbTbLU5Uxz5NUkMZ/fIBNktQ9XRjbCEynRXUD8GV4XTPkxtAPcFH8f4ZyiQQw+lNc/qItglZy/illZc8USB66Mu/BJD9BpbDhlex6tPWj6TKJDy01D9VeO9eCoeO+YonYHokrTRpjxpzJWBe3NS053XGQf+dO8eClUsTrj3mKEFAevmfPFxvG3y+zplQsEL3wxKS/7BzyW5/s9FKmfxf+Nf2h+QlxOFhExOlhh22+VB8xhE8ay510AQ7JOcROSlkdceqL55rPRhss4nZvkB18GDhHOtO89iRaYfIZeSRHWYZyLl+eQKKU+7ZEFeQEztfHeZslKg6F0suhEx6965YD62oSlgg2MyyFkU69EF3bsZenlmQdjdY1n6LgyxQX/kerqRaMlMNSEFahnQG77DhcdtgNvxtMIOeJ7rXFQRrSSAsrBvMCHi5JdP15cTHwt0JhQ7wAIy/7DBPDpTBQfVMoBwDyQpOvnZb3rRqTo6MLe/US5We27L7c2mAyW8wmkShZ+CdS55XXkvNuBYfO1qrsHNjYuUE+jGYYqoImLbEeH5J5dXJQlitvynKlxazQj1HTKm7JTMR8BiG+29eZHUFglolyDfXG4/TBGJbBeUeD8uEhK1lr0enVUnLLFLBs4bXE20xtzbr/YqiWcBmIRtxAJqb4ejgetxTMxz+bPQ== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xeDF5BjAD9atyP5KCtVEfPO5MAIHB8ghH055qoMfrswddTh4IYepv5c907Tx7flCQYFM/WzZ/AC/auekdKL/uUGlX0ZiiKyoiyRoz30P2eVbhzjKW14efaATdLxOr3ZF9w562mbF6Ia+7ep1rZBpnVoCKQyKDHm6onEE4KkIYtJI05GG2PZ/SKM289feGGAZf1mo1c6Sklu/GLDcJvcOxSnM2OVKNLm/DEvE2RpR9DGizK40wHGfSWLdYaIWQPKJ1QTaSqXP7wXY3Np9isSoxGUCuHWRZXwDSfwozLA8TvLBJuaHVB1fMVJA7cFSt7fM6XD2/Ikh6hLfO8Jc59oI72cuSVcA0DuNPvudi505mugv3uDnt0bFzaQ4v44tx2m3i9qzPeBzz0Z8HyNNGP5wEvvJoOq0VwPdi0NxLqNt/3TxwP2OZvKkTvZQT1ks/gDHf0Gapn+iE6TXgMa2gee/6YIMM/rsWLeC+Jn4POVOblTNuyIVP9bO0cVRAz/zoIzy3K3ZCcJCb9nbsWWQr8KpOBFrzhXgJ180Me7PeoUu/nfmgnynjqFuozFhXkCyE1jivpl8f575juM1o46A9X7sRaNB4zVVbUlm04VaMGufv58ijQg/G6poVeIqY7EDcI1UbaXZry5kKfgTgxDaPDYg2RTlguZpnrDazrKUkMU7ibwEANoQ/RjDxYITC7JrIX0d+TjB7ZIUfKheLhNpC7bxRXuvhicGVRruQp9SoFwuK/9KmRfDJAJ2uojdKAc1/zW2dnw9vlQTVPC/qNLyEZsTXflKGSZx+0mNzexetvKx++MoikJ6pnYK77jes9tQ/lYhej5fFOjocgnKEUrFx4tQVTRdAb07gesuOGgHmMIx6+iRW+7daWaviLfU/QE/+wuxC10SEj576khYTf7HZz1B20E3WCH0rQMkf+5GB+6fD0lcbGfOOpMG1JACu8HqXTYWBkNeUWLknU61wlEeqpWUBgUOe+Ac6lbkciHgELtwWfkuDG2o6zDv2IWp6Z9uTVUsbde50ydjr9rEy8yJZJlIfrUSckQDI9SoZCQSLWNjtADzLMNt8ktGNKIno34yMC+iSw82MYjIFoKfK3XTxZMT8zXlet60P8idOGXuoQiG9Tcb/NdcPr1OyPBbl/spOJd0H4G+ErLHlyysVi9ioKQUZrrmPYq8Pjr2nW9++uREMocIEz3x9Oo5QZqKMl48T4q9oF4WnqJzRydfxvuLCBGggkv4fwOtqaoTVgxk0avx5mmBE3y9GK0o95FLekjwCiZfFQjRzyqLXUjPTbdYHCCQJ3LniY+QJUXmMbnPQBfiCDCzuQOjgq3XDH9vD69yMjs2nvqACkp6F3mCEnNf6RlpikA17AEvZhp0LlLIlYO9M6lhmiOrBnwMtv3AxCplKo2aZJ1bghlUA97anws1frIOxFhA/Z0/1ezGQJsSyleqnVeFMef3UlfmsZ7xEJ21FtD9apZjdBGjCTjsx9+5FhnOklsIkypILlIUL1QHaLVf7z1kHWTxKVa7MytdMTsRlfOouQ1ANVvNxljAK1JJDthPdZhfb785gY9f0q3Y2ystYFt8ZeCszeD3eErq1UAid7OERlxGlijoSve/Z+viuKBvTA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4a742e7-03e1-40ee-88fe-08db00cc15ab X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:54.1511 (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: NxJ4bpcD2C3pDknHcfa+QM9QrNclNy61y8ZUGu69ZObJ0CMg/mIP0ZK6LR8o/n2x5TYTi4EO3qs/+w3AkEj3Xw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- 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 b3c25ab6a559..8ec3c0e1f741 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -40,12 +40,12 @@ struct sched_entry { */ u64 tc_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 tc_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; @@ -142,6 +142,12 @@ static void taprio_calculate_tc_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->tc_gate_close_time[tc]); +} + static ktime_t sched_base_time(const struct sched_gate_list *sched) { if (!sched) @@ -629,7 +635,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. */ @@ -761,10 +767,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, @@ -802,6 +811,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->tc_gate_duration[tc] == oper->cycle_time) + next->tc_gate_close_time[tc] = KTIME_MAX; + else + next->tc_gate_close_time[tc] = ktime_add_ns(entry->end_time, + next->tc_gate_duration[tc]); + } + if (should_change_schedules(admin, oper, end_time)) { /* Set things so the next time this runs, the new * schedule runs. @@ -1107,8 +1124,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); @@ -1120,6 +1140,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->tc_gate_duration[tc] == sched->cycle_time) + first->tc_gate_close_time[tc] = KTIME_MAX; + else + first->tc_gate_close_time[tc] = ktime_add_ns(base, first->tc_gate_duration[tc]); + } + rcu_assign_pointer(q->current_entry, NULL); } From patchwork Sat Jan 28 01:07:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119609 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5DBBC61DA7 for ; Sat, 28 Jan 2023 01:08:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233006AbjA1BIN (ORCPT ); Fri, 27 Jan 2023 20:08:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233632AbjA1BIC (ORCPT ); Fri, 27 Jan 2023 20:08:02 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2089.outbound.protection.outlook.com [40.107.8.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 995E021A2F for ; Fri, 27 Jan 2023 17:08:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iOhrngZvX2OGtGu7GzbfMEAgwB7P5JO5vqW+YDHwi7eR8Dox16mbc9Ki6NHxhU1nG/FdMtVl6br51G04GlY56ckR4BL7nC8FRdECEVs9oP2BmZRIC+7sXXiMkAdvfhOwMnQ8MW8RR9VKNer7fOiX6HHl+JHSmdXXFqwk1nIBMMSGVc5i2KNmHPLLyKJYlwvlEHe8cKgaJJtui9n0M7OzWsG51f+OiorpGE7tr0OjvD4Rr1wp4r++WQowzbr642NS3V1nroFGsDZDUGt7D0xzyhBIJxP2FORzKJfXatHfP0pG8yjl/1SyMCnfTOJcHbzybQ1JLIRB5IIw25jZZaDlag== 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=eg71mh6QMGj0pjRpywu/+aDBWVEcBP7/nJrmk7KUd8k=; b=NjNEMLH2Ax7aGbYNd6ljz3fiykXuaPNvrSJVwF6+b9cVcjqLJ8EmtQy46rSPmF7rySYztF0JH3DsPaQUKs0LAcQ022+pja81/H7BMmwCYAe5HuO0nnELSteM7ChKtS1lLXmMmEJNEEkA6eapT/gvMB7aGsIoY34y0zOdXpwKy6hkLZAECWRreLZVLJyAYtnT/SZ4n5yAm+lmKLXPAFR80B7k0x/MYF+eiatiHdI/qHDkOsjc3ygM4+K86lo08Ml4enhgJ8uLZs0p+5J9DKh4g1CnYXZopYyb76n5gDQ+izWRETCc55qEGYvwa97PdMSRS683E5kOgPsaIFpVu+dNGQ== 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=eg71mh6QMGj0pjRpywu/+aDBWVEcBP7/nJrmk7KUd8k=; b=Drxa7aIfkfRyW3Z/D3nVx8iYa647FHefuP+y6Miwm073U5HcLPFa/wjANzq4ygeKlMbqS8moGZdgczMiVdluhFwaFBonhtEa4k8lR0D5rLgjY9S86n3Wjvr5C9YgGZ8QjVnCz6Ci2I1kplbCcJWSSfyEBmhFihS8PL2Eh2Qk3ak= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:54 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:54 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 10/15] net/sched: make stab available before ops->init() call Date: Sat, 28 Jan 2023 03:07:14 +0200 Message-Id: <20230128010719.2182346-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: 61b00cc9-1365-4c6d-f9c3-08db00cc15fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qub34G6K6E/GyTcTjnZJOtfHTtFnE7dCN3LMW+XGQdDLSd4E0pVm2e5HvN60OHee+XlhozYPyqOnFxGq3iV37Ez5cqTlOCa2FRSZOxbK/g25WdHWcRMvVdz/HruH//fu1PSdB+v8NBvelfPu0JrCl8vujapHh1VrJQ2/NdZsCVDF+o3IUdQCDBbG2EE1UitbEZs4XDSAyUM2XaVWcffLSxkqCqCwrx+C8Ri24LFAdXg6ngtVwTU0+O0rejdBFjxkBBhumF+yV3+TCF4OYKsbuvxU0ZiqnFWY87K5oH2Sza0ueytj4Mzul62VNMzTyMyrmS+MHS8iBukNrX3G3l3WPd5haixKbD378DYWFozulbcafnyr1VGajxsjvgfDSBY4TWitgutl92jrJU0Fszzbf8yRLcWPRf9n9ZfoViiXC78fcytmbvyEp+C2fMpt0NxM7GJKvgW70EzkUEofjY0I3vSnKhNk85P2me6SVsEhqDVWXZARjKCjgluZESXY3hMEq5+/W4SjZ2w3St7ihqf24JFaT1as3RckEgIS+SE6s2kbpXFpaOqkcT5m046agKvxiV9vKaM9ABiLlmCV3vLFiBT9NyR4F4fSYwIIlP/47Qi7P8sua/Viirdio81hzUslTklxIt0mAnA6DkvhzyvBQuPr4o5N+7I1YV8yS0nZ4PKmkkKRqEE3kD51wN9hcBSuxTmu/2HF9/RbDbHeF2jEgg== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uv2K7iUw7uCDR+eOVNYh2GJqwZm9hA8vTwovvg4BuQAbLOnBwQ8OQgioBXUHy+n1jMlK41lZ9M0w4zk6oJ+76K+EOC8Q5TjF9bZu9jo9mZD29Lg8PfNXycYUPIHMG6LDWKxIHGtxpIGjsIyed12XaihSbrpps4ZuO5sLtHSlMR0Yhc0ldhV0eyS0ElyDOCeBupiem9HPEKkuuTPmRzdeGLZ92IS3PDY20bxR9tSIB/6Zhjm9yQXay3mxMyxpXnBC/62RWs2haU+w6KhFi3KDsIfQli09V4OrSRWI8p2vcB3VNo5eTnHFxDOcuFbUm6XJXmmoml7zfXF7vxY/byPBmzGQJJizV70shEJeaobYRp2gOlC0eEG9NrTJO3obVNAb4a4zUsXIvE7rppqVgZ+w+pNUEcvqii/+H4VN0naRVP44XanczGKl3SKm3WKdtUv9RyiobJgHnTEzMlbWD4mIFyeeMot1hm5lPPjNH/K7Lq8nvx7HInBQRe06JZRntHyWZnZ+lgWPuAlSyo8HKNQ0GxuYLI8Aak7WAjOLOapJtLDn5/NrEiIC7JjYgfYp7f5uL+PMgSbNpciGrJRIl3aUvhkiV8SQTxQJFEDVbC2kNxtkFaZvC66xozhx2iWj7MdrVKHCodJg5xmWeyBQpboUWpvLlZnyX/5hZZf1YNx4gmq2r2DOGoVEcfFcBj8yo5CLBK4D39qTsGeM5d8z9DhL87ppy6b48omYmMDhf9H28cFFHLkD/6W5Uff3mD+MnEGFBFZRfBiHVlbwS+yD3aVD/+ajFgqExfpgNXPAms/KflAkpXIf/FH2NOUAkRc+IpF1OsTcVrntWMK7z6wUdK9MjEvmSYARBL9xobBju4ZYIvNM9Bbqfu9Y2NpWpzgk5+pgLmZEFgKAwiQXuy3yFBvfvTCshmEQ42d9D/LAmhcCeWLuvKwLOtzqf9igF88b1aNbbX4ByPs3Va7vv+dkGour7HoDgU/A9bVgtgcWEexZMfK/IwF2wpTVEmy7fABubOCx7JdMaovpYNyAK29xf/AOEDkcvwrkRXDolewEwPnBda5FVjxqvbJgWjxTRg/JouhzDZ4O6LVAtyShUpd9vzdddBOXGLIGBdblI4eqznzqXp4/N/MP7/RBwg3k1I8htMAYY/P4VSCjVM29MD+508HeutwBKf5mEretSLkcZAjdl4fBNY+NGJb++dABf0kpzCL4hvglB3rCH0cqstKHuDGLwg3Ew7/DJveSBtxjNvFH9cMt2MupGbCS40L+EtTrj056W35tLA8v/qehdmVYXlbY0T7XJCMcs3nRHEneKWBX1ViXibfqkB6kOuslaJAPr9/aF0A2RFRKGgaFOOstQO8y1h2VpA2FT/ikm1YYGMvNLw6I/QwjzsknYZYhPSYDQGml4iFZLxAuEPchHwQ77BAztjG9Xo6AMedC0tzlG+zeGDCwQDddpjEg2Yo4CmI/hHBg22D98EFv/hNcOnx7VXWcQWnYONa2AcHLWN4M8AOSbjeAMpPb9mOygBvw2mFCGl+/8XfdxJu3CQBycZzmbT0vnYlrXo7EJTFqIFYmD3RtZnycPCyYwuWrM7QxmmHcPMufKw15ZgWQqNmhoQqEkl3kiA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61b00cc9-1365-4c6d-f9c3-08db00cc15fe X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:54.7135 (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: TRL0g26bDYbwooa3g5XvXV4Wu1VBXNronlkjmC/F/jORiWyYdi/fg1qM7veOpgaBD9k4wNkFD5KKoz+cRIncpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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. 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 --- 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 Sat Jan 28 01:07:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119610 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5EE0C38142 for ; Sat, 28 Jan 2023 01:08:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233688AbjA1BIP (ORCPT ); Fri, 27 Jan 2023 20:08:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233380AbjA1BID (ORCPT ); Fri, 27 Jan 2023 20:08:03 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2073.outbound.protection.outlook.com [40.107.7.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8442022DC8 for ; Fri, 27 Jan 2023 17:08:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Opp5mtJykc5Paqzci0VSHdWAJ0Nis7BGGM1rLsyF8v4+wA2mgTecRtoEOk/0knXQ/HCoVVfcfq4eWTqArUbzvKpWRO5ODUnjgfyX8IPop2x+XlBu9zAOXyErw9cN2xrkcsgRW2RuTFRpxTOfCdD3f0vMQyTEjRa2xime9icLKmZNg/IfuILWJp4DtR/ojmkpdn7fHyR0n8s6Ahx86dnqZ62R8LuywR9tY4Hb82+sdSV+aJ3mZuHmhT8eq6sgYf0iWIv0BVSPi+5cHc5Ur70rFuHLfj5r9uwsNIyX0rahnmk8dz/+UJzXnIIBUCoJQQqivw29hzx8LDO9wSq1EPQJkA== 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=8Vx7InEDr6Kk/5ZAnfT9QJL0YNtOWWBVJGVYNclJCqs=; b=dVN9ojLqhIaLkplVroWuaYEsAr3jWSzlx+Wu108GEROVoNSAi7Z+0CP4emS+pDSlBFFswIpw0PEhkm/UIEyh5PiQ+p8LB8+DSoR8VkH9Q4f2EMdGDuUjTMlV7Uc5/ZS/M6/HY2zvoMzk25TM19zGniZFr6is2TS7dz+CBwVMOKmTPuDyUTaHIsGhdfUtBVSArGHOeNAhq2g69wDnz3SXnagqkBgB7FcgmaAUoPocvvHj/VtCOn7wf/jNmlltLAtrRR05JU5khQHEHwYp15dx/qD8VR0uj12NxwkLHMn6DGfAUT2MWjHdX2Jb/CQjgCLeOY6kauLytNbDY9ryYDxDoA== 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=8Vx7InEDr6Kk/5ZAnfT9QJL0YNtOWWBVJGVYNclJCqs=; b=SMzzDn2ZGekIDPGZp2Reg67DVKDggqDJ/yBlLYyRk0kpSg8cXg++kz4fNFSlunivYykNJzB31KXGO+zix4Lfq/XBPyIgftoaSLwwnZHwHp6+NmCurRWNMkSFe9C6ZCt69A/KLSGhQCyULm2u6WspYS0Vvnq3ti6DgPAVGIzCheI= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:55 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:55 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 11/15] net/sched: taprio: warn about missing size table Date: Sat, 28 Jan 2023 03:07:15 +0200 Message-Id: <20230128010719.2182346-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: b4451158-0dc3-4eda-6a7a-08db00cc1652 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LzJzGNmGBms1yS07pjVCMPqphgf938cT+sQvMqv5agQ/rHGiq0ehmemnrI+bHwZZCBj2y6jR4mzU6aTLuMJU2n+vUNImLGQzV0k1NPjDLoCGSfIx1ltELpMvhjMKz3Bcgux5RwoeZgSfKcvgUTMZCvOL2fu9xNaua5fEFgnLoRyQ7aJY9j+Yd9AVp1HnjQUdWM0ZPtDly0Eo0Uy0Kx1cq9dcn6/WCe4kVRNUqiksSpzMKhISKHNuQBYpaNssVBE4js6ODDvMptgD9MmIv1nyHEm/cTfRo45qrg2J83iZ3yBAp5zkJuMBAe8zGMcVXTe7a0kIaDMdbCqRHqxu0su/64lPQp+Vj6qdfSPnhptxINbP+bAZ9vJXjvREbzwvepDy3mjhjw4jqLrmFrSmSKts37WjPk4eQpGHTofLJYyP8K0I1n9DFC4mnIyHV1t41k5UlRVGrbXwYUQ/7ph9404LZl56klAYbYkbm8yfAns0IrQkL3zmxwvLXpmmMtDv6TvAeZeNoukg46wkmh01izMyn0xyC/faLmLGPZlvjVGnPBx81IsgnWgQ/ZgarM/p5dfmGGQ5AxZubAPnrT1cE5MR1fP7/4rYSIfgMaF6qWWDT6rCBsUpqW5kJjxxSyfn0tqy1ZgP1Nj5FsdEwEFNm2gIQ8QQskXnCdyW7AkojDi+6BZc5j2I6juHZIaeKF83rpak42EcsZS2IfqTzdjwKn3b5GsJNZyiS9X3zJ8f3HUxlCg= 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(966005)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3FnzMi6WZ+XbXimbeaM0gywwyWHxlPQasUdJXUcEd2456qE70gcn2NPo078bMwpy7Zm+BqOGsFK0N5zCcX5+I4+Cue76cWi00KeU5QUMGB0qgk6Xl0KB9jM1qdSZTSLN1RwIgkR3nJqswH2ykywd3W0KaMXjrCR42ExqH9MAIMgB3XkzsDy7yLBeUJvPQW5vZBqdgC+olHpE3eyGiGK1TppHVQYKAtG3SGJQwszQcbrxUdFjJhYqz9W/DKiMOz3UnvVDSDqqSVX7eGDyE2bWfeY9m6zzfavjCVPiokj5M2I7C51iZyYNM9NmERV9Ei4mW2+PeHvbZf+kLWDJHDKBhnNHIKPWXnE8UpeV197IEABW2tbDfM7StJN4qrtro531n/bfLcX4hSBrp7VHk/xooNqsyMlEUdzP37BqqB1QDTANfuWUIl3VrJdRfHDQp8jYYIdNzGpqyYXcZxbpEaulPjl3IjeParpTFQm+pSZUucFV7IIx4wLB6Ax+MfSsoEcmTJbfzsSchMjw08WhwTmqMXbShuEU/Nv9d9touup8zq1qUB0M7ImfWcXprUwJ9hs4jtK+PYnvDVABZJqz+za06xnqfT+oNMH7U8wqpGetaEkGUSOsSpEncJ4pIT+7Meu5tiUt2WbIIu4W9rTobKokHOcsfS94dk0cFkcjh0ku1I/EyYCW99ovFTOzZOfyDRUJHxPnabf2XVnd7rsf+oQBiUp046IZbImaGsWzuavO70B+saVTHdaoJro87N8ISWAi9kO4VwkuGXck19kcIzgM7DI2H6N9sXp8MXns1xolmJwD/af6PT4ke/i+6zh5Fo2tLyERTDNtlRnI4yNZMzQ5IhqGI3UGf09BfUQBW0vmYAXMFxHjf7nuPwrQd2EB42Vh/mxfiqrB1dPJMYbYwukZ0ZRrxublkl5S5Co+RmR0oHIUq2jGzblgBlO4WRe9oA26oArrFlFTCGfYACCaQ0qxS43NW/cxKR1cBqmbOzyMmqw/Vqev/G9OV17JedlWMiKCh7hnI7jwr8S7EXxl2qsqHOs09pYBOZ3R+CVJ0rZ9KOlfE7vKkJpYfmBCDyXSmFdXhiNsB1fnBn4XSjBMqcxHMnk0a2xxWy5PfQCSICyjLhBCN7NgWWiUN8v9tjZTg4qK0+2Uq36nKWqzrgH2fqmhA+0/o06GH3KaKDBuaRnHLRr6oU27wJBEUNJQpdf8sbWWRlAGW6mLZMASU10br+isKuAMDL2V9rwG1YVPhyhA42rmeeUZbIHf+UzCr/YVk5b/Di970w+Hd3ok6JYvX8eUX7DYWTAyUtcVdjFeNpYDy1jOY+bosOFRJLNrg1K7kQTDRo0lLEuSbQ8kEFLZd3Srz3a3fG/Q/91r/yspEvzeywbEZnqf7qO5SmnwMA5rS1KXjO5bVX8z7ZsszYTTZTtn9pBSwIMlp8qyjn+t1QGxPVaukGwrVhiVrm0KHeF6MdOnm8galTOR9vdjghdeXdH90Q7x1UTznUrt8LBQcFAleXiavf1W5NHNBj5ukPAeZpY0DQ3TVChqK2UKrk/Rxh25z4dUCA653vEYjE7+pwI6NX6AMSfIdj3+cpZpTsDd+wStibh4JtjyZ532JQw5rklQzw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4451158-0dc3-4eda-6a7a-08db00cc1652 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:55.3229 (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: n8wAfB3d6YkDpuv6AM3ENSTb+22xHeLKJTia0dI1cGh08ZbcVa9KiEHGJxzOFjbeuz7XHnMB/Rl8e1ohqirWQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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. We can't make it mandatory, but we can warn the user with a 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 --- 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 8ec3c0e1f741..d50b2ffe32f6 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1671,6 +1671,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); @@ -1823,6 +1824,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 Sat Jan 28 01:07:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119611 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DFBFC54EAA for ; Sat, 28 Jan 2023 01:08:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231849AbjA1BIQ (ORCPT ); Fri, 27 Jan 2023 20:08:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232709AbjA1BIE (ORCPT ); Fri, 27 Jan 2023 20:08:04 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2089.outbound.protection.outlook.com [40.107.8.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F27845AA47 for ; Fri, 27 Jan 2023 17:08:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ngprD0IzaZnj9qmz0eTnthS7CG6G0P44zQmQOq+DFoso2PM/HwDnSUQAE1ZthzuY41xv2MsidyVvUq2FWKNVG8b3Yvo2q5bzQiayzGNGSpewPxIBDKwc1OLcOwhLzoSL0kg/hfNwfnzD2WzJGJflYV3PegpR9kpFRy/dK96poHJTEZCZimu/igDryFOKtdUHsxjS8G/mXdQ2EiIbBH0IK05O/UkzIuDWAZm6mGLzbJs/W4E+VetkxGviHpHZO6fhNwY7X0rR8+y1MSpgRfupMBJ4eUW9MdGHFLM6hQneC75gk71N/TjxORSzp2FEBnHNgkE4Yfp/fglIkWs/FXFApA== 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=gK3RVtK//Di0AJPvLpO7jExJbZ5NSINUc5/edoDpXH0=; b=nNOGaHaAdAg4eYqMqCWvSJOGmBhEeOJ16V3Syb/kgWLV9/yhwwteGj+jEM4D7cayvaI9sL/ZEM8E9fYJka+nt6RqNDdVfh/2IfiMzQn+qrigclVgDxdXl8mvvGuAtQ+WvmnJ7utoYvRZ5CxazL7agncKfELsOM6RbOFY+26ggHoUWtx1FJ2U6UpXQe7ZP8MAomMuDp8oqxL6aqcOlUVRun9uKgRvUUPtELfvoLTLecf1XsPw4SMGbuOPaCuI9lvXIMEaARSN3ZtnWtq/tM93L6Ljs/ZawyNIr5atD8j23r6K43rUhGU0Uay8SDWfyyrgGDWcmkMCDPsT1r8sofLk2Q== 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=gK3RVtK//Di0AJPvLpO7jExJbZ5NSINUc5/edoDpXH0=; b=jZt7MFJS4DLEWg+/gKkTGnDhOZr+hrtQd3hC9v37PFlbP37XeHCpYur8gq5DZ4kHg2IgijNibZyFklKXwdS+8LzurpRZ9X2lFeRg++Q8hPZYvYOrUyMaApppaVELnBPOohlTdXdFn0fDs0FMiWR7toYuUqD3j1BFOPq3CEYpIGI= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:56 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:55 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 12/15] net/sched: keep the max_frm_len information inside struct sched_gate_list Date: Sat, 28 Jan 2023 03:07:16 +0200 Message-Id: <20230128010719.2182346-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: c5e0090c-88fe-471b-2908-08db00cc16b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: larLwpjd4/n2tDlRgsUEYYgGsTYDdV5YIusARadv6VRyInqdQcj6T/7iUzfRUD2cRyupi9qmQBdc6O5RQhcQhItVy/QnclQyXmHpR3WnUNx2SeP+RJnv3pKjU61Bu9+ts6iS2Tq7tT/gFX24bSE9oqQo/aKX2+n2b0ET4PrpfuZfsVPL48qOkEFzn8fXFHpLZ8JD733C3ZW9Z/GY1BFGA7L3wK+TIiYhBSibM9BqI/qNIcFrMLB1f7CqG0j6Heg5hjJPWlwAQOnEuaDg6ihSQrD7LIFGSqp3uqXTJzTsVaWWM0NNYDV1n+g5Rkyd8xgNWD/g9AtR51jxUqZDKqGthwTj8Knz+i6Zybl8tDJBhdWYjNRxDHbUlvRTXsrJLDfbwWNKfdN1m6mcfvDoEqZRul5GmzuokNVR+3l/kk9gViMIzrm1U0HbSmzm0xzLra45qX9IdyL2gtL5dq0Ct45D2YbGMBQmpsSEu6QR5cNl3JQXvNiq2HiGtcPpmWJV1xovxKqM0h8IZacoAr5BbBKevGc0VByLwlwtjkACY/Xqf5JZzTCsJAyM9w9ECgQ4jc04Mt7D+1ULmZ+dvFJioWxnh48tGhw/DvIR/NrcWePD7RDXp+R/NNYbh63lwBRKhKGRKiLMm3u8YmkzMfPJZWKMafA0J0HV2clkEKJxqhYMNstljlU5sEztpbKkgNj6bbIDPqei+uwKGN8Q3prTMGX/Zw== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d3O7PU2Q/WniLKufLbH+FO/8FB8A2fA19ewpHVsrM2pEj0lPPCBlWkoWpnYFaUSujCyabMwSRsEkUAv4TRCMV+c8tkBcVk7lzK41gMCxOctSH96Oq2/vcheP0Q193QFOAoN0JWL+w1iDBJ6+u6lOegLKUb8903gJUnYfFXoI3oKoooC2cJn4rgwaLmNUBg+5geusFtPp+MoI3pCI/P+s/3BNW8lD1EMcpZDTHJCOBkjK9y04sYhv12EMSmNRJ43gCXMgcTT+HRYhdBXzLtoBTt75oidycICDaoyK+H5Vw1WYIyQ4QNe5+D5gfaaRQ+MHTbEG1ZzS/EZmEoezQZzo16/OjAk77dcw5Ij7ANkLpsdpxpCNC2WOaQQm3orCOq9n5CsYQaJq+UVp1zOOehxF5HJBwVKUQ9t4VvyMyxkgkxrZzq7kUQ8AupMU9LeCzbvAhRKuYZEUZMN05S//2FVW7vqqhbP3c8lCIV324FjrYBSUZmPqjAvozSuk3cRh3isasHTaGbaeZZM3QPRajnW9IniFYFMpIrZgP6qUEFWBh3YPQ/HV0Qy90Uc4benw7XeDUpvGuXTZTxsFr4Zn1xFmSwHinRCg94GkDXsz/lheOpyUcK9AZ2xOkW+o8BdkHHueWU56FkKtnU50rHkXICcevZXoWYPgM4zkKEhfVGJh67SkSl3umhxfKEQi98Tc7vWvXvNeJ57Ah9nApWVwAb/+20ScdY/wCmaA3/P2vJ/M7Q25/CgrI+L8HG7ERgUUpm2bcvMbrEK8BmV7dDpWbuPcMdt/CeQOhltdh7cV4SKDo62ZCSqABFEuCU42x+L5p3UoGyRMO6WeYbQnqS0zH3pseMQhUElTpT+hpyqd0HEVzzEP1iBZUmvT2PShzMC9ZaM/gQuLsbcVSQWWNPsUrjgv5s8IPPv0EfTEFZB6MeeAb7EyicTZju+lGrrXKXNZnQj/jZpLLtIBk2D5HnhSP/8hJzyjpfYPn20ZPoWp7Kko678l4Vu+XkL1R+JPnL3FhKZ9HBc83MatGsOmD/sjypZS+1UQiDnaxshDHrimObE4G2OBXDRRykmHfLjT/PvwlmOn9q0ADYiCj1OsUSLEj9WbltayXySwPgX9jVF6PxYaqVgyW6vkkYLk5CNLRtTYTksj0hLhZCfWSAqjy9+xg1378nvzKoyCmJQeqPPpk25e6H7lAah66a719lkz8++onOkFlFQ2K9FpgPLcPjpfAPRno6htAEdtixlBURKT7g6l8nt6TMxUuxhHjOaKwRVIfFcMAZys1zd8Zj901Ukj762xMwvuKUFtC/vhvDWHVidqtQClH9ig49AOuj82XTdLh1qZugpotd+xg13rNxzF/D3GUkFyP9YeKcySRLrjt96goBUu8xUpRkOlUGG5IpQ6nkqKLVm5flQhwh2dZhM/0mfvSZHFiqWsGkH7nkyxW5utlbqAJ5hyDCJQ467wTdjmG+0CNGLv5aF6atnMhnfANFdJl+qWiO63PKyR4D4b4FApMCl6b7RgqEa/XZTTMljwxwTMFMVXIwGEuTgcz9PtNXZrBMq1lsECQkp1xfrfKEoJ9J+BzO+UD9sudcIe7W0VqqYn1dCpGEjJ13cXZGbg8EPhTQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c5e0090c-88fe-471b-2908-08db00cc16b4 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:55.9009 (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: JQUbKrhrvlCm8o9F23J5cT/bqfViMkjnxrtzYkBq2wsn3p/seeFEBe9RHunCYVCZ37mavPNPipdc1oAKe3LsYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 lies 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 --- net/sched/sch_taprio.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index d50b2ffe32f6..43a8fd92a5a0 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -59,6 +59,7 @@ struct sched_gate_list { * or 0 if a traffic class gate never opens during the schedule. */ u64 max_open_tc_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; @@ -87,8 +88,7 @@ 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 max_sdu[TC_MAX_QUEUE]; /* save info from the user */ u32 txtime_delay; }; @@ -240,6 +240,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. @@ -478,6 +493,7 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch, { struct taprio_sched *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); + struct sched_gate_list *sched; int prio = skb->priority; u8 tc; @@ -493,8 +509,14 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch, /* 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]) + + rcu_read_lock(); + sched = rcu_dereference(q->oper_sched); + if (sched && skb->len > sched->max_frm_len[tc]) { + rcu_read_unlock(); return qdisc_drop(skb, sch, to_free); + } + rcu_read_unlock(); qdisc_qstats_backlog_inc(sch, skb); sch->q.qlen++; @@ -1590,7 +1612,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; @@ -1609,13 +1630,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; @@ -1756,6 +1772,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 (FULL_OFFLOAD_IS_ENABLED(q->flags)) err = taprio_enable_offload(dev, q, new_admin, extack); From patchwork Sat Jan 28 01:07:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119613 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 816AEC54EAA for ; Sat, 28 Jan 2023 01:08:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232060AbjA1BIT (ORCPT ); Fri, 27 Jan 2023 20:08:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233648AbjA1BIH (ORCPT ); Fri, 27 Jan 2023 20:08:07 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F26935A830 for ; Fri, 27 Jan 2023 17:08:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DIiJXLZpzw8k4OZ4lzG37e/1cZlgSp/YceVAXTbtcsw3R/DMzrz8UUVjvTaP/d+1EtVN7n68Lf7q0OIRLs8g4ETDRUC2ifOqLtiWdLMVPxXoaHRyq6sOAWbLPXrPPFumHcE6YUobI/imPv6DxJEkcWgm9ka6JtV3tiUQ2srtJgrOe3b7DLPCFfR3rwhVYAiP7Yqu1g1KnEeCGr/ePhGEEhlXpDGXLrjjI9CqTC9cBohktkAJStX5DJHxv8xI5g6Rk9zJZn4LBEkAfKOIwJrakOSV3AKQ8GAp1LkHYJIBd5IhMIrqcIZP2srk8Gv41DaMu8xQiWmoN3mAWJk0ZwPuDQ== 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=wA16AQlQ/8aeVoaTgy0R1oXM2n137XIHlyGL1gOI0Nk=; b=dyIXlXe1EuhrnjuJVwlfAoOrHLO7Um4TeoMyHlcx2I5drJ1Tz58Vh8j60JCBTkOCaLBZStuBkdZveVgplsA4PQOlSNepzOmJrFGg2XMPofx0nTQha3KFOFWHT57n7h+davTmSYdn08b3F/n0glOHQJcn2zN8yCyNYHqyy7XogVDv3ORaQ0uJciu0aOLBw8zPqSSwgrsPbEuixEA5TqLtQA9pkVt5XytRO4TMCkFyvZR1O4bvHXI5FtmIQUQ0tlcjYC5jKQ0aGg/LIDCi88p3DIkBUwcGkDumhNPyGM+JWUP/4DTV6HQ5fmUHYOwouz2inkxx2HShMWAyfe27LCDRmQ== 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=wA16AQlQ/8aeVoaTgy0R1oXM2n137XIHlyGL1gOI0Nk=; b=AX4F/Dhj969Z9z1BQJ786v3vzRvsEEc9d8RHw9ti1mZ44H774Yvv6YIQEvbTnfY7GijoxRMEQnOJouG/UkIgmI1n4BETpIEKp68N3rnuInjHSStjMs7tbd7O2YMRsYd44+7sAxPcq2O6V+Y7Rsf9UnZ8bAP6Df8QNbQazA0a/Rc= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:56 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:56 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 13/15] net/sched: taprio: automatically calculate queueMaxSDU based on TC gate durations Date: Sat, 28 Jan 2023 03:07:17 +0200 Message-Id: <20230128010719.2182346-14-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: 8604f35f-dae5-43d0-99c5-08db00cc1707 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Sx3xf05aYKqAQQcxNGgpXuYglo9Ks/oPGHJCJdpqwIskVMYEomCyo/3fSMwD7FvNVjos7HFSL4gmui4e5UkVLX8j5C4ZNTTXETfUiNPb7LjtteCg0NAFr8j1+u7xi4YXBs+PK2Y8wk63bERaTFCsIw4I2cF8so2Y9K7iKfmMXYosrfealLwlvXRuqDPy+zynEYBjbtzDPrZsjnbGCFqvyAFL7JyLhREpgfed45B/gY3gb7+gOXl13x4aH4Ez+7iLUs1wG6i1Or/YDV3Nmhpqb3fSU3jBhptJRmA6XjF2uzDkPXg2VUbHZGYeqT1U06SvsvgYnn3VVZ2Qlx4mdW8adryeC4AHvJoxqSjOT4O0Mt58Ktv5JIT1vkZ/q50LyOkWjN9EqeMohsnIIAJzXGa9Z+Tim7UPHU7BKG/wrGxPViSHdYrEGabB4AfHHpr+Bgh4W2S4R/GOnEhdsEtv8YvIpbmUcyGSHfEcNLrS5kP0MJ7qx5jApXqB6+z8Pe+7DOQocj8EAsifpACeMeZ9X3wHKP5aovCTVqDvZOqMq3o6mEPJxtpizENqnoq+IgHeW5sS10XVszeE+nAnM7Hu9yFr9cCsQoWKFSU4i8QoYSwIYGfMbcz/M+2/1BJLmyFMLYnJYfjg1iQKh4gGeVfcg+F2/CgCXqRpfV31Zfp1sgCUED/BAwmtMxmnG7oWXlMC2a3ck4kyklQJWL+Ln9Q1Zzlcmw== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Rl/8AqlER50UMnVY5xP4Q4hSvyRx1JHvXEEHiCzPM4LVQke2lA8R0h430C+IifWRtyQUKW3kUHp3DNf+Exl5hPsXcS754xSdYqI5WZKWNqe4G43xqTn+lJyb7SQuqvxgt0fQjjbpc49EWpq2Urp5yGN3QMlSzo5oBxJQJiuK8EIqA5jCQfVrXXPjDPDaaJphqmzCxh8tZpfArtNr3eoOGurBvyewrg1Pzzpec3Ro2ZJpSXxraMUraGQcZZAIZdYqAn4jSHFJdET1AcSo5AHsU8rHFquWVBCJ2B2mpQp7qm+TuZ+Om3dRW901ggTomrlhdKdvoaYHv60eJLhgs2y/ivE5cnd8dYTLFedHnWwiWSIxnBuPVoUHV+hoqyNk+vPrTgzWsJGwZAtiy5tsCSOb2+VTuFvLbZL2MlqzuDQUctHZhotTLyJ974o0VSQGLsKOX3wnHSxbb2XOY7PCANpfyszlFAexMR2cL3dn3CMZKUIFRcKNqewQswEL/oUDnSFSvxD+kZe8BwCCPbPWnB6bAznpBG+oVV0at0vHRTF35sU0NIJI0CjSaE0G5zp2Xp894u7uYGkrV2BnrYF1QPC6ZFRE0YX+rwRkYTnSMLxK9I4/zJRw0cmLkbH0XPQb8bfgBGj8sFlDqcgWYAwG8wP37MydF559ixqy3gqDSPbcY79ROtqRzop5mAx0Wc++etZ+K8VIgxVuGpbZui5rVVJ8knGvvDP4FcrBXKuJEs0ySSuK8Y4DvXUPMheFTAggEVW2sEKfbAqB/BHDPbMqXk7dOtqlsbLDErnaUg3d8a9KuBD6d5AhuAsL38hrOjY1b2ttwcGABV8QkEAzD50XgqJrNCWBOAMbDKiNqUtFBswwmMaSVJPmxdG0P2l0i6RUSm4dVtKOSeBS1X5XEWYGf1e8obwNFE5/tVeTdyoO3t0m0DByZT3QNX8UtJJY6X3Lty9jbx1u57zTe36UlG8les15wt9HZ/nRErRp6H0ObkKi/rlBPbK03B0n1LYnIh8St6uqQ/9WZYIjuTv6KB4xhF7MDtg+PN3N9zcBh2JYhuQzhq1Q7647m9YlG2RfdUqFVaAlanjT1075BO9SceRpBs3x2rDz0WwRHND3tgGgIhL+8tkiMO+gtavvv3wWn/rpiAcTgbdKyjJcyJQiDrTmMFOsaUG4mm073NuP12oYMHDy5Fl7BEA93N55zZPg92cCqig72S3VKwi14JxX0KyGm198+LG9hyq21k1twg0YlWQMWrQioSWHbrN/1A6BroAvRZDOr0GzM0AAAX6ZGKZLv1jLxgGDZ5e/dm6XdvmuDD5yPORGBTW02n3VSBwYaX/D1K1womMppj28kvrqGKjHXzC92E1HzV+y8ey4IWwvV7i1dbY5L4W7BqyARAkq79rfiP4CUOtPPfW6dsRa0Lv0PzzDy+ZQM70MJLR70Padb4rTh+7yDEkCT52HfLv3cyDeK18Pwcmo5CN/SwyvvgzZMwKz5Q1AOybaljRIrq4zf+oO1joDzyOAKbuQv9DZBVfqO2wUwkMuLwxUPwaFXeKMbHnr4bOwNnaq+3XnqNi/51Y3Ed1kPDlTOKgf7IMLNOyM/wa7LH66prFtqVPzVTM9uAUEtw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8604f35f-dae5-43d0-99c5-08db00cc1707 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:56.4478 (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: 3KdbS1XTrkARI5mO2AfV8tXjqFOKS/uX0SmWSHiCPrzzqh9dxfckSFtDUvSoCeGDUg0tgJ8MyUDeU0zWQq3PzA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- net/sched/sch_taprio.c | 68 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 43a8fd92a5a0..7a4c0b70cdc9 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -60,6 +60,7 @@ struct sched_gate_list { */ u64 max_open_tc_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; @@ -240,18 +241,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_tc_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_tc_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; + } } } @@ -1223,6 +1258,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(); @@ -1235,6 +1272,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; } @@ -1625,7 +1673,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; } @@ -1772,7 +1821,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 (FULL_OFFLOAD_IS_ENABLED(q->flags)) err = taprio_enable_offload(dev, q, new_admin, extack); @@ -2110,7 +2159,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; @@ -2124,7 +2174,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); @@ -2175,7 +2225,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 Sat Jan 28 01:07:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119612 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAF2DC38142 for ; Sat, 28 Jan 2023 01:08:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233694AbjA1BIS (ORCPT ); Fri, 27 Jan 2023 20:08:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233650AbjA1BIH (ORCPT ); Fri, 27 Jan 2023 20:08:07 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2073.outbound.protection.outlook.com [40.107.7.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3B2F77DD9 for ; Fri, 27 Jan 2023 17:08:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k18J9GZBUWgIp81Dd2ilfgTGxRRrYWc34np1N+7Hm9rWm+EIpWlBpB7CEmz6KX9RsH/N7ljj1onW8CPU6vQHD73RMnESHyZ6iBFsLHBV49ljDVk9fxbOH8k+Es5lYh7wW9izo57A+9WEoeO/0rfhgkKoxK0b0uJQEDZka4ONa/wM/7Vam+EYeZg4MkSNo6AZR4yAQHxOcn0gv3936nQlPcPtA/uUTkN/TrQ+4UeMoM3N+si93QXtjSQ7iitt5qiygOx4mXULT2WPDIWX+SIOfKOGYcOSrOos0yjybZzKYEc94hlEU1Jv4fUVpYFnrOUOf10twkfOcDoEvqZ+LOeGhw== 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=aeWJHvCcRBik0wfCiKH8kGwX1IMOz0+IuhYKMGDK/f8=; b=hvCOwOjHNwcbfnRAQUe59mBz7jo4lsYSof88LlbLrI1XGahDMECmpLGHbab204zb9Macp0gD6WwSRuj8+fxky0TPHM6YGgC4NlcuGynLwhENOGCWBWScJibCDUzderLHmIQdAMMlew73mqQScfjQx9dsdBelB9YsnZboT1JliFPjN8gCxD84QtxefQ34NYO+gbELBBmZYPtx6k5yHIbbzbqHNPJ9jxV1i98GWb62NfjrMOJQUiABPDQm/8v9KkPi9Xk2w/0HzgdUI85XLTr47O7TRhvxpuPs52T/w1KUtsxqA5WSa9Uj3XNv3tfISWoIsNnUHZNKdI3ffaSAaTshOQ== 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=aeWJHvCcRBik0wfCiKH8kGwX1IMOz0+IuhYKMGDK/f8=; b=XUf1RRjBFG4id8PaqtWkkiqgr3y7WP/Iyxff/1CwrcavtshVmh6Qk2UFUEmYzFO39elnSZIyMVdrhdkTlRtQfIf99It+F1uFnGlFMXsMPqW8MTADYHQRMTiKatqUoQMS6y7dmxi59lvKHKEpwOgVrooIMW+ZsSCCZ+RiruHYAPg= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:57 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:57 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 14/15] net/sched: taprio: split segmentation logic from qdisc_enqueue() Date: Sat, 28 Jan 2023 03:07:18 +0200 Message-Id: <20230128010719.2182346-15-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: 2223bfe4-32e6-40d2-cf1b-08db00cc175f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u0cqxmhbmVsB/L3PswBDN1P3iIO/14Jnz3lCTwyV7v61WmwHNHUPz5GzZ31EaVJfZ4CZi5wNgjRecRqDE+guQ6ppMjS1tKnIjsSuURKkU11Ae2WU49vsOFmuOT3pjH1qQ67XPuN3eOrs/Jtf1rZtXNHN3J/zI1SbhVPkyp0r1IOU6iQIc2O73DTZtcq1mEJYgMDVX1GJtEizG4H5BAabO7m2w6IExT+viaWdeMVUng/cECdNRUyQohlNZ7jb/rMTIzweBRqL36nO3y+cH4KpuyYiYw28VofUYb5ENpXwg7amQ7yZNHi3FuEIguzWknNzGNYZw7YULtbXg6H5gmUuNEbMu50p/1bG369J4dAKKVn3uaMbhuAnTRjDieGK8Tvthy6xeZwQyMfqmu4evXlE/hZIMXmiEJfo0V+rqwVEZMfOhSDwXpe7wK/1UNkkNCYldA58HVg71n8dKp9NmdD/SC+CAPZaD9CFXjTRLx0f47WGEslU7/l0IlOCql2si5+U76lbbOB5PEYPtHJIBn8H/LIq6/z8/pLZLSec8LHVZj/4DKBTmfKirWeEMnZyeaANhpSYEiifDX4M3IudVYErgYvv/65izb0VZOMh4Aa/KLtzTc0YBRswtmU8bn3TC98yF9Te6JTeKZFOBpST1GL3uP0f1LuXE8Bacbt9XJzJw9rnmjpd5aSCcPwPHSrk0MeKgBXRypNz3IYKVpxBXohovQ== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7zuPyd3Doly7fVgumjXHGYEt7yOth5ZeqsP5tSfcIFmOMc0YK/8f+Mpdk5CiLslkMK0JHLenyYAAgh4q/vkLpnU/oFWRXY+vSnUFQQWV6dkZDSNIy8sCXYHuEes7GibIROsNk0D6sd8SJvP2pRB9+9TfC8bFJdL6rAaZLJ4VA7mTNYn1OXMb0qk5cU/fin7tYfzf8/xLqwayy3oJxcxUt2qYviqTH0x34eZ/L9yDhFe0JkicDZyT/KXD2jKYT2JIZm87SRVEkySD8K2HC9swKkHTEaWB8bMbydhvZ8sVFE5A2VHD3XLdUY095F4OxEwXhkZjKASqa2P/duRL+soEHyOfh9oOl4QTsuQESCcA0fqIjamMr3tVM55XprFhrPVCJZ0OzmHzIrPzOx64iaAhW+zKspk2OEb6nYjYZQ6LWMa0dUQfqCTJwfvavwb3vg8eV46iaS+9pQTV//FTNbXwLxErU5H53uwl53qekI+x2kDavvcYGv/zXs1N9NkU80JIw9hZa4Qc8ofALSknaTFDYCKVGeR7AAyv0lAUaODVU6QKCWJt7yIpwgD/erKB/kqC2o18DPF3qth1y0F6JWSaNCe7rWajyfysLIaYsq3jplaH3xyd2PrsTlPI3yc9GGSS6h7n5OT1z5C2oIYJqynO0kCMmOrpLXLUEL057Lm9RwwcU3WvmYIiqjKWCWsff1FxR/ympnD0BfyWrWWo3aUtbDFpYJmXVsMmhdabve1G9iIB+oa3dWpE58UHeNuUbUSz1loOdjhEq23uvE5xHY9FeATD8Bqk5f0SwP7cCRPDUeLHnjpxl9atEooZyfXtMlOqmDPkxPjMnxOQ5ocOLMdTuvUx2gan6+yJIfOncca6UwQ4t7CnbF8OzVqQdgFUFX2HKztdhekD+WJ+SzlHSr2DmQApKwEcR+1OvEbIafLmNxyc1B2uK+NupFiH30aforIYo/vHQLjeuS4fGRbXbzfHjPpgZz3vvQd/arawJB4qbQEgFhZnd6z5luArysz/eIJNSusiGOGYY8UyI5g2s8+H5pswOtWnDZxmk8lXterdA/qLjLWN0AyC88058ZUh9XrrEbyhu2nxNzAMUkc20nB0TSN+bs6nsde8WTbCvhvySVp7MRUMdhjlzgz9dfUkuWkCxgsWlFHaB4B4cto9u9FQLDMYe5GF3BBwcE1p92oTbdWqyd/chbFi0z9yEuR0DXReG0XV1jUUnMY7/AnRR/7ENPd/rxD6Q0Xhq+4y0zlwdWYYkyaoeutqMb1NMC1D7vZMYGh+AUky6WLjUl8rDYzIVSX57rrNWv6WAjCI+Ztwut39pG5MI1umpS7WW1Chb+uGryayO81Xdo/EBdp0MS0ioN/RwiwMJgrrpjTa7O/nz3DAWKeSpzbNCkVhVhR46NwvYNiE4MFjuxWWGkF4UTJwbj6MugAv4f08dO2g4CD/c+ls/Zidqz0ywCyMZh3xNBMS0HWlHsudpV3rI851xR+RJnsTxjN2Es3SZUtVJ8DX/eR/utnSrUFZyzAE6FJEWO2JbIhIcQaWmrvQkXBBmcOQwCBI2vADxexNG31pJmMWZBKY4aCUzSkx/L4WLix3R544uhJMeV4S8YTYor6p137C0w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2223bfe4-32e6-40d2-cf1b-08db00cc175f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:57.0415 (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: VTslfsXoOpiL9PZh+YRkJ8eZSA7xlfwoa3wguUZ8IzbyamKKhO+0ycTB0YdVaYjHAhtuqeZ7960Mk7gTGNYiOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- 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 7a4c0b70cdc9..cc11787dc62a 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -559,6 +559,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() */ @@ -580,36 +614,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 Sat Jan 28 01:07:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13119614 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9305BC54EAA for ; Sat, 28 Jan 2023 01:08:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229495AbjA1BIp (ORCPT ); Fri, 27 Jan 2023 20:08:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233687AbjA1BIM (ORCPT ); Fri, 27 Jan 2023 20:08:12 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2089.outbound.protection.outlook.com [40.107.8.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1D8E790AB for ; Fri, 27 Jan 2023 17:08:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g49neMMbqVIg4FNwfW5MSEidTtK4ecA8MUBkk/Z1R2SgPUNlbzC7LOFOdDDRR71k5+3gu8z7GmLxbtZcuWP3lnGnkRxItCJ+ytAVoZkHlT2O1JUAo16LcPMOCHHDHVg2FV556Y3Ulp5VXHWXVh7h1/1qVrfp7IDtgZ0y4JdwDldpVitsqlhV1mgkvwX4AeGsZvCxaRQszz996qDHB6/vvJcnp2S7j720ffixm4cQJGfEN11CoOkQhBT5+7PybygalP8LtCdUpRUa9eIjZSBZpHHQoU+31+R+EWhk4mTN2+pPsrkRdZjEqGVmxH2AKf7xavAEGgcoSsPmGTHrKPs1IA== 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=ouHCHEy9RBErJLlFIjE/V+7sb5no2Et9ZIXCselWNTw=; b=Sxj/srQJZKGveRlxJClIXbBvokzirkETTwHedbd1elgu2xHepUa/AnxLMzqtPR58TU4tFd4+/kknrTKUPX6klG9rvtkhDoVZ2hWnbvEKMKlqnOi5CmwLKv408MMEliqGbQw6ZT0VnKio6rAKFLhHGYHdyqpgZfVJNkgOXVhZeSC9yp4Vu+iUIS2d+mHqgLdKIVk2ojO5it0n0Bz8THrphfFGvVhvw5ef8SDgDNa+44Si+WuY6Y8+nUqDLpssPM20EBCwqC8MhY8KMlxbZp8S3uly18iXM2UJngYoUnlV8eLusuXSSHzwZHimtyf9a2AQnCgetMFUEbMuGp2XGgOp2w== 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=ouHCHEy9RBErJLlFIjE/V+7sb5no2Et9ZIXCselWNTw=; b=ST6yGKQF/k1Pa83gotKrxRUs7RHc6hxRVWMVKCUElBJm9hbUaJP/GnpDbau0zpF5z4hyf/rMJIInKhE1hOKioMVRDANY5/YOB9WYBqq5km6WWJ8J3CtroPn2ZEFJpMlwOw6UftZAgfSxt8QgnX0BbRmJ9wvrSxn8114nJva4U3M= 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 PAXPR04MB9203.eurprd04.prod.outlook.com (2603:10a6:102:222::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25; Sat, 28 Jan 2023 01:07:57 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6043.025; Sat, 28 Jan 2023 01:07:57 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Kurt Kanzenbach Subject: [RFC PATCH net-next 15/15] net/sched: taprio: don't segment unnecessarily Date: Sat, 28 Jan 2023 03:07:19 +0200 Message-Id: <20230128010719.2182346-16-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230128010719.2182346-1-vladimir.oltean@nxp.com> References: <20230128010719.2182346-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0128.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7a::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB9203:EE_ X-MS-Office365-Filtering-Correlation-Id: 2193cbe3-a205-439c-66c8-08db00cc17ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uHJEaq+t5GcYLCbjPEtyK7naSdbZF8e53gZltghAJEizhuSP05KLMqtW7t9iLLTWoBz3WHy5WxD8Hu5aGhHWgk3T0V9Q4Z0e/35Le/oGYFvj/M6pz8TjHVY954TYEQno04waqopdS24bJJqy8vpCgaBl1EmN9RVTSSuAKkltqRIovCvbm3QMl2lb62BzgHe6VNoD7OMun+Gqt+4wXb4bqoOzW3jwOopjxKmJ2hFmhFsQ5Qj3BFOot6/hbciNY39kUR1D/ZS/15X8vA76lNb1YA4nUEE9ZD+Z0j7C8JTijTrjXCqRF2rr+DUYS1BXHrbB+0cLOiaXPsUjbO2yQdnQMN5tX02bbrPcjTzsD+5yu4PHHa5UMWzcpa7TqFT7K9gdZXFk6ThftuEebUDzczUs9TOMcav2fGk4cOd9jxg3smS4D8G4sufVqrAYVI9fsvu2xDW1HjhiHjuFP5LCRORqn4V1Y6tCocAea6SLN/CzT/lVdx2Tn+Z5S68Aeh1+lzEv7jlYlp320CPbVEzMIFijrKAopeZlmn3Mz8WOWos50wE47JMQipfD+1XMEeLb4bAFuKtNPbsOvZLIEfZ14gMm8HtvnIbzGqVIa1ISg5y8xEPUT7Sas5V1NJookzrjrnCdsghB76nTtBR0dJ7U9iHzzhBXZitt1FqdNgobTvjNWnVaStr7W0izfHVRkDDt3GmFIyC3wMYrib1ds4xio91HFw== 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)(346002)(396003)(39860400002)(136003)(366004)(376002)(451199018)(186003)(36756003)(6506007)(1076003)(6512007)(26005)(38350700002)(5660300002)(38100700002)(44832011)(2906002)(6486002)(6666004)(52116002)(2616005)(86362001)(83380400001)(6916009)(4326008)(66946007)(54906003)(478600001)(66476007)(66556008)(316002)(8676002)(8936002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mtsV7Fe9iXoXkNVLJ6SOudnbY/aqp/W08Hv7EayFmeW8fYCvDuzwkc/Uor1L3n3OosOXYUKVNvp2D9EhAeJKczGFYXcyCzs0ca5735LaOSGHfLjc5AHkfmEJDazRd4y0yn6F8oWsfEU55JC9MblzV9W85A9GZY3dOtI9NlTIumOYlKstZM6SaBPYygjP/CBp/lg3nOQGelrdKOVl5N9lzspXS0p/v2rbloh1Bp7aXtBRiJrbZ/iO0iYQBnNCaERWzGwIKe39Jd0AXtoG9UXTU1/oKljAhmA+AQAb2nk3dyQRzmDlQNf5lRQiUAhDSX+yZhgggeyZVNWcxQK/cpBhC82iaQscP6MVwyO5h1hPd00ialj/QP+SqDMkMTbC3qaJ4LNGoXL9hcgGeCwdJ+POLqIsVVbI8GfvCRYsyWxE4lv1BNjlDG2ULUeYfTmyFzvOZgcN3pLN/KG0p9KZXRvJHRGuZDSW4B9tb7UKkDcb99ah3CfkzkjVz+aD0WZpo65LnIa0rPAbOn81dcjhcnyQ8UJ2Kn0xbfPKIZicP/N9nRwxx2mvAxWtYnsS+BjlVxUWg8fMkqWrTGTe8kZfvO6r0xqZx5kmoXYC2imVvRSg8W7u+F1jzcipCGVpDbWkmvTI6dzWXbLW1vhEuCBGJULNrGY5EUi+0rWoeHfAguJmUihM20IOcSOK1fmUqhkey6kHP5ZavPzz5QK+nulZ2BhFOjKdolzxQXqGFeMx6ibvuUl+ea5BpUu/uMWhI/L3Vsfh5wZeHfycXkLqPOyFJhJWGUmvBioiBVtTBR5n7iPiZXVkmWQXjGE8Bm7w8oE1ioBJKnzC4k07csIHTNTar3cEyj7TASXTCEOA7+1qUASNMDiQU0yu4GqAoL/JVrK1SvEEK71aTc6E+H+2WZkczyoe9HrFGDtFwWv2LxV1BofF/6oXk3A6IBi8+XodFaBH8lwioGNsdMHWlA8LEEzF+9PM64hAOUI2synDA4NI0H66ro2CXhhRoSMbTrG+puPr65KMDv1z0Oq2t8ggYea1xP9v1c9Ma2wpTAm4PJ/gEM2oJq12fKKZNr2/ClBU38XWJ8C6NNeYlZPbe5Bu79Ou3ih7Xo/lPRByVPKghnnOJYC0i7My79YMRQeedNBVnzjy/+wRl0fCRauxXzBVYZAuKOY4XUZ7lMas7MgMeSv2k1a5L7E2TPj1yFAXhiqd1GZenpvSF1M062lyEzBIa+As2EIz1NqwBB5/SDm8ntoxvuUIoWp3k45iE2RdtkXhGGAoFks1fcJSR4XBPLDTYBGIaMSbZkI3XArtbWoTpF/nmPQlTdice9W6YKnyhfkOwpCjQQOKircLqiN1XiAZfxgciiABsVSiIqZpA8nH3C72o5RUXxPUR02gXZLpXpPpIGLnrOPaIrQtc+dqd3Ke07C9zWMc8u9g8WetLnlrC7sqvzK8tiWnhiI3FrenesyHq5NMFYt7PBuvWj0VaznW54oJGH29xKYon1ww5EEJRN14bCAOjexYJCWYY17juyvks7bBo8aD0WwmuWMNOSi+mPldRSF2YlpkSx1fNioO8K9TkLVnMKujX+nK9dbTdM1ETfvHiRZLscGW/1yMs5oL2gHd5jOUBQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2193cbe3-a205-439c-66c8-08db00cc17ba X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2023 01:07:57.5883 (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: +MA4bMw4W9yCFy871/4qp2dQxBK2U7wZjPXqStiSKNK/Q43SY5fD45dVPk4/k8DJNHsC10Dqf6rTLKup4gxmRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9203 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- net/sched/sch_taprio.c | 67 ++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index cc11787dc62a..e0bd613a6415 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -527,10 +527,6 @@ 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); - struct net_device *dev = qdisc_dev(sch); - struct sched_gate_list *sched; - int prio = skb->priority; - u8 tc; /* sk_flags are only safe to use on full sockets. */ if (skb->sk && sk_fullsock(skb->sk) && sock_flag(skb->sk, SOCK_TXTIME)) { @@ -542,17 +538,6 @@ 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); - - rcu_read_lock(); - sched = rcu_dereference(q->oper_sched); - if (sched && skb->len > sched->max_frm_len[tc]) { - rcu_read_unlock(); - return qdisc_drop(skb, sch, to_free); - } - rcu_read_unlock(); - qdisc_qstats_backlog_inc(sch, skb); sch->q.qlen++; @@ -565,19 +550,34 @@ static int taprio_enqueue_segmented(struct sk_buff *skb, struct Qdisc *sch, { unsigned int slen = 0, numsegs = 0, len = qdisc_pkt_len(skb); netdev_features_t features = netif_skb_features(skb); + struct taprio_sched *q = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + struct sched_gate_list *sched; struct sk_buff *segs, *nskb; - int ret; + int tc, ret; + + tc = netdev_get_prio_tc_map(dev, skb->priority); segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); if (IS_ERR_OR_NULL(segs)) return qdisc_drop(skb, sch, to_free); + rcu_read_lock(); + sched = rcu_dereference(q->oper_sched); + 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); + /* FIXME: we should be segmenting to a smaller size + * rather than dropping these + */ + if (sched && skb->len > sched->max_frm_len[tc]) + 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); @@ -586,6 +586,8 @@ static int taprio_enqueue_segmented(struct sk_buff *skb, struct Qdisc *sch, } } + rcu_read_unlock(); + if (numsegs > 1) qdisc_tree_reduce_backlog(sch, 1 - numsegs, len - slen); consume_skb(skb); @@ -600,8 +602,11 @@ static int taprio_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free) { struct taprio_sched *q = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + struct sched_gate_list *sched; + int prio = skb->priority; struct Qdisc *child; - int queue; + int tc, queue; queue = skb_get_queue_mapping(skb); @@ -609,13 +614,25 @@ 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); + /* Devices with full offload are expected to honor this in hardware */ + 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]) { + rcu_read_unlock(); + /* 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); + } + rcu_read_unlock(); return taprio_enqueue_one(skb, sch, child, to_free); }