Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp472951rdg; Thu, 12 Oct 2023 10:47:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHrWYUj89pnjy14d+esBfvL6c3ukF8ar/tq2qRW+Q5ynW8zg7ZBTwYyaqgRWXIh2iuF6ClF X-Received: by 2002:a92:cda2:0:b0:34d:ea35:842b with SMTP id g2-20020a92cda2000000b0034dea35842bmr30683191ild.27.1697132867096; Thu, 12 Oct 2023 10:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697132867; cv=none; d=google.com; s=arc-20160816; b=TtyY/H1PEPdqbmQHfFZpWsC5xpOVy4XHAM5PisPpmp5EnqHM5HmMUcw9miBTDKPVkS 1eGFN9ruAd1Z456m+dIKb+OFvao2lJpJ1LQ5ssUEWuGjfFpX2j4xHIK5/n0oO50Nj/vo Q42PozrQmKvPVQ8r+h0aDIJ0aqZWTKE1sqlkzHiXUKDXkFr1qPCQppn1cTLjh6leCyD0 Tr16U5wMyxrHuyJgiOmzvgrvIGt/qEgwegLk2ggK8ouXTzJMdZGvNkWVE7cXBkcCoiur YbIKaVD5CXzpTvvQBUM5h3G5mlDeNDMRWcYUf/5tz7No2wuObREQ6uJuQX7LfgtP55dD dNew== 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=XwbTrkbxDIFSg05UbqbWKfMPoF8XcfYtFUblxKnNE4s=; fh=3hMqaci1aSMG0AFmuDTcNcT9Fdla45I/j/Dj+Dy/pas=; b=ldQAmHatQmz6HhIeFOur/tjyzDNm/C00n6WO1KdpfH9bq5+r8PP1I7scApyE0XpHg4 Gbyeb/VmOLQ0H+mvdgwEz/ABTz3mNWQ3+v30Zl6GXJ+8cftPo26/mNKGimqxx3GsQttM y36ecbQXVOrP6jTfEgLX8S8msfjjt38kc3ohzh/WfNEMj3JU8JXeSbqNrGufKwKLUeEw rYswB3VdyLXmgMuy9Fq5zGwObfr+XnyZ0S35fWG3Bw6BYQgq3CgkBoTZ515o2g6/22ra kzmd2FC6YHXpLbwzXHSBuZotRiiQIsxwVGdXEulweAUXUqvoJd6XQCb2IzzZUK47b1oH 59zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=VJ7nwvbV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bt21-20020a056a00439500b0068a52819fd2si15068998pfb.331.2023.10.12.10.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 10:47:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=VJ7nwvbV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id A1C17819F999; Thu, 12 Oct 2023 10:47:42 -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 S1379617AbjJLRrf (ORCPT + 99 others); Thu, 12 Oct 2023 13:47:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379549AbjJLRre (ORCPT ); Thu, 12 Oct 2023 13:47:34 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34D4EB8 for ; Thu, 12 Oct 2023 10:47:31 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-9a58dbd5daeso205210466b.2 for ; Thu, 12 Oct 2023 10:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1697132849; x=1697737649; 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=XwbTrkbxDIFSg05UbqbWKfMPoF8XcfYtFUblxKnNE4s=; b=VJ7nwvbV2MxMYJLoN3Sx5NCv8Jv+HnhnubmYeT6p47RU8pKp6wq6uEvYPsWn0rNLWp yG19VXX38sN8J8scDKwMPheII/k/WX+bmozIJlVxtUq3MNGYfcLNvm3q9k9rytueDwHD JKPn+if3Id8Mc4maqQO/Xz8pqPg/6hPeJziUQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697132849; x=1697737649; 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=XwbTrkbxDIFSg05UbqbWKfMPoF8XcfYtFUblxKnNE4s=; b=N9wdvPOkn3UTl5+2m1TmAn6TBYY0WzsN5URTAve7Gv92x2y3fX9goSr0NOG8tjcrvz jlyNuaecvs+xzQ/qeqt3bGEwYBYhijMSgpRMNJSD2x0OE3TivgYwg32N0f/JXyWehRsG 0IBQL7KakIL2q6dXVrqqCwKkMKF2x1ECo7U1CVVr98pT26chUnxWytFZvIVyK6x+hFtH gh/HBkSdamZRJC76G7du8kOAXS0ik/IB2m1dJJMwrzIpEEA4nzQ0V9F/CUem/EDxROt0 /T67FmITDBkC2ZnKh0Z7gAzech0Bq5cuMn0y65XOD8MT0zNxxFPglCkrYIo5oCP2I6hi Q94A== X-Gm-Message-State: AOJu0YyveYxiIy2ayuptyiQslVMJeBf0tlfY4L47+r84Yyp6/N8MTz0D 2X1FGqdxJHRRyGWzN+1pW3O5JWT6DYMpb0ikss86RYNS X-Received: by 2002:a17:907:7636:b0:9ba:4163:1801 with SMTP id jy22-20020a170907763600b009ba41631801mr6955484ejc.60.1697132849443; Thu, 12 Oct 2023 10:47:29 -0700 (PDT) Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com. [209.85.208.50]) by smtp.gmail.com with ESMTPSA id p8-20020a170906b20800b009a1b857e3a5sm11333986ejz.54.2023.10.12.10.47.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Oct 2023 10:47:28 -0700 (PDT) Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-53d8320f0easo2144786a12.3 for ; Thu, 12 Oct 2023 10:47:28 -0700 (PDT) X-Received: by 2002:a17:906:191:b0:9b2:b7f2:bc7a with SMTP id 17-20020a170906019100b009b2b7f2bc7amr25226560ejb.34.1697132848272; Thu, 12 Oct 2023 10:47: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: Linus Torvalds Date: Thu, 12 Oct 2023 10:47:10 -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: 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" 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 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:47:42 -0700 (PDT) On Thu, 12 Oct 2023 at 10:10, Linus Torvalds wrote: > > 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]") \ Nope. That doesn't work at all. It turns out that we're not the only ones that didn't know about the 'a' modifier. clang has also never heard of it in this context, and the above one-liner results in an endless sea of errors, with error: invalid operand in inline asm: 'movq %gs:${1:a}, $0' Looking around, I think it's X86AsmPrinter::PrintAsmOperand() that is supposed to handle these things, and while it does have some handling for 'a', the comment around it says case 'a': // This is an address. Currently only 'i' and 'r' are expected. and I think our use ends up just confusing the heck out of clang. Of course, clang also does this: case 'P': // This is the operand of a call, treat specially. PrintPCRelImm(MI, OpNo, O); return false; so clang *already* generates those 'current' accesses as PCrelative, and I see movq %gs:pcpu_hot(%rip), %r13 in the generated code. End result: clang actually generates what we want just using 'P', and the whole "P vs a" is only a gcc thing. Why *does* gcc do that silly thing of dropping '(%rip)' from the address, btw? Linus