Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1591656 > unrolled thread
| Started by | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| First post | 2017-03-03 04:50 +0100 |
| Last post | 2017-03-03 04:50 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v2] hlist_add_tail_rcu disable sparse warning "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2017-03-03 04:50 +0100
| From | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-03-03 04:50 +0100 |
| Subject | Re: [PATCH v2] hlist_add_tail_rcu disable sparse warning |
| Message-ID | <tgMoa-3DI-9@gated-at.bofh.it> |
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
>
Back to top | Article view | linux.kernel
csiph-web