Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754083AbbL3CT1 (ORCPT ); Tue, 29 Dec 2015 21:19:27 -0500 Received: from mail-oi0-f49.google.com ([209.85.218.49]:35264 "EHLO mail-oi0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750908AbbL3CTY (ORCPT ); Tue, 29 Dec 2015 21:19:24 -0500 MIME-Version: 1.0 In-Reply-To: <20151230002640.GL4054@linux.vnet.ibm.com> References: <20151230002640.GL4054@linux.vnet.ibm.com> From: Jianyu Zhan Date: Wed, 30 Dec 2015 10:18:44 +0800 Message-ID: Subject: Re: Inconsistent description in memory-barrier.txt To: Paul McKenney Cc: LKML 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: 2526 Lines: 57 On Wed, Dec 30, 2015 at 8:26 AM, Paul E. McKenney wrote: > It looks like you are quite correct, good catch! Does the patch below > fix this? > > Thanx, Paul > > ------------------------------------------------------------------------ > > commit add179813efa2ba8a4afd29828d3335cf346d2a8 > Author: Paul E. McKenney > Date: Tue Dec 29 16:23:18 2015 -0800 > > documentation: Fix control dependency and identical stores > > The summary of the "CONTROL DEPENDENCIES" section incorrectly states that > barrier() may be used to prevent compiler reordering when more than one > leg of the control-dependent "if" statement start with identical stores. > This is incorrect at high optimization levels. This commit therefore > updates the summary to match the detailed description. > > Reported by: Jianyu Zhan > Signed-off-by: Paul E. McKenney > > diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt > index 85304ebd187c..50190368400c 100644 > --- a/Documentation/memory-barriers.txt > +++ b/Documentation/memory-barriers.txt > @@ -800,9 +800,13 @@ In summary: > use smp_rmb(), smp_wmb(), or, in the case of prior stores and > later loads, smp_mb(). > > - (*) If both legs of the "if" statement begin with identical stores > - to the same variable, a barrier() statement is required at the > - beginning of each leg of the "if" statement. > + (*) If both legs of the "if" statement begin with identical stores to > + the same variable, then those stores must be ordered, either by > + preceding both of them with smp_mb() or by using smp_store_release() > + to carry out the stores. Please note that it is -not- sufficient > + to use barrier() at beginning of each leg of the "if" statement, > + as optimizing compilers do not necessarily respect barrier() > + in this case. > > (*) Control dependencies require at least one run-time conditional > between the prior load and the subsequent store, and this Yep. It looks good to me. Concise, precise wording, as always. Thanks, Jianyu Zhan -- 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/