From nobody Mon Sep 16 19:43:28 2024 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=1684927591; cv=none; d=zohomail.com; s=zohoarc; b=EpHThjsHoVApfKRuCCltQ/6XWQwYw4YP7kFuxuwe4dDCtNuEqnU7RIDMYrB2P5eAxhT7hGpI/EeITcWEDne2AQIW7gnqk2F5NDmVnIe9yJyRQthXVrzzxR4xs/li4he5D0XMiIhtM/ZI5n/aQN6N/tL3NnF8DWpRYIr8pALCnsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684927591; 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=0WtRhdGqWZys6Apb+5b9kD+V8sSl5oZRJXNfpqdddW8=; b=hXelcKHnNZuuGVbdfzAxFDAigFAFyEUl/ziOXiQ9sgNVaDk4zRryPaht2dmaBkQGAqo8rk0fE9/kQQdhUDKtEP6ptZMY8linhvxuHBTpfHwHkqXHhc8zpf+ooxjpiNZ70m8XZqIVOnq7T5qzIpwgYBKzXGHHrNG56ON1hiurecU= 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 1684927591131479.33457978600495; Wed, 24 May 2023 04:26:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.538974.839465 (Exim 4.92) (envelope-from ) id 1q1mcp-0008OW-9H; Wed, 24 May 2023 11:25:51 +0000 Received: by outflank-mailman (output) from mailman id 538974.839465; Wed, 24 May 2023 11:25:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q1mcp-0008Mc-2R; Wed, 24 May 2023 11:25:51 +0000 Received: by outflank-mailman (input) for mailman id 538974; Wed, 24 May 2023 11:25:49 +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 1q1mcn-0006nQ-72 for xen-devel@lists.xenproject.org; Wed, 24 May 2023 11:25:49 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id bb3d1b93-fa25-11ed-b22f-6b7b168915f2; Wed, 24 May 2023 13:25:48 +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: bb3d1b93-fa25-11ed-b22f-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1684927548; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2M4LsdJHQ+3Rfju7ux5VA/VnrdGS15MZcIC/IW123ak=; b=LuHGGZ0BzxUb6ZDvCDw3FPG+3diMk3Qc8aW8eGcWQ8iINEtjKIgmOAak 8vLVD4iL7unWp0ym3/GHyDds34b4iJJXSCEbNeBtJhiBIjQRfoLu5+6UO uNKPd0SiQRfGSpPKENjDKkgSv8grg3E6rYcIg4lNb2kEwgidEMektka8R g=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 112680560 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:Lwvlqq1rZr2iUEXQzvbD5dtxkn2cJEfYwER7XKvMYLTBsI5bpzIBy WUcDT+HP/qLZGv9ctpwb4iyoB4Bv5DUnNJhTQVlpC1hF35El5HIVI+TRqvS04F+DeWYFR46s J9OAjXkBJppJpMJjk71atANlVEliefTAOK6ULWeUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8teTb8HuDgNyo4GlD5gFkOagQ1LPjvyJ94Kw3dPnZw0TQGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiI+t5qK23CulQRrukoPD9IOaF8/ttm8t4sZJ OOhF3CHYVxB0qXkwIzxWvTDes10FfUuFLTveRBTvSEPpqFvnrSFL/hGVSkL0YMkFulfGmJCx NY+FCI0TE6qjcG5y6mQR9Zov5F2RCXrFNt3VnBIyDjYCbAtQIzZQrWM7thdtNsyrpkQR7CEP ZNfMGcxKk2aOHWjOX9OYH46tM6uimPybHtzr1WNqLBsy2PS0BZwwP7mN9+9ltmiHJwPwBbA+ zyel4j/KgE6P8Oc1BvfyUy9p7WI2hPWVqMbPqLto5aGh3XMnzdOWXX6T2CTvv2RmkO4HdVFJ CQ86ico6KQ/6kGvZt38RAGj5m6JuAYGXNhdGPF87xuCooLW6QuEAmkPThZadccr8sQxQFQXO kShxo2zQ2Y16fvMFCzbr+3Pxd+vBcQLBXQBaR4uazcX2vu9iYsQgRnUZdtcFJfg27UZBgrM6 zyNqSE/gZAagsgKy7i38Dj7vt68mnTaZlVrv1uKBwpJ+is8Pdf4PNLwtTA3+N4adO6kok+9U G/ociR0xMQHFtmzmSOEW43h95n5tq/eYFUwbbOCdqTNFghBGVb5Jei8Axkkfi+F1/ronhe3C HI/QSsLuPdu0IKCNMebmb6ZBcUw1rTHHt/4TP3SZdcmSsEvJFPXon8+ORXOjjqFfK0QfUYXY M3zTCpRJSxCVfQPIMSeHI/xLoPHNghhnDiOFPgXPjys0KaEZW79dIrpxGCmN7hjhIvd+VW9z jqqH5fSo/mpeLGkM3a/HE96BQxiEEXX8rip9pUIL7ffc1UO9aNII6a5/I7NsrdNx8x9/tokN FnmMqOE4DITXUH6FDg= IronPort-HdrOrdr: A9a23:a64lz6BZAp9E4RflHelo55DYdb4zR+YMi2TDt3oddfU1SL38qy nKpp4mPHDP5wr5NEtPpTniAtjjfZq/z/5ICOAqVN/PYOCPggCVxepZnOjfKlPbehEX9oRmpN 1dm6oVMqyMMbCt5/yKnDVRELwbsaa6GLjDv5a785/0JzsaE52J6W1Ce2GmO3wzfiZqL7wjGq GR48JWzgDQAkj+PqyAdx84t/GonayzqK7b X-Talos-CUID: =?us-ascii?q?9a23=3AMFJnNWjHRJ6KlXK5rhMCWYb+NTJuaX7R/V32H12?= =?us-ascii?q?BKzhAQp6aQkS79Zxgqp87?= X-Talos-MUID: 9a23:LoRdkAWLSS/Jm3Hq/C/Mjy5hKeYy2Jq/KRpK1qUrteiNHzMlbg== X-IronPort-AV: E=Sophos;i="6.00,189,1681185600"; d="scan'208";a="112680560" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 07/10] x86/cpufeature: Rework {boot_,}cpu_has() Date: Wed, 24 May 2023 12:25:23 +0100 Message-ID: <20230524112526.3475200-8-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112526.3475200-1-andrew.cooper3@citrix.com> References: <20230524112526.3475200-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: 1684927591943100009 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 v2: * Drop stdbool. It is already covered by other includes. --- xen/arch/x86/include/asm/cpufeature.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/include/asm/cpufeature.h b/xen/arch/x86/include/a= sm/cpufeature.h index 4140ec0938b2..d0ead8e7a51e 100644 --- a/xen/arch/x86/include/asm/cpufeature.h +++ b/xen/arch/x86/include/asm/cpufeature.h @@ -17,7 +17,6 @@ #define X86_FEATURE_ALWAYS X86_FEATURE_LM =20 #ifndef __ASSEMBLY__ -#include =20 struct cpuinfo_x86 { unsigned char x86; /* CPU family */ @@ -43,8 +42,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 --=20 2.30.2