From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754115AbbDVUgF (ORCPT ); Wed, 22 Apr 2015 16:36:05 -0400 Received: from mail.efficios.com ([78.47.125.74]:60585 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751459AbbDVUgC (ORCPT ); Wed, 22 Apr 2015 16:36:02 -0400 Date: Wed, 22 Apr 2015 20:36:04 +0000 (UTC) From: Mathieu Desnoyers To: Thomas Gleixner , Josh Triplett Cc: linux-kernel@vger.kernel.org, KOSAKI Motohiro , Steven Rostedt , Nicholas Miell , Linus Torvalds , Ingo Molnar , Alan Cox , Lai Jiangshan , Stephen Hemminger , Andrew Morton , Peter Zijlstra , David Howells , Pranith Kumar , Michael Kerrisk Message-ID: <1984143894.34526.1429734964859.JavaMail.zimbra@efficios.com> In-Reply-To: References: <1429283202-6245-1-git-send-email-mathieu.desnoyers@efficios.com> Subject: Re: [PATCH v16] sys_membarrier(): system-wide memory barrier (generic, x86) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [192.222.194.238] X-Mailer: Zimbra 8.0.7_GA_6021 (ZimbraWebClient - FF37 (Linux)/8.0.7_GA_6021) Thread-Topic: sys_membarrier(): system-wide memory barrier (generic, x86) Thread-Index: QL0Nv4iRb/+vKyN/t8nyVpy8sQo7rg== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- Original Message ----- > On Fri, 17 Apr 2015, Mathieu Desnoyers wrote: > > +/** > > + * enum membarrier_cmd - membarrier system call command > > + * > > * @MEMBARRIER_CMD_QUERY: Explanatory blurb...... > > Hint: Create a kerneldoc document and build it. Oops, fixed, and figured out how to build it. Next version should be ok. > > > + * Command to be passed to the membarrier system call. > > Please epxlain, that the commands need to be a single bit each. OK > > > +config MEMBARRIER > > + bool "Enable membarrier() system call" if EXPERT > > + default y > > + depends on SMP > > + help > > + Enable the membarrier() system call that allows issuing memory > > + barriers across all running threads, which can be used to distribute > > + the cost of user-space memory barriers asymmetrically by transforming > > + pairs of memory barriers into pairs consisting of membarrier() and a > > + compiler barrier. > > + > > + If unsure, say Y. > > Is it really worth to make this configurable? Josh Triplett asked for it to be made configurable. I don't have any strong opinion one way or the other. > > > +/** > > + * sys_membarrier - issue memory barriers on a set of threads > > + * @cmd: MEMBARRIER_CMD_QUERY: > > + * Query the set of supported commands. It returns a bitmask > > of > > + * supported commands. > > + * MEMBARRIER_CMD_SHARED: > > + * Execute a memory barrier on all running threads. Upon > > + * return from system call, the caller thread is ensured that > > + * all running threads have passed through a state where all > > + * memory accesses to user-space addresses match program order > > + * between entry to and return from the system call > > (non-running > > + * threads are de facto in such a state). This covers threads > > + * from all processes running on the system. This command > > + * returns 0. > > I think the explanation for the commands should be in the enum > documentation. This here should explain that @cmd takes command values > defined in the enum. OK > > > +SYSCALL_DEFINE2(membarrier, int, cmd, int, flags) > > +{ > > + switch (cmd) { > > + case MEMBARRIER_CMD_QUERY: > > + return MEMBARRIER_CMD_BITMASK; > > + case MEMBARRIER_CMD_SHARED: > > + if (num_online_cpus() > 1) > > + synchronize_sched(); > > + return 0; > > + default: > > + return -EINVAL; > > + } > > +} > > This looks way cleaner now :) Much smaller too :) Thanks, Mathieu > > Thanks, > > tglx > -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com