Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755761AbbDULr0 (ORCPT ); Tue, 21 Apr 2015 07:47:26 -0400 Received: from www.linutronix.de ([62.245.132.108]:57694 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754541AbbDULrX (ORCPT ); Tue, 21 Apr 2015 07:47:23 -0400 Date: Tue, 21 Apr 2015 13:47:38 +0200 (CEST) From: Thomas Gleixner To: Mathieu Desnoyers cc: linux-kernel@vger.kernel.org, Josh Triplett , 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 Subject: Re: [PATCH v16] sys_membarrier(): system-wide memory barrier (generic, x86) In-Reply-To: <1429283202-6245-1-git-send-email-mathieu.desnoyers@efficios.com> Message-ID: References: <1429283202-6245-1-git-send-email-mathieu.desnoyers@efficios.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2425 Lines: 71 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. > + * Command to be passed to the membarrier system call. Please epxlain, that the commands need to be a single bit each. > +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? > +/** > + * 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. > +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 :) Thanks, tglx -- 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/