From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751557AbdB0Svp (ORCPT ); Mon, 27 Feb 2017 13:51:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36564 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751344AbdB0Svn (ORCPT ); Mon, 27 Feb 2017 13:51:43 -0500 Date: Mon, 27 Feb 2017 20:26:01 +0200 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , David Miller Subject: Re: [PATCH] hlist_add_tail_rcu disable sparse warning Message-ID: <20170227202547-mutt-send-email-mst@kernel.org> References: <1486748308-16653-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1486748308-16653-1-git-send-email-mst@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 27 Feb 2017 18:26:03 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 10, 2017 at 07:39:49PM +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 > --- ping > changes since RFC > added commit log text to explain why don't we use __hlist_for_each_rcu > > include/linux/rculist.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/rculist.h b/include/linux/rculist.h > index 4f7a956..bf578e8 100644 > --- a/include/linux/rculist.h > +++ b/include/linux/rculist.h > @@ -509,7 +509,7 @@ 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)) > + for (i = h->first; i; i = i->next) > last = i; > > if (last) { > -- > MST