[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200908173624.160024-1-kuba@kernel.org>
Date: Tue, 8 Sep 2020 10:36:24 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org, paulmck@...nel.org, joel@...lfernandes.org,
josh@...htriplett.org, peterz@...radead.org,
christian.brauner@...ntu.com, rcu@...r.kernel.org,
linux-kernel@...r.kernel.org, nikolay@...ulusnetworks.com,
sfr@...b.auug.org.au, roopa@...dia.com,
Jakub Kicinski <kuba@...nel.org>
Subject: [PATCH net-next] rcu: prevent RCU_LOCKDEP_WARN() from swallowing the condition
We run into a unused variable warning in bridge code when
variable is only used inside the condition of
rcu_dereference_protected().
#define mlock_dereference(X, br) \
rcu_dereference_protected(X, lockdep_is_held(&br->multicast_lock))
Since on builds with CONFIG_PROVE_RCU=n rcu_dereference_protected()
compiles to nothing the compiler doesn't see the variable use.
Prevent the warning by adding the condition as dead code.
We need to un-hide the declaration of lockdep_tasklist_lock_is_held()
and fix a bug the crept into a net/sched header.
Signed-off-by: Jakub Kicinski <kuba@...nel.org>
---
include/linux/rcupdate.h | 2 +-
include/linux/sched/task.h | 2 --
include/net/sch_generic.h | 2 +-
3 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index d15d46db61f7..cf3d3ba3f3e4 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -320,7 +320,7 @@ static inline void rcu_preempt_sleep_check(void) { }
#else /* #ifdef CONFIG_PROVE_RCU */
-#define RCU_LOCKDEP_WARN(c, s) do { } while (0)
+#define RCU_LOCKDEP_WARN(c, s) do { } while (0 && (c))
#define rcu_sleep_check() do { } while (0)
#endif /* #else #ifdef CONFIG_PROVE_RCU */
diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h
index a98965007eef..9f943c391df9 100644
--- a/include/linux/sched/task.h
+++ b/include/linux/sched/task.h
@@ -47,9 +47,7 @@ extern spinlock_t mmlist_lock;
extern union thread_union init_thread_union;
extern struct task_struct init_task;
-#ifdef CONFIG_PROVE_RCU
extern int lockdep_tasklist_lock_is_held(void);
-#endif /* #ifdef CONFIG_PROVE_RCU */
extern asmlinkage void schedule_tail(struct task_struct *prev);
extern void init_idle(struct task_struct *idle, int cpu);
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index d60e7c39d60c..eb68cc6e4e79 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -443,7 +443,7 @@ 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)
+static inline bool lockdep_tcf_chain_is_locked(struct tcf_chain *chain)
{
return true;
}
--
2.24.1
Powered by blists - more mailing lists