From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA492CDB474 for ; Fri, 20 Oct 2023 07:59:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376438AbjJTH7A (ORCPT ); Fri, 20 Oct 2023 03:59:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376613AbjJTH6Y (ORCPT ); Fri, 20 Oct 2023 03:58:24 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB5EF1704 for ; Fri, 20 Oct 2023 00:57:59 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-53dd752685fso683229a12.3 for ; Fri, 20 Oct 2023 00:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697788678; x=1698393478; 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=R0CED4KL9zezq3HoQP/JfPVszwxf8r4ApnYMP0RUL/M=; b=C0sKfLhmKz3ZqTRasHMRE6II4Pa0r/cb1/FarnECQZORX+7hUyzcrP0gH+ObqisR64 +7ayUB/sJ4TdkroJKZXOsaW9+nk8ascirrQkusZh5IaCbDF4XNo0PadqmUtZwZBS/+w5 Fn93P4/tjpStWjH1EgRzslrs8XDW2i3FHwUCB4o9MOclzvauSjK9776AzCKB49Wx2RjE xpkx1GmHNzvmEYxx8Lsy9wynU/zDBNYU6ghaGmzSC+eZrDpaMndJUgt61Litdtd2E1vC uqPS/Ef+emPedpyXpHEQu7pvj0Eqpi0taXtKCFvEjK4cEAuI2lw09BX5mptJIHemFeCu KIgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697788678; x=1698393478; 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=R0CED4KL9zezq3HoQP/JfPVszwxf8r4ApnYMP0RUL/M=; b=JrY+AAdJyeJc6YFBqxYF+nCqGGv+9DLMKL4aRTyBlAH/j9LxJ/zrNHMY/SEEUkSb/N olPiXx+2CisQPaqPQh+eJcOEIIBqAw/8trA1CyOMHjzq7qIUbjymKZuUfd4aWnJzvWOW qcBLlnyUblgE/CWvLB/D+AYAHJX5OEcJN1HOYRHzHoO+S21yXHktL/3kH3a9jo3fdtb2 BYRHzbJGaEjpV8t/cxZx2DQwwykAcRmxAy9dTWRD9y73g81G8cYB17q1K3zpHaw5S0ls e5AbWUjA+h7OoSyKmIBoJh6YzXDA7nPhk1u1Tbk6Hw9N/XG0Wi8ONiOvrXpAfzNuds7G d7MQ== X-Gm-Message-State: AOJu0Yzb1AGnbJxL7d5w45EU+C9d3K7A3La0K6juEWY/24Sx1QAue+ed 5VEkUTyv6y++wOw/+9zoTKUpRn7NQ7nYPBSvSus= X-Google-Smtp-Source: AGHT+IENLJCj6azOkWZ8QWY9aSkT8dAwDkC16bJmsyS+3RwYYFnOtrR7DkuhygLfbS0Ku5nnFxaQqr8qJPJ48XlsPzA= X-Received: by 2002:a50:ab4f:0:b0:53e:34c5:fc14 with SMTP id t15-20020a50ab4f000000b0053e34c5fc14mr844119edc.23.1697788678120; Fri, 20 Oct 2023 00:57:58 -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: Fri, 20 Oct 2023 09:57:46 +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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 19, 2023 at 9:07=E2=80=AFPM Linus Torvalds wrote: > > 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 have made an experiment and changed: #define __raw_cpu_read(qual, pcp) \ ({ \ - *(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)); \ + *(__my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)); \ }) #define __raw_cpu_write(qual, pcp, val) = \ do { \ - *(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)) =3D (val); \ + *(__my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)) =3D (val); \ } while (0) Basically, I removed "volatile" from read/write accessors. With all new percpu patches in place the difference in all percpu accesses is: Reference: 15990 accesses Patched: 15976 accesses. So, the difference is 14 fewer accesses. Waaay too low of a gain for a potential pain. The code size savings are: text data bss dec hex filename 25476129 4389468 808452 30674049 1d40c81 vmlinux-new.o 25476021 4389444 808452 30673917 1d40bfd vmlinux-ref.o So, 108 bytes for the default build. Uros.