Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1887721pxj; Fri, 18 Jun 2021 19:22:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQw53MHOAxL2XtllAtovRxS7Wd8kbD3BBagBjemjLC/WBTMVtdYOYdneQyNpkn39dkgpxf X-Received: by 2002:a5d:804f:: with SMTP id b15mr10422680ior.187.1624069353207; Fri, 18 Jun 2021 19:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624069353; cv=none; d=google.com; s=arc-20160816; b=zzOGtd2FgKWNndbHPJOgdmhGXMGGctaB9fk7rTDHfTTezayApJ6awlZuVqyAQzg352 2xvGSBthj2xMhP4K8EjjQiS1161Rpa6G/DSYo4G2N9Y+u2Z3ODPQtKWK0C26HVcpxf6i 9OcBPkPmsrs8LfGnpRDfYLHPn3DWcjXNgTVET5POiumy5haZGoke7uDxAr2hXeKtvemU GhpIJJKzCMjsOc+4R6CIWEWwI7Nb+Yimgqo++mY9vNRgf0u6W3BeJMVtEiFIDZD5ZHMB YBymcEHVC8SKz7y1hPw42SJmiOYmrNIVdvi4tndkEznfqmmhO95G/kkCbtbnjTs0C1hU rmnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:cc:to:from :date:references:in-reply-to:message-id:mime-version:user-agent :dkim-signature; bh=OnnKs2YZKgTJotazpj6ePMLAvIBiNpWuj4c62wqs4Q8=; b=fs88iL7IusYoT6wV8vWdHnw5WAvnTHjOzTTzaOjXUx3J6Z8bwUeYFxDItb5dyf0Xf0 om5qpDlJC98IUKDnDiIYv9676f/NsHkgd2zEY4Ws61juperkZ4xJknEx5aZKd3uzksxj 6SIt+jxEo6gNq5AMZgMcVEKjyNCYyFlVx7hP1qhffHjWLZtnh4ASrAYFNJACkh/tfDXB v9rH7tj82mIgLWlNgfC8KJXeHjhLd9iJyMBzZdvxZdvdIZrVrDuI84ag3T8JquNec/18 qDZVPqsHhvVI0puCBixycpH865Pv/VUqVKJ+NLWpmmQFVqEnr14WgxvCPaGPzNqaVMgG mv/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZFwYmRIs; 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 f16si9689433iox.100.2021.06.18.19.22.21; Fri, 18 Jun 2021 19:22:33 -0700 (PDT) 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=k20201202 header.b=ZFwYmRIs; 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 S233488AbhFRUAp (ORCPT + 99 others); Fri, 18 Jun 2021 16:00:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:44250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232605AbhFRUAn (ORCPT ); Fri, 18 Jun 2021 16:00:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 62B7D60C3D; Fri, 18 Jun 2021 19:58:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624046313; bh=D7oBl/0a90lKe9pWfqLnpCpCt9G9AbWx/2EijH8CQy4=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=ZFwYmRIs2uRf1tIy8hT6Wi0I+iZUU7Gz+mTMkEZBflk9hqT2FNIz0/3iBhFoj0iYf zFbcLcIY3NG911o6doq5+lh9n4k8TAoWTjKvg7+suYYJ4Z//xJQ7SW/1Q6tZ5oqlqC KRbz/ZENYmXGbxnzQFHAaRU0My3Pe9jLWUrnEsHYt801nl7MUg4TJK/qYoS/6sOOgF RpP2phEll/ZETdKFJS/NSI2oES8OAx6Gar9IN3BHHe3jpi1DaLqPV47F9x/nt6ffIi 44khMWq29Tid3SRb8+DbVNpwVwPkswRfo/BJbyWc3atNlPFDD1wWjPEPAoCIaK5MKa +kN/kviVn/f+w== Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailauth.nyi.internal (Postfix) with ESMTP id 76E9127C0054; Fri, 18 Jun 2021 15:58:31 -0400 (EDT) Received: from imap21 ([10.202.2.71]) by compute2.internal (MEProxy); Fri, 18 Jun 2021 15:58:31 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeeffedgudefiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepfdet nhguhicunfhuthhomhhirhhskhhifdcuoehluhhtoheskhgvrhhnvghlrdhorhhgqeenuc ggtffrrghtthgvrhhnpedvleehjeejvefhuddtgeegffdtjedtffegveethedvgfejieev ieeufeevuedvteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpegrnhguhidomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqudduiedu keehieefvddqvdeifeduieeitdekqdhluhhtoheppehkvghrnhgvlhdrohhrgheslhhinh hugidrlhhuthhordhush X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 8510651C0060; Fri, 18 Jun 2021 15:58:28 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-526-gf020ecf851-fm-20210616.001-gf020ecf8 Mime-Version: 1.0 Message-Id: <1d617df2-57fa-4953-9c75-6de3909a6f14@www.fastmail.com> In-Reply-To: <593983567.12619.1624033908849.JavaMail.zimbra@efficios.com> References: <07a8b963002cb955b7516e61bad19514a3acaa82.1623813516.git.luto@kernel.org> <827549827.10547.1623941277868.JavaMail.zimbra@efficios.com> <26196903-4aee-33c4-bed8-8bf8c7b46793@kernel.org> <593983567.12619.1624033908849.JavaMail.zimbra@efficios.com> Date: Fri, 18 Jun 2021 12:58:07 -0700 From: "Andy Lutomirski" To: "Mathieu Desnoyers" Cc: "the arch/x86 maintainers" , "Dave Hansen" , "Linux Kernel Mailing List" , linux-mm , "Andrew Morton" , "Michael Ellerman" , "Benjamin Herrenschmidt" , "Paul Mackerras" , linuxppc-dev , "Nicholas Piggin" , "Catalin Marinas" , "Will Deacon" , linux-arm-kernel , "Peter Zijlstra (Intel)" , stable Subject: =?UTF-8?Q?Re:_[PATCH_8/8]_membarrier:_Rewrite_sync=5Fcore=5Fbefore=5Fuse?= =?UTF-8?Q?rmode()_and_improve_documentation?= Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 18, 2021, at 9:31 AM, Mathieu Desnoyers wrote: > ----- On Jun 17, 2021, at 8:12 PM, Andy Lutomirski luto@kernel.org wro= te: >=20 > > On 6/17/21 7:47 AM, Mathieu Desnoyers wrote: > >=20 > >> Please change back this #ifndef / #else / #endif within function fo= r > >>=20 > >> if (!IS_ENABLED(CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE)) { > >> ... > >> } else { > >> ... > >> } > >>=20 > >> I don't think mixing up preprocessor and code logic makes it more r= eadable. > >=20 > > I agree, but I don't know how to make the result work well. > > membarrier_sync_core_before_usermode() isn't defined in the !IS_ENAB= LED > > case, so either I need to fake up a definition or use #ifdef. > >=20 > > If I faked up a definition, I would want to assert, at build time, t= hat > > it isn't called. I don't think we can do: > >=20 > > static void membarrier_sync_core_before_usermode() > > { > > BUILD_BUG_IF_REACHABLE(); > > } >=20 > Let's look at the context here: >=20 > static void ipi_sync_core(void *info) > { > [....] > membarrier_sync_core_before_usermode() > } >=20 > ^ this can be within #ifdef / #endif >=20 > static int membarrier_private_expedited(int flags, int cpu_id) > [...] > if (!IS_ENABLED(CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE)) > return -EINVAL; > if (!(atomic_read(&mm->membarrier_state) & > MEMBARRIER_STATE_PRIVATE_EXPEDITED_SYNC_CORE_REA= DY)) > return -EPERM; > ipi_func =3D ipi_sync_core; >=20 > All we need to make the line above work is to define an empty ipi_sync= _core > function in the #else case after the ipi_sync_core() function definiti= on. >=20 > Or am I missing your point ? Maybe? My objection is that an empty ipi_sync_core is a lie =E2=80=94 it doesn=E2= =80=99t sync the core. I would be fine with that if I could have the co= mpiler statically verify that it=E2=80=99s not called, but I=E2=80=99m u= ncomfortable having it there if the implementation is actively incorrect= .