From nobody Fri Oct 31 04:02:47 2025 Delivered-To: importer@patchew.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; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1751621466; cv=pass; d=zohomail.com; s=zohoarc; b=eZvB1ClYkdkM0VRmDrai1o8Nu0uokhChd23T0JSvrUGqI8Q1PJJjERyMghA4BM8+ai2QfneCXeVkezNRh7xIizjEVzp0UvtTrvOEzWz8wfN82/cL3lzRdxygzTnR8tvWS3hh4oGMnzxjPqHSHUZKuSgPIrPgrLEOHhkUIT7m50M= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751621466; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QecYoeOZZxssyXE8XinkAofZ+aon7XKcTK0uGY706Nc=; b=TeYSlwis3jh8mLvZn/GWEHD4wbf2wRwUiDwwrI2GoB1jd9B5BsdXnpG1EOvqwzbK4p1NIiU3378ml0r0HeHXGv3iYLIxf8IjD7iVoyHmbZ9FQ0tWQdfvVpid2sUAVnEMymssJsheLOx0jw8jAEdqAbjCJXWldcdR2yOU7LzaodE= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 175162146639713.915460233421527; Fri, 4 Jul 2025 02:31:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1033101.1406584 (Exim 4.92) (envelope-from ) id 1uXckn-0001PC-BU; Fri, 04 Jul 2025 09:30:45 +0000 Received: by outflank-mailman (output) from mailman id 1033101.1406584; Fri, 04 Jul 2025 09:30:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uXckn-0001Ov-7x; Fri, 04 Jul 2025 09:30:45 +0000 Received: by outflank-mailman (input) for mailman id 1033101; Fri, 04 Jul 2025 09:30:44 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uXckm-0007ek-1a for xen-devel@lists.xenproject.org; Fri, 04 Jul 2025 09:30:44 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20604.outbound.protection.outlook.com [2a01:111:f403:2414::604]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8cb00071-58b9-11f0-b894-0df219b8e170; Fri, 04 Jul 2025 11:30:41 +0200 (CEST) Received: from MN2PR15CA0038.namprd15.prod.outlook.com (2603:10b6:208:237::7) by CY1PR12MB9698.namprd12.prod.outlook.com (2603:10b6:930:107::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8901.22; Fri, 4 Jul 2025 09:30:36 +0000 Received: from BN1PEPF0000468D.namprd05.prod.outlook.com (2603:10b6:208:237::4) by MN2PR15CA0038.outlook.office365.com (2603:10b6:208:237::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8901.22 via Frontend Transport; Fri, 4 Jul 2025 09:30:35 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by BN1PEPF0000468D.mail.protection.outlook.com (10.167.243.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8901.15 via Frontend Transport; Fri, 4 Jul 2025 09:30:35 +0000 Received: from penny-System-Product-Name.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 4 Jul 2025 04:30:32 -0500 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: 8cb00071-58b9-11f0-b894-0df219b8e170 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SIvzlAABDvzgbyC1MqCBADVxeK0CLO8oHSWYzQz/BLpnBTxNSSr1+/yuYlf3kGcIrmFuhoTKu6DMOwIvfPSedMQANkwR3BzqyhjvMXbGus8vKWhkWiPvtpNsE73u2CCLOvvcnI1+2+cefvmt+ra10Djj7jhD+/uEv/B+Mvd85Dt8+6qHNydh3DsEofKV5zYl4I9RoZHS2/BGrLX2VSRuUQN63mwdD2Lk1zYDt65gkfG8AU4jPRv+YK1yIa8UWSv377upu87QIVSYykFWreRrVmo8tuopSBDB4y3EJY6EzndQDEGUiKdad4DF8txOAEKYeXgEp+XxE0o2ccF363qEKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QecYoeOZZxssyXE8XinkAofZ+aon7XKcTK0uGY706Nc=; b=gAhJp1YV+i7IEikwBJhlXR5kN9qyvwfeKj+eEDqqYm2asyaI1vIIwYzBTEjH89ztVt0KhdxqR/dRgqvY5l9PUcKHw4ZEqxhpZLb8Nff40UNZ/DEMMPEOUTNk2FAo2DBcBtJQoUXUoegRZuOQ7SiHaWYaiQaaaXmPz6nrvgUMc6SMooVWof/MTjG6pZjOfRbqYBvr2UM/R9i7memN3yxut2NUwrxx2nYdy4y1C2PPfNXWmFds7fhPotZLV3ZmhNzIueAffm3nEuKbjtF4+UrGlr8foTvTFD4rvXcO8GpVWc9IBUYKWoLuEKjJRzAFEPy93dAKRz6zjWr8NHZOQnsoQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QecYoeOZZxssyXE8XinkAofZ+aon7XKcTK0uGY706Nc=; b=lBM64dSsJa9jZi8IcoHMOEUzlvLsNq4CrM8Vy+mUnk1iNVqXdH4sTikpAdcIr8Oq6byaBJPoLyR39EM5Yk7K1pZoovuJb3eRwNUS3kDaqx+0eUDqAVEO/9l/N/WgjlV0OCmvHG/n70SASmz4jE8P1xIRpEBhRpm3pE3WMbeOwU4= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; 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; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Penny Zheng To: CC: , Penny Zheng , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Anthony PERARD , Michal Orzel , "Julien Grall" , Stefano Stabellini Subject: [PATCH v6 09/18] xen/sysctl: introduce CONFIG_PM_STATS Date: Fri, 4 Jul 2025 17:29:43 +0800 Message-ID: <20250704092952.822578-10-Penny.Zheng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250704092952.822578-1-Penny.Zheng@amd.com> References: <20250704092952.822578-1-Penny.Zheng@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF0000468D:EE_|CY1PR12MB9698:EE_ X-MS-Office365-Filtering-Correlation-Id: c8daf90a-ea47-4f93-3ffb-08ddbadd6e07 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?YZO8ZQkjBH27U8711xhUyBEc4SflUq+m4BBfRTj+dyWvq9WFDw3v6B3uiUxl?= =?us-ascii?Q?9Mn2svgM9PX5WZuiYyFEqIvWO8IZ/g4TdfKNSwi8cRq8Jn1Q1i1FylPX7mXz?= =?us-ascii?Q?aydEpHHHP4p3oX1MC+3+JncmA+r4KCncnfxHjBPfyWNJRgM/c5Y1TXfIyEZT?= =?us-ascii?Q?srGb+gfUneW6je/kp+dRPvdXCRZhE/NHTenu8F8pcU1pT4oB86hazJZgDiqF?= =?us-ascii?Q?VXCdZ8JfLyp5Z+EFISWyv4omg/0bn5XYZLnQB8ItkTy38PPUGKpPdRvyZLS+?= =?us-ascii?Q?NcyjwqQo2GB1vFLe1JtSkjxk7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jwyK+aEBskbjXT0qS4s/iGPCbkiO1CUiA1ZSQiSl1pdrGUTdc50?= =?us-ascii?Q?lMpbrGwWQVp6BWCLZzKRJvpw3Q13J9PLgA2B4PlSslbbrSfLq2ZP891nBKi2?= =?us-ascii?Q?pFeLtjUriwFWJB0P3zjWkcdY9WPvI+mEilq3kFheYSLas/IE0NuhmGlszKsY?= =?us-ascii?Q?K2U4VqjBt67/S++JWx/uN+7pcYWmbTwticH6NNkj8p7UM9Px6pn2zn59ROKt?= =?us-ascii?Q?XRrfQXBUfT8AAmy8pee8vuMOXCX8TQ1L8+xM5CWmO2uE4UY32QalMLFqiwF0?= =?us-ascii?Q?wqpUYRQahNKpHyeMr8HZpOAq2fUrYXcQgk3E?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2025 09:30:35.2565 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8daf90a-ea47-4f93-3ffb-08ddbadd6e07 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF0000468D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB9698 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1751621467713116600 Content-Type: text/plain; charset="utf-8" We introduce a new Kconfig CONFIG_PM_STATS for wrapping all operations regarding performance management statistics. The major codes reside in xen/drivers/acpi/pmstat.c, including the pm-statistic-related sysctl op: do_get_pm_info(). CONFIG_PM_STATS also shall depend on CONFIG_SYSCTL We shall also provide "# CONFIG_PM_STATS is not set" in preset configs for PV shim on x86. Signed-off-by: Penny Zheng Reviewed-by: Stefano Stabellini Acked-by: Jan Beulich --- v1 -> v2: - rename to CONFIG_PM_STATS - fix indention and stray semicolon - make code movements into a new commit - No need to wrap inline functions and declarations --- v2 -> v3: - sepearte functions related to do_pm_op() into a new commit - both braces shall be moved to the line with the closing parenthesis --- v3 -> v4: - be consistent with the comment on the #endif --- v4 -> v5 - add blank line before endmenu --- v5 -> v6 - add "# CONFIG_PM_STATS is not set" in preset configs for PV shim on x86 --- xen/arch/x86/acpi/cpu_idle.c | 2 ++ xen/arch/x86/configs/pvshim_defconfig | 1 + xen/common/Kconfig | 8 ++++++++ xen/common/sysctl.c | 2 +- xen/drivers/acpi/Makefile | 2 +- xen/include/acpi/cpufreq/processor_perf.h | 10 ++++++++++ 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c index 6c3a10e6fb..3a5524691b 100644 --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -1490,6 +1490,7 @@ static void amd_cpuidle_init(struct acpi_processor_po= wer *power) vendor_override =3D -1; } =20 +#ifdef CONFIG_PM_STATS uint32_t pmstat_get_cx_nr(unsigned int cpu) { return processor_powers[cpu] ? processor_powers[cpu]->count : 0; @@ -1609,6 +1610,7 @@ int pmstat_reset_cx_stat(unsigned int cpu) { return 0; } +#endif /* CONFIG_PM_STATS */ =20 void cpuidle_disable_deep_cstate(void) { diff --git a/xen/arch/x86/configs/pvshim_defconfig b/xen/arch/x86/configs/p= vshim_defconfig index bacd04c963..9dc91c33e3 100644 --- a/xen/arch/x86/configs/pvshim_defconfig +++ b/xen/arch/x86/configs/pvshim_defconfig @@ -27,3 +27,4 @@ CONFIG_EXPERT=3Dy # CONFIG_DEBUG is not set # CONFIG_GDBSX is not set # CONFIG_PM_OP is not set +# CONFIG_PM_STATS is not set diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 943cf0a950..998e672fa7 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -628,4 +628,12 @@ config PM_OP This option shall enable userspace performance management control to do power/performance analyzing and tuning. =20 +config PM_STATS + bool "Enable Performance Management Statistics" + depends on ACPI && HAS_CPUFREQ && SYSCTL + default y + help + Enable collection of performance management statistics to aid in + analyzing and tuning power/performance characteristics of the system + endmenu diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index daf57fbe56..5207664252 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -170,7 +170,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_s= ysctl) op->u.availheap.avail_bytes <<=3D PAGE_SHIFT; break; =20 -#if defined (CONFIG_ACPI) && defined (CONFIG_HAS_CPUFREQ) +#ifdef CONFIG_PM_STATS case XEN_SYSCTL_get_pmstat: ret =3D do_get_pm_info(&op->u.get_pmstat); break; diff --git a/xen/drivers/acpi/Makefile b/xen/drivers/acpi/Makefile index 1d811a51a7..477408afbe 100644 --- a/xen/drivers/acpi/Makefile +++ b/xen/drivers/acpi/Makefile @@ -5,7 +5,7 @@ obj-$(CONFIG_X86) +=3D apei/ obj-bin-y +=3D tables.init.o obj-$(CONFIG_ACPI_NUMA) +=3D numa.o obj-y +=3D osl.o -obj-$(CONFIG_HAS_CPUFREQ) +=3D pmstat.o +obj-$(CONFIG_PM_STATS) +=3D pmstat.o obj-$(CONFIG_PM_OP) +=3D pm-op.o =20 obj-$(CONFIG_X86) +=3D hwregs.o diff --git a/xen/include/acpi/cpufreq/processor_perf.h b/xen/include/acpi/c= pufreq/processor_perf.h index fa28b14faf..caa768626c 100644 --- a/xen/include/acpi/cpufreq/processor_perf.h +++ b/xen/include/acpi/cpufreq/processor_perf.h @@ -9,9 +9,19 @@ =20 unsigned int powernow_register_driver(void); unsigned int get_measured_perf(unsigned int cpu, unsigned int flag); +#ifdef CONFIG_PM_STATS void cpufreq_statistic_update(unsigned int cpu, uint8_t from, uint8_t to); int cpufreq_statistic_init(unsigned int cpu); void cpufreq_statistic_exit(unsigned int cpu); +#else +static inline void cpufreq_statistic_update(unsigned int cpu, uint8_t from, + uint8_t to) {} +static inline int cpufreq_statistic_init(unsigned int cpu) +{ + return 0; +} +static inline void cpufreq_statistic_exit(unsigned int cpu) {} +#endif /* CONFIG_PM_STATS */ =20 int cpufreq_limit_change(unsigned int cpu); =20 --=20 2.34.1