Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4044453rwb; Sun, 9 Oct 2022 16:42:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4azZLeEFpEy1e+AdAQvhIlQl5X76JN7xFy9tKhOFNa9hSVZ/lBOT8Oaj8Mbxprd8koIeAv X-Received: by 2002:a05:6a00:1d05:b0:563:5715:7f3d with SMTP id a5-20020a056a001d0500b0056357157f3dmr3177043pfx.48.1665358957379; Sun, 09 Oct 2022 16:42:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665358957; cv=none; d=google.com; s=arc-20160816; b=k9qJmoMkfLHovYFN9pBtG/wbuDS1p23KHMAFktxKheT4rn6zgKKlUDuCofSa4ZhHD0 YPWSxou2TT8tjqUaZ7uRWQEbizTgqjuHSDvtFWwJ/rKmHpr6kQaWepknTN93K1jXseYg E2PAO7urxcTKI9r0wFOj7/0cjtoBoQVK5IwtwuWQYa4EYFGuc0nj97Rt5NDQm1cysn7t XyrCb29G7w2a/obXRu8VgxB9xF7/7GgXZx805ucN4yiR9HHFKQzG1fzLylIr+v3CpA8i xBN2/ZdNWKLUzEWRbwn0Zc0P37KiD3xKRw7+F0hryWziezurz+5PRuaHhRFIZNjrQP7/ EoKA== 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=N9jw8E250VwPFe8/UW6TzXcMkro9JJUXyBMo9XkU2bM=; b=p2mtlXgt5leCSbqWbITTigMVlUH5WXUFPGgD6X9v7lIfUGyR7JaaklNw4Xgdr9TxZA HZSmp0APslM+o+JjR8T4pbZk8bUp5UTvfu4YQrLb83EXoj5KPCrHoHuTAs2AMnepVmKk rDsZOvJZwCuDoNkYQ780iX9Gvr8WFy7OB5VjI5xjwr0enBgyjsN+X4gf3CpLOYmm+q3e O5gLImqNN3641UvtyLXqplUG1droZGRRloPHKUmJW2w6T8o7EkjF6bFA9JtsO8Zoyajb CbGJmukCahj0fIHRkDakBwKtmvEK1fY8AC20gPXqhvE55MO019A73YzAhOWM4pdCHoAm DLew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HBK3+JU+; 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 z15-20020a170902d54f00b00179ec1d9eb4si10011699plf.112.2022.10.09.16.42.26; Sun, 09 Oct 2022 16:42:37 -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=HBK3+JU+; 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 S231539AbiJIWSZ (ORCPT + 99 others); Sun, 9 Oct 2022 18:18:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231506AbiJIWSA (ORCPT ); Sun, 9 Oct 2022 18:18:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2A202F019; Sun, 9 Oct 2022 15:15:36 -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 B2F6160D17; Sun, 9 Oct 2022 22:12:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5228C433D6; Sun, 9 Oct 2022 22:12:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665353537; bh=XwHKS7e8GthxQUR4oQfDVgwh4JKJsT8M94kHeLGQLys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HBK3+JU+Ba0NrroQG7mPn+fVxpJR+ngG/8Y0nYxLayPV3VUu3zOOugXmcRQJ7HUoA gb39+FoJvdCXJOuN75TTVNBxUe6pmbnhQYkxixzLOObtoDapvzoD2PYS4BzARTzcQP I1VQHCUVhnGENU4c+v83lIAb/LF595Gcb+1YDSQOrjszFipUQcExwYZ+gH/3+lAxbp gSG3hF8jJwkpH3IznKCfg7ZSTOf6kTKyevp14tRUXvIsbSSb3Mx3CCIypbiFK9Qwhe LNUOZe/fialliWlk+VB0mO0F429LmVJhZ10Ii4Et6Grss+NlkQJh4IupNZHbvcXxwQ 6Msyyk6tH+emA== 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 6.0 55/77] net/sched: taprio: taprio_dump and taprio_change are protected by rtnl_mutex Date: Sun, 9 Oct 2022 18:07:32 -0400 Message-Id: <20221009220754.1214186-55-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009220754.1214186-1-sashal@kernel.org> References: <20221009220754.1214186-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 86675a79da1e..71408136d4a0 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1492,10 +1492,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)) @@ -1888,9 +1886,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)); @@ -1934,8 +1931,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: @@ -1945,7 +1940,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