From nobody Mon Mar 10 02:36:58 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=1741251500; cv=pass; d=zohomail.com; s=zohoarc; b=nbR30R5h8DbSghLkx4Zj4s7fiBqnIopSmVm5PggSoyVl4QherSgOdM7Ylpyahc1yyDU7C4Zw9TLp/MXEwi588QQzOdlC8UB+iLT0LQR2vENSW7VEoDfkVa/JFOjKieDO61N78LeJKOuoetaxqI1hZe5tCwaOCIwllrN3pALNQWY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741251500; 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=6c9sueaBP6Rd4TxQW09D/ICaquL7cGU914u/trV6d4s=; b=mEvkcczLY2zVA40b/xKJswD4VOkBzI8m36CLp3PI82isO8xGogKInF07+jG5eoKkIWix59ZguQA5WK/Q2J1nQm9pe5KXYX2FEf/cGO9uz07ceg2+WDvZ+/GhwXsadmSU0IHSbawFgtdRQM58x4DOUcTxBUXHDeCySXFZv0xUS4s= 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 1741251500254130.37972191769825; Thu, 6 Mar 2025 00:58:20 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.903235.1311175 (Exim 4.92) (envelope-from ) id 1tq73P-0005Dx-Tk; Thu, 06 Mar 2025 08:58:07 +0000 Received: by outflank-mailman (output) from mailman id 903235.1311175; Thu, 06 Mar 2025 08:58:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tq73P-0005Dq-Qb; Thu, 06 Mar 2025 08:58:07 +0000 Received: by outflank-mailman (input) for mailman id 903235; Thu, 06 Mar 2025 08:58:06 +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 1tq6mq-00031D-4g for xen-devel@lists.xenproject.org; Thu, 06 Mar 2025 08:41:00 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20605.outbound.protection.outlook.com [2a01:111:f403:2418::605]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b8afbc87-fa66-11ef-9898-31a8f345e629; Thu, 06 Mar 2025 09:40:56 +0100 (CET) Received: from CH2PR10CA0026.namprd10.prod.outlook.com (2603:10b6:610:4c::36) by SJ0PR12MB8137.namprd12.prod.outlook.com (2603:10b6:a03:4e5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8489.25; Thu, 6 Mar 2025 08:40:51 +0000 Received: from CH1PEPF0000AD74.namprd04.prod.outlook.com (2603:10b6:610:4c:cafe::6e) by CH2PR10CA0026.outlook.office365.com (2603:10b6:610:4c::36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8511.16 via Frontend Transport; Thu, 6 Mar 2025 08:40:50 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD74.mail.protection.outlook.com (10.167.244.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8511.15 via Frontend Transport; Thu, 6 Mar 2025 08:40:50 +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; Thu, 6 Mar 2025 02:40:48 -0600 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: b8afbc87-fa66-11ef-9898-31a8f345e629 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fJdCkYzbpKVQMc5c3fHLH32oQCpjU3k6KJZZxhUdTrTR9JNrLsbpepjxjmJn/4cR5hQDNLuyWROEvidBgLywo+gvRfu/s3KULpegfz+NfQluLbjIvYD3sW4122MQrwLLjHwAQZAozw1BWCCcmVHNNrA3kdBLQcK1T/FuoljIFFjwMlzAkYqAeNPCcQhLhitEaALkMA8ocKzOpy04ebf9ZQESjBUu2LVtkGKVcsRgGJUslaLN7zC/l1nJKt9cxktuOtzsldBXj1Rk9E7mjfI0b94q2njljYF2QBtoClMzYVM0z7j6eiLWusOuRrTI8fc8AGJ14fjZjKQEm9++jV/DiA== 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=6c9sueaBP6Rd4TxQW09D/ICaquL7cGU914u/trV6d4s=; b=sBgQgjS//pGfW57jh1UDshIP6KCMcD1WOdBoxXPdVVSVse0VcbT7ThTWifXVrQGR1qA8ejIFjbN715ICRzogqem9+LgmINR057LNP52wDJjX5cJqzZ7mGXDsIPaAcnlrjCrr6D2QnlczQqDNqDFutk84931KdB1bc6qOAxnIE/w4LHjF0C7ffGFQAhUTfoIvjVx55X6Z32Gz97YpqtsDgX+JbBUAdwF5+hEeRhs6RRdZw+8Bktfn/Cl+Zr6U+gb2AZWtdkwSJW6xl6j2M2Oo33kfuUq+aJBCbPvaK8MommxmNqpDWIjJ0FWaOB29vK7bdrsyxVJbwOqL2ab2wkD+Pg== 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=6c9sueaBP6Rd4TxQW09D/ICaquL7cGU914u/trV6d4s=; b=4jXY//7Pn1I1tRmwcf9eMgvg3DuGTx/dTxSpzuvHStOyy8+UhTAZc+gE44ic3gU3ClYrovlUUFIeHvNMJN52iTUFg4P8cv/ixFBcQK7rmhWcz1YdQrbTMNhCEtepeh/acNG3uyuJzn5jNWVgvjTNo9eDwJ+fjIhA5yQbh0GjDFY= 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 , Anthony PERARD , Juergen Gross , Jan Beulich Subject: [PATCH v3 14/15] xen/xenpm: Adapt cpu frequency monitor in xenpm Date: Thu, 6 Mar 2025 16:39:48 +0800 Message-ID: <20250306083949.1503385-15-Penny.Zheng@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250306083949.1503385-1-Penny.Zheng@amd.com> References: <20250306083949.1503385-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: CH1PEPF0000AD74:EE_|SJ0PR12MB8137:EE_ X-MS-Office365-Filtering-Correlation-Id: a455b2b3-a5ce-412c-ecce-08dd5c8a9982 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?MBwpxHXd+0sjlYVisTPz06s9BYtbKIBMmUJHwpA5OwHxuGu/aTEVow49RSoq?= =?us-ascii?Q?u/Rm8Wj6stJZ3YGiB4rN5jWTKC9vZsvbuvx1VNddmeG056iZF2LzpBAVLa3J?= =?us-ascii?Q?TZitzQA/8HSF+9Qc/KzndlytYWqY96B1m54bacXy/CF6KxO0iwHLRbPsmY3w?= =?us-ascii?Q?b7xuejp2cyq27bsAsP7DCECECtfHYnmnvXlYqLB5WxRvyEflehbg9z2ILy/i?= =?us-ascii?Q?Vh1+uGqh5HMBqFT5xTwmBQ3V/+DtTSBOj40jJ7mBhzDMCYKXkCAM5fiaGykD?= =?us-ascii?Q?52dPtE+Xzn/N8hIMVcrudIa+MnF0zBUZszIOEpu2kD9eoooXmqi+4jDeDKWY?= =?us-ascii?Q?zCGvSdwk3AecLVetCPwx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1F2oW+F?= =?us-ascii?Q?fF8mrWkN6E9q/pXPtCuo15Sk3Vf+lSDYtZNcGlZjLGwzBRbj52flsidOkQVx?= =?us-ascii?Q?JzjpW5MBpsJ2wn6E5RG4b5IXB7GMPEF+UD8gt1wwHDEzXAvbQlK+LpLfZetE?= =?us-ascii?Q?J7GNNuHKlrFVoaNXgsy47yELg67WZv8riyqBt2HyudAqaoTfX+yhMBItlngH?= =?us-ascii?Q?AtaQrAGIJ8hZs+ZsetH0Gy5MuJUIJiF5vxFG9GRaCD0F2YApPUqRw2HnLjGw?= =?us-ascii?Q?K1dlSNmtVje4mIA=3D?= 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)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2025 08:40:50.6277 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a455b2b3-a5ce-412c-ecce-08dd5c8a9982 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: CH1PEPF0000AD74.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB8137 X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1741251502239019000 Content-Type: text/plain; charset="utf-8" Make `xenpm get-cpureq-para/set-cpufreq-para` available in CPPC mode. Also, In `xenpm get-cpufreq-para `, para scaling_available_frequenci= es only has meaningful value when cpufreq driver in legacy P-states. So we loosen "has_num" condition to bypass scaling_available_frequencies check in CPPC mode. Also, in `xenpm get-cpyfreq-para start`, the monitor of average frequency s= hall not depend on the existence of legacy P-states. Signed-off-by: Penny Zheng --- v2 -> v3: - new commit --- tools/libs/ctrl/xc_pm.c | 12 +++++++----- tools/misc/xenpm.c | 5 +++-- xen/drivers/acpi/pmstat.c | 30 +++++++++++++++++------------- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/tools/libs/ctrl/xc_pm.c b/tools/libs/ctrl/xc_pm.c index b27b45c3dc..d843b79d6d 100644 --- a/tools/libs/ctrl/xc_pm.c +++ b/tools/libs/ctrl/xc_pm.c @@ -214,13 +214,12 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid, user_para->gov_num * CPUFREQ_NAME_LEN * sizeof(char), XC_HYPERCALL_BUF= FER_BOUNCE_BOTH); =20 bool has_num =3D user_para->cpu_num && - user_para->freq_num && user_para->gov_num; =20 if ( has_num ) { if ( (!user_para->affected_cpus) || - (!user_para->scaling_available_frequencies) || + (user_para->freq_num && !user_para->scaling_available_frequen= cies) || (user_para->gov_num && !user_para->scaling_available_governor= s) ) { errno =3D EINVAL; @@ -228,14 +227,16 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid, } if ( xc_hypercall_bounce_pre(xch, affected_cpus) ) goto unlock_1; - if ( xc_hypercall_bounce_pre(xch, scaling_available_frequencies) ) + if ( user_para->freq_num && + xc_hypercall_bounce_pre(xch, scaling_available_frequencies) ) goto unlock_2; if ( user_para->gov_num && xc_hypercall_bounce_pre(xch, scaling_available_governors) ) goto unlock_3; =20 set_xen_guest_handle(sys_para->affected_cpus, affected_cpus); - set_xen_guest_handle(sys_para->scaling_available_frequencies, scal= ing_available_frequencies); + if ( user_para->freq_num ) + set_xen_guest_handle(sys_para->scaling_available_frequencies, = scaling_available_frequencies); if ( user_para->gov_num ) set_xen_guest_handle(sys_para->scaling_available_governors, scaling_available_governors); @@ -301,7 +302,8 @@ unlock_4: if ( user_para->gov_num ) xc_hypercall_bounce_post(xch, scaling_available_governors); unlock_3: - xc_hypercall_bounce_post(xch, scaling_available_frequencies); + if ( user_para->freq_num ) + xc_hypercall_bounce_post(xch, scaling_available_frequencies); unlock_2: xc_hypercall_bounce_post(xch, affected_cpus); unlock_1: diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index a7aeaea35e..a521800504 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -539,7 +539,7 @@ static void signal_int_handler(int signo) res / 1000000UL, 100UL * res / (double)sum_px[i]); } } - if ( px_cap && avgfreq[i] ) + if ( avgfreq[i] ) printf(" Avg freq\t%d\tKHz\n", avgfreq[i]); } =20 @@ -926,7 +926,8 @@ static int show_cpufreq_para_by_cpuid(xc_interface *xc_= handle, int cpuid) ret =3D -ENOMEM; goto out; } - if (!(p_cpufreq->scaling_available_frequencies =3D + if (p_cpufreq->freq_num && + !(p_cpufreq->scaling_available_frequencies =3D malloc(p_cpufreq->freq_num * sizeof(uint32_t)))) { fprintf(stderr, diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c index c8e00766a6..7f432be761 100644 --- a/xen/drivers/acpi/pmstat.c +++ b/xen/drivers/acpi/pmstat.c @@ -202,7 +202,7 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op) pmpt =3D processor_pminfo[op->cpuid]; policy =3D per_cpu(cpufreq_cpu_policy, op->cpuid); =20 - if ( !pmpt || !pmpt->perf.states || + if ( !pmpt || ((pmpt->init & XEN_PX_INIT) && !pmpt->perf.states) || !policy || !policy->governor ) return -EINVAL; =20 @@ -229,17 +229,20 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *= op) if ( ret ) return ret; =20 - if ( !(scaling_available_frequencies =3D - xzalloc_array(uint32_t, op->u.get_para.freq_num)) ) - return -ENOMEM; - for ( i =3D 0; i < op->u.get_para.freq_num; i++ ) - scaling_available_frequencies[i] =3D - pmpt->perf.states[i].core_frequency * 1000; - ret =3D copy_to_guest(op->u.get_para.scaling_available_frequencies, - scaling_available_frequencies, op->u.get_para.freq_num); - xfree(scaling_available_frequencies); - if ( ret ) - return ret; + if ( op->u.get_para.freq_num ) + { + if ( !(scaling_available_frequencies =3D + xzalloc_array(uint32_t, op->u.get_para.freq_num)) ) + return -ENOMEM; + for ( i =3D 0; i < op->u.get_para.freq_num; i++ ) + scaling_available_frequencies[i] =3D + pmpt->perf.states[i].core_frequency * 1000; + ret =3D copy_to_guest(op->u.get_para.scaling_available_frequencies, + scaling_available_frequencies, op->u.get_para.freq_num= ); + xfree(scaling_available_frequencies); + if ( ret ) + return ret; + } =20 op->u.get_para.cpuinfo_cur_freq =3D cpufreq_driver.get ? alternative_call(cpufreq_driver.get, op->cpui= d) @@ -465,7 +468,8 @@ int do_pm_op(struct xen_sysctl_pm_op *op) switch ( op->cmd & PM_PARA_CATEGORY_MASK ) { case CPUFREQ_PARA: - if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_PX) ) + if ( !(xen_processor_pmbits & (XEN_PROCESSOR_PM_PX | + XEN_PROCESSOR_PM_CPPC)) ) return -ENODEV; if ( !pmpt || !(pmpt->init & (XEN_PX_INIT | XEN_CPPC_INIT)) ) return -EINVAL; --=20 2.34.1