From patchwork Mon May 27 15:39:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13675533 X-Patchwork-Delegate: kuba@kernel.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2059.outbound.protection.outlook.com [40.107.7.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7380A17E919; Mon, 27 May 2024 15:40:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.7.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716824419; cv=fail; b=HFyFzUYAjrpnFkyVDESeB6CEs3Ch5KN0I/9SwN2Wb2/IamTOZFL+XpaaWR6ysm+NNfsg4y6la0k9Al+RhcBXzEOm0WAmuEFddzvi1HVWYlXPLX5G8TRMjKOjBjEFGPjZHVmTIZDMcio28XwHBxXrvn511z3OfAlxc6MU3ySptFw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716824419; c=relaxed/simple; bh=m/wkENAXXx6u1PI5bg2VtZGzw68HESibN8Zkx23L8C4=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=WBJnrNEelrzuZUlevqB2+QMKm4i4fgPM0EXgcg9FxC7syX75U27s8bS8yLGNN/PMUXDqjNJK/YPMFEuagz17VNI7TwByUxKR4rZA2Zi7GS110KBwnaJ/3r723cV1yHNxY8nBTHvrNIdC1g89Ygb007MsiXsHbdPp9f1N6q9QIJw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=INTejVd3; arc=fail smtp.client-ip=40.107.7.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="INTejVd3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q8IWmw8MRU/CGubOmQci9ELDwGfGoanxnsrugtidcni91FwWqlMHMdyGrPbsM6UcGqJfE7nBPoQap6N+3wQWp+PSwrALFTvQfUvftsDZmud1kEbJ5MtseoF7235kcwmVGDxDe30nYok/H14G85Aq0D4dQpgn6YLGt2Ot9ykVHK65MwCrL38e7pijyrvh7ErlSP5L39xBisA4dHOXTc2tGHaM9SdQshdHxJdd6D4vP+q06dkXriZmVGmbQWSoVaSlWWl7ZYoAyES4Vx68VTcHI3FujshjRH/3qUO3zz0Q3wuAcVwy/FIOTawl8nhzMVXO5/DZPQApKox60dubQGeXRQ== 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=wT4tNKXB+u3mQBtVjwjrKpUly0ew9Nb94YgWxVvtcVM=; b=LAlgg3oarS4LUB9lS6Tzbybz4GwZe5pnAM0UoaMT/TKJKafPQ4RChiSWGoVdcxYOUY3ScbJOMAjA55ksEtD3hDSZsJWz04JRumqweDcCpdMDEHX8QLA7H6QCnqHtpf6En11eFEbErzvfDrYZ9oEHbbM0FgNBl7d9eEduK9VW/tYLms3c6sCqqKLq0nIOXI8MbeHZfmdcXSR4nug8b722IWpLcEdjyoJcYKEV464gWTzxsQtzeEvZSHfwsZkyGD91i1cbrE/lw4yu2ij4QubiSwIV3/wRsAH4EnPWqev/WzdIYqAV/YoebNvRMfITy1hZPaCCj8qIOviBCYDGz5ClSA== 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=wT4tNKXB+u3mQBtVjwjrKpUly0ew9Nb94YgWxVvtcVM=; b=INTejVd32ar5kNd6+NiJdCa/Sq5r+IbrKqHXOsLoIT/Cm0HaoClodOjQ5zwHBErlbAEOCchWdJfY6hq1hifbrwFJPD1se5l4oDP5dtn8OiNyY29ebB770VSAsOtotmC1StAI8ybiQ/YS47zR05I+fHuchGroqnP0XA9u4cCP8bI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) by DB9PR04MB9961.eurprd04.prod.outlook.com (2603:10a6:10:4ee::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.29; Mon, 27 May 2024 15:40:14 +0000 Received: from DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a]) by DB7PR04MB4555.eurprd04.prod.outlook.com ([fe80::86ff:def:c14a:a72a%7]) with mapi id 15.20.7611.025; Mon, 27 May 2024 15:40:13 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: linux-kselftest@vger.kernel.org, Vinicius Costa Gomes , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Pedro Tammela Subject: [PATCH net 1/2] net/sched: taprio: make q->picos_per_byte available to fill_sched_entry() Date: Mon, 27 May 2024 18:39:54 +0300 Message-Id: <20240527153955.553333-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: VI1PR06CA0116.eurprd06.prod.outlook.com (2603:10a6:803:8c::45) To DB7PR04MB4555.eurprd04.prod.outlook.com (2603:10a6:5:33::26) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB7PR04MB4555:EE_|DB9PR04MB9961:EE_ X-MS-Office365-Filtering-Correlation-Id: c3f85d8a-b7cf-47fa-703c-08dc7e634ce6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|366007|1800799015|52116005|7416005|38350700005; X-Microsoft-Antispam-Message-Info: vtl2jXZI1c80IN4ixF6XH/x6IcTSyYr9Lm73Wfh+JEOtpXOWYKVpMpQ4b1mopO6TOnGAFuq32YXFedSlZ1x3rhJ6xSCkSwJrKaOnKW0QEpkWfLR0sD1WsH1FaDhi4ShoN5ieDh7d8orSw7BV5nt094hf+QKYcNbqjFJPMkYWxbSD0QHgUA9lCBxvMqq/AsLW9tCIxCWhATaoAcub9OLAaE/as+o5Y0fmb72X2ove9Tv7w/+fSe6gKmG6QwDRULHhHOQ2KLmXu9FQcOOv0QSc6LQustytN+znRcf2nMPteKEDy+QAeD3V9qGNfYoDF/8rorKNI3vHu/C/hUV1ejcLDF+4Wkva6qudhP5KCSOTbJIbfNMq05RWZs876rMohu8sbpYjykCC5BGtU+0n7cd5WKYddLiPOWJ6zpCJG83XMiJo4Ks/047VvsJmXh6kGUGVsTg1YS5ormHcKLDDM6+pEMguxTuEmtnS1kBFykRAkXeydYEWnQMbS2ap171Z2o2VfX3wnqK1Au60CiIx0QcYzrQ4xZw4FjoA78IPLl7yumTq+Lh9ZyXlHtbwCJEuog665pbSS/SidXUu5JWKdSj9qpuO1zEIU4KJKHwEfYt0gYCtllMrdsAnjyDO9DANh0hZ7gfySLvgEmyRExyT71ErIwstEhF+Cd9c1UeekES71NLwCVuySz9+eQ5JOdPd6qq+mLA22IvlIDm3drsfKlwSn9BkDMa+BzjJj0Mnxngip+m+sQuSxTdbC/NH2Imy6PdTuo4Oajx1r+BLJBlWhy1fZ9IHIqKldWhHPPr/jNCUQLRZF3yrethYBvqBW2Fi4lg2fAUViyp+SpnUr2vLg9610FWucpva7AF77YcrYl6xH84dEdd2dXWo3WU7Lbbgy3M4xd/hS2Q2MiyX+3dXExmNsf8u1KnxV1Wv0Q/yysM46iQjLOB1HHbedkQ+RIorYL7NUjnlpvTkU8ib1fQqheuxGeoEAqskWz3QnPnngMpGGorgMYvYAKRMaGXhGZFjcPdVo5deOxwDP1QCpeOWUFHHgTkpTbYnEjuHVmZA5pZScf9XWIDzEldhk5M0SqGNcxyPaK+sAcKfVwWk6NlyXwNWi3XtNVom1SyftACJmgUn/+SorG7KWnDUZqtND4gAI4IP3Cm8IPBke+fAWsnVgDdSrqLOdfkPk5dU3bKGfPQlrej9iYWiroQ15OGRXPQapVWADHDafYrnaghm2OKvRMWC6UUVgPMyBjPQCnGz9LN1y1ElasIW1cCPxoEN0/Nc6OL3pvMqzk9f9dem3DNsKAU7qkc17oLmVDl7j3uU3cbgYBosG2gkkuAzylSZw4twId8I3dp8nLedTSnwho3G0MiVvA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR04MB4555.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(366007)(1800799015)(52116005)(7416005)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QU3kiKSJjjAOY2hyf9ezEaXyYs0oHndBfnoZjZ5tGyTXa4EU5zAQmD1lo+uhz7dlxculjJ7OEgmcefdDsY6yqhFboojqm5wWSBfioIv+UrbfaBGZY42Ggeh2nLKbWHYLIVg6kBfBXD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iVEKjQn7/LSnIOI7v4YDNoI7eulYB0UAuE61zxS6SLPscbRTu0nPE4TzD6PcDw9IB90yckd5+bQsnZJY3WkhIdIkQeCsYxDKs6sNKWFAjh6Usj9GBTJ8u5OneB0Ysdyl5xEuTtWUvPEXGH6WgKlviWi+pDadmxtgctVUIn9mutnStxn5hrS169bzLzfHYBN/zwsFs2Fh+U5mh2GhtEO2BBfsx/YXPnMV0Nc9mhHKH+8iWhFhEVuLU4JhqU6yXYoSHFRcE4oaM20QTLgWmx/WLyjM3qhg30Vci7OxYF2t96LVQsZs/YrdD6zj+LnXuTRI61ePIUpl7VrLGRNZ2TnwsO1YY3O+uoASKWWV3TJUqHPLWI6AU4z5N0P4R2IIdONZY4qJHuXM/DCg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c3f85d8a-b7cf-47fa-703c-08dc7e634ce6 X-MS-Exchange-CrossTenant-AuthSource: DB7PR04MB4555.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2024 15:40:13.8616 (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: ABnEv5K4R2k55pAj0QxmsJAGpgPsPmZ1RMt77H3LdMB1XLE695UjAXYkFPClX5f6a5Bd+tqF1egQp3pZX6h6CA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9961 X-Patchwork-Delegate: kuba@kernel.org In commit b5b73b26b3ca ("taprio: Fix allowing too small intervals"), a comparison of user input against length_to_duration(q, ETH_ZLEN) was introduced, to avoid RCU stalls due to frequent hrtimers. The implementation of length_to_duration() depends on q->picos_per_byte being set for the link speed. The blamed commit in the Fixes: tag has moved this too late, so the checks introduced above are ineffective. The q->picos_per_byte is zero at parse_taprio_schedule() -> parse_sched_list() -> parse_sched_entry() -> fill_sched_entry() time. Move the taprio_set_picos_per_byte() call as one of the first things in taprio_change(), before the bulk of the netlink attribute parsing is done. That's because it is needed there. Add a selftest to make sure the issue doesn't get reintroduced. Fixes: 09dbdf28f9f9 ("net/sched: taprio: fix calculation of maximum gate durations") Signed-off-by: Vladimir Oltean Reviewed-by: Eric Dumazet --- net/sched/sch_taprio.c | 4 +++- .../tc-testing/tc-tests/qdiscs/taprio.json | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 1ab17e8a7260..118915055360 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1848,6 +1848,9 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, } q->flags = taprio_flags; + /* Needed for length_to_duration() during netlink attribute parsing */ + taprio_set_picos_per_byte(dev, q); + err = taprio_parse_mqprio_opt(dev, mqprio, extack, q->flags); if (err < 0) return err; @@ -1907,7 +1910,6 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, if (err < 0) goto free_sched; - taprio_set_picos_per_byte(dev, q); taprio_update_queue_max_sdu(q, new_admin, stab); if (FULL_OFFLOAD_IS_ENABLED(q->flags)) diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json index 12da0a939e3e..8f12f00a4f57 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json +++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json @@ -132,6 +132,28 @@ "echo \"1\" > /sys/bus/netdevsim/del_device" ] }, + { + "id": "6f62", + "name": "Add taprio Qdisc with too short interval", + "category": [ + "qdisc", + "taprio" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "echo \"1 1 8\" > /sys/bus/netdevsim/new_device" + ], + "cmdUnderTest": "$TC qdisc add dev $ETH root handle 1: taprio num_tc 2 queues 1@0 1@1 sched-entry S 01 300 sched-entry S 02 1700 clockid CLOCK_TAI", + "expExitCode": "2", + "verifyCmd": "$TC qdisc show dev $ETH", + "matchPattern": "qdisc taprio 1: root refcnt", + "matchCount": "0", + "teardown": [ + "echo \"1\" > /sys/bus/netdevsim/del_device" + ] + }, { "id": "3e1e", "name": "Add taprio Qdisc with an invalid cycle-time",