Received: by 10.192.165.156 with SMTP id m28csp591020imm; Wed, 11 Apr 2018 04:21:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/q12pM4TX5R8DbtKC114LayctdeMf6d0DzNKlmhP/AW7q3QT+FwYccv+0d+j71PRHnByRB X-Received: by 10.99.95.142 with SMTP id t136mr3066576pgb.302.1523445677867; Wed, 11 Apr 2018 04:21:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523445677; cv=none; d=google.com; s=arc-20160816; b=CFXs4n4KO5DnnIYUBr0A1ejUEr+msBcofsF1+GXxLmMbD8eyXRp50FNiS8AaaQ0MaG KH1o8Pnf4418rdVZGV9fJqyu9MXNcYLTeiRnyBr9iSv3FOY6D8US9AVqz3lAPdIAW8lb aa+a+GZB6Fqfe3gdt23iHwAmkFs+CCjQSi8rKbWJEaX1FxPJlRFWS/yozdP7XxkmFKrE 0B7Cxb/6u5XXKBEtByIidymg2+GUuRvZjhY0OFTcdonAJIR5AevB8sqKCqxTkQWBRIow 3qfdCfh/k6IFZFNE1Hwz809ihf893XAUycodKluoOvYCWnbs37n1SsWl7TudusWsCWTz OYOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=iQuzMh97TIxgy8rL2xNJ6Ab1TrsFyLZQZDFgjTV2EIs=; b=gIGvz8GtiSXgS9J/9oIrWWVYwhmJbZqbhaAq/mVl/yMfjwTUSNATUIGl+LFsfaHKC4 BJVCKV6lZNbvQ6BXJAbkGQTkO7o1HVaU77K3bO2yQBmdqLqUmDIK93MW37JkkTYzphR7 1mPi6H/585qoUe5XLJIQfAwq426q9Xs5wKU9/0oF3JvVEWOOdSRSNXww3UlGkET+/gO6 qzq+ry/W3+GFbSXmb1CnwOP6xWNqK4rrFflmMbKvjWIU2Er8Gfg5e0E83J67WD71GRaZ tNVFsS1bXNuS1hK07OFHwmFNLAkir87OlZoPSn4y6xYzgv4dgYbzlg56wuz2vJW78RZ+ TKpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=dGgjl0ic; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j8si675365pfn.85.2018.04.11.04.20.40; Wed, 11 Apr 2018 04:21:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=dGgjl0ic; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753001AbeDKLQL (ORCPT + 99 others); Wed, 11 Apr 2018 07:16:11 -0400 Received: from mail-io0-f179.google.com ([209.85.223.179]:47036 "EHLO mail-io0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751819AbeDKLQJ (ORCPT ); Wed, 11 Apr 2018 07:16:09 -0400 Received: by mail-io0-f179.google.com with SMTP id q80so1900663ioi.13 for ; Wed, 11 Apr 2018 04:16:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:openpgp:autocrypt:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=iQuzMh97TIxgy8rL2xNJ6Ab1TrsFyLZQZDFgjTV2EIs=; b=dGgjl0icEChYK4WgPD/UDOn8VYGGo5kPUFnUGbzn1KNqLiVZAE67s/czIPEvk6spoo JpEc3qrMoWO/vdzsp/hvuZH+Ge3TVNXUDoWlJtLEY77iU/EPlP0Kn97MCeCF+GBMhgVp 7BYEV7nTQIGjy+MT+xol93ULD0KjyTZMug/j11ylvgZZeMyUIKbogmflPvdNeteJ4pKg Dji/RoazqFAwvXgHuYahnc8Eian82Yy/Xxj7zKG/5peeKnmH2ntM5qxhhfQjhpseSe14 sPOKXDasri6jNUMnTgpfswQni7HPgsKEUsoofT6hspDGD8zuNlR1/+vN0NvwvXsDbxmt Lfag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:openpgp :autocrypt:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=iQuzMh97TIxgy8rL2xNJ6Ab1TrsFyLZQZDFgjTV2EIs=; b=JszPatElVhKIVTpTUWQU1kJ3unmceiD5SJYmLQfmTmLDR0ddQC5ygeGMbvOyHQaHVl 4IZb2Md7Y6gwWMFsYWxZik84i0yL+GTN0RwZaONruNLVmjPAxWV3Sxq9HDPTJI0IZ5O/ Jy29wGQZMOYR9zbYcQrOubt6fhOKIXjDuGSKYm/4jAPUjWsQZCdLDATvVOc1Gr9VDFbW fH+hyIbAKYVMYInIceJBdmzs0vFK2ky6ojJac91ayTk3fbH9gWRRvYA/avOuOd51VNt0 t0FchpmPCxpKhmy0nAGUy9rS2JgM2q3qigXDRl6LyYfZSvCSOUhseZA2eDbiWRZrFlEa 3V3w== X-Gm-Message-State: ALQs6tBux3s1FbYjNFcw7NGWt4zkipOltfspLdpLbzgVqq0kbDPTFHp1 HzpxudmVrwvA7dd2a1f4hXatei2f X-Received: by 10.107.200.203 with SMTP id y194mr3985041iof.182.1523445368472; Wed, 11 Apr 2018 04:16:08 -0700 (PDT) Received: from [192.168.10.165] ([82.84.121.178]) by smtp.googlemail.com with ESMTPSA id z7sm387889iob.9.2018.04.11.04.16.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Apr 2018 04:16:07 -0700 (PDT) Subject: Re: [PATCH] memory-model: fix cheat sheet typo To: paulmck@linux.vnet.ibm.com Cc: linux-kernel@vger.kernel.org, Alan Stern , Andrea Parri , Will Deacon , Peter Zijlstra , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , Akira Yokosawa References: <1523292618-10207-1-git-send-email-pbonzini@redhat.com> <20180409184258.GP3948@linux.vnet.ibm.com> <20180410203214.GA19606@linux.vnet.ibm.com> <8cbda122-6aa3-365b-fd09-52dca0644cbd@redhat.com> <20180410213434.GC3948@linux.vnet.ibm.com> From: Paolo Bonzini Openpgp: preference=signencrypt Autocrypt: addr=pbonzini@redhat.com; keydata= xsEhBFRCcBIBDqDGsz4K0zZun3jh+U6Z9wNGLKQ0kSFyjN38gMqU1SfP+TUNQepFHb/Gc0E2 CxXPkIBTvYY+ZPkoTh5xF9oS1jqI8iRLzouzF8yXs3QjQIZ2SfuCxSVwlV65jotcjD2FTN04 hVopm9llFijNZpVIOGUTqzM4U55sdsCcZUluWM6x4HSOdw5F5Utxfp1wOjD/v92Lrax0hjiX DResHSt48q+8FrZzY+AUbkUS+Jm34qjswdrgsC5uxeVcLkBgWLmov2kMaMROT0YmFY6A3m1S P/kXmHDXxhe23gKb3dgwxUTpENDBGcfEzrzilWueOeUWiOcWuFOed/C3SyijBx3Av/lbCsHU Vx6pMycNTdzU1BuAroB+Y3mNEuW56Yd44jlInzG2UOwt9XjjdKkJZ1g0P9dwptwLEgTEd3Fo UdhAQyRXGYO8oROiuh+RZ1lXp6AQ4ZjoyH8WLfTLf5g1EKCTc4C1sy1vQSdzIRu3rBIjAvnC tGZADei1IExLqB3uzXKzZ1BZ+Z8hnt2og9hb7H0y8diYfEk2w3R7wEr+Ehk5NQsT2MPI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02v02 8TVAaYbIhxvDY0hUQE4r8ZbGRLn52bEzaIPgl1p/adKfeOUeMReg/CkyzQpmyB1TSk8lDMxQ zCYHXAzwnGi8WU9iuE1P0wARAQABwsEzBBgBAgAJBQJUQnHuAhsMAAoJEH4VEAzNNmmxp1EO oJy0uZggJm7gZKeJ7iUpeX4eqUtqelUw6gU2daz2hE/jsxsTbC/w5piHmk1H1VWDKEM4bQBT uiJ0bfo55SWsUNN+c9hhIX+Y8LEe22izK3w7mRpvGcg+/ZRG4DEMHLP6JVsv5GMpoYwYOmHn plOzCXHvmdlW0i6SrMsBDl9rw4AtIa6bRwWLim1lQ6EM3PWifPrWSUPrPcw4OLSwFk0CPqC4 HYv/7ZnASVkR5EERFF3+6iaaVi5OgBd81F1TCvCX2BEyIDRZLJNvX3TOd5FEN+lIrl26xecz 876SvcOb5SL5SKg9/rCBufdPSjojkGFWGziHiFaYhbuI2E+NfWLJtd+ZvWAAV+O0d8vFFSvr iy9enJ8kxJwhC0ECbSKFY+W1eTIhMD3aeAKY90drozWEyHhENf4l/V+Ja5vOnW+gCDQkGt2Y 1lJAPPSIqZKvHzGShdh8DduC0U3xYkfbGAUvbxeepjgzp0uEnBXfPTy09JGpgWbg0w91GyfT /ujKaGd4vxG2Ei+MMNDmS1SMx7wu0evvQ5kT9NPzyq8R2GIhVSiAd2jioGuTjX6AZCFv3ToO 53DliFMkVTecLptsXaesuUHgL9dKIfvpm+rNXRn9wAwGjk0X/A== Message-ID: <156ac07b-7393-449f-518a-6b1c2cff8efb@redhat.com> Date: Wed, 11 Apr 2018 13:15:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180410213434.GC3948@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/04/2018 23:34, Paul E. McKenney wrote: > Glad it helps, and I have queued it for the next merge window. Of course, > if a further improvement comes to mind, please do not keep it a secret. ;-) Yes, there are several changes that could be included: - SV could be added to the prior operation case as well? It should be symmetric - The *_relaxed() case also applies to void RMW - smp_store_mb() is missing - smp_rmb() orders prior reads fully against subsequent RMW because SV applies between the two parts of the RMW; likewise smp_wmb() orders prior RMW fully against subsequent writes I am going submit these changes separately, but before doing that I can show also my rewrite of the cheat sheet. The advantage is that, at least to me, it's clearer (and gets rid of "Self" :)). The disadvantage is that it's much longer---almost twice the lines, even if you discount the splitting out of cumulative/propagating to a separate table (which in turn is because to me it's a different level of black magic). --------------------- Memory operations are listed in this document as follows: R: Read portion of RMW W: Write portion of RMW DR: Dependent read (address dependency) DW: Dependent write (address, data, or control dependency) RMW: Atomic read-modify-write operation SV Other accesses to the same variable Memory access operations order other memory operations against themselves as follows: Prior Operation Subsequent Operation --------------- --------------------- R W RMW SV R W DR DW RMW SV - - --- -- - - -- -- --- -- Store, e.g., WRITE_ONCE() Y Y Load, e.g., READ_ONCE() Y Y Y Y Unsuccessful RMW operation Y Y Y Y *_relaxed() or void RMW operation Y Y Y Y rcu_dereference() Y Y Y Y Successful *_acquire() Y r r r r r Y Successful *_release() w w w Y Y smp_store_mb() Y Y Y Y Y Y Y Y Y Y Successful full non-void RMW Y Y Y Y Y Y Y Y Y Y Key: Y: Memory operation provides ordering r: Cannot move past the read portion of the *_acquire() w: Cannot move past the write portion of the *_release() Memory barriers order prior memory operations against subsequent memory operations. Two operations are ordered if both have non-empty cells in the following table: Prior Operation Subsequent Operation --------------- -------------------- R W RMW R W DR DW RMW - - --- - - -- -- --- smp_rmb() Y r Y Y Y smp_wmb() Y Y Y Y w smp_mb() & synchronize_rcu() Y Y Y Y Y Y Y Y smp_mb__before_atomic() Y Y Y a a a a Y smp_mb__after_atomic() a a Y Y Y Y Y Key: Y: Barrier provides ordering r: Barrier provides ordering against the read portion of RMW w: Barrier provides ordering against the write portion of RMW a: Barrier provides ordering given intervening RMW atomic operation Finally the following describes which operations provide cumulative and propagating fences: Cumulative Propagates ---------- ---------- Store, e.g., WRITE_ONCE() Load, e.g., READ_ONCE() Unsuccessful RMW operation *_relaxed() or void RMW operation rcu_dereference() Successful *_acquire() Successful *_release() Y smp_store_mb() Y Y Successful full non-void RMW Y Y smp_rmb() smp_wmb() smp_mb() & synchronize_rcu() Y Y smp_mb__before_atomic() Y Y smp_mb__after_atomic() Y Y ---------- Perhaps you can see some obvious improvements. Otherwise I'll send patches for the above issues. Thanks, Paolo