From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751552AbdCCDj4 (ORCPT ); Thu, 2 Mar 2017 22:39:56 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36556 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751276AbdCCDjz (ORCPT ); Thu, 2 Mar 2017 22:39:55 -0500 Date: Wed, 1 Mar 2017 11:37:53 -0800 From: "Paul E. McKenney" To: "Michael S. Tsirkin" Cc: linux-kernel@vger.kernel.org, Steven Rostedt , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan Subject: Re: [PATCH v2] hlist_add_tail_rcu disable sparse warning Reply-To: paulmck@linux.vnet.ibm.com References: <1488222831-26482-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1488222831-26482-1-git-send-email-mst@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17030303-0016-0000-0000-00000656D3EB X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006712; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000206; SDB=6.00829332; UDB=6.00406571; IPR=6.00606828; BA=6.00005186; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014503; XFM=3.00000012; UTC=2017-03-03 03:38:02 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17030303-0017-0000-0000-000037E4D48C Message-Id: <20170301193753.GN30506@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-03_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703030030 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Reviewed-by: Steven Rostedt (VMware) 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 >