From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758004AbdCUSKE (ORCPT ); Tue, 21 Mar 2017 14:10:04 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54398 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757975AbdCUSJ4 (ORCPT ); Tue, 21 Mar 2017 14:09:56 -0400 Date: Tue, 21 Mar 2017 11:09:50 -0700 From: "Paul E. McKenney" To: Michalis Kokologiannakis Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] doc: Update the comparisons rule in rcu_dereference.txt Reply-To: paulmck@linux.vnet.ibm.com References: <1490045915-18759-1-git-send-email-mixaskok@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1490045915-18759-1-git-send-email-mixaskok@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17032118-0040-0000-0000-000002F0BCFB X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006824; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000206; SDB=6.00836931; UDB=6.00411390; IPR=6.00614697; BA=6.00005227; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014745; XFM=3.00000013; UTC=2017-03-21 18:09:52 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17032118-0041-0000-0000-000006E4C279 Message-Id: <20170321180950.GN3637@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-21_16:,, 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-1703210154 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 20, 2017 at 10:38:35PM +0100, Michalis Kokologiannakis wrote: > When an RCU-protected pointer is fetched but never dereferenced > rcu_access_pointer() should be used in place of rcu_dereference(). > This commit explicitly records this very fact in Documentation/ > RCU/rcu_dereference.txt, in order to prevent the usage of > rcu_dereference() in comparisons. > > Signed-off-by: Michalis Kokologiannakis Queued for review, thank you! Thanx, Paul > --- > Documentation/RCU/rcu_dereference.txt | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/Documentation/RCU/rcu_dereference.txt b/Documentation/RCU/rcu_dereference.txt > index c0bf244..b2a613f 100644 > --- a/Documentation/RCU/rcu_dereference.txt > +++ b/Documentation/RCU/rcu_dereference.txt > @@ -138,6 +138,15 @@ o Be very careful about comparing pointers obtained from > This sort of comparison occurs frequently when scanning > RCU-protected circular linked lists. > > + Note that if checks for being within an RCU read-side > + critical section are not required and the pointer is never > + dereferenced, rcu_access_pointer() should be used in place > + of rcu_dereference(). The rcu_access_pointer() primitive > + does not require an enclosing read-side critical section, > + and also omits the smp_read_barrier_depends() included in > + rcu_dereference(), which in turn should provide a small > + performance gain in some CPUs (e.g., the DEC Alpha). > + > o The comparison is against a pointer that references memory > that was initialized "a long time ago." The reason > this is safe is that even if misordering occurs, the > -- > 2.1.4 >