Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp475397rdg; Thu, 12 Oct 2023 10:52:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkPrFR/XPA0T6+9YXrDup2V3iqYyUw2oNVnTW+2t9Yli+t+wNTDH0LNKniZvDxH4x3AupS X-Received: by 2002:a05:6830:1642:b0:6b9:c51c:f4d5 with SMTP id h2-20020a056830164200b006b9c51cf4d5mr26631827otr.10.1697133164230; Thu, 12 Oct 2023 10:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697133164; cv=none; d=google.com; s=arc-20160816; b=dm/tqfAEoabgKASuOLI3DAF8h5DOxWbac1zsAtK2x3mAgtlRlzq2CsOnJHbAmkDs6f zW1dNRnoeVaC93/O7aK+XVMFljVixs4lImJMM5L7VutfmIgXYIyjp07IexgCJXERK2+u TFFexn/LB6Zi9oXSS9CwDtUdiUThF25kakKXSqXK2REbH10h+xYjRHcEK7X8G7mMr4Hy bUUflHxHDMU3WGpmoW7Y0Fx4DdWXuTy1Lf/jYnpGHUh8hvJR7ccEvEcgxm7kA94equlW lG1990GQVluo2uOnFAFE+F107egTSnydziDXhzqbx1LblzLdZfG4T1X9N5u+hS9sLvBH zJdg== 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=pWeWf9WKcL+DWJavFYJJq/qaaNEhtZOwsOe7pUHZDW4=; fh=/Dnf++/2xG0Xi30TGscvcX3UaoYjzLSxPPap0bUcRsE=; b=a/ZTbk5oFUfTQtcfiO8rxg2qj7YcX6b45fc+ASGUOG65kSXzkM4uWJAdekoTnQ9aqZ yqBLCkJ6eEe1P133PVLGZsSpptVApthnc8OXXNZBRFSoVeP6/T0Hw6wtbPUk2HRzXMUB 6YVPVoCpb40wZfRH+XcLugjp2OhJ/AY6md7+so3aKtP6wS6fZiIDfrsHP8Xf910ZuixW r9WpPepOwrEnRaJblrs4hOpz+Stj/HJmSnFso5ESiglmpNrCp8KDtAaq0Cjfh838OMzs gKLQ9PsCIz/u9gVuLHw2B+eF+m8zgv2drHy8cdlQEcSAW3neFOEJzkOzYt4Z/bJRprG4 THtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=at+ZF7Gq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id d4-20020a056a00244400b0068fea8a6169si14946162pfj.404.2023.10.12.10.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 10:52:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=at+ZF7Gq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id EEE9B819F9B6; Thu, 12 Oct 2023 10:52:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441845AbjJLRwd (ORCPT + 99 others); Thu, 12 Oct 2023 13:52:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379655AbjJLRwb (ORCPT ); Thu, 12 Oct 2023 13:52:31 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA54BD9 for ; Thu, 12 Oct 2023 10:52:29 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-53dd752685fso2236659a12.3 for ; Thu, 12 Oct 2023 10:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697133148; x=1697737948; 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=pWeWf9WKcL+DWJavFYJJq/qaaNEhtZOwsOe7pUHZDW4=; b=at+ZF7GqHA82Aey/60EeWFPxzmfMHogXYlB3VK0kIwgSvmBahbQWoYKci7YgMDNedb 9DzrBcaT9rWEmMMYoom3TjkSJB0SzE/AqeHkqqcsmYQdrrTfOCem+nPqodwBnMXNiuke Cj/pKIwRAqwFGt17QKXzoDu3/TcZoThbXKSh2KX8aUv2VcMd5g3GMRW/QVMbG8UICgTy EH95z+ieG0VVjKJj6qASCjqxuRbxR3e9JQabBOa/D79JzymCvGbO1RFnDYxAGkNW53NT 316Mhj1VbO4yTTnBiH5+vS4G1I9ejGDGKyWlgl+LLzKTpDRYFiOkwFhYnB+dtkmldwJt Mulw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697133148; x=1697737948; 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=pWeWf9WKcL+DWJavFYJJq/qaaNEhtZOwsOe7pUHZDW4=; b=OEXPXKYL6wf3am5ZAYoGAaQIB3L59lgeQW3YLYtEbJ5mwyXWJPEviFY1sZbh3S1nIJ W6RDp2RUeFN5OV6b9VN1BXuTXsXke5URKXfP7RGFMlxVXtUZIyMayV2uXgNczLefbSIo GrAIjmFSt9aWGcC35eP6FyXtkJFi4fZNjP5ErN6mS5QqMEgrwfRklRZC44rlCFnPhRDz Is+3ytuHC4/vCVYXeRyxlRH41ycp2sZsXjgOJoHyI+WCDoI9ODYYnz8sq5Ii9ypS9bB4 1P1cc6ffIhLS5F9vvxKH9KbPQsvI60yO/TedB1/eVaD8PtCVfwIlNA+NY2t5N+J+biEy WODg== X-Gm-Message-State: AOJu0YzBo/XkhU93WWg15lrUgghfxfKmxjO9x3moffRx8UGifaQJDxUY 3fxVXnScKhswsLz1YTs4gWcAf4R889wgUuKPMozwVNIkDr3mLQ== X-Received: by 2002:a05:6402:205:b0:534:8bdf:a258 with SMTP id t5-20020a056402020500b005348bdfa258mr22151348edv.31.1697133148079; Thu, 12 Oct 2023 10:52:28 -0700 (PDT) MIME-Version: 1.0 References: <20231010164234.140750-1-ubizjak@gmail.com> <0617BB2F-D08F-410F-A6EE-4135BB03863C@vmware.com> In-Reply-To: From: Uros Bizjak Date: Thu, 12 Oct 2023 19:52:16 +0200 Message-ID: Subject: Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr() To: Linus Torvalds Cc: Nadav Amit , "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.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 12 Oct 2023 10:52:42 -0700 (PDT) On Thu, Oct 12, 2023 at 7:10=E2=80=AFPM Linus Torvalds wrote: > > On Thu, 12 Oct 2023 at 09:55, Uros Bizjak wrote: > > > > An example: > > Oh, I'm convinced. > > The fix seems to be a simple one-liner, ie just > > - asm(__pcpu_op2_##size(op, __percpu_arg(P[var]), "%[val]") \ > + asm(__pcpu_op2_##size(op, __percpu_arg(a[var]), "%[val]") \ The effect of the change: 25542442 4387686 808452 30738580 1d50894 vmlinux-new.o 25546484 4387686 808452 30742622 1d5185e vmlinux-old.o > and it turns out that we have other places where I think we could use tha= t '%a', > > For example, we have things like this: > > asm ("lea sme_cmdline_arg(%%rip), %0" > : "=3Dr" (cmdline_arg) > : "p" (sme_cmdline_arg)); > > and I think the only reason we do that ridiculous asm is that the code > in question really does want that (%rip) encoding. It sounds like this > could just do > > asm ("lea %a1, %0" > : "=3Dr" (cmdline_arg) > : "p" (sme_cmdline_arg)); > > instead. Once again, I claim ignorance of the operand modifiers as the > reason for these kinds of things. > > But coming back to the stable op thing, I do wonder if there is some > way we could avoid the unnecessary reload. > > I don't hate Nadav's patch, so that part is fine, but I'd like to > understand what it is that makes gcc think it needs to reload. We have > other cases (like the ALTERNATIVE() uses) where we *have* to use > inline asm, so it would be good to know... > > Is it just that "p" (in the constraint, not "P" in the modifier) ends > up always being seen as a memory access, even when we only use the > address? > > That part has never really been something we've been entirely clear > on. We *are* passing in just the address, so the hope in *that* place > is that it's only an address dependency, not a memory one. Let's see the difference of: --cut here-- int m; void foo (void) { asm ("# %a0" :: "p" (&m)); } void bar (void) { asm ("# %0" :: "m" (m)); } --cut here-- The internal dump shows: (insn:TI 5 2 15 2 (parallel [ (asm_operands/v ("# %a0") ("") 0 [ (symbol_ref:DI ("m") [flags 0x2] ) ] [ (asm_input:DI ("p") rip.c:5) ] [] rip.c:5) (clobber (reg:CC 17 flags)) ]) "rip.c":5:3 -1 (expr_list:REG_UNUSED (reg:CC 17 flags) (nil))) vs: (insn:TI 5 2 13 2 (parallel [ (asm_operands/v ("# %0") ("") 0 [ (mem/c:SI (symbol_ref:DI ("m") [flags 0x2] ) [1 m+0 S4 A32]) ] [ (asm_input:SI ("m") rip.c:10) ] [] rip.c:10) (clobber (reg:CC 17 flags)) ]) "rip.c":10:3 -1 (expr_list:REG_UNUSED (reg:CC 17 flags) (nil))) The first argument is internally regarded as "constant": -- Macro: CONSTANT_P (X) 'CONSTANT_P', which is defined by target-independent code, accepts integer-values expressions whose values are not explicitly known, such as 'symbol_ref', 'label_ref', and 'high' expressions and 'const' arithmetic expressions, in addition to 'const_int' and 'const_double' expressions. So, it should not have any dependency. Perhaps a testcase should be created and posted to gcc-bugs for further analysis. Uros.