Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1050623rdg; Wed, 11 Oct 2023 12:52:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjNri84sS1amyRmFe0Up+Jfv4tY48C+Uw5HhZapIa4AAl3vnM3URvslPA+DXtW2N1045Rf X-Received: by 2002:a17:90a:b00a:b0:268:3b8b:140d with SMTP id x10-20020a17090ab00a00b002683b8b140dmr17182464pjq.35.1697053950437; Wed, 11 Oct 2023 12:52:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697053950; cv=none; d=google.com; s=arc-20160816; b=HtHXJVZ/08XkDpirzr5j28HLKBZXQlDObY/GQ7dB0bCVS7gIGQ91YTRHSAp7e+pP3t pn8owQ38jwwFFzZIR4cl7h3ft6iGKRyr0wIa6Mj0U3SUxDFaVJD37eXDhmch6nvTRppV qTj1ggprKtFLIH4GjmKQ/HvgY61NAu9W6tQ/BVY//eRtfR0UXu26VjnaMqqqSNuj7Xpp 77H48cnyksSjSMTT3RO53JPOryuGMR19Yih9Qur9g1ClQY609UtYSpt388bfUhwMggoU 4UyiOqbsxLYZcLmqe8a8WvfO1Tpb5voAepMsHUsEQH/207qJtfht20CtqkZpL1lEDPi0 PQCw== 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=GfFDJdH5W2KsoZBFM8tAF2+ELipfCkZ7tnwEzIAb7iM=; fh=7KUfrZGZf/EAj3r522dEJiH1mntVxCNU0xlLCVeoX68=; b=Xk7KuaJNJXZLmE424nMI5J++JVzfbcxX4cNHMWbA5+j/ikKBGBTvBdJILcD9SEEsMR 554yjT9DBJFaALgHG00cTlS8O7Wmhav4jbNUBDfeC3GF69uVdIeLvI7aEIVRCbPk6NOR S/nNoktJJBWGcuzQ2q6ZTMF9QJEu9eqI4wDzic30JBDpagactUelEPUplv1zLlOCQebe meI6KMh3aJIAEDSnigB3aN/DxBeG0jFYTsBUXW07l6ioU1BRFoF0xQJkYZtXGpefH768 JbJf/qHpUNCnUnZEdPCbQTJTyVNNGV6NBe1s4Wdqb/qWGVEcvlALDx9uHxd1mdpwjC6C k4HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=aOY5eeio; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id z8-20020a17090acb0800b002792364334bsi483917pjt.124.2023.10.11.12.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 12:52:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=aOY5eeio; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 0236A81BF304; Wed, 11 Oct 2023 12:52:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233419AbjJKTwU (ORCPT + 99 others); Wed, 11 Oct 2023 15:52:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233369AbjJKTwT (ORCPT ); Wed, 11 Oct 2023 15:52:19 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0E099E for ; Wed, 11 Oct 2023 12:52:15 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-9a9f139cd94so30544466b.2 for ; Wed, 11 Oct 2023 12:52:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1697053934; x=1697658734; 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=GfFDJdH5W2KsoZBFM8tAF2+ELipfCkZ7tnwEzIAb7iM=; b=aOY5eeiodXb7Zhynz7Z4S8ASd5wJHZIxXiYTSSH4XEQrVGf32YBG4oKnjLCMQ4Mkmh QDLm90BbXN2/o1woOHC/E6F1PTp2DXMgZe3bbUtP78oQ1wggmk8G79SxridTo55Zmyeq OXKOqmSCNsmgFXB6C5NfTtjv0DIW4xy52HwtU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697053934; x=1697658734; 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=GfFDJdH5W2KsoZBFM8tAF2+ELipfCkZ7tnwEzIAb7iM=; b=ietqx50BopVJyXw4bPHtE+G/aiPJi5nHb6jJbk+ZWhZfDXu893lkNIx9V2yzsEJdeR Fj6kCO7QZo0lXQRvBgIJ/RjD2eBQDLBWwi1jv2yDxxrDM346gme4zv8hv+LEiooBQyGO eDmb5Dg21J4GcJ2g/Z6na32JksUg3UpTOoNtE6JVutafk3meFpjigQv8RLvD//HhOnsG yjON0BkU0vZBqhsrG42Aj2iesbGAuZcLxssLdB1MpAGme+FkIz05QXyUkO0f8WCDYQ4n A3UEN5RrhKdEd2oZBmC2t7t2tOTrvENQby5OpHhIZu2BfL2A3lqGj29zYDXTfXAieMss 0UZw== X-Gm-Message-State: AOJu0Yykar14ag5gY9nTL41BIeTSBs+ivYB57eDrpAsPULzpkVMiKByW NR2pPfAJ8Us03qtNTeeSoJrXx2jMl5wBQ2x06onJ8Szi X-Received: by 2002:a17:906:100e:b0:9b3:47f:1c05 with SMTP id 14-20020a170906100e00b009b3047f1c05mr17326723ejm.64.1697053933940; Wed, 11 Oct 2023 12:52:13 -0700 (PDT) Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com. [209.85.208.49]) by smtp.gmail.com with ESMTPSA id e25-20020a1709062c1900b009adc77fe164sm10250416ejh.66.2023.10.11.12.52.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Oct 2023 12:52:13 -0700 (PDT) Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-53dd3f169d8so426786a12.3 for ; Wed, 11 Oct 2023 12:52:13 -0700 (PDT) X-Received: by 2002:a05:6402:1859:b0:530:74ed:fc8a with SMTP id v25-20020a056402185900b0053074edfc8amr19163331edy.41.1697053933076; Wed, 11 Oct 2023 12:52:13 -0700 (PDT) MIME-Version: 1.0 References: <20231010164234.140750-1-ubizjak@gmail.com> In-Reply-To: From: Linus Torvalds Date: Wed, 11 Oct 2023 12:51:56 -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: x86@kernel.org, linux-kernel@vger.kernel.org, Nadav Amit , Andy Lutomirski , Brian Gerst , Denys Vlasenko , "H . Peter Anvin" , Peter Zijlstra , Thomas Gleixner , Josh Poimboeuf Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 11 Oct 2023 12:52:28 -0700 (PDT) X-Spam-Level: ** On Wed, 11 Oct 2023 at 11:42, Uros Bizjak wrote: > > The attached patch was tested on a target with fsgsbase CPUID and > without it. It works! .. I should clearly read all my emails before answering some of them. Yes, that patch looks good to me, and I'm happy to hear that you actually tested it unlike my "maybe something like this". > The patch improves amd_pmu_enable_virt() in the same way as reported > in the original patch submission and also reduces the number of percpu > offset reads (either from this_cpu_off or with rdgsbase) from 1663 to > 1571. Dio y ou have any actka performance numbers? The patch looks good to me, and I *think* rdgsbase ends up being faster in practice due to avoiding a memory access, but that's very much a gut feel. > The only drawback is a larger binary size: > > text data bss dec hex filename > 25546594 4387686 808452 30742732 1d518cc vmlinux-new.o > 25515256 4387814 808452 30711522 1d49ee2 vmlinux-old.o > > that increases by 31k (0.123%), probably due to 1578 rdgsbase alternatives. I'm actually surprised that it increases the text size. The 'rdgsbase' instruction should be smaller than a 'mov %gs', so I would have expected the *data* size to increase due to the alternatives tables, but not the text size. [ Looks around ] Oh. It's because we put the altinstructions into the text section. That's kind of silly, but whatever. So I think that increase in text-size is not "real" - yes, it increases our binary size because we obviously have two instructions, but the actual *executable* part likely stays the same, and it's just that we grow the altinstruction metadata. Linus