Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3953977rdg; Wed, 18 Oct 2023 10:24:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTC7Ixx3H5B/hBVXZlINuX6ryQHy27fIuUyagbjck4zDoVSdyijUl69rT/7nsPOpa9p+9+ X-Received: by 2002:a17:903:32d0:b0:1ca:3cd7:eadb with SMTP id i16-20020a17090332d000b001ca3cd7eadbmr4403plr.9.1697649871042; Wed, 18 Oct 2023 10:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697649871; cv=none; d=google.com; s=arc-20160816; b=K3Fc7cXXiwuCARID3r2G8rm66WvOKr8fn0I9D5jtJr5ryeefy/RJQo/9y0vQDYu+8m 6MdRFYx9YcNGZeX8+kkOSaePb9qDhW0hNqsZ2lDu6nZq1iud4b2Be1wMBTrLuhYivq1F BIzLg6A0eMMIk5/okJTY4pRNg5xcgP45L1THAunw0S+LVow07KkallWlu4RLxp8VGGNC N3TxUC1kBS9iddthG6OQUgDGArRTLXANh6tHPut9QU5HXKeJy0FOLZRHxmPvQrLy+W0i lvbEJG/Lz/hqB/NSIOOa2dyjdQnIpcx/5rsxdsuI0OQ8PH97jjZXP3TOASFpI9WBmV8B bnOg== 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=TC+0I+zWgSfzwJAuAf0X+3Iv9+B3fQ87MnP7gIaazJY=; fh=/Dnf++/2xG0Xi30TGscvcX3UaoYjzLSxPPap0bUcRsE=; b=jyBsunRVS0IS0tK/wB2Icj112vdQ+TmAlyq466+9F71C7Oj9fArVXAr4dqSWIMt50h 83Z8A0rEMU2OnJMFHhP5WRbPMIMdo6JIW4AMjGXmqxB2sikSazihV+8VcYdM+EJ2zmpE oR91LGBOPLLzgeUROdYDxgtmRBNCd8mJXL72fkncGL0fdFZTqs6JsraykbKbUut9caEA JoGl93azvd4eO0SCaiBqH9qplsZwjnEkRFiRM+XD7yMQW64gJ7swbdcgoRay59JAVxVg 8wB7M2BuNAlsazusM2ccrk9/vbSGVGfxuXLgwDOzMiGz5bDU7GuZ8jSLnyzJMiqQVPq3 eP+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fmE0ESG5; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id k9-20020a170902694900b001c20db25108si295042plt.41.2023.10.18.10.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 10:24:31 -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=@gmail.com header.s=20230601 header.b=fmE0ESG5; 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; 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 4EA6180E6CAC; Wed, 18 Oct 2023 10:24:28 -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 S232684AbjJRRKQ (ORCPT + 99 others); Wed, 18 Oct 2023 13:10:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232728AbjJRRKF (ORCPT ); Wed, 18 Oct 2023 13:10:05 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96945326C for ; Wed, 18 Oct 2023 10:08:10 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-9c603e2354fso444919866b.1 for ; Wed, 18 Oct 2023 10:08:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697648877; x=1698253677; 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=TC+0I+zWgSfzwJAuAf0X+3Iv9+B3fQ87MnP7gIaazJY=; b=fmE0ESG5y5+k6eKwnzkewUrzBNQydIp4U6uTwzheXcvLlsPWmBMJYnNdhVgcQ10+ZT xlA4uPulIcbhael+36CEkinkE58RLXYTy8GmWro36FmhaDFkIrnGvOVbwaKyE7RWagxh SgYDV5T7z4HGaWABtaFA01/B8+e7mi//2VdmwhwN9y1jhFei4X0nLA5oSjYcweHxfLka 1dFQZ2GumSg95dNtwWxSN9cANTk5knmGkbpdhFJLfT/ddJlbs5QLgiY3bo0QuHPUiQPd 7teyrtjQUiEu0/nrfv9ung9PbDxlq/EI3Tv+UVdGdd3VbY2alxR/9MSOYOqJ5twOzGzI L3mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697648877; x=1698253677; 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=TC+0I+zWgSfzwJAuAf0X+3Iv9+B3fQ87MnP7gIaazJY=; b=mR4C481cPVGSJtlaGlo/vQaWQRq+xL2L9AcM/4AgznCpEA+Lo9ZvGGODiSuCWWuEAJ XMA2UV8yCB/oi5RQLi2n+t/TJU57H0YVffPW2S3pSJBAIeLgdAUr4R5A55GyUho7PdNQ gFiIRupOcq8opsWWjqxMn6tzjmKNYm6c8C1vnYNxYMEI0M71hxmT87wmm+OeP4f6Egvk Gdp2YnQSB+t7wnFqZGvTXda0FujGVU80TlGFc6uLJODNnAA/pp2JasE4iTKeSVU+oByq EvExFsEarmAP0gaP4oKCI8HipeAKnkr3pEqK5+6TgLt0K3oekUQ6N+ccr6/RupQDIIn6 Laug== X-Gm-Message-State: AOJu0YwIwMFIlEcfc+xTeg7r8uxonAtL2qsGULux90Hhll+lBal7gmhy 3woyW6HU7TTv5SMO4IJeuvwgmVbnqpz0b7p7R3g= X-Received: by 2002:a17:907:1ca4:b0:9a4:11a3:c32b with SMTP id nb36-20020a1709071ca400b009a411a3c32bmr4522888ejc.29.1697648877405; Wed, 18 Oct 2023 10:07:57 -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> In-Reply-To: From: Uros Bizjak Date: Wed, 18 Oct 2023 19:07:45 +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: multipart/mixed; boundary="0000000000004aa548060800ae12" 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]); Wed, 18 Oct 2023 10:24:28 -0700 (PDT) --0000000000004aa548060800ae12 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Oct 18, 2023 at 6:13=E2=80=AFPM Linus Torvalds wrote: > > On Wed, 18 Oct 2023 at 06:15, Uros Bizjak wrote: > > > > Attached is the prototype patch that works for me (together with > > Linus' FPU switching patch). > > That looks reasonable, but I think the separate compilation unit is > unnecessary, and I still absolutely hate how that const_pcpu_hot thing > is declared twice (your patch does it in both current.h and in > percpu-hot.c). > > How about we just do the whole alias as a linker thing instead? So the > same way that we just do > > jiffies =3D jiffies_64; > > in our arch/x86/kernel/vmlinux.lds.S file, we could just do > > const_pcpu_hot =3D pcpu_hot; > > in there. > > Then, as far as the compiler is concerned, we just have > > DECLARE_PER_CPU_ALIGNED( > const struct pcpu_hot __percpu_seg_override, > const_pcpu_hot) > > and the compiler doesn't know that it's aliased to anything else. Oh... ... this works, too! Please see the attached patch. (Note to self: Leave linking stuff to linker) ;) > And please do that declaration in just *one* place. Sure. Now the patch looks quite slim, but works as expected, reducing the number of current_task accesses from 3841 to 3220. Thanks, Uros. --0000000000004aa548060800ae12 Content-Type: text/plain; charset="US-ASCII"; name="current-2.diff.txt" Content-Disposition: attachment; filename="current-2.diff.txt" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lnw0aage0 ZGlmZiAtLWdpdCBhL2FyY2gveDg2L2luY2x1ZGUvYXNtL2N1cnJlbnQuaCBiL2FyY2gveDg2L2lu Y2x1ZGUvYXNtL2N1cnJlbnQuaAppbmRleCBhMTE2OGU3YjY5ZTUuLjM2OTAyZDYxZmQ1NSAxMDA2 NDQKLS0tIGEvYXJjaC94ODYvaW5jbHVkZS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