Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp563652rdb; Thu, 19 Oct 2023 12:08:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKqofK407pH2ZWOBB9S0ItQ3rH7ha8/nI0pQdD35RTgnDtkDxCJWB1tZLUxWS9kq5jIvlh X-Received: by 2002:a05:6a21:a598:b0:16b:8bcf:9e27 with SMTP id gd24-20020a056a21a59800b0016b8bcf9e27mr3749586pzc.20.1697742489885; Thu, 19 Oct 2023 12:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697742489; cv=none; d=google.com; s=arc-20160816; b=B87rfO5GH7ODs3j5n/VuopuxmdFTFl+QgMDSFgwCQl0wA9KK/qIF9cLkNCMCwL8xNv DBOfmzzTsVHO56uaMVWGU1gQhfK044GbMFpMLvQIWG9rhGtWmmCUJseqOD/OG0ecC8IE 33g0f+6+lezmsZeYutRqOkqF8sL9yZp0Sl142kbwKZvUtzVKmkjq5CJw7F4/4kYUSEEs S50g7LOmCZMbbh82Fs4A2LH0fAW0tzsAOagMMlD3Jkf9LgCscHwJ+tXRjnsIr252FgY6 bivLhQdrAPOclcuzvT7B6SKjZeEM+82gx8c4ZRvaT6bNNVH+uLyP9p/augsDA+YFZtfJ pEJw== 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=pxkX0hlLsrsi0HqjozFEPHzJw86ORdSfG0zaw7CJEN0=; fh=l1jjhj9N74C+OUMGFFZgEIqzo5fBEvmOeqFfpgIhBwI=; b=U9R7nGuCTAzdg8Y0xU/ZpLRMnwBAwn6pMNApgaFnTqN15EfCbwp3vUUrMLT0uEGmiM JtrqfQvkd+4nhbH/9LTLUTZutjgfIpIhxguVt+GE1p7b3pn1XSTMvoHnHRVFtVXhQEZ9 zJpDX5b6e9B2qnKUZz36Uvk4ZwVpUgtrxZToTmiwzimCeESs7QgUWbxxcZzoTYwU7REg VHji7c1zsK290kCoxHhgWJREqTJsvPw/UoSAIU3xqa3ZY75dEEC/E43HgPgdO3t9JOrY y1i1zvgp6IkVFyX2YPiBbFn4BDVUdr4C4laxMadRXvy+1bRY01k6TWR2LrS8MPrOIv5v n86w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=M8fNyV8V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h4-20020a636c04000000b00578b79c785bsi217131pgc.217.2023.10.19.12.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 12:08:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=M8fNyV8V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 90F708271772; Thu, 19 Oct 2023 12:08:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346282AbjJSTID (ORCPT + 99 others); Thu, 19 Oct 2023 15:08:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235518AbjJSTIC (ORCPT ); Thu, 19 Oct 2023 15:08:02 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90026CF for ; Thu, 19 Oct 2023 12:07:58 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-9ae2cc4d17eso7501466b.1 for ; Thu, 19 Oct 2023 12:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1697742477; x=1698347277; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=pxkX0hlLsrsi0HqjozFEPHzJw86ORdSfG0zaw7CJEN0=; b=M8fNyV8V7ugc8Xf97wC4UhQxX1abftL3rgXD5RcckU6S42weGSD2KtT1wKAR5hI1uU RxdIFbNwYQtS/8bKqyw7nrDs7JFsKfTG7VHkYUjYkP8rpqdkf5VJb+u3DglsKYOLgcp4 XXY+dxhNn7ZAQk1t9Pw39JYiKetZXrZmLybow= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697742477; x=1698347277; h=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=pxkX0hlLsrsi0HqjozFEPHzJw86ORdSfG0zaw7CJEN0=; b=iltV/2EIUTGY1tJyq51XqqgHTwLHapY7h5D65TgGsWuN9HClwvC/a7216G77ASA8X3 xonP273BrAOzPZx4+S0UsiQR+n0Cd7M7RHl9BgtIj5GwA5gy3ee5VePSt69HySFg/MZ4 kxjAjKnChYr5nm7c7hJNKqXUGT77yDo1QSE1dZmRY3AQvhfuCLMcaBY8SjlyOjpk34eK Be+iMCxHxNf67s4EkVkWZgS/DNwgLO717pSreiGYBZ2/suhqRlqpPyEZy3qLVMSv2UUB j2IbZo1S+nOM9IZ3spfGSgRFsUeZRcjLLOoiZaRTwQ+mBf0jliXjoLglukRTTzNym4V5 3n5A== X-Gm-Message-State: AOJu0Ywi0B2b1xMXiq2PTOPecM19n44ZYvt8wDW87EzqEtEOYu2aMCZa PmyiVG/ZG0Be95+FCUr2PZAEWkHQ3J9c4fMYEZD6R6cW X-Received: by 2002:a17:907:268e:b0:9c7:4d98:9847 with SMTP id bn14-20020a170907268e00b009c74d989847mr2406245ejc.53.1697742476747; Thu, 19 Oct 2023 12:07:56 -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 26-20020a170906011a00b009ae69c303aasm50924eje.137.2023.10.19.12.07.56 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Oct 2023 12:07:56 -0700 (PDT) Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-9936b3d0286so9324066b.0 for ; Thu, 19 Oct 2023 12:07:56 -0700 (PDT) X-Received: by 2002:a17:907:6092:b0:9b2:b9ad:ddd1 with SMTP id ht18-20020a170907609200b009b2b9adddd1mr2654778ejc.28.1697742475784; Thu, 19 Oct 2023 12:07:55 -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: From: Linus Torvalds Date: Thu, 19 Oct 2023 12:07:37 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr() To: Uros Bizjak Cc: peterz@infradead.org, Nadav Amit , "the arch/x86 maintainers" , Linux Kernel Mailing List , Andy Lutomirski , Brian Gerst , Denys Vlasenko , "H . Peter Anvin" , Thomas Gleixner , Josh Poimboeuf , Nick Desaulniers Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 12:08:08 -0700 (PDT) On Thu, 19 Oct 2023 at 11:49, Linus Torvalds wrote: > > Honestly, I've actually never seen gcc rematerialize anything at all. > > I really only started worrying about remat issues in a theoretical > sense, and because I feel it would be relatively *easy* to do for > something where the source is a load. .. I started looking around, since I actually have gcc sources around. At least lra-remat.cc explicitly says o no any memory (as access to memory is non-profitable) so if we could just *rely* on that, it would actually allow us to use memory ops without the volatile. That would be the best of all worlds, of course. I do have clang sources too, but I've looked at gcc enough that I at least can do the "grep and look for patterns" and tend to have an idea of what the passes are. Clang, not so much. From my "monkey see patterns" check, it does look like clang mainly just rematerializes immediates (and some address generation), but also memory accesses without a base register (allowing a "base register" of (%rip)). See X86InstrInfo::isReallyTriviallyReMaterializable() in case anybody cares. So it does look like clang might actually rematerialize exactly percpu loads with a constant address, and my "those are easy to rematerialize" worry may have been correct. HOWEVER, I'd like to once again say that I know so little about llvm that my "monkey with 'grep' and some pattern matching ability" thing really means that I'm just guessing. Now, PeterZ is obviously worried about even just CSE and re-ordering, so remat isn't the *only* issue. I do agree that we've had 'volatile' on many of the asms possibly hiding any issues for the last five years. Linus