Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751625AbdFGM1Y (ORCPT ); Wed, 7 Jun 2017 08:27:24 -0400 Received: from merlin.infradead.org ([205.233.59.134]:48312 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751470AbdFGMZo (ORCPT ); Wed, 7 Jun 2017 08:25:44 -0400 Date: Wed, 7 Jun 2017 14:25:38 +0200 From: Peter Zijlstra To: Palmer Dabbelt Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann , olof@lixom.net, albert@sifive.com, patches@groups.riscv.org Subject: Re: [PATCH 13/17] RISC-V: Add include subdirectory Message-ID: <20170607122538.jy3nps6erhlfi4bh@hirez.programming.kicks-ass.net> References: <20170523004107.536-1-palmer@dabbelt.com> <20170606230007.19101-1-palmer@dabbelt.com> <20170606230007.19101-14-palmer@dabbelt.com> <20170607115423.qdhpl5dhtmmq4q4u@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170607115423.qdhpl5dhtmmq4q4u@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1159 Lines: 27 On Wed, Jun 07, 2017 at 01:54:23PM +0200, Peter Zijlstra wrote: > On Tue, Jun 06, 2017 at 04:00:03PM -0700, Palmer Dabbelt wrote: > > +/* Assume that atomic operations are already serializing */ > > +#define smp_mb__before_atomic_dec() barrier() > > +#define smp_mb__after_atomic_dec() barrier() > > +#define smp_mb__before_atomic_inc() barrier() > > +#define smp_mb__after_atomic_inc() barrier() > > > +#define smp_mb__before_clear_bit() smp_mb() > > +#define smp_mb__after_clear_bit() smp_mb() > > These no longer exist.. Also how can they be different? bitops would use > the same atomic primitives as regular atomic ops would and would thus > have the very same implicit ordering. Your manual states that each atomic instruction (be it AMO or LR/SC) have two ordering bits: AQ and RL. If neither are set the instruction is unordered, if either one is set, its either an ACQUIRE or a RELEASE and if both are set its SC. So you can in fact make the above happen, however your atomic implementation does not appear to use ".aq.rl" mnemonics so would be entirely unordered, just like your bitops. Therefore the above is just plain wrong and broken.