Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp537797rdb; Thu, 19 Oct 2023 11:17:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrCegsz5KmNNtiyWjOuKjtwJRP+8eI0/OumteUAAeTc8fIw3DJDc3EPDUY9I1UHWCbIR1h X-Received: by 2002:a05:6a20:3d07:b0:128:ffb7:dcfe with SMTP id y7-20020a056a203d0700b00128ffb7dcfemr3836848pzi.1.1697739448809; Thu, 19 Oct 2023 11:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697739448; cv=none; d=google.com; s=arc-20160816; b=Ii5C/gqA0W7y73C1xlrLPCD5/yzI/i1ZiGmLEnjwTohmhRMCFNQdqmYqjDwdP2ARWK SBTGP4tAMz4+rLPDl6sanz98qJJNfqxw/oOtbipgVAEYLBsEcEa2Kdeh8lsaIHOAwAyU Hj9MR5o21jeyMUAJEo9eqEboZ6znOcuVfgYtm4EAjmBTJqwZzSkq+XOxFIOiys9qiwJp lnSVWf/XOCeKVmfm7WsVTcp8f1LfifIjCPBFdHuRbgCqouT3o2CjyfGZ3843yiapFfvk x4qjE4SobkyWbQvEc2787eNnf2Ccp6yOJtepvwDzsBRveS38EzNar45cc41N/vZJMZ4p bMNg== 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=YMvBZw/5ibdJUtRpjBP1gLboueYiqJ7FmUJP3xGwISY=; fh=TuuuGpTiDGt8cLITKAD9aywCBLE/HV6krcer7Bl+EDo=; b=YtsaarNYoGULc8QZ+rgs5Vd9ufgFtiRwI5IbnLcfK1D/ADb2cCeFInKI/nFBLwjYbo udmd7NhLXXGrnN336RRhmiUSeXEp5ehMTVVH2KsNzvWvpwrFq5BObwMiOgGH67Vd3n5m MWoPHupOmb/cGlWXpF9B7AaZ14H3xIaxqhiInoKKWSzdvamf80HQNzs6eeiGOerI9fj1 TAJnqNJyerpTS7wwb5gcjct0y2+zElvayuXfxsnz5YkhX1CsXVmKeNbDN7NjXIzy0mBR TZrOQdgej7xVHJqvMcEezy7TPL/vxDOpElrEoJFnLwhiEpO2L7g+X2SzMg978ki/ST8A 4Ncg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Lz7EWYYC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id m185-20020a6326c2000000b005859e224624si109042pgm.823.2023.10.19.11.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 11:17:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Lz7EWYYC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 2CF7B801B4A9; Thu, 19 Oct 2023 11:16:47 -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 S1345100AbjJSSQm (ORCPT + 99 others); Thu, 19 Oct 2023 14:16:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235514AbjJSSQk (ORCPT ); Thu, 19 Oct 2023 14:16:40 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 681BA124 for ; Thu, 19 Oct 2023 11:16:38 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-507c91582fdso2866903e87.2 for ; Thu, 19 Oct 2023 11:16:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697739396; x=1698344196; 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=YMvBZw/5ibdJUtRpjBP1gLboueYiqJ7FmUJP3xGwISY=; b=Lz7EWYYCxgfXfnRR1b5i8rQo4EZ1BWBr+Eb6NXmk3DSNaTe7/+v2Bf0BvkXS2Wixlm YeBX2D1hBa2tmQUft9ozJFhuggnsH2UZoGPPaurug73VCR8oBVEfsrywSogmVmKzEY0O IEL7rQqGKZVfVQp0+lAKLbGOMVMnp2IIFygHifHVm16LH6s1HK57XXjMMStpzkmBNjg9 vPPxWccLZEkLsypobfcsuC9Bw/+W2YOZbMZhYA+nW69X+vYlaKepMIRnNbmqJ9o99MVJ LPgB78giTjHBkoQOHF4x4fJkuScUTMYtO6l6ewEpfM7093NeXWsAwHl6yDpZ4UBD+YYM gNXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697739396; x=1698344196; 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=YMvBZw/5ibdJUtRpjBP1gLboueYiqJ7FmUJP3xGwISY=; b=sFJCaTHd734SH2GNm+0qKMsYwzntJA2lgWaGTC1/SMJxNq34yB3OVCzXIocVhKjNf5 PsCNAMKCFmuCVoMi5yxu1t5oO01IHKSOyEVXjRogr7BdECBxZFI4uc7G8AcFxUK3wwJl 1LOe+pp9tReka/tzpV8i4YOw4AF6GxJn/Ivx6NMvZ6dqtvw4vlAxT1UEPIT1YOGExZbk SsU1v40WIX7z2H/pBdf0yo0mFAwx6bGrmTTv0x4/1zigFAEhwQ7UeHbcHM7DhOwMl3PT EImmI5alJ2xAle3EvMB7UdH8bhwxg/4LRgKGUDWAC+sClRELhzw0pfmQL36kkhPt4LUE 086w== X-Gm-Message-State: AOJu0YzsOQG5chw+pxkrtZR/Ot7KR3pNwXvGvUQabmwwegmBk4KuHGhL jjtDSAKwPx+5WWD9HfokYsHYQA+Ws/pm9M+IaPE= X-Received: by 2002:ac2:58ca:0:b0:507:a96c:e76 with SMTP id u10-20020ac258ca000000b00507a96c0e76mr1901093lfo.21.1697739396328; Thu, 19 Oct 2023 11:16:36 -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: Uros Bizjak Date: Thu, 19 Oct 2023 20:16:24 +0200 Message-ID: Subject: Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr() To: Linus Torvalds 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" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 11:16:47 -0700 (PDT) On Thu, Oct 19, 2023 at 8:06=E2=80=AFPM Linus Torvalds wrote: > > On Thu, 19 Oct 2023 at 10:21, Uros Bizjak wrote: > > > > > A compiler that were to rematerializes an inline asm (instead of > > > spilling) would be a bad joke. That's not an optimization, that's jus= t > > > a crazy bad compiler with a code generation bug. > > > > But that is what the compiler does without volatile. > > Do you actually have a real case of that, or are basing it purely off > insane documentation? > > Because remat of inline asm really _is_ insane. The following testcase pushes the compiler to the limit: --cut here-- extern void ex (int); static int read (void) { int ret; asm ("# -> %0" : "=3Dr"(ret)); return ret; } int foo (void) { int ret =3D read (); ex (ret); asm volatile ("clobber" : : : "ax", "cx", "dx", "bx", "bp", "si", "di"); return ret; } extern int m; int bar (void) { int ret =3D m; ex (ret); asm volatile ("clobber" : : : "ax", "cx", "dx", "bx", "bp", "si", "di"); return ret; } --cut here-- Please compile the above with -S -O2 -m32 (so we don't have to list all 16 x86_64 registers). And NO (whee...), there is no rematerialization of asm (foo() ). OTOH, there is also no rematerialization from non-volatile memory (bar() ), although it would be more optimal than spill to/fill from a frame pair of moves. I wonder what are "certain circumstances" that the documentation is referring to. Uros. Uros.