From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753163AbcGFIOS (ORCPT ); Wed, 6 Jul 2016 04:14:18 -0400 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:45793 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752507AbcGFIOO (ORCPT ); Wed, 6 Jul 2016 04:14:14 -0400 X-Original-SENDERIP: 156.147.1.151 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com Date: Wed, 6 Jul 2016 17:12:26 +0900 From: Byungchul Park To: Peter Zijlstra Cc: Boqun Feng , mingo@kernel.org, linux-kernel@vger.kernel.org, walken@google.com Subject: Re: [PATCH] lockdep: Add a document describing crossrelease feature Message-ID: <20160706081226.GC2279@X58A-UD3R> References: <1466398527-1122-1-git-send-email-byungchul.park@lge.com> <1467346538-1579-1-git-send-email-byungchul.park@lge.com> <20160701104521.GG30154@twins.programming.kicks-ass.net> <20160704064259.GX2279@X58A-UD3R> <20160706004943.GA20366@insomnia> <20160706021710.GA2279@X58A-UD3R> <20160706053328.GB2279@X58A-UD3R> <20160706075608.GE30921@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160706075608.GE30921@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 06, 2016 at 09:56:08AM +0200, Peter Zijlstra wrote: > On Wed, Jul 06, 2016 at 02:33:29PM +0900, Byungchul Park wrote: > > On Wed, Jul 06, 2016 at 11:17:10AM +0900, Byungchul Park wrote: > > > > > > lock(A) > > > wait_for(B) > > > ~~~~~~~~~~~~~~~~~~~~~~~~ <- serialized by atomic operation > > > lock(A) > > > unlock(A) > > > wake(B) > > > unlock(A) > > > > By the way, I have a question. Is there anyone who could answer it? > > > > I want to serialize between two context's lock operations, for example, > > > > context A context B > > -------------- -------------- > > lock A > > lock B ... > > lock C > > atomic_inc_return > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <- serialization > > atomic_read > > lock D > > ... lock E > > lock F > > > > so that we can see these in the order like A -> B -> C -> D -> E -> F. > > > > atomic_inc_return() is used after lock C in context A, and atomic_read() > > is used before lock D in context B. And I want to make it serialized when > > the atomic_read() can see the increased value. > > > > Can I use smp_mb__after_atomic() just after atomic_read() > > No. atomic_set() and atomic_read() are not RmW operations. > > > or should I use > > smp_mb()? I think anyway I have to choose one of them for that ordering. > > smp_load_acquire(), if that observes the increment it will ensure D > comes after etc.. > > Also, atomic_read() _could_ be enough, if its part of a control > dependency, because LOCK very much involves a store, so the load->store > order provided by the control dependency will already order things. Indeed. Thank you very much. I can rely on the control dependency if possible. I will check it. Thank you, Byungchul