Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2441925pxu; Sat, 28 Nov 2020 14:16:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKpxGgvP3n/+TA0XbbGhvfR3ywmhRt+ndr8Dh42CEgHRXo6ioCjutsSORbQgND7fvpoBH7 X-Received: by 2002:aa7:d8c1:: with SMTP id k1mr4171268eds.241.1606601818592; Sat, 28 Nov 2020 14:16:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606601818; cv=none; d=google.com; s=arc-20160816; b=eJetooQfxhhf7pz+9XdA23hReADrY+7izFhWRVawgRkxzbxQHE2c1Yr2nmtgp9pLsq xH5jIzd61Iv0uI/hMrWFdcII69VYXK/xpwU5aFAaXoJUXWXFHs73GmXfEPTYy5uJsWt8 Ynjrl5xnDLZ7xBakVAHPCFeAxUp7SmxsPMhcv1BeD+YXsVYviCVVpa/ztpJDGDEZWeC3 cDio42lMBZvjdfwtZRcUQskueGRIv/7VRDC0EUU9RJGh/cOfKnQoK745qzqsk8+20g5C Jh2sYwhWQHEwbGFyuGCiLGXIi8USR/jyF6eKd+o09ElcFPWnG7czq12vMiwE0B/tZf8F TOqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=a4qIhwYA55ildlRtDsbYu/5HEPY6/KDxYjiOMfiXhx4=; b=Md0p5wm+dGzB0PvRnx/0rg8AGZdH9s4enNRL1lARzETzS/JHSrniajPxB0TQzoeveq Zr3NSjx1SwZ/tg6tFb+QDkA1WsO38E71Rhtm4naWBeMZ7c6n3Gjb9ESRV8IR1IcwHPTe dKBXBBgUWmLCWQPqFjgSNEZAf4F09Bi1FYWq6cSsaPmZGDuF9F/lqydLE8jhiG8tfmx8 QxKoQMtU14P0L7JMNsHuahOnvQzV5Ih4ltqPX/Lod6kbBWUGGotKpg9A5zEzn5a3akIP dlSWmtpqfzoFSkT6MkpimS+0YuFM1qIBE18E7buZoWwloJNxy7OjS/1XhjZ6qa7g7V07 +OfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=epX46Lo5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j12si3241714ejb.431.2020.11.28.14.16.36; Sat, 28 Nov 2020 14:16:58 -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=@kernel.org header.s=default header.b=epX46Lo5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387625AbgK1Vty (ORCPT + 99 others); Sat, 28 Nov 2020 16:49:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:44582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731889AbgK1SBz (ORCPT ); Sat, 28 Nov 2020 13:01:55 -0500 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C2C86246E5 for ; Sat, 28 Nov 2020 17:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606586151; bh=ZZhMRxdkDiUtjJhs9EzGkFNzkESkUN3IT5oRokS68Qo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=epX46Lo5gyxVc+A48tcBI9o2KY5N0B8LeGVmlne+5FIJLCKzXxKJbO8s5nD3xgFEq X4i5sPbFp4pWFdxVxrkkA2Zo+E6LU8KzScdnd4wUs/DuAJxVyePHnhRMsXt1NPg65k bczZ20BbxsSWXKhjoKXb+3UfQFkWGyoh+eDumXHw= Received: by mail-wm1-f50.google.com with SMTP id d3so4793886wmb.4 for ; Sat, 28 Nov 2020 09:55:50 -0800 (PST) X-Gm-Message-State: AOAM532Y5xjP9TT4k4IvUxR1ikzPpFtU8hPr+0nwqqdjicRQgZd9c1u/ 5ReHxiPTvIWfM8V9AIBbSo0DCEmjUueTcHxFQZW2Eg== X-Received: by 2002:a1c:7e90:: with SMTP id z138mr436606wmc.49.1606586149355; Sat, 28 Nov 2020 09:55:49 -0800 (PST) MIME-Version: 1.0 References: <20201128160141.1003903-1-npiggin@gmail.com> <20201128160141.1003903-3-npiggin@gmail.com> In-Reply-To: <20201128160141.1003903-3-npiggin@gmail.com> From: Andy Lutomirski Date: Sat, 28 Nov 2020 09:55:37 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/8] x86: use exit_lazy_tlb rather than membarrier_mm_sync_core_before_usermode To: Nicholas Piggin Cc: LKML , X86 ML , Mathieu Desnoyers , Arnd Bergmann , Peter Zijlstra , linux-arch , linuxppc-dev , Linux-MM , Anton Blanchard Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 28, 2020 at 8:02 AM Nicholas Piggin wrote: > > And get rid of the generic sync_core_before_usermode facility. This is > functionally a no-op in the core scheduler code, but it also catches > > This helper is the wrong way around I think. The idea that membarrier > state requires a core sync before returning to user is the easy one > that does not need hiding behind membarrier calls. The gap in core > synchronization due to x86's sysret/sysexit and lazy tlb mode, is the > tricky detail that is better put in x86 lazy tlb code. > > Consider if an arch did not synchronize core in switch_mm either, then > membarrier_mm_sync_core_before_usermode would be in the wrong place > but arch specific mmu context functions would still be the right place. > There is also a exit_lazy_tlb case that is not covered by this call, which > could be a bugs (kthread use mm the membarrier process's mm then context > switch back to the process without switching mm or lazy mm switch). > > This makes lazy tlb code a bit more modular. I have a couple of membarrier fixes that I want to send out today or tomorrow, and they might eliminate the need for this patch. Let me think about this a little bit. I'll cc you. The existing code is way to subtle and the comments are far too confusing for me to be quickly confident about any of my conclusions :)