Re: [srcu] Can we suppress sparse warning?
From: Paul E. McKenney
Date: Wed Nov 09 2016 - 13:58:58 EST
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