Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754684AbdGJUjx (ORCPT ); Mon, 10 Jul 2017 16:39:53 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:36539 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754593AbdGJUju (ORCPT ); Mon, 10 Jul 2017 16:39:50 -0400 Date: Mon, 10 Jul 2017 13:39:48 -0700 (PDT) X-Google-Original-Date: Mon, 10 Jul 2017 13:36:02 PDT (-0700) Subject: Re: [PATCH 2/9] RISC-V: Atomic and Locking Code In-Reply-To: <20170707080819.krtmzeqlyrl6c35p@hirez.programming.kicks-ass.net> CC: mingo@redhat.com, mcgrof@kernel.org, viro@zeniv.linux.org.uk, sfr@canb.auug.org.au, nicolas.dichtel@6wind.com, rmk+kernel@armlinux.org.uk, msalter@redhat.com, tklauser@distanz.ch, will.deacon@arm.com, james.hogan@imgtec.com, paul.gortmaker@windriver.com, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, albert@sifive.com, patches@groups.riscv.org From: Palmer Dabbelt To: peterz@infradead.org Message-ID: Mime-Version: 1.0 (MHng) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1213 Lines: 30 On Fri, 07 Jul 2017 01:08:19 PDT (-0700), peterz@infradead.org wrote: > On Thu, Jul 06, 2017 at 06:04:13PM -0700, Palmer Dabbelt wrote: >> +/* >> + * TODO_RISCV_MEMORY_MODEL: I don't think RISC-V is allowed to perform a >> + * speculative load, but we're going to wait on a formal memory model in order >> + * to ensure this is safe to elide. >> + */ >> +#define smp_acquire__after_ctrl_dep() smp_mb() > > So typically a control dependency already provides read->write ordering, > by virtue of speculative writes being BAD. > > So a control dependency only needs to provide read->read ordering in > addition to the existing read->write ordering and hence this barrier is > typically a smp_rmb(). > > See the definition in asm-generic/barrier.h. > > Having to use a full barrier here would imply your architecture does not > respect control dependencies, which would be BAD because we actually > rely on them. > > So either the normal definition is good and you don't need to do > anything, or you prohibit read speculation in which case you have a > special case like TILE does. I'd be very surprised (and very unhappy) if we ended up with speculative writes, as that would be a huge mess. Thanks!