Re: [PATCH net-next] rcu: prevent RCU_LOCKDEP_WARN() from swallowing the condition

From: David Miller
Date: Tue Sep 08 2020 - 23:12:56 EST


From: Jakub Kicinski <kuba@xxxxxxxxxx>
Date: Tue, 8 Sep 2020 10:36:24 -0700

> 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@xxxxxxxxxx>

I ended up applying Nikolay's fix, but this situation with the rcu macros
needs to be addressed.