Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1054422rdg; Wed, 11 Oct 2023 13:01:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvglljAojRkXZF5L/VenZQozohsWlZ7tjXtdvwboGRnHupR9KNhbfxrvboL7Vd2pKsQonN X-Received: by 2002:a05:6a00:1a92:b0:690:bdda:7c35 with SMTP id e18-20020a056a001a9200b00690bdda7c35mr23415365pfv.1.1697054477943; Wed, 11 Oct 2023 13:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697054477; cv=none; d=google.com; s=arc-20160816; b=hgphhhZTL9OomSIy+VgjgQI7crVQaL0Q21l5RIeitoqRNsDKHBwSF8dwqPPJbeghcf d34QDj7FTaaFGlc8AUOgnMglTHHTiB8brhgBuVyUQ096fhDDaxNtJrfVJwUtZcf9gQTJ Kic/Pc/RUYyV3eaPJJdWzVdcrW9LmZqvqsSBNYEDaYSHpOqHAxvrdml1sY7I9MO8mjGt 6NMrLgCOxa8r5HW0zL/Z9LigR/sHZBQnn++p18CD74Vjnt/MsOS6wdxKN2zDG1x0OVnw belZL8cGAaQ213rrb1xhi8eGhpxFK+fKaUUIj41EXbaon024dTT/BaXuMDJO5as2KcHT LE+A== 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=N++n3Jote5Wa5vsNaDvtu8z3YCnpc3qg46kanlFv2qc=; fh=tF7riTkuBa8O3vMSvJNFl/jVCIdpn/sknKnZT2xFBLQ=; b=Jau5gYQWW9moCpRuQivXp+AKKIIBXtYJbt+RCJ5hvyfNumiDBsJ1cILlqP1xVkDO/0 Cn1rC0zik+yZGUHo3xHcXdQYL1eovuOqnvDosocWA583Yb6sxpjFn5GUhNZQaZbjus6X nwJgnuN5+TmwVpToWDi5LUmMJPDhwB0ADWNI7S7YoAsetkbfv8u0fl/vesk1enDIoIXk YgOJHH2JR0Dq0/vJLQrM+7d8xNV08d5KBRkTDIXJBN85qIUiyHep8k+oI0ps71lqQRD2 xOewCVue3L/04u7uO9mCtRsi37FafGwCtZFfFbyYje6Ae9rEBq9mlvweb5pw+JYr8nSe H/Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Yk1JTyjl; 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 j10-20020a63ec0a000000b00566022bbcafsi516272pgh.566.2023.10.11.13.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 13:01:17 -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=Yk1JTyjl; 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 176C2802691C; Wed, 11 Oct 2023 13:01:15 -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 S1346812AbjJKUA6 (ORCPT + 99 others); Wed, 11 Oct 2023 16:00:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233308AbjJKUA5 (ORCPT ); Wed, 11 Oct 2023 16:00:57 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B1619E for ; Wed, 11 Oct 2023 13:00:55 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5334d78c5f6so442025a12.2 for ; Wed, 11 Oct 2023 13:00:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697054454; x=1697659254; 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=N++n3Jote5Wa5vsNaDvtu8z3YCnpc3qg46kanlFv2qc=; b=Yk1JTyjlcxx0etuy1WNro15lNg/gM9+6Zbx9EVavcHhqqVsYNdti7ni4lMkLwBK2Mf SjeaOr3GepfeObxpBbcys/N/9AkH65mV/jMyT5qsx5wA2rNnRP245TH20OV/xjQQxaoi TRtLslKlmnFztwZZ9KldMz7CeV/1H5kbHruvGyU4JdjCSyM/Yv53oR8CVwaeTT1Qmv4y winLmFWGw2Pf2xfT0H1Cx1xzV4Jr0deTzGWa5KlE+S4pgU1Fei4YNfD7wN5du5/2iMGo fFApNNtIU3HicpAEfkkEaBg7KBIfF2zgXVY/k1EsKvZg6Jh4RAjn2oUF3WR/i2OmiNQm QdFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697054454; x=1697659254; 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=N++n3Jote5Wa5vsNaDvtu8z3YCnpc3qg46kanlFv2qc=; b=QLBsY17Dj7WMjmugFYDS6Cj1P6LcVMK1caNqh8q5Oo7ImMrFpVxH/24S0gRUNSHN4R hRry+XvdTQo4+8OopL4KioxIPtvwXOJooD68FCVSITtVerTJCSnDJBHcTa5FNnb7qoMS U3wekgdMlGU6OpX0AYSOL0Rm6wMSqmPEAD5XrQBz3R2U/RctvzwuXpCfdXNg3jdXGLab o1lDiOZlDnTy5MRZKu/FSF1x+VXuwWwNLWHG7aI7pHHs/YkKtd0SgAwtBsQhp/8nR6G5 +kfcdh7BPpJRg04MqCNuXQoQZOMJmi9d1v57N0mZbeIP0GOajQPejVylSd0kdXCWY239 OvZg== X-Gm-Message-State: AOJu0YxZgCXUILteI9xM/8cmmvFs6PNFAv/DLp6FaZSNQp2imEXcSM4L 0WyRW7e/0vVT8UpomXqKOGzrC0zqHZWPMhh5aT4= X-Received: by 2002:a05:6402:944:b0:53d:e875:d229 with SMTP id h4-20020a056402094400b0053de875d229mr1837676edz.29.1697054453531; Wed, 11 Oct 2023 13:00:53 -0700 (PDT) MIME-Version: 1.0 References: <20231010164234.140750-1-ubizjak@gmail.com> In-Reply-To: From: Uros Bizjak Date: Wed, 11 Oct 2023 22:00:42 +0200 Message-ID: Subject: Re: [PATCH v2 -tip] x86/percpu: Use C for arch_raw_cpu_ptr() To: Linus Torvalds 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" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 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, 11 Oct 2023 13:01:15 -0700 (PDT) X-Spam-Level: ** On Wed, Oct 11, 2023 at 9:52=E2=80=AFPM Linus Torvalds wrote: > > 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. Unfortunately, I don't have any perf numbers, only those from Agner's instruction tables. The memory access performance has so many parameters, that gut feeling is the only thing besides real case-by-case measurements. The rule of thumb in the compiler world is also that memory access should be avoided. Uros. > > > 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 alternati= ves. > > 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