From nobody Thu Nov 28 08:33:36 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2078.outbound.protection.outlook.com [40.107.244.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2586E482ED; Thu, 3 Oct 2024 08:46:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727945171; cv=fail; b=pL2ODap7FaxCRMBxEr7TsLUWJPN3hRcm7j+2pMs/8GYn2NfI2cLNiyDUGc5yBlDIgDQekGXqsQuamQ+cwBWd8slJwdF5sUuTwEGLZE9jbThqY9Yz5U/gvMwmJQiTG37yzegRaKzFnTmFHuw2DMWBCg67WpN/RUpzLf2tAj8GhB0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727945171; c=relaxed/simple; bh=4Ve6i4Rv3Mwn88STU8da3QNPK6uVAlggZRA168oFL7A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SnV9CrazzilfOa8LecW4qH5snavRJ+B4ASovQI43AcuEaqgswNbC+5jAtKDktCEOJLF+i8x5EIgMVGZaAMFLX7STyIqq87rQ91+JkJeo9U956OGKFxFc0yk8qIYnX7i/79SKJ3s7mQTrnVNo4JayKk+3CkZAVScISOQB9JFe62o= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=lT2rwUBg; arc=fail smtp.client-ip=40.107.244.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="lT2rwUBg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DiYZicawj4MFTWSKpn8dB90LWhsSuvkSPFdf9FyQIy7NGtOJgNvA6FFnrqmmmOGKFARvyQGE7b75twZ0q+wA/ixv45GLRTrqatRpHULcY4mm3rqKWaE19eLd3cJ2pytaJiR0OXTaIvWFWeo/gPPxj0vNX828/Y0rlV7d5gKWwg6GHbVsZwNskXy4j0xlktl2Gtowbn7AjfoTtJ5QIQTlSI/caizuNA9m3xtP555zv9wqmjxp08OrnbbVNoSiklATqyoZb1b1IygTrW3PQ3B7XKXjNQDBY+oT16Jo71ZIGA5emRPdoLkKNkvCgRjlHTXx8JzFfUJRpSjukLpuPBHSpg== 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=rM15UiT3u2QbAYi3rT/oD6jbgjwQb5wY1LJWn2+vBL0=; b=aqYDSIlyzCmBgkRt06gBW3JDr3y87ez+iPb3pZItbqTjmllNxf1BvGqaLr+Hqy6rjCWLn5IuGAlGt3nGOIIPEhryRuzLU+n2kfXYj7F0XWK0GTwBkbJmNPZL6dIawDvmAUWVinn5MuCnr8QhKxbZaRwejxerS2Q/RnmT/FpIb1W9xCSQ261uZfHW1/b7VYqXkeHrYnhTgajGPWkG8u6ZelHCYygDw57Y16oceSo7dlcW6dA37ssyTs222dAZRqe5kZKR4pc4Sp2ReeE90tHfHW4u43iPOw1aWiS70HtN2dUIc+A4F1hS8PMztVRTV/jOXe/Dt39ORmrftl9IGKynDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=rM15UiT3u2QbAYi3rT/oD6jbgjwQb5wY1LJWn2+vBL0=; b=lT2rwUBgy+iHwZyfYQjklmTB9CS8yr5Qk+XZYy7bY1hxlxF3DIFym82nbcVfZK65OkTl4PX4LbbUNB3jtwFM1PzrzrSnYq4/WKfungy0ZgLsZ/XfxWgdL7ULacog86F5uMOs3gATdg5wJ4WiRY2iSqcJAfcvf7tJU9WavYxrbX0= Received: from DM6PR06CA0051.namprd06.prod.outlook.com (2603:10b6:5:54::28) by DS0PR12MB6654.namprd12.prod.outlook.com (2603:10b6:8:d1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.27; Thu, 3 Oct 2024 08:46:03 +0000 Received: from CY4PEPF0000EE34.namprd05.prod.outlook.com (2603:10b6:5:54:cafe::39) by DM6PR06CA0051.outlook.office365.com (2603:10b6:5:54::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Thu, 3 Oct 2024 08:46:03 +0000 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 (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 Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE34.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8026.11 via Frontend Transport; Thu, 3 Oct 2024 08:46:03 +0000 Received: from shatadru.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, 3 Oct 2024 03:45:59 -0500 From: Dhananjay Ugwekar To: , , , , , CC: , , "Dhananjay Ugwekar" Subject: [PATCH 2/3] cpufreq/amd-pstate: Set the initial min_freq to lowest_nonlinear_freq Date: Thu, 3 Oct 2024 08:39:54 +0000 Message-ID: <20241003083952.3186-3-Dhananjay.Ugwekar@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241003083952.3186-1-Dhananjay.Ugwekar@amd.com> References: <20241003083952.3186-1-Dhananjay.Ugwekar@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE34:EE_|DS0PR12MB6654:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f38b0db-f658-4aa3-cb60-08dce387d03c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|1800799024|30052699003; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?iaF3O0HewwlfveIA6+jLb/aFTk7myaHjiYTT5ZYVADjYtlhpStbE+EmLxvZT?= =?us-ascii?Q?HWcitNsBx6HtYPBmfZ7UKNoThaafztfWElsqwRE/78t9b6a+mVKvVhfT+c8G?= =?us-ascii?Q?HMlquBDaH1ECqSzIZ/QREvw3hvST6pLTJZmqkGq9yr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gOER4DXk4Ia1faLwyVpW16dndFFZLDMns9KzPAHkaAbAG?= =?us-ascii?Q?0J+kFDvFkNjkIYR+Z5CIgBC6qJvpo1lN+Pjnr/fXbAdkezCrxGto2+YbNJcL?= =?us-ascii?Q?fHUs9okkXyRwnQRCKbJJ6FwAflt6oepiPAcCxE7ZaMdvQEMmwpkP1GJLpSbM?= =?us-ascii?Q?4nwveDPI79cIh6ZUUkEIBZGPuHqREzmj1d+va+vFYQak66T0EVyfQt3FxIgB?= =?us-ascii?Q?Tu6HprUxZsJffJPtZQhXn4idVZT1x1PS+S0AxSxLFZ213LTzoLyJrrOsWUpw?= =?us-ascii?Q?P3axUJANDj55JMtnO8hoUaRfEPWjExcCTjL3U9xhwkS26zJoV471HpnrP5uS?= =?us-ascii?Q?dcO6HSvtUugputOeMis8DqKtBwol?= 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)(36860700013)(376014)(1800799024)(30052699003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2024 08:46:03.1628 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f38b0db-f658-4aa3-cb60-08dce387d03c 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: CY4PEPF0000EE34.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6654 Content-Type: text/plain; charset="utf-8" According to the AMD architectural programmer's manual volume 2 [1], in section "17.6.4.1 CPPC_CAPABILITY_1" lowest_nonlinear_perf is described as "Reports the most energy efficient performance level (in terms of performance per watt). Above this threshold, lower performance levels generally result in increased energy efficiency. Reducing performance below this threshold does not result in total energy savings for a given computation, although it reduces instantaneous power consumption". So lowest_nonlinear_perf is the most power efficient performance level, and going below that would lead to a worse performance/watt. Also, setting the minimum frequency to lowest_nonlinear_freq (instead of lowest_freq) allows the CPU to idle at a higher frequency which leads to more time being spent in a deeper idle state (as trivial idle tasks are completed sooner). This has shown a power benefit in some systems, in other systems, power consumption has increased but so has the throughput/watt. Use the get_init_min_freq() callback to set the initial lower limit for amd-pstate driver to lowest_nonlinear_freq instead of lowest_freq. Link: https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/= programmer-references/24593.pdf [1] Signed-off-by: Dhananjay Ugwekar Reviewed-by: Gautham R. Shenoy --- drivers/cpufreq/amd-pstate.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index b7a17a3ef122..f8abae9a0156 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -995,13 +995,6 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *= policy) if (cpu_feature_enabled(X86_FEATURE_CPPC)) policy->fast_switch_possible =3D true; =20 - ret =3D freq_qos_add_request(&policy->constraints, &cpudata->req[0], - FREQ_QOS_MIN, policy->cpuinfo.min_freq); - if (ret < 0) { - dev_err(dev, "Failed to add min-freq constraint (%d)\n", ret); - goto free_cpudata1; - } - ret =3D freq_qos_add_request(&policy->constraints, &cpudata->req[1], FREQ_QOS_MAX, policy->cpuinfo.max_freq); if (ret < 0) { @@ -1706,6 +1699,13 @@ static int amd_pstate_epp_resume(struct cpufreq_poli= cy *policy) return 0; } =20 +static int amd_pstate_get_init_min_freq(struct cpufreq_policy *policy) +{ + struct amd_cpudata *cpudata =3D policy->driver_data; + + return READ_ONCE(cpudata->lowest_nonlinear_freq); +} + static struct cpufreq_driver amd_pstate_driver =3D { .flags =3D CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS, .verify =3D amd_pstate_verify, @@ -1719,6 +1719,7 @@ static struct cpufreq_driver amd_pstate_driver =3D { .update_limits =3D amd_pstate_update_limits, .name =3D "amd-pstate", .attr =3D amd_pstate_attr, + .get_init_min_freq =3D amd_pstate_get_init_min_freq, }; =20 static struct cpufreq_driver amd_pstate_epp_driver =3D { @@ -1735,6 +1736,7 @@ static struct cpufreq_driver amd_pstate_epp_driver = =3D { .set_boost =3D amd_pstate_set_boost, .name =3D "amd-pstate-epp", .attr =3D amd_pstate_epp_attr, + .get_init_min_freq =3D amd_pstate_get_init_min_freq, }; =20 static int __init amd_pstate_set_driver(int mode_idx) --=20 2.34.1