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: Sat, 12 Nov 2016 11:17:32 -0800 [thread overview]
Message-ID: <20161112191732.GB4127@linux.vnet.ibm.com> (raw)
In-Reply-To: <201611122326.GGI69239.OJLFtQVFMHOFSO@I-love.SAKURA.ne.jp>
On Sat, Nov 12, 2016 at 11:26:15PM +0900, Tetsuo Handa wrote:
> Paul E. McKenney wrote:
> > 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?
>
> Sorry, I wrote this code for only showing warning message.
> This self-referential has no intention.
>
> Well, you can reproduce this warning with current linux.git by running
> make C=1 security/tomoyo/ with CONFIG_SECURITY_TOMOYO=y .
>
> security/tomoyo/common.c:896:9: error: incompatible types in comparison expression (different address spaces)
> security/tomoyo/common.c:896:9: error: incompatible types in comparison expression (different address spaces)
>
> ---------- security/tomoyo/common.c ----------
> 896: list_for_each_cookie(head->r.acl, &tomoyo_kernel_namespace.
> 897: policy_list[TOMOYO_ID_MANAGER]) {
>
> ---------- security/tomoyo/common.h ----------
> 1320: /**
> 1321: * list_for_each_cookie - iterate over a list with cookie.
> 1322: * @pos: the &struct list_head to use as a loop cursor.
> 1323: * @head: the head for your list.
> 1324: */
> 1325: #define list_for_each_cookie(pos, head) \
> 1326: if (!pos) \
> 1327: pos = srcu_dereference((head)->next, &tomoyo_ss); \
> 1328: for ( ; pos != (head); pos = srcu_dereference(pos->next, &tomoyo_ss))
This definition will be fun if used in an "if" statement, but I will leave
that in your capable hands.
>
> Both head->r.acl and &tomoyo_kernel_namespace.policy_list[TOMOYO_ID_MANAGER]->next
> refer normal kernel address space. Thus, I think that this warning is a false positive.
>
> This warning goes away if I disable rcu_dereference_sparse() call in
> __rcu_dereference_check() from srcu_dereference_check() from srcu_dereference().
>
> --- 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); */ \
> ((typeof(*p) __force __kernel *)(________p1)); \
> })
> #define __rcu_dereference_protected(p, c, space) \
OK.
One approach would be for you to replace your:
pos = srcu_dereference((head)->next, &tomoyo_ss);
with:
pos = ecu_dereference_raw((head)->next);
This will suppress the sparse complaint, but would also suppress the
lockdep complaint about using list_for_each_cookie() unprotected by an
SRCU read-side critical section. But this can be handled by placing an
appropriate RCU_LOCKDEP_WARN() in list_for_each_cookie().
Does that work for you?
Thanx, Paul
next prev parent reply other threads:[~2016-11-12 19:17 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
2016-11-12 14:26 ` Tetsuo Handa
2016-11-12 19:17 ` Paul E. McKenney [this message]
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=20161112191732.GB4127@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.