From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753567AbdKIR0a (ORCPT ); Thu, 9 Nov 2017 12:26:30 -0500 Received: from mx2.suse.de ([195.135.220.15]:60416 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753016AbdKIR00 (ORCPT ); Thu, 9 Nov 2017 12:26:26 -0500 Date: Thu, 9 Nov 2017 09:24:08 -0800 From: Davidlohr Bueso To: Boqun Feng Cc: Andreas Dilger , Jan Kara , Waiman Long , Alexander Viro , Jan Kara , Jeff Layton , "J. Bruce Fields" , Tejun Heo , Christoph Lameter , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Andi Kleen , Dave Chinner Subject: Re: [PATCH v4] lib/dlock-list: Scale dlock_lists_empty() Message-ID: <20171109172408.q5oo7u5skc5vjswb@linux-n805> References: <1509475860-16139-2-git-send-email-longman@redhat.com> <20171102170431.oq3i5mxtjcg53uot@linux-n805> <81bb3365-63f3-fea8-d238-e3880a4c8033@redhat.com> <20171103133420.pngmrsfmtimataz4@linux-n805> <20171103142254.d55bu2n44xe4aruf@linux-n805> <20171106184708.kmwfcchjwjzucuja@linux-n805> <20171107115921.GC11391@quack2.suse.cz> <20171108020834.GC6280@tardis> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="nrdk2jrsgy2mdrrj" Content-Disposition: inline In-Reply-To: <20171108020834.GC6280@tardis> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --nrdk2jrsgy2mdrrj Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline On Wed, 08 Nov 2017, Boqun Feng wrote: >Or worse: > > * CPU0 CPU1 > * dlock_list_add() dlock_lists_empty() > * smp_mb__before_atomic(); > * [L] atomic_read(used_lists) > * [S] atomic_inc(used_lists); > * smp_mb__after_atomic(); > >, in which case dlock_lists_empty() misses a increment of used_lists. > >That said, this may be fine for the usage of dlock_list. But I think the >comments are confusing or wrong. The reason is you can not use barriers >to order two memory ops on different CPUs, and usually we add comments >like: So I think that case is OK as CPU1 legitimately reads a 0, the problem would be if we miss the inc it because we are doing spin_lock(). > > [S] ... [S] ... > > [L] ... [L] ... That is true. > >Davidlohr, could you try to improve the comments by finding both memory >ops preceding and following the barriers? Maybe you will find those >barriers are not necessary in the end. Ok so for the dlock_list_add() the first barrier is so that the atomic_inc() is not done inside the critical region, after the head->lock is taken. The other barriers that follow I put such that the respective atomic op is done before the list_add(), however thinking about it I don't think they are really needed. Regarding dlock_list_empty(), the smp_mb__before_atomic() is mainly for pairing reasons; but at this point I don't see a respective counterpart for the above diagram so I'm unclear. Thanks, Davidlohr --nrdk2jrsgy2mdrrj Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJaBI84AAoJEF08bMdqyvoC0mAP/RNnR23NsEZ4E3sGgfvkYJxG 43bXdWBUQabpAF4SBWZhBRz5VUNI73n8wOXJsz+ukrEBN9H1w3h8KPjNe5wKNeBC o6dB82BnpGF0aA12P9rhwA6fhg6Nfq3EVUFaaICbNNVF2r9zQZ8ONxEXDFNMyB3X nOBI90hPr5tjyKchzQhjVosYJLOF+/XF1Qt2sFx22XHeF0+4G5B+D7L1sTOwPXcB TvkHYgwreH/QWgwM1pDFfUhfEf7bhyfbdhcrii9JcNVcb7XHDim++YDYkY/EYv+y 25hzfkEdxulTVbf8fyYRnArXwkbIJVJvkDHEDv72BqR/I3e/QEEdSviH8C9sYMol NoD52IyFcWrZV+Mo3TNDS0LRgTXbUcuUFXLIiUK14+m2uitaYnCLm3E646GeRHst Hpl5LOcInE/+CcQpSiwpcVqG/qzmGREfn0XXKVKexIBkCoTcWfeolRIykEaZvo12 yKSGQ03RO59VHQEQ204OLhIq1wTSjn1OVPyLEvNtvUI+QW1rg/DOaIfxfa5ZwLEV 7zblWNIFXFbNxv8qzq0RH0UqAcDvd6ke3Y9FIbsnckG/TU1ARC2DTct8lNSqipML FDQTn3TDmszZLrhrPaWlTkwWBZrYZ4rZPt/nVbSmStaqupQUcJzY6Ugd/q4lVeXz xxprzZdVd44L3L4tQrm6 =OfBb -----END PGP SIGNATURE----- --nrdk2jrsgy2mdrrj--