Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932398AbVKLPfL (ORCPT ); Sat, 12 Nov 2005 10:35:11 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932400AbVKLPfK (ORCPT ); Sat, 12 Nov 2005 10:35:10 -0500 Received: from mx1.rowland.org ([192.131.102.7]:45062 "HELO mx1.rowland.org") by vger.kernel.org with SMTP id S932398AbVKLPfJ (ORCPT ); Sat, 12 Nov 2005 10:35:09 -0500 Date: Sat, 12 Nov 2005 10:35:07 -0500 (EST) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: "Paul E. McKenney" cc: Chandra Seetharaman , , Subject: Re: [Lse-tech] Subject: [RFC][PATCH] Fix for unsafe notifier chain mechanism In-Reply-To: <20051112052213.GB3335@us.ibm.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1690 Lines: 42 On Fri, 11 Nov 2005, Paul E. McKenney wrote: > > > > + down_write(&nh->rwsem); > > > > + nl = &nh->head; > > > > + while ((*nl) != NULL) { > > > > + if (n->priority > (*nl)->priority) > > > > + break; > > > > + nl = &((*nl)->next); > > > > + } > > > > + rcu_assign_pointer(n->next, *nl); > > > > > > The above can simply be "n->next = *nl;". The reason is that this change > > > of state is not visible to RCU readers until after the following statement, > > > and it therefore need not be an RCU-reader-safe assignment. You only need > > > to use rcu_assign_pointer() when the results of the assignment are > > > immediately visible to RCU readers. > > > > Correct, the rcu call isn't really needed. It doesn't hurt perceptibly, > > though, and part of the RCU documentation states: > > > > * ... More importantly, this > > * call documents which pointers will be dereferenced by RCU read-side > > * code. > > > > For that reason, I felt it was worth putting it in. > > But the following statement does a much better job of documenting the > pointer that is to be RCU-dereferenced. Duplicate documentation can > be just as confusing as no documentation. It's not really duplicate documentation since _both_ pointers are to be RCU-dereferenced. But maybe you mean that only the second pointer can be RCU-dereferenced at the time the write occurs? I don't think that's what the documentation comment intended. Alan Stern - 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/