Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751800AbdHAKqZ (ORCPT ); Tue, 1 Aug 2017 06:46:25 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:47516 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751571AbdHAKqX (ORCPT ); Tue, 1 Aug 2017 06:46:23 -0400 Date: Tue, 1 Aug 2017 12:46:16 +0200 From: Peter Zijlstra To: Avi Kivity Cc: Nicholas Piggin , Mathieu Desnoyers , Michael Ellerman , "Paul E. McKenney" , linux-kernel , Boqun Feng , Andrew Hunter , maged michael , gromer , Benjamin Herrenschmidt , Palmer Dabbelt , Dave Watson Subject: Re: [RFC PATCH v2] membarrier: expedited private command Message-ID: <20170801104616.fmw5zcag2ducwsn6@hirez.programming.kicks-ass.net> References: <20170728085532.ylhuz2irwmgpmejv@hirez.programming.kicks-ass.net> <20170728115702.5vgnvwhmbbmyrxbf@hirez.programming.kicks-ass.net> <87tw1s4u9w.fsf@concordia.ellerman.id.au> <20170731233731.32e68f6d@roar.ozlabs.ibm.com> <973223324.694.1501551189603.JavaMail.zimbra@efficios.com> <20170801120047.61c59064@roar.ozlabs.ibm.com> <20170801081230.GF6524@worktop.programming.kicks-ass.net> <20170801195717.7a675cc2@roar.ozlabs.ibm.com> <20170801102203.urldoripgbh2ohun@hirez.programming.kicks-ass.net> <3db6b20b-df76-8284-5bc1-37a511ee0534@scylladb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3db6b20b-df76-8284-5bc1-37a511ee0534@scylladb.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1003 Lines: 21 On Tue, Aug 01, 2017 at 01:32:43PM +0300, Avi Kivity wrote: > I hate to propose a way to make this more complicated, but this could be > fixed by a process first declaring its intent to use expedited process-wide > membarrier; if it does, then every context switch updates a process-wide > cpumask indicating which cpus are currently running threads of that process: > > if (prev->mm != next->mm) > if (prev->mm->running_cpumask) > cpumask_clear(...); > else if (next->mm->running_cpumask) > cpumask_set(...); > > now only processes that want expedited process-wide membarrier pay for it > (in other than some predictable branches). You can even have threads opt-in, > so unrelated threads that don't participate in the party don't cause those > bits to be set. Either that or conditionally put in a smp_mb in switch_mm() for that process. But yes, once we advertise intent (either explicit or implicit on first use), there's various things that can be done.