From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3y7RZn6qb6zDqhb for ; Fri, 6 Oct 2017 09:02:25 +1100 (AEDT) Received: by mail-wm0-x243.google.com with SMTP id i124so4445186wmf.3 for ; Thu, 05 Oct 2017 15:02:25 -0700 (PDT) Date: Fri, 6 Oct 2017 00:02:14 +0200 From: Andrea Parri To: Mathieu Desnoyers Cc: Peter Zijlstra , "Paul E. McKenney" , linux-kernel , Ingo Molnar , Lai Jiangshan , dipankar , Andrew Morton , Josh Triplett , Thomas Gleixner , rostedt , David Howells , Eric Dumazet , fweisbec , Oleg Nesterov , Boqun Feng , Andrew Hunter , maged michael , gromer , Avi Kivity , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Dave Watson , Alan Stern , Will Deacon , Andy Lutomirski , Ingo Molnar , Alexander Viro , Nicholas Piggin , linuxppc-dev , linux-arch Subject: Re: [PATCH tip/core/rcu 1/3] membarrier: Provide register expedited private command Message-ID: <20171005220214.GA7140@andrea> References: <20171004213734.GA11463@linux.vnet.ibm.com> <1507153075-12345-1-git-send-email-paulmck@linux.vnet.ibm.com> <20171005121250.prr5ff5kf3lxq6hx@hirez.programming.kicks-ass.net> <312162.31738.1507219326334.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <312162.31738.1507219326334.JavaMail.zimbra@efficios.com> List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Thu, Oct 05, 2017 at 04:02:06PM +0000, Mathieu Desnoyers wrote: > ----- On Oct 5, 2017, at 8:12 AM, Peter Zijlstra peterz@infradead.org wrote: > > > On Wed, Oct 04, 2017 at 02:37:53PM -0700, Paul E. McKenney wrote: > >> diff --git a/arch/powerpc/kernel/membarrier.c b/arch/powerpc/kernel/membarrier.c > >> new file mode 100644 > >> index 000000000000..b0d79a5f5981 > >> --- /dev/null > >> +++ b/arch/powerpc/kernel/membarrier.c > >> @@ -0,0 +1,45 @@ > > > >> +void membarrier_arch_register_private_expedited(struct task_struct *p) > >> +{ > >> + struct task_struct *t; > >> + > >> + if (get_nr_threads(p) == 1) { > >> + set_thread_flag(TIF_MEMBARRIER_PRIVATE_EXPEDITED); > >> + return; > >> + } > >> + /* > >> + * Coherence of TIF_MEMBARRIER_PRIVATE_EXPEDITED against thread > >> + * fork is protected by siglock. > >> + */ > >> + spin_lock(&p->sighand->siglock); > >> + for_each_thread(p, t) > >> + set_ti_thread_flag(task_thread_info(t), > >> + TIF_MEMBARRIER_PRIVATE_EXPEDITED); > > > > I'm not sure this works correctly vs CLONE_VM without CLONE_THREAD. > > The intent here is to hold the sighand siglock to provide mutual > exclusion against invocation of membarrier_fork(p, clone_flags) > by copy_process(). > > copy_process() grabs spin_lock(¤t->sighand->siglock) for both > CLONE_THREAD and not CLONE_THREAD flags. > > What am I missing here ? > > > > >> + spin_unlock(&p->sighand->siglock); > >> + /* > >> + * Ensure all future scheduler executions will observe the new > >> + * thread flag state for this process. > >> + */ > >> + synchronize_sched(); > > > > This relies on the flag being read inside rq->lock, right? > > Yes. The flag is read by membarrier_arch_switch_mm(), invoked > within switch_mm_irqs_off(), called by context_switch() before > finish_task_switch() releases the rq lock. I fail to graps the relation between this synchronize_sched() and rq->lock. (Besides, we made no reference to rq->lock while discussing: https://github.com/paulmckrcu/litmus/commit/47039df324b60ace0cf7b2403299580be730119b replace membarrier_arch_sched_in with switch_mm_irqs_off ) Could you elaborate? Andrea > > Is the comment clear enough, or do you have suggestions for > improvements ? > > Thanks, > > Mathieu > > > > > > +} > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com