Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1266252pxu; Sat, 5 Dec 2020 09:29:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDZfhhYr8cbUHcWQxMnlyzMZjceyPxqAZ4jREFulSc7VHSVw8gFTtXnYz54hMNigd4F8Wl X-Received: by 2002:a05:6402:388:: with SMTP id o8mr12591144edv.359.1607189362960; Sat, 05 Dec 2020 09:29:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607189362; cv=none; d=google.com; s=arc-20160816; b=g1FaBHZW54waUoBsKbh+QFW9wfp0XrjBvejfZXVkZ7he8AmglHWMh0Se3dZ0Wum8zw MuPNLUCNJQmN3rkGKE8JRl2H/4OZqk4c7UGCoEcP4InyhRMrOvAYGWNwW9xqix0YKj0/ aosoXF1saqtVbl8JjxtvBL13SXci/75zBeovGb7HWkRUXb3nxkChi7qa1p29FDbfxAlB HNtnQr5hvkg9p0qfcBeiUTeAp2X/IHltrerHaYVNdIxg/bc9v1YNxVN4jzGSEWEKGY7x LjKunb8vXR5tJR4HSU778CTtHku1ZKTeG0nnP0cZ1OOkrd5CeEdKN6CNoIJCRUlDMGcq lcZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=Mz/7Yi61thJ88HE692aK3MZiSQS4EROkVabvy/8vXTw=; b=LNYZvtZUSTRTZRJqIRT1k3bP7k1UsO/hs3MFLszXhch0GyuNVVCGRUAKNBZ/oRWTz+ UYrTBm3rmMkwK4IoH0UGyKbnV1qELbQEhOn/nphvjQ7T+eo7LfOHDilRsCJxhxhSTyVp 9122XCoSdzQE8OwrnyvkuGm4GIkPrFROA7jC63c25hDMXJAGCcbskAD3I7JRNLmSm1pM JMtp81EutllTFJRiIfaW+Rwz2knVlQ/mH++TZ25qjG/K/8b+EkFyVDdlI9NoLSzQVaty qU8NeCZUWzITFH0HnELXyg2tkCyq+BfcmoMxmloXk5nnE/lPuSfCQPeEYgu39WKgsZru MK0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=DhL2umox; 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 q17si3605986ejj.426.2020.12.05.09.29.00; Sat, 05 Dec 2020 09:29:22 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=DhL2umox; 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 S1726867AbgLERRC (ORCPT + 99 others); Sat, 5 Dec 2020 12:17:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726684AbgLEQtF (ORCPT ); Sat, 5 Dec 2020 11:49:05 -0500 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C16BCC02B8FA for ; Sat, 5 Dec 2020 08:11:57 -0800 (PST) Received: by mail-pj1-x1043.google.com with SMTP id lb18so2340947pjb.5 for ; Sat, 05 Dec 2020 08:11:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=Mz/7Yi61thJ88HE692aK3MZiSQS4EROkVabvy/8vXTw=; b=DhL2umoxMynanfmyKr00u4At2reQZYap7bLysS7iO2w5j378kBnpkqTo925b1AMXV9 GfnmqNtET9W86zssaaOutcBbaatQqvIuT0cFpK/81Z7C+e8JNbfIu0fT5XUcH3GNcfdc TB+RF64MfXALrRuW3BwDZoBwlIBtNKpXrKm5Y0/qTBIU331wiDfW9P9m9Ss4s+Q3hmKj IbLQSoUJ7xJOh7w9Sws/9AcCKZ+1eQgOt1ThRR6L9HNeFOZO+EVk2vhjr0XajH5/mYrN BMTdOzYSYOvXdJvjmZaBKKSwrzDg8IwR22EhWuj7sLHF1rrlBKjTfwBTm4b8Mzs0E+Hn xxiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=Mz/7Yi61thJ88HE692aK3MZiSQS4EROkVabvy/8vXTw=; b=lVAwLaErU1Wa/fW4+K1gmf70qIj6dkTOGRVSAY++HXKG1b2btuQcrOXh3hGUcc27wZ pxTBeoPzhyGSsTd+2zBxWT2qjmHUwFZf5tRMujoFApxTJOAuF8dZzlx1n1zYSQE6UZjj /wMqyKOseVeUYJacdcmtr6RVd1K5tZ+uVBA6t1VufjaWtRij9j13SdT/QqAn2ajLL+fr sOwZuqdaVuLYe0ioa7aWOQMrEQq6Q7Ur+uu2LPsorCOFq2XLdg7yILO0FbjYyA2ft8JM 2iFnaGRI9+L8+Xk+KXjOHnl0pQM8SFMKSs6zgWD17FXpWfjMEHHVX2qfuIxqXJI0WTqA o3XA== X-Gm-Message-State: AOAM530/ZtwKew9l5NFD7z7erUqlyN9YaVNB/bZHFWtmNnGad1uv8/G/ vuL/K3WuuxcAUjS69o9/IeLp3w== X-Received: by 2002:a17:902:bd4c:b029:d8:fd6a:6ca2 with SMTP id b12-20020a170902bd4cb02900d8fd6a6ca2mr8830175plx.53.1607184717112; Sat, 05 Dec 2020 08:11:57 -0800 (PST) Received: from ?IPv6:2601:646:c200:1ef2:c541:6c6c:97fe:790? ([2601:646:c200:1ef2:c541:6c6c:97fe:790]) by smtp.gmail.com with ESMTPSA id mr7sm5466394pjb.31.2020.12.05.08.11.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 05 Dec 2020 08:11:56 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 2/8] x86: use exit_lazy_tlb rather than membarrier_mm_sync_core_before_usermode Date: Sat, 5 Dec 2020 08:11:54 -0800 Message-Id: <116A6B40-C77B-4B6A-897B-18342CD62CEC@amacapital.net> References: <1607152918.fkgmomgfw9.astroid@bobo.none> Cc: Andy Lutomirski , Anton Blanchard , Arnd Bergmann , linux-arch , LKML , Linux-MM , linuxppc-dev , Mathieu Desnoyers , Peter Zijlstra , X86 ML In-Reply-To: <1607152918.fkgmomgfw9.astroid@bobo.none> To: Nicholas Piggin X-Mailer: iPhone Mail (18B121) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Dec 5, 2020, at 12:00 AM, Nicholas Piggin wrote: >=20 >=20 > I disagree. Until now nobody following it noticed that the mm gets > un-lazied in other cases, because that was not too clear from the > code (only indirectly using non-standard terminology in the arch > support document). > In other words, membarrier needs a special sync to deal with the case=20 > when a kthread takes the mm. I don=E2=80=99t think this is actually true. Somehow the x86 oddities about C= R3 writes leaked too much into the membarrier core code and comments. (I dou= bt this is x86 specific. The actual x86 specific part seems to be that we c= an return to user mode without syncing the instruction stream.) As far as I can tell, membarrier doesn=E2=80=99t care at all about laziness.= Membarrier cares about rq->curr->mm. The fact that a cpu can switch its ac= tual loaded mm without scheduling at all (on x86 at least) is entirely besid= e the point except insofar as it has an effect on whether a subsequent switc= h_mm() call serializes. If we notify membarrier about x86=E2=80=99s asynchr= onous CR3 writes, then membarrier needs to understand what to do with them, w= hich results in an unmaintainable mess in membarrier *and* in the x86 code. I=E2=80=99m currently trying to document how membarrier actually works, and h= opefully this will result in untangling membarrier from mmdrop() and such. A silly part of this is that x86 already has a high quality implementation o= f most of membarrier(): flush_tlb_mm(). If you flush an mm=E2=80=99s TLB, w= e carefully propagate the flush to all threads, with attention to memory ord= ering. We can=E2=80=99t use this directly as an arch-specific implementatio= n of membarrier because it has the annoying side affect of flushing the TLB a= nd because upcoming hardware might be able to flush without guaranteeing a c= ore sync. (Upcoming means Zen 3, but the Zen 3 implementation is sadly not u= sable by Linux.)