Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp424856rdb; Thu, 5 Oct 2023 09:42:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5xFrRjo/OYzbcALoPEycKeAW6QlCBV5x4sbodvxy7ylhbysOTDhfdlFefVYCy7Phw1pds X-Received: by 2002:a17:90a:f2cf:b0:273:a392:7077 with SMTP id gt15-20020a17090af2cf00b00273a3927077mr5400161pjb.10.1696524153071; Thu, 05 Oct 2023 09:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696524153; cv=none; d=google.com; s=arc-20160816; b=VBZkuFMXLTFyFvYWxlDzvtqEWTIUXySqbvZYJ5NdRiaAaESxqS76llA4wHNabpii0D TUYdGSqR12yD2sHXtolqLmoVNhTXrczFZU6CMRiA4toOhZCyt0JU23pj/xq64mzFQBDv JYmpnr3GVoAmX0jGvcM8yTcQEl6HBkiQuIr/1Fm1Tt4BSBsNS+gAYC5ttrpnoX379Jg5 QhZwngH06cSjFUw1RhiYZjwz6rjduA7L0CC1ihuMXmNcOMeLvrI296qTEf53NBqX8Idk 3HsEhg+rwcBY+OUhHWH7I4aUg+O4OuG6Tyt545p+Bg7QCt9hB7oZ+kaE+uGHXOuK7ugs yPkA== 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=Ub4SbvJZIBTTOm+vLGBixykTBKO190h0Hw/1II6U3Uo=; fh=g5QCq7U8Gtzh0bgFRg6dM2n76DzrOfIz2U1aURRW+sc=; b=YwyPfMiFK1cKdd9XXxiYmw5mYIiFvsHR9ejSTbvzcBx1WKbBtfEw4jS/3rxwVMX477 jFSpDMLOn/ANUT5sL55AZJs1oA+5CDXy77coax+q2+wX1KfSFhViBVfdVhizomzklGTQ icBxs6P1xpdkSNnsamT8IlvRBgxT1SKNChQB++E8ws/yMtYE39fd+skc0AFFz9D2/WVf v8rAIqCCGDQJo8tjE/mSxDkaex48AVHW+eT8dDXTPuMV08+DTUVvx1DN2FXkk60u6Oy4 8ySuVFyAiAR0BBt2QJacdQUqJNwVsTuEInTiHN/Wuo6DMmx4XzgV/1rWyethPkmPtlDg I/Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jfxuozjS; 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 lb5-20020a17090b4a4500b00274cd892b39si2036332pjb.132.2023.10.05.09.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:42:33 -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=jfxuozjS; 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 A217B804ACFF; Thu, 5 Oct 2023 09:41:14 -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 S233468AbjJEQkm (ORCPT + 99 others); Thu, 5 Oct 2023 12:40:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234744AbjJEQjV (ORCPT ); Thu, 5 Oct 2023 12:39:21 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EE897D99 for ; Thu, 5 Oct 2023 00:41:06 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-533c5d10dc7so1045403a12.3 for ; Thu, 05 Oct 2023 00:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696491665; x=1697096465; 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=Ub4SbvJZIBTTOm+vLGBixykTBKO190h0Hw/1II6U3Uo=; b=jfxuozjSS18Qamq3q+F9gv2Pe18aCSNMwRo+dXWI1zHtUWedMxUghU5a8ophiu0/rt 1IAjyh+MlW+NvzdJXRRJo2U3v0hkXvuSNbYEdfyt3IpNHrz1zQzrM6hxjBLf5E/CFv3n XxLtvaAB1PxPWvuHe7Hzm5vg5hckmaR97nPGnOJ0fQV8FCpiwQkUlMQCPR07w5r0aTWP 0o5+lAdhjSGQ4MVdS7aVGcjKVWrnL4BOQKpAmpod5bmbpDvco/bVN58NiqSfX5pAp9vZ Mlux6U1zdYy+cfewW3KcU4AcqaxPr8Z+eSV8YifolpCnB4mHQ4p9i26mJLjbPJpGSv0j ILzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696491665; x=1697096465; 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=Ub4SbvJZIBTTOm+vLGBixykTBKO190h0Hw/1II6U3Uo=; b=ljO5LiSyRetOHp3niXT5peHk1sVkFzFx1pyNTCLLslZlbsq02+ABJfSVR1NkFx1MQQ qM7THNuPEDy/uXrYZYgmsIyuGnVAEm98GK4KXLSkKBje7EsABWU6tUYq7AueFFxO/o6p QcNGMqzjJRo8azvRcMea4QtPN0rnFTIm2bYJPi3/Ry/5Rcgo7Ei5gO5KYYsCuYd7xaFu 30+o7NmULSq8LUROteSgqEV7VwzbI+KWdkLz7ArZ8KYocBgPt/oX7cM9cE3hYkWWNuK2 MgWP7Nt8q4IHYuLER452RTm95wAEaVIL7o0sqsb4yx58a0AjFiVoUfJz+mqpnGQr5rzK 9R6Q== X-Gm-Message-State: AOJu0YwItYh9VXJSJUU3BU4GhFVSY5safcTqAxN9quaPRofXenSekwIa pQPnzCw2hM/V/+ZsMchPSE75lzyy+/FZ3VVFasFqCMcYkOht94gn X-Received: by 2002:aa7:d489:0:b0:523:37ff:1170 with SMTP id b9-20020aa7d489000000b0052337ff1170mr3770181edr.16.1696491664488; Thu, 05 Oct 2023 00:41:04 -0700 (PDT) MIME-Version: 1.0 References: <20231004192404.31733-1-ubizjak@gmail.com> In-Reply-To: From: Uros Bizjak Date: Thu, 5 Oct 2023 09:40:53 +0200 Message-ID: Subject: Re: [PATCH v2 4/4] x86/percpu: Use C for percpu read/write accessors To: Ingo Molnar Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Andy Lutomirski , Nadav Amit , Brian Gerst , Denys Vlasenko , "H . Peter Anvin" , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Borislav Petkov , Josh Poimboeuf 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_BLOCKED,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, 05 Oct 2023 09:41:14 -0700 (PDT) On Thu, Oct 5, 2023 at 9:06=E2=80=AFAM Ingo Molnar wrote= : > > > * Uros Bizjak wrote: > > > The percpu code mostly uses inline assembly. Using segment qualifiers > > allows to use C code instead, which enables the compiler to perform > > various optimizations (e.g. propagation of memory arguments). Convert > > percpu read and write accessors to C code, so the memory argument can > > be propagated to the instruction that uses this argument. > > > text data bss dec hex filename > > 25508862 4386540 808388 30703790 1d480ae vmlinux-vanilla= .o > > 25500922 4386532 808388 30695842 1d461a2 vmlinux-new.o > > Ok, this all looks like a pretty nice optimization. This is just the beginning, named AS enables several other optimizations, as can be seen in Nadav's original patch series. If we want to make the kernel PIE, then we have to get rid of the absolute address in percpu_stable_op (AKA this_cpu_read_stable). We can use __raw_cpu_read, but PATCH 7/7 [1] optimizes even further. > As discussed previously, I've created a new tip:x86/percpu topic branch > for this, based on tip:x86/asm that carries the other percpu patches. > This branch will be merged in v6.8, best-case scenario. > > Also note that I lowered the version cutoff from GCC 13.1 to 12.1, for > the simple selfish reason to include my own daily systems in test coverag= e. > > Is there any known bug fixed in the GCC 12.1 ... 13.1 version range that > could make this approach problematic? Not that I know of. I have done all of the work with GCC 12.3.1 (the default Fedora 37 compiler) and additionally tested with GCC 13.2.1 (Fedora 38). I have made the patched kernel the default kernel on my main workstation, and haven't encountered any problems since I installed it a week ago. If there are any problems encountered with the compiler, we (the GCC compiler authors) can and will fix them promptly. I'd push for all supported GCC versions, but maybe not just yet ;) [1] https://lore.kernel.org/lkml/20190823224424.15296-8-namit@vmware.com/ Uros.