Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4049587rwb; Sun, 9 Oct 2022 16:50:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5rnoTdCQZDI5NZioJXvbSD+IyBUvivbkY4CLp20VZeEtqdUeDfOap2jO9QqCr4zY36WU8p X-Received: by 2002:a05:6402:270f:b0:45b:f231:146c with SMTP id y15-20020a056402270f00b0045bf231146cmr5585074edd.269.1665359422219; Sun, 09 Oct 2022 16:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665359422; cv=none; d=google.com; s=arc-20160816; b=r5yyvg14rQnbbbBBfGoEGyBiFR4DWPhrILFN22aTG9vp0sgE3zedjZf3NAUjPN4nTZ adbKJOTOyyvcRA9l3oYmmTvxpuUHYzaHdaXsomRcBeNiEUXFhgH+MPgb5UfBUmxRPOxM 0EdKFPq4k8ubDVbONXFQrSnmw06Tj11QmxwA8HKX/kvUJb0dhWruxzVB45KPBbMkEyzX w43E83a1xgLMxMB97hjghOQ5p5GXiHOLeUBXzEeoqXASeQAodf9bKJu7W66asJST2ETN V1M2osNzXOuCvscU7SZjl7lJl5XVyzVgQDcJYtGBCvpBHmz1WURNxV0kt8xiSUOjORji FDcw== 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=yfzEvKKDC6gCsELHw/NSdBxPahbdJ8XijZ0Gj9P7p3U=; b=nTqUL+E0XjOl0JqWudhaDciTOzIHE6jZ13MzsNzWAQ6jolyOtl8P7GoyT7owRvxiSH /3C6jNl3iNBhYeMOQStc9Y8FmmT6KdhpLbsf+6XTkFCecAiRFUuhQ43TaUC1r74dPUEQ 3epMyIWfjvGyEoOe6BlkTGB+E5Z+ADUKzAcp1ZUIHn8pocP0lMenmt+IDyBoZfLxv28V Y3wD/GyxraUBzWot5LP9DPqbiy9Os/e6kNE5H/4GCN4xOXakPXtBWlweGc0U5ZNvmHGT D9EFuIVRlBr1grIfbe2cwH3csg2l8B/xO5NZ3N2Y6JsFV9RM9QLmW8WvZ0dhW1TdechA pPHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RX3GFz7V; 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 qa42-20020a17090786aa00b0078d8db64fffsi6821676ejc.20.2022.10.09.16.49.56; Sun, 09 Oct 2022 16:50:22 -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=RX3GFz7V; 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 S232952AbiJIWmg (ORCPT + 99 others); Sun, 9 Oct 2022 18:42:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233040AbiJIWk1 (ORCPT ); Sun, 9 Oct 2022 18:40:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73AB041D07; Sun, 9 Oct 2022 15:21:58 -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 311B360C2A; Sun, 9 Oct 2022 22:20:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55398C43470; Sun, 9 Oct 2022 22:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665354051; bh=Svku7iPweTfGQwgBqouCE3/CF9p7StAi3Qh/c7ijZ5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RX3GFz7VjxvoYlPzfrPCbuEgBSB04iqtnGevpEkbES4JJbxfW8r2aH34aQ13kg1Ly vc3EpzuN4PWSYJQFWf6AbKMy576TnQE5pOmJyB9N8kjOpvdpyBsWrtoB0rA8KKze5c CRqv5q7ZnuPq9k86jWfOsiLxkUXD2pIeAevtloZaLEJwV82jJk/4BlTRqj43j9mz3K Wruramz9gS1ccyyDdWk0nBhzhPaRYb7tXImYHNBW9jo/wv3Q/nztLK1jJml1itU5HL N1gYBVQCV8KEEVAp1y0eG/Z96a8eyy4R6iChVbXPuX/EGjUvpVqW2Nc4DSP7Pb1BzF p/lirsSamnMyQ== 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.15 33/46] net/sched: taprio: taprio_dump and taprio_change are protected by rtnl_mutex Date: Sun, 9 Oct 2022 18:18:58 -0400 Message-Id: <20221009221912.1217372-33-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009221912.1217372-1-sashal@kernel.org> References: <20221009221912.1217372-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 ae7ca68f2cf9..0ac3fbc13b7e 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1491,10 +1491,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)) @@ -1887,9 +1885,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)); @@ -1933,8 +1930,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: @@ -1944,7 +1939,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