From nobody Sat Feb 7 06:39:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1684248854; cv=none; d=zohomail.com; s=zohoarc; b=h7fBkEA78fBImxwewLzgmyYQcVNPsffnktWYP9WZ6evHG7dUnqYzOu4qaE2LmmdAf2uap5WMh/yxnycVLsBm5fWRe9TM7gvCPvIyUziZc8zKbCKSSkPbuQtA3jEF4jaw8JN2A/JeYznPvk2ZNIXx8+uTVrMr/fj2Jq/ZEag4F/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684248854; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CuN+1sQRC/72AdfMCcHk80XroOdWWTS6o8GiPqXmGzQ=; b=ES2KXW7y8rTLG+T5TcG/T9hPqkc+TWmbHSM2Ruh0J4i1Y5iktApiN7x1y6FUd0ZHnZfpkhzMHTnEOLQbYrP03AtTmj/6fb3OepiXY9xRm+/DK7yFe3SzTz4/IUug9Y2/OYNlABf1iEHQYvjjV4xCjdeb1WwIgULE13nbQ6Ckj98= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1684248854031160.1718701898593; Tue, 16 May 2023 07:54:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.535262.832948 (Exim 4.92) (envelope-from ) id 1pyw3h-0006Sa-D2; Tue, 16 May 2023 14:53:49 +0000 Received: by outflank-mailman (output) from mailman id 535262.832948; Tue, 16 May 2023 14:53:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pyw3h-0006S2-83; Tue, 16 May 2023 14:53:49 +0000 Received: by outflank-mailman (input) for mailman id 535262; Tue, 16 May 2023 14:53:48 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pyw3g-0006OC-DR for xen-devel@lists.xenproject.org; Tue, 16 May 2023 14:53:48 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 745f770e-f3f9-11ed-b229-6b7b168915f2; Tue, 16 May 2023 16:53:46 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 745f770e-f3f9-11ed-b229-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1684248825; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nyQur+30ZM6XscWFa3iBiYiEbv5nHeYpGVnr0FExeKQ=; b=VSFv6Z+6ku77nlo+gSIF+uvMIjQD5fKGuo89Oz6Z/p/fsGeEFtMU8fVm VmxTHFSIpTwyZ03W5i1bx4Z+m4is51H6MQHH5ywC+UgqnraOTf/ejMDpm b5+vNtjRvkp/bsb4kriQRPoM0nsXpy77GZPDCHhB4mGedk4PjfPCY9BY9 I=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 109117764 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:QB58IK71qn8wGRrfY7ImjgxRtDHHchMFZxGqfqrLsTDasY5as4F+v jcbD2iHOqmKNjHyc412PIrnoE9T6p7WndJgSAU4rHxhHi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRGvynTraCYnsrLeNdYH9JoQp5nOIkiZJfj9G8Agec0 fv/uMSaM1K+s9JOGjt8B5mr9VU+7ZwehBtC5gZlPa0S4geE/5UoJMl3yZ+ZfiOQrrZ8RoZWd 86bpJml82XQ+QsaC9/Nut4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5iXBYoUm9Fii3hojxE4 I4lWapc6+seFvakdOw1C3G0GszlVEFM0OevzXOX6aR/w6BaGpdFLjoH4EweZOUlFuhL7W5m3 uIFAzcNPlO4rO+omI2DW9tn1+t7BZy+VG8fkikIITDxCP8nRdbIQrnQ5M8e1zA17ixMNa+AP YxDM2MpNUmeJUQVYT/7C7pn9AusrlD5fydVtxS+oq0v7nKI5AdwzKLsIJzefdniqcB9xx7J/ zuZoDqlav0cHIez1Weo7FGoveCMpjrEe4U8G/6WrfE/1TV/wURMUUZLBDNXu8KRlUqWS99Zb UsO9UIGvaU0sUCmUNT5dxm5u2Kf+A4RXcJKFO834x3LzbDbiy67LGUZSj9KaPQ9qdQ7Azct0 ze0c8jBXGI19ufPEDTEq+nS9GnpUcQIEYMcTQQaUCAC44mgm6o+kErwdsdRG/+a1vSgTFkc3 Au2hCQ5grwSi+sC2KO64U3LjlqQm3TZcuImzl6JBzz4t2uVcKbgPtX1sgaDsZ6sOa7DFjG8U G44d99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WG2bqYw8up87?= X-Talos-MUID: =?us-ascii?q?9a23=3A1sEVUQ7S5rIBv2XxGS2G2UO2xowzz7jzJV4ula4?= =?us-ascii?q?J+PKdCg93FTjeom+4F9o=3D?= X-IronPort-AV: E=Sophos;i="5.99,278,1677560400"; d="scan'208";a="109117764" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH 1/4] x86/cpufeature: Rework {boot_,}cpu_has() Date: Tue, 16 May 2023 15:53:31 +0100 Message-ID: <20230516145334.1271347-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230516145334.1271347-1-andrew.cooper3@citrix.com> References: <20230516145334.1271347-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1684248854840100003 One area where Xen deviates from Linux is that test_bit() forces a volatile read. This leads to poor code generation, because the optimiser cannot mer= ge bit operations on the same word. Drop the use of test_bit(), and write the expressions in regular C. This removes the include of bitops.h (which is a frequent source of header tangles), and it offers the optimiser far more flexibility. Bloat-o-meter reports a net change of: add/remove: 0/0 grow/shrink: 21/87 up/down: 641/-2751 (-2110) with half of that in x86_emulate() alone. vmx_ctxt_switch_to() seems to be the fastpath with the greatest delta at -24, where the optimiser has successfully removed the branch hidden in cpu_has_msr_tsc_aux. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu --- xen/arch/x86/include/asm/cpufeature.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/include/asm/cpufeature.h b/xen/arch/x86/include/a= sm/cpufeature.h index 4140ec0938b2..4f827cc6ff91 100644 --- a/xen/arch/x86/include/asm/cpufeature.h +++ b/xen/arch/x86/include/asm/cpufeature.h @@ -7,6 +7,7 @@ #define __ASM_I386_CPUFEATURE_H =20 #include +#include #include =20 #define cpufeat_word(idx) ((idx) / 32) @@ -17,7 +18,6 @@ #define X86_FEATURE_ALWAYS X86_FEATURE_LM =20 #ifndef __ASSEMBLY__ -#include =20 struct cpuinfo_x86 { unsigned char x86; /* CPU family */ @@ -43,8 +43,15 @@ struct cpuinfo_x86 { =20 extern struct cpuinfo_x86 boot_cpu_data; =20 -#define cpu_has(c, bit) test_bit(bit, (c)->x86_capability) -#define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability) +static inline bool cpu_has(const struct cpuinfo_x86 *info, unsigned int fe= at) +{ + return info->x86_capability[cpufeat_word(feat)] & cpufeat_mask(feat); +} + +static inline bool boot_cpu_has(unsigned int feat) +{ + return cpu_has(&boot_cpu_data, feat); +} =20 #define CPUID_PM_LEAF 6 #define CPUID6_ECX_APERFMPERF_CAPABILITY 0x1 base-commit: 8f9c8274a4e3e860bd777269cb2c91971e9fa69e prerequisite-patch-id: ceeba7d5ab9498cb188e5012953c7e8c9a86347d prerequisite-patch-id: c0957b9e1157ae6eb8de973c96716fd02587c486 prerequisite-patch-id: d2574bba15748cd021e5b33fa50e6cadc38863b6 prerequisite-patch-id: 0f66cd4287ffdc06f24dc01c7d26fb428f3e8c09 prerequisite-patch-id: a585f61b546ff96be3624ff253f8100b2f465de6 prerequisite-patch-id: 54551cdefaca083b4a4b97528d27d0f3dc9753ee prerequisite-patch-id: 051423463e4a34728ab524f03e801e7103777684 --=20 2.30.2