Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4049600rwb; Sun, 9 Oct 2022 16:50:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76wNgBxpLnJXB5YGebnUz4tWlCAWpJnlCvfcytzYwbhAaBZ2tWZFeRLr8Rl0lvT4ohMx/M X-Received: by 2002:a17:907:7ba1:b0:783:198e:7df2 with SMTP id ne33-20020a1709077ba100b00783198e7df2mr12559911ejc.126.1665359423141; Sun, 09 Oct 2022 16:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665359423; cv=none; d=google.com; s=arc-20160816; b=W2Mhm5yTC5G9Ne4tuSw72kp7QMK9T72c6Q+3nv5QglEi63KB28VKGLi53htpmOe9fV xI0ZOIiYlGGglyxlmVsXGse7NyMUWdo34QPucEKFpVG1FO72l3bCyN+5lodlVC0Yfjew HmksloWZ8HxOW6x0PQO6R4lj8OitcpbUoYUSam2PZFkAzd4aSVJlvInJovM+WzOuWVUX 2fb5xF6TrZS02HYomDznZMThM4UMsoOuju4hd1yrS/EDytV/fP7oJSt5IF4baMOG/3+A R2sAvPo4uE+dTR+w6kBovm2TztINoMSOBAJVcWSxn0pNUt3nYu2e9YKgpQOv9HpGNXEE UC5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O0nAI3Z7kp2NHZTZNUZC3sxTkhffuy5x0QW/EKb3FzQ=; b=askpY+D7/UBdIFKvCfDN3MyBv7WyGmPPa6hvd9miBfZkNK8D5c+jZeDkOgjHAznk9J uYyf1LyvQLxLOG10y7ZikXnOZBv1AJmOg/CGejeRi3JTXvrffEWZbukRVKMKuLP5ZhWw EnIv9n9FNA4DkMAie9tU0jmcSkBMJ8UXDaFjcstUPedbeJaEB3HfEOif7QPF/4TBQ8/3 hMZRIVl1tMwsgRh2xsdVTl6fojVCDnjjd/Ckql6WM9oBx4URQYFEdfx1Uq0YiclGsTev 4FKwRi1ukz43gK7AkgYum8lhx5zpdTE+SAMeqbejWTDjjLyTl1Btqa2rQSZe+LBpIZEK qCcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mScMQSwe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw17-20020a170906479100b0074168953071si8112207ejc.866.2022.10.09.16.49.56; Sun, 09 Oct 2022 16:50:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mScMQSwe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233221AbiJIWt5 (ORCPT + 99 others); Sun, 9 Oct 2022 18:49:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233171AbiJIWrz (ORCPT ); Sun, 9 Oct 2022 18:47:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B393F64; Sun, 9 Oct 2022 15:24:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AF88B60C19; Sun, 9 Oct 2022 22:22:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0332C43470; Sun, 9 Oct 2022 22:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665354157; bh=luY0azZv8cvOxQJDnUdYH2ZEc90x8GEWhYFzr1Sap24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mScMQSwe3gSm47ekE+PSYs25fKmeTh8ifRq1dwFmAdOFAckV0jelJLeKvGGkYhV2i e/OX/UeZbLBKB/qS2vthjmu88K0T4c/R68Ep84sH/O6AH/7Ukwl82pajG7YtRRmfVG u1zUxAEKPnyDJkr5SIZMsq9PEFkS1TrkcVegdxKhU1cIFUUT5pIsEil0+Mo4UY3oVz eY7gA0TXjWwk81amkBDfy4Z+FUjfLvjZCNCP1HdcK5AEOloa6PW1o8n6o2sdHVXpQm XmitZbDYNY6U7V66r0kvfbGogzB55RH5d880wQyMZocuFSfBgw1mh3foXnbYTaC5WX rNaEnaCzIYVJg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vladimir Oltean , Jakub Kicinski , Sasha Levin , vinicius.gomes@intel.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 22/34] net/sched: taprio: taprio_dump and taprio_change are protected by rtnl_mutex Date: Sun, 9 Oct 2022 18:21:16 -0400 Message-Id: <20221009222129.1218277-22-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009222129.1218277-1-sashal@kernel.org> References: <20221009222129.1218277-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean [ Upstream commit 18cdd2f0998a4967b1fff4c43ed9aef049e42c39 ] Since the writer-side lock is taken here, we do not need to open an RCU read-side critical section, instead we can use rtnl_dereference() to tell lockdep we are serialized with concurrent writes. Signed-off-by: Vladimir Oltean Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sched/sch_taprio.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index ab8835a72cee..d70a5c4aafe5 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1480,10 +1480,8 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, } INIT_LIST_HEAD(&new_admin->entries); - rcu_read_lock(); - oper = rcu_dereference(q->oper_sched); - admin = rcu_dereference(q->admin_sched); - rcu_read_unlock(); + oper = rtnl_dereference(q->oper_sched); + admin = rtnl_dereference(q->admin_sched); /* no changes - no new mqprio settings */ if (!taprio_mqprio_cmp(dev, mqprio)) @@ -1843,9 +1841,8 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb) struct nlattr *nest, *sched_nest; unsigned int i; - rcu_read_lock(); - oper = rcu_dereference(q->oper_sched); - admin = rcu_dereference(q->admin_sched); + oper = rtnl_dereference(q->oper_sched); + admin = rtnl_dereference(q->admin_sched); opt.num_tc = netdev_get_num_tc(dev); memcpy(opt.prio_tc_map, dev->prio_tc_map, sizeof(opt.prio_tc_map)); @@ -1889,8 +1886,6 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb) nla_nest_end(skb, sched_nest); done: - rcu_read_unlock(); - return nla_nest_end(skb, nest); admin_error: @@ -1900,7 +1895,6 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb) nla_nest_cancel(skb, nest); start_error: - rcu_read_unlock(); return -ENOSPC; } -- 2.35.1