From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-3893847-1517253008-2-16188647763295293961 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.001, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='US', FromHeader='org', MailFrom='org' X-Spam-charsets: plain='us-ascii' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: linux-api-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1517253007; b=Fp8A89G2DVPbWals5Oku4e5QF1U5t/RuN6jyC64Q05rAzVq AsNLtEVPMue01fYI6waYHf3cPqYF5UOLVJX/LLTTFOrSowtHUsgUmdGVY24yunsW lggBPoNZLItdPOzOS+ZznlEESdfbzEfBZ8XZWG5hkrAYYLt6YWdHlteYTRT30qMW cowhFewgfPPCUDx03naC8lluoVtwSdz4q6WYA0aH5SRc44uVFGAk0A7oQdFKKqk4 P3w5UE4BK7+GFpfRonYn3Dyra04ASXut4cmlIzbMZPeOmB3qsQlO/2VBMrOFc7dh tvs0UL12JreCd/bUiJHYPah/AAX8ouLBB6bz5Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to:sender :list-id; s=arctest; t=1517253007; bh=+c/nBdDw6KMRbG1Wv4jC3ll+vl T0jaFIVa4ifMvjAB0=; b=FFSUnHlq7frcwq5M+2dBfvRUoDO2SRcJUg6f4OspAY 5+qJjpery4qmoXD6JE7JHa6dUL6PfElyg1h/69yyafDZnlo3bXNmpcwbm3ydLDkM iziXBpYwSYQU8gwiA/B3p4yrfAKzN39ktFcs8QN/3ylbmT8Ms1+oCPsaGTA8Nfw+ 19Onc3Oa8KBXasNFYNI/GrvLSOoGM0Lz7ru3btii1x+wNdRpd+EsNe2o/SOer8yf fv0nq4595eoKKOdwM/C4XgZ8sMes12/MSMd3wen1KgEiQUqWfAg6XfnA7yJwHEsO +2lCag9H15qO1D2Rj9Msv14zaQkIGOokLjn/rwUZHMJA== ARC-Authentication-Results: i=1; mx4.messagingengine.com; arc=none (no signatures found); dkim=fail (message has been altered; 2048-bit rsa key sha256) header.d=infradead.org header.i=@infradead.org header.b=yE3NOmJu x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=merlin.20170209; dmarc=none (p=none,has-list-id=yes,d=none) header.from=infradead.org; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=linux-api-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=infradead.org header.result=pass header_is_org_domain=yes Authentication-Results: mx4.messagingengine.com; arc=none (no signatures found); dkim=fail (message has been altered; 2048-bit rsa key sha256) header.d=infradead.org header.i=@infradead.org header.b=yE3NOmJu x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=merlin.20170209; dmarc=none (p=none,has-list-id=yes,d=none) header.from=infradead.org; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=linux-api-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=infradead.org header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751264AbeA2TJy (ORCPT ); Mon, 29 Jan 2018 14:09:54 -0500 Received: from merlin.infradead.org ([205.233.59.134]:59172 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751072AbeA2TJw (ORCPT ); Mon, 29 Jan 2018 14:09:52 -0500 Date: Mon, 29 Jan 2018 20:09:23 +0100 From: Peter Zijlstra To: Mathieu Desnoyers Cc: Ingo Molnar , Thomas Gleixner , linux-kernel , linux-api , Andy Lutomirski , "Paul E. McKenney" , Boqun Feng , Andrew Hunter , maged michael , Avi Kivity , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Dave Watson , "H. Peter Anvin" , Andrea Parri , "Russell King, ARM Linux" , Greg Hackmann , Will Deacon , David Sehr , Linus Torvalds , x86 , linux-arch Subject: Re: [PATCH 08/11] membarrier: Provide core serializing command (v2) Message-ID: <20180129190923.GP2249@hirez.programming.kicks-ass.net> References: <20180123155733.3404-1-mathieu.desnoyers@efficios.com> <20180123155733.3404-9-mathieu.desnoyers@efficios.com> <20180129180414.GO2249@hirez.programming.kicks-ass.net> <20180129181529.GG2295@hirez.programming.kicks-ass.net> <485936677.11601.1517250965043.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <485936677.11601.1517250965043.JavaMail.zimbra@efficios.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-api-owner@vger.kernel.org X-Mailing-List: linux-api@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Mon, Jan 29, 2018 at 06:36:05PM +0000, Mathieu Desnoyers wrote: > ----- On Jan 29, 2018, at 1:15 PM, Peter Zijlstra peterz@infradead.org wrote: > > Aaah, its the case where we do not pass through switch_mm(), the partial > > comment got to me. I only realized after reading the next patch. > > Indeed, if we read the entire comment, it's made clear that this case is for > when switch_mm is not invoked, where the current mm is changed without going > through switch_mm(), when scheduling between uthread->kthread->uthread for > instance. > > /* > * When transitioning from a kernel thread to a userspace > * thread, mmdrop()'s implicit full barrier is required by the > * membarrier system call, because the current active_mm can > * become the current mm without going through switch_mm(). > * membarrier also requires a core serializing instruction > * before going back to user-space after storing to rq->curr. > */ > > Is there something I should improve in the wording of this added > sentence to make it clearer ? Can be improved I think, its got two unqualified "membarrier"s in and its a bit mixed up. I'm having a major case of the mondays (brain just won't start today), but maybe something like: When we switched through a kernel thread, the loop in membarrier_{private,global}_expedited() can have observed that kernel thread and not issued an IPI. We will also not pass through switch_mm(). Membarrier requires a barrier after writing rq->curr and returning to userspace, so provide them here: - a full memory barrier for {PRIVATE,GLOBAL}_EXPEDITED - a sync_core for SYNC_CORE Also I think changing the changlog to state where we need core-sync would be good. Currently the x86 patch does that, but not this one, while this introduces the feature.