All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: josh@joshtriplett.org, rostedt@goodmis.org,
	mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com,
	linux-kernel@vger.kernel.org
Subject: Re: [srcu] Can we suppress sparse warning?
Date: Wed, 9 Nov 2016 10:58:10 -0800	[thread overview]
Message-ID: <20161109185810.GM4127@linux.vnet.ibm.com> (raw)
In-Reply-To: <201611092036.DAJ05243.HOOMQSVOJFFLtF@I-love.SAKURA.ne.jp>

On Wed, Nov 09, 2016 at 08:36:31PM +0900, Tetsuo Handa wrote:
> Hello.
> 
> When I build
> 
> ---------- test/test.c ----------
> #include <linux/module.h>
> 
> static int __init test_init(void)
> {
>         DEFINE_SRCU(srcu);
>         int idx = srcu_read_lock(&srcu);
>         void *ptr = srcu_dereference(ptr, &srcu);

I am really confused by the above line of code...

>         srcu_read_unlock(&srcu, idx);
>         return -EINVAL;
> }
> 
> module_init(test_init);
> MODULE_LICENSE("GPL");
> ---------- test/test.c ----------
> 
> with C=1 option, I get
> 
>   test/test.c:7:21: error: incompatible types in comparison expression (different address spaces)
> 
> warning from
> 
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -605,7 +605,7 @@ static inline void rcu_preempt_sleep_check(void)
>         /* Dependency order vs. p above. */ \
>         typeof(*p) *________p1 = (typeof(*p) *__force)lockless_dereference(p); \
>         RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_check() usage"); \
> -       rcu_dereference_sparse(p, space); \
> +       rcu_dereference_sparse(p, space); /** this line **/ \
>         ((typeof(*p) __force __kernel *)(________p1)); \
>  })
>  #define __rcu_dereference_protected(p, c, space) \
> 
> . 
> 
> I want to use srcu_dereference() at
> https://lists.01.org/pipermail/kbuild-all/2016-October/026587.html .
> Can we have srcu version of 995f1405610bd844 ("rcu: Suppress sparse
> warnings for rcu_dereference_raw()") ?

Notwithstanding my confusion about what your self-referential
srcu_dereference() is intended to achieve, what happens if you change the
"void *ptr = srcu_dereference(ptr, &srcu);" to add __rcu?

	void __rcu *ptr = srcu_dereference(ptr, &srcu);

Or, more to the point:

	void __rcu *gptr;

	void *lptr = srcu_dereference(ptr, &srcu);

							Thanx, Paul

  reply	other threads:[~2016-11-09 18:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-09 11:36 [srcu] Can we suppress sparse warning? Tetsuo Handa
2016-11-09 18:58 ` Paul E. McKenney [this message]
2016-11-12 14:26   ` Tetsuo Handa
2016-11-12 19:17     ` Paul E. McKenney
2016-11-13 12:55       ` Tetsuo Handa

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=20161109185810.GM4127@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=rostedt@goodmis.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.