From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752049AbdGYNTI (ORCPT ); Tue, 25 Jul 2017 09:19:08 -0400 Received: from mail.efficios.com ([167.114.142.141]:45678 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751503AbdGYNTH (ORCPT ); Tue, 25 Jul 2017 09:19:07 -0400 Date: Tue, 25 Jul 2017 13:21:08 +0000 (UTC) From: Mathieu Desnoyers To: "Paul E. McKenney" Cc: linux-kernel , Ingo Molnar , Lai Jiangshan , dipankar , Andrew Morton , Josh Triplett , Thomas Gleixner , Peter Zijlstra , rostedt , David Howells , Eric Dumazet , fweisbec , Oleg Nesterov Message-ID: <1889183220.24786.1500988868552.JavaMail.zimbra@efficios.com> In-Reply-To: <1500933497-12612-4-git-send-email-paulmck@linux.vnet.ibm.com> References: <20170724215758.GA12075@linux.vnet.ibm.com> <1500933497-12612-4-git-send-email-paulmck@linux.vnet.ibm.com> Subject: Re: [PATCH tip/core/rcu 4/5] sys_membarrier: Add expedited option MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.141] X-Mailer: Zimbra 8.7.9_GA_1794 (ZimbraWebClient - FF52 (Linux)/8.7.9_GA_1794) Thread-Topic: sys_membarrier: Add expedited option Thread-Index: U2z6s5g83tIkZMGb4Gs3WhEfMciJog== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Jul 24, 2017, at 5:58 PM, Paul E. McKenney paulmck@linux.vnet.ibm.com wrote: > The sys_membarrier() system call has proven too slow for some use > cases, which has prompted users to instead rely on TLB shootdown. > Although TLB shootdown is much faster, it has the slight disadvantage > of not working at all on arm and arm64. This commit therefore adds > an expedited option to the sys_membarrier() system call. Is this now possible because the synchronize_sched_expedited() implementation does not require to send IPIs to all CPUS ? I suspect that using tree srcu now solves this somehow, but can you tell us a bit more about why it is now OK to expose this to user-space ? The commit message here does not explain why it is OK real-time wise to expose this feature as a system call. Thanks, Mathieu > > Signed-off-by: Paul E. McKenney > --- > include/uapi/linux/membarrier.h | 11 +++++++++++ > kernel/membarrier.c | 7 ++++++- > 2 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/include/uapi/linux/membarrier.h b/include/uapi/linux/membarrier.h > index e0b108bd2624..ba36d8a6be61 100644 > --- a/include/uapi/linux/membarrier.h > +++ b/include/uapi/linux/membarrier.h > @@ -40,6 +40,16 @@ > * (non-running threads are de facto in such a > * state). This covers threads from all processes > * running on the system. This command returns 0. > + * @MEMBARRIER_CMD_SHARED_EXPEDITED: Execute a memory barrier on all > + * running threads, but in an expedited fashion. > + * 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. > * > * Command to be passed to the membarrier system call. The commands need to > * be a single bit each, except for MEMBARRIER_CMD_QUERY which is assigned to > @@ -48,6 +58,7 @@ > enum membarrier_cmd { > MEMBARRIER_CMD_QUERY = 0, > MEMBARRIER_CMD_SHARED = (1 << 0), > + MEMBARRIER_CMD_SHARED_EXPEDITED = (2 << 0), > }; > > #endif /* _UAPI_LINUX_MEMBARRIER_H */ > diff --git a/kernel/membarrier.c b/kernel/membarrier.c > index 9f9284f37f8d..b749c39bb219 100644 > --- a/kernel/membarrier.c > +++ b/kernel/membarrier.c > @@ -22,7 +22,8 @@ > * Bitmask made from a "or" of all commands within enum membarrier_cmd, > * except MEMBARRIER_CMD_QUERY. > */ > -#define MEMBARRIER_CMD_BITMASK (MEMBARRIER_CMD_SHARED) > +#define MEMBARRIER_CMD_BITMASK (MEMBARRIER_CMD_SHARED | \ > + MEMBARRIER_CMD_SHARED_EXPEDITED) > > /** > * sys_membarrier - issue memory barriers on a set of threads > @@ -64,6 +65,10 @@ SYSCALL_DEFINE2(membarrier, int, cmd, int, flags) > if (num_online_cpus() > 1) > synchronize_sched(); > return 0; > + case MEMBARRIER_CMD_SHARED_EXPEDITED: > + if (num_online_cpus() > 1) > + synchronize_sched_expedited(); > + return 0; > default: > return -EINVAL; > } > -- > 2.5.2 -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com