Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp204943pxu; Tue, 5 Jan 2021 08:42:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyST3WAUSOoF5d58ZbFEMrLrDnO35wjoGi0Iy89X7/EDweKBRiwoUXkqos3DAKw4rDa0owL X-Received: by 2002:a05:6402:254c:: with SMTP id l12mr626077edb.290.1609864955989; Tue, 05 Jan 2021 08:42:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609864955; cv=none; d=google.com; s=arc-20160816; b=cxJ5a4BNeiGRKGzdAXIKIl2zx31ktzmpYamCl0SDI+4urhofd9sQMPtQ6TlsQ4HqfO IJ15nDZLrSAXnEMSGvzl1M44XfRYmXNqZK3i7ynSoYaU9eaygwMsT60nUNGprgxeACat ErpCh3vACzTxxsVv/AreIIRMLMlmkDXGmRD0Rz/vrto3SFO472fi4Xox02L52yltfY0p vJLxUiyRGM/xP5hO8wOD4O+hRR6QqJtwI+dL3OhUu7lGamnykjOwHxh7N0/BtGcKbOAs 0G4EYqsnr4/aA+5ae70Qkiu3wlQzkKRPD5Yi9Tc2/W8CbLAW8AMq5ORi4VEg04x0lI9n irhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Zn9Jeh+wfsmeZ8Kq39gSdD4WJohBEoNPA6/OyBxQvc4=; b=dCgacd/cFRVC/aoFs1mqza026MAdezW7DdYlRVDzOws46msry5FhTKzBM2VhKVvbuH RTDYjaFGv0gg64lg90BJlUSwXY4Mq7bWtju75wHpKTZiQnFFAhMErw5CzrqwiW01mBI1 MPMl8exFvcNytCAlb4M645AYTOGpvY0RMTpXxv2/xacP8d3iXxCf8cxf+SMJlX+MsC35 EFpQwOU6Vo23kEQ+lpcKkecXOo+qtYIdkaxalbTo3+08dvgF1kfM6LcKXOEAeCA1gbZ1 8hCK+xPg8O93/PP8mekSSgLR7cJCFU1yY6Z7muAME13vKrsUKgqrkDWUFhfRRaNT0EP2 Lg3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=W9LdNbFy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k20si62197edo.493.2021.01.05.08.42.11; Tue, 05 Jan 2021 08:42:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=W9LdNbFy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729460AbhAEQik (ORCPT + 99 others); Tue, 5 Jan 2021 11:38:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727791AbhAEQik (ORCPT ); Tue, 5 Jan 2021 11:38:40 -0500 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 027A9C061574; Tue, 5 Jan 2021 08:37:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=Zn9Jeh+wfsmeZ8Kq39gSdD4WJohBEoNPA6/OyBxQvc4=; b=W9LdNbFyUJiYe4Igi7trBCh09W dU5OhOWsJnmIDyHBzwHRZTyPMFx64HwIbTXQBh7gyCJzdWcUsEQ2WxRAJWskQiOuEhy0b6bE152NZ sXE2x5ffBSo4RcnqYRHfCChmQppvv/t6u8aLkVQQAPVPDN/3F7w2A3MG887DP5WJmCrfftZi7Z+AC Ri80MMCtdo/0Y81aJQ2iCoh1V8DMrZE0Qe1IG35yePUiR/oRYePfuyin4jUazSoBVFvIxhQ8Q2cWK AaS7NqtK6UoLG1n0LbD4CSv2+MgQ2fyGiL1QFhAD5Wthi60eLUgVSQ6whG/nN2TWTZ2oWWXBahadX I6zb6MgA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kwpKw-0004Bv-QX; Tue, 05 Jan 2021 16:37:35 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 9CB9330377D; Tue, 5 Jan 2021 17:37:31 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 8408420D9B72E; Tue, 5 Jan 2021 17:37:31 +0100 (CET) Date: Tue, 5 Jan 2021 17:37:31 +0100 From: Peter Zijlstra To: Andy Lutomirski Cc: Will Deacon , Andy Lutomirski , Nicholas Piggin , Mathieu Desnoyers , X86 ML , Arnd Bergmann , Benjamin Herrenschmidt , Catalin Marinas , linux-arm-kernel , LKML , linuxppc-dev , Michael Ellerman , Paul Mackerras , stable Subject: Re: [RFC please help] membarrier: Rewrite sync_core_before_usermode() Message-ID: <20210105163731.GM3040@hirez.programming.kicks-ass.net> References: <20210105132623.GB11108@willie-the-truck> <7BFAB97C-1949-46A3-A1E2-DFE108DC7D5E@amacapital.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7BFAB97C-1949-46A3-A1E2-DFE108DC7D5E@amacapital.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 05, 2021 at 08:20:51AM -0800, Andy Lutomirski wrote: > > Interestingly, the architecture recently added a control bit to remove > > this synchronisation from exception return, so if we set that then we'd > > have a problem with SYNC_CORE and adding an ISB would be necessary (and > > we could probable then make kernel->kernel returns cheaper, but I > > suspect we're relying on this implicit synchronisation in other places > > too). > > > > Is ISB just a context synchronization event or does it do more? IIRC it just the instruction sync (like power ISYNC). > On x86, it’s very hard to tell that MFENCE does any more than LOCK, > but it’s much slower. And we have LFENCE, which, as documented, > doesn’t appear to have any semantics at all. (Or at least it didn’t > before Spectre.) AFAIU MFENCE is a completion barrier, while LOCK prefix is not. A bit like ARM's DSB vs DMB. It is for this reason that mb() is still MFENCE, while our smp_mb() is a LOCK prefixed NO-OP. And yes, LFENCE used to be poorly defined and it was sometimes understood to be a completion barrier relative to prior LOADs, while it is now a completion barrier for any prior instruction, and really should be renamed to IFENCE.