From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757305AbbCPRZJ (ORCPT ); Mon, 16 Mar 2015 13:25:09 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:34140 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754427AbbCPRZH (ORCPT ); Mon, 16 Mar 2015 13:25:07 -0400 Date: Mon, 16 Mar 2015 18:24:45 +0100 From: Peter Zijlstra To: Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, KOSAKI Motohiro , Steven Rostedt , "Paul E. McKenney" , Nicholas Miell , Linus Torvalds , Ingo Molnar , Alan Cox , Lai Jiangshan , Stephen Hemminger , Andrew Morton , Josh Triplett , Thomas Gleixner , David Howells , Nick Piggin Subject: Re: [RFC PATCH] sys_membarrier(): system/process-wide memory barrier (x86) (v12) Message-ID: <20150316172445.GI21418@twins.programming.kicks-ass.net> References: <1426447459-28620-1-git-send-email-mathieu.desnoyers@efficios.com> <20150316141939.GE21418@twins.programming.kicks-ass.net> <1203077851.9491.1426520636551.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1203077851.9491.1426520636551.JavaMail.zimbra@efficios.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 16, 2015 at 03:43:56PM +0000, Mathieu Desnoyers wrote: > > > +enum { > > > + /* > > > + * Private flag set: only synchronize across a single process. If this > > > + * flag is not set, it means "shared": synchronize across multiple > > > + * processes. The shared mode is useful for shared memory mappings > > > + * across processes. > > > + */ > > > + MEMBARRIER_PRIVATE_FLAG = (1 << 0), > > > + > > > + /* > > > + * Expedited flag set: adds some overhead, fast execution (few > > > + * microseconds). If this flag is not set, it means "delayed": low > > > + * overhead, but slow execution (few milliseconds). > > > + */ > > > + MEMBARRIER_EXPEDITED_FLAG = (1 << 1), > > > > > > I suppose this is an unprivileged syscall; so what do we do about: > > > > for (;;) > > sys_membar(EXPEDITED); > > > > Which would spray the entire system with IPIs at break neck speed. > > Currently, combining EXPEDITED with non-PRIVATE returns -EINVAL. Ah, tl;dr that bit. This patch really had _too_ much verbiage. > Therefore, if someone cares about issuing barriers on the entire > system, the only option is to use non-EXPEDITED, which rely on > synchronize_rcu(). > > The only way to invoke expedited barriers in a loop is: > > for (;;) > sys_membarrier(MEMBARRIER_EXPEDITED | MEMBARRIER_PRIVATE); > > Which will only send IPIs to the CPU running threads from the same > process. That is indeed less of a problem.