From patchwork Wed Sep 16 18:45:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 260772 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24641C433E2 for ; Wed, 16 Sep 2020 18:49:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB3CC20809 for ; Wed, 16 Sep 2020 18:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600282143; bh=/HpLIcbRVuD2ycvpBlOy4OEqMVgIAQBp4R33DdeUlQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=YauovT6t5WR5x/SE95S9fzqoUG5kOr55N0yLvCDhQMGjpmYKujLppZS7IVndcRnnI 090WWuL3eIUDTJ/P4bD03y4x8h6SXGK8U691mr/Ek1LilqYzR5jByFEbqUBZ7Fdm40 9AzvGcawNTl2cahsd0PoRNURbOyI27Z1E8A2zADg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728118AbgIPSs5 (ORCPT ); Wed, 16 Sep 2020 14:48:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:44210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728070AbgIPSqK (ORCPT ); Wed, 16 Sep 2020 14:46:10 -0400 Received: from kicinski-fedora-PC1C0HJN.thefacebook.com (unknown [163.114.132.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B9830221EB; Wed, 16 Sep 2020 18:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600281967; bh=/HpLIcbRVuD2ycvpBlOy4OEqMVgIAQBp4R33DdeUlQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wP0aRCB1uK+qdp8y7T3xK4Wtdz9pxXu+PGs5sgQ8WRlMrZkOOnk3vg7R/bd1OBtMg DUQg+x3Ek81vr/5LEGAbZMcLwbxJjXlikFz5GQU77hOZdOdP9Wsq4aDjzlvmPpIHxJ ++eL57a4FFpQoq1BMyorPg4yb7RwjKOIjTF4bQus= From: Jakub Kicinski To: davem@davemloft.net, paulmck@kernel.org, joel@joelfernandes.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org, josh@joshtriplett.org, peterz@infradead.org, christian.brauner@ubuntu.com, Jakub Kicinski Subject: [PATCH net-next 3/7] net: un-hide lockdep_sock_is_held() for !LOCKDEP Date: Wed, 16 Sep 2020 11:45:24 -0700 Message-Id: <20200916184528.498184-4-kuba@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916184528.498184-1-kuba@kernel.org> References: <20200916184528.498184-1-kuba@kernel.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We're trying to make LOCKDEP-related function declarations visible to the compiler and depend on dead code elimination to remove them. Un-hide lockdep_sock_is_held(). Signed-off-by: Jakub Kicinski --- include/net/sock.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index eaa5cac5e836..1c67b1297a72 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1566,13 +1566,11 @@ do { \ lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0); \ } while (0) -#ifdef CONFIG_LOCKDEP static inline bool lockdep_sock_is_held(const struct sock *sk) { return lockdep_is_held(&sk->sk_lock) || lockdep_is_held(&sk->sk_lock.slock); } -#endif void lock_sock_nested(struct sock *sk, int subclass); From patchwork Wed Sep 16 18:45:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 260771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F11CBC43461 for ; Wed, 16 Sep 2020 18:50:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 906C221D90 for ; Wed, 16 Sep 2020 18:50:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600282217; bh=PizuCKedVSnuiRnh+VWDe8s8rBgOspdAMA6AwoPh/Gc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=x2YIi2Om2VJFRCVDACiw8selzFptKcf0ziXz1xcjK8srtn8dhor3O1G1e0izMhZX+ gIzbAUsvBfAFFIArgO75Hb7fgI8fc89Mw7BbFooGmlGZx2/OqRc1NX8cpPvtJJaVhK o7sPDx9UnykcQ4ah/JPNvRQpyqIqjEnl7twhtm+o= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727953AbgIPStV (ORCPT ); Wed, 16 Sep 2020 14:49:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:44254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728153AbgIPSqK (ORCPT ); Wed, 16 Sep 2020 14:46:10 -0400 Received: from kicinski-fedora-PC1C0HJN.thefacebook.com (unknown [163.114.132.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6F57B221EC; Wed, 16 Sep 2020 18:46:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600281968; bh=PizuCKedVSnuiRnh+VWDe8s8rBgOspdAMA6AwoPh/Gc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dIU3ykcWb2WBvNWiyT3UXZW4LWEhGDEOphqKmW2ht45g5bHd7arfDoUmqR83zdfya RSIPqoxJqquhj29t20MbqoKanCRyAH/AkBuuiFaiLGmdlQlKDyhhw8ysWuzvPh5nAM Tu8EbtUOhflNPEEgXnGPa9uGCsrC8fgHGfeb9ZsI= From: Jakub Kicinski To: davem@davemloft.net, paulmck@kernel.org, joel@joelfernandes.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org, josh@joshtriplett.org, peterz@infradead.org, christian.brauner@ubuntu.com, Jakub Kicinski , jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us Subject: [PATCH net-next 4/7] net: sched: remove broken definitions and un-hide for !LOCKDEP Date: Wed, 16 Sep 2020 11:45:25 -0700 Message-Id: <20200916184528.498184-5-kuba@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916184528.498184-1-kuba@kernel.org> References: <20200916184528.498184-1-kuba@kernel.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We're trying to make LOCKDEP-related function declarations visible to the compiler and depend on dead code elimination to remove them. Fix up the situation with lockdep_tcf_chain_is_locked() and lockdep_tcf_proto_is_locked(). Signed-off-by: Jakub Kicinski --- CC: jhs@mojatatu.com CC: xiyou.wangcong@gmail.com CC: jiri@resnulli.us --- include/net/sch_generic.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index d60e7c39d60c..1aaa9e3d2e9c 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -432,7 +432,6 @@ struct tcf_block { struct mutex proto_destroy_lock; /* Lock for proto_destroy hashtable. */ }; -#ifdef CONFIG_PROVE_LOCKING static inline bool lockdep_tcf_chain_is_locked(struct tcf_chain *chain) { return lockdep_is_held(&chain->filter_chain_lock); @@ -442,17 +441,6 @@ static inline bool lockdep_tcf_proto_is_locked(struct tcf_proto *tp) { return lockdep_is_held(&tp->lock); } -#else -static inline bool lockdep_tcf_chain_is_locked(struct tcf_block *chain) -{ - return true; -} - -static inline bool lockdep_tcf_proto_is_locked(struct tcf_proto *tp) -{ - return true; -} -#endif /* #ifdef CONFIG_PROVE_LOCKING */ #define tcf_chain_dereference(p, chain) \ rcu_dereference_protected(p, lockdep_tcf_chain_is_locked(chain)) From patchwork Wed Sep 16 18:45:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 260774 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92178C433E2 for ; Wed, 16 Sep 2020 18:46:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4247320809 for ; Wed, 16 Sep 2020 18:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600281995; bh=jPXAjpQCZ862tVOBiMIHndV4XBLyC44PoH4AOVqApsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=b6B58DgnpCc9CDMK35GQjNjey5eCVWa9AM6XDeGr3gmEKg5t1bzDwH/k7ZGqIF1mf gtFnNhCI7pdNXxYVvRL6kD/oQOXN6/AEgRgBP+HHFRvhpHU5asenDg68mDBq3E9E5G wPrRodlRkKuUoQ2c2+ISY2j8NCK15Dg+xTkDwd4U= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728240AbgIPSqV (ORCPT ); Wed, 16 Sep 2020 14:46:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:44342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728154AbgIPSqO (ORCPT ); Wed, 16 Sep 2020 14:46:14 -0400 Received: from kicinski-fedora-PC1C0HJN.thefacebook.com (unknown [163.114.132.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7A478221EF; Wed, 16 Sep 2020 18:46:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600281969; bh=jPXAjpQCZ862tVOBiMIHndV4XBLyC44PoH4AOVqApsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cfYutagyCDKhwiv/fmpQgLz/EQNVGj5JbRF/wF2xF/EkczxIDcDUYXgyqJIRRXKHJ Xf9riCS2eLkWCfBZNsAfbBojDPloJuaqOW/vCrM8XMeThsOoIsTJI8hUNzx5O6JCLy DNzji6bBqiaB1iOWKtCZ0q0fkUAhiOu2vW8KE8dg= From: Jakub Kicinski To: davem@davemloft.net, paulmck@kernel.org, joel@joelfernandes.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org, josh@joshtriplett.org, peterz@infradead.org, christian.brauner@ubuntu.com, Jakub Kicinski , jiangshanlai@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com Subject: [PATCH net-next 5/7] srcu: use a more appropriate lockdep helper Date: Wed, 16 Sep 2020 11:45:26 -0700 Message-Id: <20200916184528.498184-6-kuba@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916184528.498184-1-kuba@kernel.org> References: <20200916184528.498184-1-kuba@kernel.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org lockdep_is_held() is defined as: #define lockdep_is_held(lock) lock_is_held(&(lock)->dep_map) it hides away the dereference, so that builds with !LOCKDEP don't break. We should use it instead of using lock_is_held() directly. This didn't use to be a problem, because RCU_LOCKDEP_WARN() cuts the condition out with the preprocessor if !LOCKDEP. This will soon change. Signed-off-by: Jakub Kicinski --- CC: jiangshanlai@gmail.com CC: paulmck@kernel.org CC: josh@joshtriplett.org CC: rostedt@goodmis.org CC: mathieu.desnoyers@efficios.com --- kernel/rcu/srcutree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c index c100acf332ed..8123ef15a159 100644 --- a/kernel/rcu/srcutree.c +++ b/kernel/rcu/srcutree.c @@ -919,7 +919,7 @@ static void __synchronize_srcu(struct srcu_struct *ssp, bool do_norm) { struct rcu_synchronize rcu; - RCU_LOCKDEP_WARN(lock_is_held(&ssp->dep_map) || + RCU_LOCKDEP_WARN(lockdep_is_held(ssp) || lock_is_held(&rcu_bh_lock_map) || lock_is_held(&rcu_lock_map) || lock_is_held(&rcu_sched_lock_map), From patchwork Wed Sep 16 18:45:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 260773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 574B6C43461 for ; Wed, 16 Sep 2020 18:47:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 090B420732 for ; Wed, 16 Sep 2020 18:47:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600282060; bh=irzvRf7PhwsJvmwGcl2SYLLh2jImSgngjZEHOI6ZgHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=oWi24vgqzZPzzQRJDuvIP9zqox6BAhDyPWKillHfZte+eW25OQaGHfN3f/wiWuJSi czsUzODvOGMze7mB3pnyNL+xpxUQ8Cfz+k1X8jS3LGmjn7w9HFB0U/Inw2VwYLHya/ mTJSwUGHgCOmikt5z/PtIRDH01/KEoGByP45I5rM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728226AbgIPSrf (ORCPT ); Wed, 16 Sep 2020 14:47:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:44344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728156AbgIPSqO (ORCPT ); Wed, 16 Sep 2020 14:46:14 -0400 Received: from kicinski-fedora-PC1C0HJN.thefacebook.com (unknown [163.114.132.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E649221F0; Wed, 16 Sep 2020 18:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600281969; bh=irzvRf7PhwsJvmwGcl2SYLLh2jImSgngjZEHOI6ZgHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L3eSFrSAAuZloLBvrxMzAKZvqa5BEzcCYSHW/yAKM5NAlbmppVcwWz+ramz/Vmcpi SBrVlASyv5K/tfOF0Mu6Ereue0WGqS7KE/nUYhYVCiiZ0NMXOUUlTta2n+kfELejBh Zvof/qcaAIbwV0jGVv9ajqJzKT8KfecGf7N0URHw= From: Jakub Kicinski To: davem@davemloft.net, paulmck@kernel.org, joel@joelfernandes.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org, josh@joshtriplett.org, peterz@infradead.org, christian.brauner@ubuntu.com, Jakub Kicinski , mingo@redhat.com, will@kernel.org Subject: [PATCH net-next 6/7] lockdep: provide dummy forward declaration of *_is_held() helpers Date: Wed, 16 Sep 2020 11:45:27 -0700 Message-Id: <20200916184528.498184-7-kuba@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200916184528.498184-1-kuba@kernel.org> References: <20200916184528.498184-1-kuba@kernel.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When CONFIG_LOCKDEP is not set, lock_is_held() and lockdep_is_held() are not declared or defined. This forces all callers to use ifdefs around these checks. Recent RCU changes added a lot of lockdep_is_held() calls inside rcu_dereference_protected(). rcu_dereference_protected() hides its argument on !LOCKDEP builds, but this may lead to unused variable warnings. Provide forward declarations of lock_is_held() and lockdep_is_held() but never define them. This way callers can keep them visible to the compiler on !LOCKDEP builds and instead depend on dead code elimination to remove the references before the linker barfs. We need lock_is_held() for RCU. Signed-off-by: Jakub Kicinski --- CC: peterz@infradead.org CC: mingo@redhat.com CC: will@kernel.org --- include/linux/lockdep.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 6a584b3e5c74..6b5bbc536bf6 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -371,6 +371,12 @@ static inline void lockdep_unregister_key(struct lock_class_key *key) #define lockdep_depth(tsk) (0) +/* + * Dummy forward declarations, allow users to write less ifdef-y code + * and depend on dead code elimination. + */ +int lock_is_held(const void *); +int lockdep_is_held(const void *); #define lockdep_is_held_type(l, r) (1) #define lockdep_assert_held(l) do { (void)(l); } while (0)