From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752568AbdGYQZD (ORCPT ); Tue, 25 Jul 2017 12:25:03 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36752 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752156AbdGYQZB (ORCPT ); Tue, 25 Jul 2017 12:25:01 -0400 Date: Tue, 25 Jul 2017 09:24:54 -0700 From: "Paul E. McKenney" To: Boqun Feng Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com Subject: Re: [PATCH tip/core/rcu 4/5] sys_membarrier: Add expedited option Reply-To: paulmck@linux.vnet.ibm.com References: <20170724215758.GA12075@linux.vnet.ibm.com> <1500933497-12612-4-git-send-email-paulmck@linux.vnet.ibm.com> <20170725042701.awyqowhgc6s3r44h@tardis> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170725042701.awyqowhgc6s3r44h@tardis> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17072516-2213-0000-0000-000001FF7A55 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007424; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00892746; UDB=6.00446245; IPR=6.00672910; BA=6.00005492; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016372; XFM=3.00000015; UTC=2017-07-25 16:24:58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17072516-2214-0000-0000-000056FEE5A5 Message-Id: <20170725162454.GP3730@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-25_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707250258 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 25, 2017 at 12:27:01PM +0800, Boqun Feng wrote: > On Mon, Jul 24, 2017 at 02:58:16PM -0700, Paul E. McKenney 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. > > > > 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), > > Should this better be "(1 << 1)" ;-) Same value, but yes, much more aligned with the intent. Good catch, thank you, fixed! Thanx, Paul > Regards, > Boqun > > > }; > > > > #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 > >