Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753378AbaKRAkA (ORCPT ); Mon, 17 Nov 2014 19:40:00 -0500 Received: from gate.crashing.org ([63.228.1.57]:52749 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752155AbaKRAj6 (ORCPT ); Mon, 17 Nov 2014 19:39:58 -0500 Message-ID: <1416271083.18381.14.camel@kernel.crashing.org> Subject: Re: [PATCH 2/4] arch: Add lightweight memory barriers fast_rmb() and fast_wmb() From: Benjamin Herrenschmidt To: paulmck@linux.vnet.ibm.com Cc: Alexander Duyck , linux-arch@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, mathieu.desnoyers@polymtl.ca, peterz@infradead.org, heiko.carstens@de.ibm.com, mingo@kernel.org, mikey@neuling.org, linux@arm.linux.org.uk, donald.c.skidmore@intel.com, matthew.vick@intel.com, geert@linux-m68k.org, jeffrey.t.kirsher@intel.com, romieu@fr.zoreil.com, nic_swsd@realtek.com, will.deacon@arm.com, michael@ellerman.id.au, tony.luck@intel.com, torvalds@linux-foundation.org, oleg@redhat.com, schwidefsky@de.ibm.com, fweisbec@gmail.com, davem@davemloft.net Date: Tue, 18 Nov 2014 11:38:03 +1100 In-Reply-To: <20141117201823.GD5050@linux.vnet.ibm.com> References: <20141117171005.22333.96544.stgit@ahduyck-server> <20141117171812.22333.90395.stgit@ahduyck-server> <20141117201823.GD5050@linux.vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.7-0ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2014-11-17 at 12:18 -0800, Paul E. McKenney wrote: > On Mon, Nov 17, 2014 at 09:18:13AM -0800, Alexander Duyck wrote: > > There are a number of situations where the mandatory barriers rmb() and > > wmb() are used to order memory/memory operations in the device drivers > > and those barriers are much heavier than they actually need to be. For > > example in the case of PowerPC wmb() calls the heavy-weight sync > > instruction when for memory/memory operations all that is really needed is > > an lsync or eieio instruction. > > Is this still the case if one of the memory operations is MMIO? Last > I knew, it was not. I *think* (Alexander, correct me if I'm wrong), that what he wants is the memory<->memory barriers (the smp_* ones) basically for ordering his loads or stores from/to the DMA area. The problem is that the smp_* ones aren't compiled for !CONFIG_SMP IE. Something like: - Read valid bit from descriptor - Read rest of descriptor That needs an rmb of some sort in between, but a full blown "rmb" will also order vs. MMIOs and end up being a full sync, while an smp_rmb is a lwsync which is more lightweight. Similarily: - Populate descriptor - Write valid bit Same deal with wmb ... Basically, rmb and wmb order both cachable and non-cachable (memory and MMIO) which makes them needlessly heavy on powerpc and possibly others when all you need is to order memory accesses to some DMA data structures. In that case you really want the normal smp_* variants except they may not be around... Cheers, Ben. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/