From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
Josh Triplett <josh@joshtriplett.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>
Subject: Re: [PATCH v2] hlist_add_tail_rcu disable sparse warning
Date: Wed, 1 Mar 2017 11:37:53 -0800 [thread overview]
Message-ID: <20170301193753.GN30506@linux.vnet.ibm.com> (raw)
In-Reply-To: <1488222831-26482-1-git-send-email-mst@redhat.com>
On Mon, Feb 27, 2017 at 09:14:19PM +0200, Michael S. Tsirkin wrote:
> sparse is unhappy about this code in hlist_add_tail_rcu:
>
> struct hlist_node *i, *last = NULL;
>
> for (i = hlist_first_rcu(h); i; i = hlist_next_rcu(i))
> last = i;
>
> This is because hlist_next_rcu and hlist_next_rcu return
> __rcu pointers.
>
> It's a false positive - it's a write side primitive and so
> does not need to be called in a read side critical section.
>
> The following trivial patch disables the warning
> without changing the behaviour in any way.
>
> Note: __hlist_for_each_rcu would also remove the warning but it would be
> confusing since it calls rcu_derefence and is designed to run in the rcu
> read side critical section.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Queud for further review and testing, thank you both!
Thanx, Paul
> ---
>
> Comments from v2:
> add a comment as requested by Steven Rostedt
>
> include/linux/rculist.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/rculist.h b/include/linux/rculist.h
> index 4f7a956..b1fd8bf 100644
> --- a/include/linux/rculist.h
> +++ b/include/linux/rculist.h
> @@ -509,7 +509,8 @@ static inline void hlist_add_tail_rcu(struct hlist_node *n,
> {
> struct hlist_node *i, *last = NULL;
>
> - for (i = hlist_first_rcu(h); i; i = hlist_next_rcu(i))
> + /* Note: write side code, so rcu accessors are not needed. */
> + for (i = h->first; i; i = i->next)
> last = i;
>
> if (last) {
> --
> MST
>
prev parent reply other threads:[~2017-03-03 3:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-27 19:14 Michael S. Tsirkin
2017-03-01 19:37 ` Paul E. McKenney [this message]
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=20170301193753.GN30506@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=mst@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome