From patchwork Thu Sep 15 10:50:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12977234 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 B72EAECAAA1 for ; Thu, 15 Sep 2022 10:51:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230022AbiIOKvD (ORCPT ); Thu, 15 Sep 2022 06:51:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbiIOKvC (ORCPT ); Thu, 15 Sep 2022 06:51:02 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2086.outbound.protection.outlook.com [40.107.22.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA5CC4DB05; Thu, 15 Sep 2022 03:51:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oMr5psWNVP4f0u5U6pvMFSRfECnJg7howY1eWe2botNJLV97ahfBvrtKTCi52qUonsr71EMW0KlzuKIsYO3b2l4fTpXo1dCyz3ptmjH11qVUWBYS6lZjhyymdTT1f5gaf1Nvux+t1qWz136K0ghn3XsZQ/wlQ5ooQpG4XAEz7ciYLgTkIYArcgxN2MHztsk5rTWVFwl6x+Ejk4dB1oljQCthoKfwIMXRCDq1BmE5vhlXcNpL8MiNu1/GSEBhg6FXTeFPgizst0meN+WqfVQYCbJjH4WSVtDlFmbKOPOAxfS4mMhY0NM+NyXPPUsSqFF7kt+HEuFwdds2Fi4W2d272A== 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=QPYr3gi02pCxjw7Cn4QkinU+FClOZUJSPxpxxITibUw=; b=jfmFF9d0T1NLQps5MfxYTTDEH5tYvlBf/TJxgpygeax8xSi9NELUKiAPlu0skBpWv3tomlLJS7oz2kgioFAjdIW++q4w0AOLTZDJt4leRR/jgEiVwEArcv7xf3RvqVlczdeYSXsUMNzIbF0MTsRKWr8EcBBGAnTH8sJVC5OqLz/7juvgsux2Mk7SCEMzsBPXE/rF/ycmIGWlCOzJdKkE66C58t9LEFBiApvavkM6vO5zVJ1MK34SJo6ByyQzjS2HdkpBvarPfeASCd9B6Amg4tFM2vkTVVzD5DM8wU9yHWFTjNlsXh4mXE/LIXtLVt4fjPhwC7oRNoXah779kE7mDg== 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=QPYr3gi02pCxjw7Cn4QkinU+FClOZUJSPxpxxITibUw=; b=qNoraUBLLQU8OvjwjCQuXPFV1Reojkras8wumIntNh2/C+WwcOAgpJZpp5pmLKuyKx3cjqoYwNMKLtAxqEDSKT1KHvZKV/OoW4fqR+kMrMMwdeM2WmtD3XQCgZHigQt7uvdVDFp3SRTOKMERQu6di83yPcWrFeS4z275oCzv9Z0= 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 DB8PR04MB7163.eurprd04.prod.outlook.com (2603:10a6:10:fe::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.22; Thu, 15 Sep 2022 10:50:57 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1%7]) with mapi id 15.20.5612.022; Thu, 15 Sep 2022 10:50:57 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Vinicius Costa Gomes , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Voon Weifeng , Vladimir Oltean , Kurt Kanzenbach , linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 1/7] net/sched: taprio: taprio_offload_config_changed() is protected by rtnl_mutex Date: Thu, 15 Sep 2022 13:50:40 +0300 Message-Id: <20220915105046.2404072-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220915105046.2404072-1-vladimir.oltean@nxp.com> References: <20220915105046.2404072-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR09CA0052.eurprd09.prod.outlook.com (2603:10a6:802:28::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB8PR04MB7163:EE_ X-MS-Office365-Filtering-Correlation-Id: a2538350-0e1b-4865-41ea-08da97082b64 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LZuHa5FC0q4iU+6Y2XqfUfVgEKMV8fg9t7rz7Y6Aj4xFkgrsxWxWqXpsRn9Wxp3JYigHNUiDVZ+ZSIDUIacBpqOy1l6sM70GhDQXlCtbBBLzV/THEEawFH9x7mIu9nj4s4roK7O43RhjYM/dbRcYf05aqJE4VUF0hfdmW62cjEQcgrBVwdcj4vjxG/SIbQ/FjwRaYEljvylUqXWZAJoP62s0UKFSBpt+86k/vWOD8nHAVbGKSazNNhV23ax7ZdHyzvHKUkaxaeykZjEfdOEsFap46jK95HnNdOBEN08+xW4myJstdLh4JpjkcqHp9Ij64I+0cJ4JXf8PwmVWH92m9IheJfYHbaezS57b0xTD7GSq4pqleZpSNlfgP7nOKt6JM/+wSnHH28UVwYrODj/RsgkLAJtA9oVWsrqEP5wPZIjmGq2X7VEE9xBAcM7sR++0ni+jSXXgRQa9J9cGcvtwAd58D9FQWudHEsK9WKa0SqEUKCj79tRI8yzVzYaMJCqj0EpUmabzhOIiW+Zw3PZUbtmcFZ+6H5DqwUM+CkzksrMAEjFU7+D6dl+LCoIQcRAo1AXnXrd2tYQo76QWwzpdPdTK2K/JH5s9SXB/JClbMta75JNRof3rwa+gWzGX1Piv+kNNcsDATQSwFJuhOwy0Ek7XMkDnvP+nTZpv0QlSXT6fgruTYi06QN4mAalJeIDi+MAwek9E/wZioQ/JtWfgzkSFm8HkNe892JfyaZ1cwd70QFbfg8zSGrLmem7mLlwhIcgzpJfdoqyKoaxqXpYtrg== 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:(13230022)(4636009)(376002)(346002)(396003)(39860400002)(366004)(136003)(451199015)(6916009)(5660300002)(6486002)(7416002)(2906002)(478600001)(66476007)(36756003)(54906003)(44832011)(38350700002)(8676002)(38100700002)(6666004)(316002)(2616005)(83380400001)(1076003)(186003)(66946007)(41300700001)(6512007)(86362001)(4326008)(6506007)(8936002)(66556008)(52116002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kvv1gZiJ5Hu/kBWb3tyhUqBGYCJQL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4SZbFjy/1dFtRfnQvu8/HN4mShRRjiP2ZGPmYNA24B0Bn8wXj6hBzaM2AqgTaPDNtXl4Q1jy/Z+Y7sizawGBiFv6CvRhMvuLVjMF4o498+uat9CQr9Kms6z3mld2GnYKWIEbk0MaY4GgxEfEZkEF1g+dpH9D9SZFkF7qeYhtLMuM9M7f3hE1oQibHNnRomAjntQlYfY8VaSG1NIGtZyX971I1rjHIExxNNTTNSTTeOs0ur+dNkqNrFxdqhaalQatyQSJ5MCQ5/8lZp+2R1F1uciEUku3ZdUV1uKduBd3xJ1rQOu5sxqfM4QyIFBFCr7g8AWm9BNtQTUzrL6y4VJ0o2hSZmb38PR82M7n9vmcyVz9Tg1vBcBnxsjYEpLT7QCq6TJswmymSCw4EKVbrZrdXPjQ3YqcW+qta77jPus431bwLHj3sL/nRR42zLSbGHPb4SP5rB3lUE7XkNCVoTAqajTuT1Mil6yjRA1ikl1F4NhyOndi1Usae3YA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a2538350-0e1b-4865-41ea-08da97082b64 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2022 10:50:57.2213 (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: CbxlJoORD2UQ4ZefAcfCKPjCV8W0gA9/zBAb5ibyV//q8PsRVOfoziFVGMb3Apap8wuouOd0LjJXkRD26o88Cw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7163 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The locking in taprio_offload_config_changed() is wrong (but also inconsequentially so). The current_entry_lock does not serialize changes to the admin and oper schedules, only to the current entry. In fact, the rtnl_mutex does that, and that is taken at the time when taprio_change() is called. Replace the rcu_dereference_protected() method with the proper RCU annotation, and drop the unnecessary spin lock. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new net/sched/sch_taprio.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 5bffc37022e0..550afbbae8bc 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1194,16 +1194,10 @@ static void taprio_offload_config_changed(struct taprio_sched *q) { struct sched_gate_list *oper, *admin; - spin_lock(&q->current_entry_lock); - - oper = rcu_dereference_protected(q->oper_sched, - lockdep_is_held(&q->current_entry_lock)); - admin = rcu_dereference_protected(q->admin_sched, - lockdep_is_held(&q->current_entry_lock)); + oper = rtnl_dereference(q->oper_sched); + admin = rtnl_dereference(q->admin_sched); switch_schedules(q, &admin, &oper); - - spin_unlock(&q->current_entry_lock); } static u32 tc_map_to_queue_mask(struct net_device *dev, u32 tc_mask)