netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: nikolay@cumulusnetworks.com
To: Jakub Kicinski <kuba@kernel.org>, davem@davemloft.net
Cc: netdev@vger.kernel.org, paulmck@kernel.org,
	joel@joelfernandes.org, josh@joshtriplett.org,
	peterz@infradead.org, christian.brauner@ubuntu.com,
	rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
	sfr@canb.auug.org.au, roopa@nvidia.com
Subject: Re: [PATCH net-next] rcu: prevent RCU_LOCKDEP_WARN() from swallowing the condition
Date: Tue, 08 Sep 2020 21:15:56 +0300	[thread overview]
Message-ID: <5ABC15D5-3709-4CA4-A747-6A7812BB12DD@cumulusnetworks.com> (raw)
In-Reply-To: <20200908173624.160024-1-kuba@kernel.org>

On 8 September 2020 20:36:24 EEST, Jakub Kicinski <kuba@kernel.org> wrote:
>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@kernel.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;
> }

Ah, you want to solve it for all. :) 
Looks and sounds good to me, 
Reviewed-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>


  reply	other threads:[~2020-09-08 18:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08  3:00 linux-next: build warning after merge of the net-next tree Stephen Rothwell
2020-09-08  3:49 ` Jakub Kicinski
2020-09-08  7:17 ` [PATCH net-next] net: bridge: mcast: fix unused br var when lockdep isn't defined Nikolay Aleksandrov
2020-09-08 16:00   ` Jakub Kicinski
2020-09-08 16:09     ` nikolay
2020-09-08 17:36     ` [PATCH net-next] rcu: prevent RCU_LOCKDEP_WARN() from swallowing the condition Jakub Kicinski
2020-09-08 18:15       ` nikolay [this message]
2020-09-09  0:27         ` Jakub Kicinski
2020-09-14 20:21           ` Joel Fernandes
2020-09-14 22:47             ` Jakub Kicinski
2020-09-15  0:20               ` Paul E. McKenney
2020-09-15  0:30                 ` Jakub Kicinski
2020-09-15 17:02                   ` Paul E. McKenney
2020-09-15  1:34               ` Joel Fernandes
2020-09-09  3:12       ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5ABC15D5-3709-4CA4-A747-6A7812BB12DD@cumulusnetworks.com \
    --to=nikolay@cumulusnetworks.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=davem@davemloft.net \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rcu@vger.kernel.org \
    --cc=roopa@nvidia.com \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).