Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3916631rdg; Wed, 18 Oct 2023 09:27:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEY07V0ysXbyZzJr8yThZNJXT1PWCl4tmOmDHr/kMbydtnXHscJkFhE3SuMzmr13ASU29OY X-Received: by 2002:a05:6870:ac29:b0:1e9:de2c:3bd with SMTP id kw41-20020a056870ac2900b001e9de2c03bdmr6818887oab.30.1697646442206; Wed, 18 Oct 2023 09:27:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697646442; cv=none; d=google.com; s=arc-20160816; b=hIFC6vjNJLnrA4bciAR1CXUxbLY45KBJzcbrxXoAefTxfH3EOoqnZ7Xh+/ar7l3R0d GpZvBOf6dAE/a/yH8eqW/ssk0DyGx36TnfO7v3wJrtq5kcrYE/1FvQE9HOLon5+aTxQL Wk2nklLQJxfdaj3JbTDp0RmED/Ug+RMq41ZTf/uHZjGKFQVagwMza6wdrrcaAfbcyH7h I5NpL8hSy37x6wFwJ2HZNdNDRbpKlG8yaGqv6cR6ZHGw8CMG1fVin7xAiWKYZscDMOt+ F1uy+wt0uNdZhwwI9YDEqMFeA7G/wa4yAOb7s4/wj9kL8cltH1gnZEfpMf/Ucm7axrun WgHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Fa5WhSbXi1geOvYtlQrVXIlJD9l6hQOxw08qavSltA0=; fh=2W7QWOT4LLEZc93hpAJV9qeXTsNW2Zd+/+ufcs7IIZU=; b=MZ1l3Ww2SwwXONWZAe34qJHtIPvviW476DwDtFam9ncZJpyur7twki4vVCMHyo1n3q ZoPdLeegV3er6ySTYcwGN19O46G20VfuCZWvlcHB/fbdWCr4s2SkE5DTuhYprsJN+RUe GwnE0d+qYLxMON9801sVcHo6To23m+gXCrQ2jIU0GELqh4wQwWd7/ib6L9Y3qlRlXdY3 ZBjMjfUMSl3iV6TfKwq4RhOfLyFfn6OrQdrqr4sOqhJPlM5CM7e0FebXkdylG4X/Mzni rJVqGwJrd15gO5QDWTzPgH5mNFYQ7MvKBAAZY0jW3gP5ruHiqk7OiQuBtlSQhp4hLDl/ qjuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=N8s3FIQw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id 201-20020a6300d2000000b005b0c0fd35f0si1477717pga.695.2023.10.18.09.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:27:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=N8s3FIQw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id ACE4480A856D; Wed, 18 Oct 2023 09:27:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230284AbjJRQ1H (ORCPT + 99 others); Wed, 18 Oct 2023 12:27:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbjJRQ1G (ORCPT ); Wed, 18 Oct 2023 12:27:06 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DED7A137 for ; Wed, 18 Oct 2023 09:26:59 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-53ebf429b4fso6269878a12.1 for ; Wed, 18 Oct 2023 09:26:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1697646418; x=1698251218; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Fa5WhSbXi1geOvYtlQrVXIlJD9l6hQOxw08qavSltA0=; b=N8s3FIQwP7ZDvI3RCx/7azZDc46BVrAYwOWyOrcjkNGY3PCG2PEMh6snP89jXFDj0r YEpE3SbtrjM/puKcv7xMBuPp8GDkTTqy6lzf0LwUmHNzNj3R5G4KBg8mCm6nrq7vgC84 OyPdANA2ajDLuLtE05Iv213akT9T03ghUwEh8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697646418; x=1698251218; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fa5WhSbXi1geOvYtlQrVXIlJD9l6hQOxw08qavSltA0=; b=UfdlbdwIIQaTm0OHOq+7+2iSGA1iZiMywwsCqFN73eBv5WD452pijxKXTmnNxsRivH B5g64hlDxJ9rmx9Z0HaDne5gp/F1BlAE9M2Et5hd7sZPVgrAdjd6MboGirXMLeIYKhC6 VCJuiMSsq0IHm6kCFDpsqt6AwlxCbXhLKZ9exG8e3l9XFjhKMvYVeUOP48IxSHzHYU6N 8X3RlBMGBDx6CSLftB7rDj9ESTYaxEALtoPL9+o6ASYD/jBDUcmQ+WrgtCCbMlNCXwql fvC/EFkRZGRUCOhXnJoXWXgj3Jjm+ve75NWqle22m5MNM8hpOSALK1IAr0A9oMHf+3CH kJkA== X-Gm-Message-State: AOJu0YxSXeKNNbFmImKOlfzKf5IjdA4mmvepncp1DOi8QgdhxNBrm6NZ 3GOdRgejLZRiH75V8+sbUzcU8gNNxWdH9Qk9/NdGa8yD X-Received: by 2002:a17:907:744:b0:9bf:63b2:b6e2 with SMTP id xc4-20020a170907074400b009bf63b2b6e2mr4844033ejb.26.1697646418116; Wed, 18 Oct 2023 09:26:58 -0700 (PDT) Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com. [209.85.218.50]) by smtp.gmail.com with ESMTPSA id t12-20020a1709060c4c00b00997e00e78e6sm1990722ejf.112.2023.10.18.09.26.57 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Oct 2023 09:26:57 -0700 (PDT) Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-9ae2cc4d17eso1139474666b.1 for ; Wed, 18 Oct 2023 09:26:57 -0700 (PDT) X-Received: by 2002:a17:907:1c0c:b0:9be:b43c:38dc with SMTP id nc12-20020a1709071c0c00b009beb43c38dcmr5130678ejc.12.1697646417119; Wed, 18 Oct 2023 09:26:57 -0700 (PDT) MIME-Version: 1.0 References: <20231010164234.140750-1-ubizjak@gmail.com> <0617BB2F-D08F-410F-A6EE-4135BB03863C@vmware.com> <7D77A452-E61E-4B8B-B49C-949E1C8E257C@vmware.com> <9F926586-20D9-4979-AB7A-71124BBAABD3@vmware.com> <3F9D776E-AD7E-4814-9E3C-508550AD9287@vmware.com> <28B9471C-4FB0-4AB0-81DD-4885C3645E95@vmware.com> In-Reply-To: <28B9471C-4FB0-4AB0-81DD-4885C3645E95@vmware.com> From: Linus Torvalds Date: Wed, 18 Oct 2023 09:26:38 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr() To: Nadav Amit Cc: Uros Bizjak , "the arch/x86 maintainers" , Linux Kernel Mailing List , Andy Lutomirski , Brian Gerst , Denys Vlasenko , "H . Peter Anvin" , Peter Zijlstra , Thomas Gleixner , Josh Poimboeuf , Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 18 Oct 2023 09:27:20 -0700 (PDT) On Wed, 18 Oct 2023 at 09:03, Nadav Amit wrote: > > Having said that, I am not sure what other usages you have in mind. > =E2=80=9Ccurrent=E2=80=9D is a pretty obvious straight forward case with = considerable > impact on code generation. There may be additional variables, but it is > likely that there would be more functions/TU in which they would not be > constant and would require more refined techniques to avoid mistakes > such as the use of stale cached values. Yeah, I don't think there really are other cases. We do have things that could be considered stable (like "smp_processor_id()" which is stable as long as preemption or migration is disabled (or it's in an irq-off section). And it might be lovely to optimize those too, *BUT* that would require that there be a barrier against that optimization that works. And if there is anything that this thread has made clear, it's that the whole 'load from a constant section' doesn't seem to have any sane barriers. So while the CSE for inline asm statements is a bit too weak with that whole "only CSE within a basic block" thing, the CSE of "load a constant value from memory" is too *strong*, in that we don't seem to have _any_ sane way to say "now you need to reload". The traditional way we've done that is with our "barrier()" macro, which does the whole inline asm with a memory clobber, but even that doesn't act as a barrier for gcc optimizing the constant load. Which means that while we'd probably love for the compiere to optimize smp_processor_id() a bit more, we can't use the 'stable memory location' trick for it. Because I can't think of anything but 'current' that would be _that_ stable as far as C code is concerned. Linus