Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933984AbbDQPzy (ORCPT ); Fri, 17 Apr 2015 11:55:54 -0400 Received: from mail-oi0-f51.google.com ([209.85.218.51]:36813 "EHLO mail-oi0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932809AbbDQPzv (ORCPT ); Fri, 17 Apr 2015 11:55:51 -0400 MIME-Version: 1.0 In-Reply-To: <1429266816-27004-1-git-send-email-milos@redhat.com> References: <1429266816-27004-1-git-send-email-milos@redhat.com> From: Pranith Kumar Date: Fri, 17 Apr 2015 11:55:20 -0400 Message-ID: Subject: Re: [PATCH] rcu: small rcu_dereference doc update To: Milos Vyletel Cc: "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Jonathan Corbet , "open list:READ-COPY UPDATE..." , "open list:DOCUMENTATION" , jeff.haran@citrix.com Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1661 Lines: 50 On Fri, Apr 17, 2015 at 6:33 AM, Milos Vyletel wrote: > Make a note stating that repeated calls of rcu_dereference() may not > return the same pointer if update happens while in critical section. Might as well make it more explicit with an example then. See below: > > Reported-by: Jeff Haran > Signed-off-by: Milos Vyletel > --- > Documentation/RCU/whatisRCU.txt | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt > index 88dfce1..82b1b2c 100644 > --- a/Documentation/RCU/whatisRCU.txt > +++ b/Documentation/RCU/whatisRCU.txt > @@ -256,7 +256,9 @@ rcu_dereference() > If you are going to be fetching multiple fields from the > RCU-protected structure, using the local variable is of > course preferred. Repeated rcu_dereference() calls look > - ugly and incur unnecessary overhead on Alpha CPUs. > + ugly, do not guarantee that same pointer will be returned > + if update happened while in critical section and incur > + unnecessary overhead on Alpha CPUs. > An example like follows: struct some_ds { int data; bool ready; }; struct some_ds *p = ...; rcu_read_lock(); if (rcu_dereference(p->ready)) data = rcu_dereference(p->data); // bug rcu_read_unlock(); or some such. -- Pranith -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/