Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp547788rdb; Thu, 19 Oct 2023 11:38:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFFjaWPcz6Bp6Q72CHvBLwIfY0kPwH9xF5gpsnYAwi/betPEcrph1ZBCtYX18X75t8hRZVz X-Received: by 2002:a05:6359:3015:b0:13c:eea2:d021 with SMTP id rf21-20020a056359301500b0013ceea2d021mr2606894rwb.9.1697740683986; Thu, 19 Oct 2023 11:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697740683; cv=none; d=google.com; s=arc-20160816; b=XNXEO6ElCtvexlBLJdLd5GjWNH8HUH/J4MjFH5FoLRvkIDaCJtDvEFRhYf3XPHT5Ku I2GfL1xZPsTVOvHcehH1Us42FQIM8AMySc/VyEuLCaD8oeDNlzkyCLlkeTIFSINkwQ9d Hqaxx1AD/sj94iEss5HJhhcebyuvhKD/BnFA9IGuC8k2vV2bpkeQDFuUlvU03yZ8qFj0 6KltnVSAz8+W4lFotC7YtUQ0vgh9CBo5CrE/clx8GkV6hXZji3ZqKFh0yPWt7aixh5na IjhVJ2bXpiBteTHiB0eg//7r6JJs1fPZCOImRNvo3e+HR5ipWjKVGa+xcHcRDEJ1VE4D 4E8Q== 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=tWF+wHWkChXhN6iIX2xagS57zOPfIX+NhafNJTMlCrE=; fh=Gz3p2oSXPireyFs9lNT6J0tiXf68nE2nD2nXqm3YcO0=; b=HOB/oUULJmoHk0DKmCnlfAYQmHebzgTdflx7dC9F23BlprhCJsYzYMMZ2z5F/4ulRc NludVHuzNtwJDoXOQ3UgXad7olB9dEcD5O4b91Ejdk96kHd4ODgVWA9uZ5sFwOHj11ll xNMir2daQQGsnEJupKYjbosJJ0KOH5N9J3xWC1xC4fW+fmjXTtQo322Pblvm108JIM02 pKfirxHaRI5utgyJN5VZ8X+PSsuffHKbbo23O91sx1tiCDMh5AVCoJsgzSzpRatZAooB U4f0Rn/WkvsEaSAv3kwg3UciI4ewHSf2+dmKa5LDQHIeRkkV4+jCaXddrAp21HWZjP1u d7pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=j3nPTXuO; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ca27-20020a056a00419b00b006be0b790ebfsi194639pfb.255.2023.10.19.11.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 11:38:03 -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=@gmail.com header.s=20230601 header.b=j3nPTXuO; 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; 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 988A1804DD95; Thu, 19 Oct 2023 11:38:02 -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 S1346451AbjJSShy (ORCPT + 99 others); Thu, 19 Oct 2023 14:37:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346455AbjJSSht (ORCPT ); Thu, 19 Oct 2023 14:37:49 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BD9B126 for ; Thu, 19 Oct 2023 11:37:47 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-507a29c7eefso7987063e87.1 for ; Thu, 19 Oct 2023 11:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697740666; x=1698345466; 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=tWF+wHWkChXhN6iIX2xagS57zOPfIX+NhafNJTMlCrE=; b=j3nPTXuOJuHJf2aI4J7CRGFLIoIIt9mjMIkGr+MfldBn6Dc2HGeM816ycw2+erjFzB bktUOYpc+gsYHMLjTlqWKQ4XOxTgVdmgFqJTOzzwnOWshDfPbcqPaGW2vTXW9IcvIn7B flIklRkcVUZXJO8eCiArfcu/G/fIfWCLQ+nTkui+ks1Gr2AqIrBJkpYMDIMQmmRSHAke R3h/Op5VQk4vuX7zt2wWV6f76npMFF53pMkIa24ttTPyBN0BRlSjqnp/mjsFWd8lWSWZ +5/2saC/83dn/Lj5jYDkD95nfOgR5GPoWqHmHuVo1OpQggYU4WOlufJ64Pnq4rEKSGxa smIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697740666; x=1698345466; 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=tWF+wHWkChXhN6iIX2xagS57zOPfIX+NhafNJTMlCrE=; b=nyUyvrN3pcbSucIHg9fFh/Rxr9m4wYe4GuQsUudlJl+A+MQnkx4xF95KxV1EZOxiQF h1FIjaKaxtNSaxF6dC8htIct5/FUXVcvM9wcMuY70BG1St0zIcyvhmB2bu0g3NNw5qcw iPqeo74fIFfEWN2u1zrUpjMkunpqPm1GpLUaiEmm6WsGDj9BYbSL9R45KwmgBxr+W3iw 6OF62jVt7yYRttB8X7C9CoZRZW5fkbkFNdHtzchjNaM/oFR37b5w9Xwm+xqBMGmPZkHS Vlt7UnObaG6r3EjkTTHQ52uQsqxYbCmAIJvKhXdnvcdBuExKxkHbPNl6c3jRjSx020gP Z9gQ== X-Gm-Message-State: AOJu0YybwKOW0xtffbRlEtyZt8+tifOKMeuHPZbw89ZiY+SQ3o2sf4S8 +R4zD+33IT3QkRIJSGLMLgcNs+MMK1Vz+F9Cvq8= X-Received: by 2002:a05:6512:3d05:b0:500:be57:ce53 with SMTP id d5-20020a0565123d0500b00500be57ce53mr2585608lfv.42.1697740665278; Thu, 19 Oct 2023 11:37:45 -0700 (PDT) MIME-Version: 1.0 References: <20231019085432.GQ33217@noisy.programming.kicks-ass.net> <20231019181359.GA35308@noisy.programming.kicks-ass.net> In-Reply-To: From: Uros Bizjak Date: Thu, 19 Oct 2023 20:37:33 +0200 Message-ID: Subject: Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr() To: Linus Torvalds Cc: Peter Zijlstra , 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_NONE,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:38:02 -0700 (PDT) On Thu, Oct 19, 2023 at 8:22=E2=80=AFPM Linus Torvalds wrote: > > On Thu, 19 Oct 2023 at 11:14, Peter Zijlstra wrote= : > > > > But are you really saying this_cpu_read() should not imply READ_ONCE()? > > Well, Uros is saying that we may be *forced* to have that implication, > much as I really hate it (and wonder at the competence of a compiler > that forces the code-pessimizing 'volatile'). Please note that my patch mitigates exactly this. The propagation of volatile(!) arguments allows huge instruction and code savings. By using non-volatile asm, a very limited BB CSE can perhaps remove a few asms. However, if there is no READ_ONCE requirement, then we can simply remove "volatile" qualification for this_cpu_read from the memory-ops patch. It will be like a field trip for the compiler, because *then* it will be able to optimize everything without limitations. Uros. > And the "it's not volatile" is actually our historical behavior. The > volatile really is new, and didn't exist before your commit > b59167ac7baf ("x86/percpu: Fix this_cpu_read()"). > > So the whole "implies READ_ONCE()" really seems to be due to that > *one* mistake in our percpu sequence locking code. > > Yes, it's been that way for 5 years now, but it was the other way > around for the preceding decade.... > > Linus