From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.52.9 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796116699; b=Ga72NbxIBNoRGHeSHPma0FzxFfoLhl0tJV2POBKTr1r/UaOCbZihS7OXtfqv5A1SyQDa +nHLX6KRSe4WY3u4hmB3hzSywckAtb7XQFuxTO6Pz4WvjEDxFEVRi6jx8HAeFFpfYr+CH PZOUOo2BsHOAAgdjFP2nl7u3Pc9QImMupifglbbwWJKjcc8FA/yOPkUbSOhycD585B+mT 8f9dbF5l8YsEmKCrl2tVLXEqAEmBN8susGRz8FTzhCBkPQ2vWEGxj+TwwgjSxOdJSX0Dz Xf3IEjdDZPvovk6WShVB1OWuzZ5Ocu3ifPRU9F3Mh3hZFz/oQ8X71ZxtAvq7WJVZCxw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796116699; h=DMARC-Filter:DKIM-Signature:Received:Received:Message-ID:Date: User-Agent:Subject:To:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-ClientProxiedBy:MIME-Version: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=+EFgI+gaVUBiw10DBDGLPM/A5BAWLSq+UdRYT/sEJCQ=; b=StIexVdJ3l560S/JdsDibGTEN59+5aQ1/es13tCfbUj6tEV+0cnGpQatDuQMLSySbWz8 4r69s3P6PqnUK2AiZFzWQPHd8RXFlD4lWw0wGp3soZ+vhj2lQvyXkqm77jVF19a3B4L5n 0ZvE+Zsq6q+R+0CYU6OxcAoJq9Xo6DQQEd4uC8qw71OycPtmmcukpPYk5hMoRSJ5NLnmA DQAqXSSK0qN4fqSb/eW+PyNoe8Vbah3A8El5fNmRtplw4ykRO6OUTe/e/Triq1L0S+HC+ EUtgKhYGdXmNSJeeOpTm0PtYaVIlLn3TkbD3i8nfRElG2myRk8EJuc4FamgAO2VO+og== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b="a/MAHLji"; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.52.9 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011009.outbound.protection.outlook.com [52.101.52.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D8F2606A32E; Tue, 1 Dec 2026 09:18:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5D8F2606A32E 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, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=a/MAHLji ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SOOt5y0DtNfOqXva3Dri10rXZ7ahXagi3E7hcArxPyOPIdU76tzq9PelTUVT9KeLMFz92L4iuqRW+mWmLPvtO/q0wi4YipHMfF/aXKZoO0/r50xPVgsH/bfCT/RfnSCTqL7SUC2mg6ogRsl148Cq4bTIVN/Gh8j625XDn+PEqZQJSFaeD2rMZchW6ZHQZHCZqLt/fo0fBRlBbvop8NidMMR1rZziwVvgeEdd8ecpXgdkswAsSgIAGpVcyd8EfsBMQdFpJ7e+GUyn4irc4LgpaWriVs3onM9xJHXhWuC8CeAfBRz1llUq9Pn/ilEaCYwPDQndNDK1GPZjg0QZwFUpnw== 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=+EFgI+gaVUBiw10DBDGLPM/A5BAWLSq+UdRYT/sEJCQ=; b=c8zIrsfFJcGtw1Q5S5ISeChyZh8Pnwqg0so7rSzcVoFXBKaOOGmYqB2rM6pffqYTKViuUZtaG4ACPiSd29zCVULEqpETLi46PlgFhz+n0vU3I0pJpmkDnT5WjVIsd3jzsMyN313UPDcS+lK9exZ9oc/Dd/a56/pfKw3ne5ydE7bodB+w46qPF7EG+DvbhrZTInNE8b+/23HhYhRuNYypy+gUyrKSiuG45MHIKdRFQJzqDiV3kGH1NUuB6OgdjWlboGU6c3GQ+Ck+rqPnG+9ppQzCBj/BbC2W1unxj0pKD/bnrjQIhmXVx6XJAXANW0Nysqjja5PFA+841EjBcyevBQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none 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=+EFgI+gaVUBiw10DBDGLPM/A5BAWLSq+UdRYT/sEJCQ=; b=a/MAHLji8VFgTQuuZCXWLPOYeVhcREM51UAwiYmuAA8yB4AhSdDq2tBVtZ9nFfIraFHwCen0QtGM2DVDha7WR2nR/IAUwZ+4oCz7KjRBu63EIm03JyoEKh7aXYRKxkFc7m0fK8+f2QrKu+Q9vM31w6kbpk4PYoyu3SJGkapAmUg= Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from IA1PR12MB292992.namprd12.prod.outlook.com (2603:10b6:208:5a1::21) by MW4PR12MB7335.namprd12.prod.outlook.com (2603:10b6:303:22b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Tue, 1 Dec 2026 09:18:14 +0000 Received: from IA1PR12MB292992.namprd12.prod.outlook.com ([fe80::4b88:460d:65c0:def1]) by IA1PR12MB292992.namprd12.prod.outlook.com ([fe80::4b88:460d:65c0:def1%6]) with mapi id 15.21.0662.012; Tue, 1 Dec 2026 09:18:14 +0000 Message-ID: <955f1ea8-65da-4100-93dd-11bfebc4954c@amd.com> Date: Tue, 1 Dec 2026 14:48:07 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/3] cpufreq: amd-pstate: Set asymmetric CPU capacity on hybrid platforms To: K Prateek Nayak , ray.huang@amd.com, mario.limonciello@amd.com, rafael@kernel.org, viresh.kumar@linaro.org, perry.yuan@amd.com, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261125172031.741740-1-Vishal.Badole@amd.com> <20261125172031.741740-3-Vishal.Badole@amd.com> <7fb17998-e523-4264-91af-0af3c25b0143@amd.com> Content-Language: en-US From: "Badole, Vishal" In-Reply-To: <7fb17998-e523-4264-91af-0af3c25b0143@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: MA5PR01CA0222.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:1f3::15) To IA1PR12MB292992.namprd12.prod.outlook.com (2603:10b6:208:5a1::21) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR12MB292992:EE_|MW4PR12MB7335:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a005658-11a3-4401-0887-08df4f8c0711 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|23010399003|376014|921020|10067099003|56012099006|261028144727099003|261026121527099003|261026140227099003|261102123227099003|261022105027099003|261021121427099003|261022075727099003|261102130727099003|261009223027099003|18002099003|22082099003|11063799006|4143699003|6133799003; X-Microsoft-Antispam-Message-Info: 0NtWQbselqLU5uKRZyxxdAc1fuoxdcWTScfy7c5TNxVwJ7LBPOSnJePGK2U45pIcglF7VtVVC/ddIGYoogywTMNYWXE4aWniGM8kZFxAlkbOTVwQyC1XdKrQ3pkTnHJOFNfsH1bhK/aXLKWnNRGnEZPtRZqlnDSxLEUYxJoXjgiAOq+zrWk6i7IK5B8QPnM1EpA/8/v+zcdPSBl6PPfS+7Pbq6SeHRpo2WVAFg/nbsTkiSLYJBXS5AfuVISf5lvqNp22r4pm2Euf4N+bjXYQywn6U/QxT0y/b01jJTl7LoCEk5XM03FL2iV921cB5knnWX2y4qv50Hp5pL62zt4fEHJvujaOu4Hocu7qvDKbsDwhqpsf/6pDUMLcCuFRGERaJBbHYMTJupeWDBthcptikOpXD472caOF9bwlZ6rJGazG7/nLrxe9MxfDvKtnMtwz3ONwnjUQNiNaoHi/BAEARqOGCeRiYlW3gTgIMOo7ztUtSU6nyRSSNu4y8TUdv63UH9VLXmtFWX2FMA2g7W0LHmrqab170JCHNCrZRt3ofEYJvgufjmZstJVbUttYdAllh8DZraSsYdQfWS8ACcAYuicaDrRtI5Hn/FOKvcaRmu689g7A50IUJJ1TSIvN4Hq/5z0T1TX8yeReGyJsnmusFgU1oCYh+GHNUqI5BOwAprGnkD04WuT/cZLpppIDVwn6RwZ88Pzfls+QIBAOTW39xA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:IA1PR12MB292992.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(23010399003)(376014)(921020)(10067099003)(56012099006)(261028144727099003)(261026121527099003)(261026140227099003)(261102123227099003)(261022105027099003)(261021121427099003)(261022075727099003)(261102130727099003)(261009223027099003)(18002099003)(22082099003)(11063799006)(4143699003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?b2dSdVhaWk9naHJvK2daSnR3NVcyd0JaWTdsYkpRVDlGL3NQVm1JVktEWEVL?= =?utf-8?B?MEJVUXQyZ2tqYnZId1pmNnRzUWtLT2JPeXY2djh2dkh6YzhtRXBybk9Vb2xy?= =?utf-8?B?YzA4SE1oQ01TRlYyNmRIUFRLYURoVm5KaXVqZVFWMUo0ODB6UDd6UlFtbGZE?= =?utf-8?B?NHFXT1IrYVlwOW5xQW5TL2FVNENyNTdLK29HZTgvWHBjWGZsSGxoSEFYa0lI?= =?utf-8?B?eHdCSGV6b3VidVhITC9tMG93VlFBRTh3NzFXWGplcVdZUWo1cksvZ3UxL3ZK?= =?utf-8?B?VVdYSU5lV1NacStCb0FGWmRVMUxjbDFGYStpVHhLcENRdGtqWU4xMUVvOEhj?= =?utf-8?B?akJpQnZrcVdSN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qd3hLT3k0L1Qxc01JNHRmNHZD?= =?utf-8?B?VFM4U3kraW9BWCs1R3lJa0Rha3pKODIrVEI1MHdET2NxMWEyZlN2bzNleWJN?= =?utf-8?B?dEFsVzJsRU43aW1PVUJ2Y0h6QTBRd0ZhdkFnTE5CREU5Z3gvRGhwQ25DeXNa?= =?utf-8?B?ZXFrNFo1aCtPWWRDRThqM0VsSUZpL1FKb3d6T1JHY0MvMFVsT1N2Zz09?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a005658-11a3-4401-0887-08df4f8c0711 X-MS-Exchange-CrossTenant-AuthSource: IA1PR12MB292992.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 09:18:14.5571 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pU1IKaWuCQ1w/QMTQvjrTIt5uAsadqC++1aHKpx8aZU+Zufw3HxMJMgjCSg/361VMYh8MGWweHIVef/zGnPdKg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7335 On 11/30/2026 1:54 PM, K Prateek Nayak wrote: > Hello Vishal, > > On 11/25/2026 10:50 PM, Vishal Badole wrote: >> +bool amd_pstate_cas_active(void) >> +{ >> + return READ_ONCE(amd_pstate_cas_initialized); >> +} >> +EXPORT_SYMBOL_GPL(amd_pstate_cas_active); >> + >> +static void __init amd_pstate_init_cas(void) >> +{ >> + int ref_highest_perf = 0, ref_max_freq = 0; >> + int cpu, highest_perf, max_freq; >> + >> + if (!amd_pstate_cas) >> + return; >> + >> + amd_pstate_cas = false; >> + if (!cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) >> + return; >> + >> + for_each_online_cpu(cpu) { >> + highest_perf = amd_get_effective_highest_perf(cpu); >> + if (highest_perf <= 0) { >> + pr_warn("Invalid highest performance (%d) on CPU%d\n", >> + highest_perf, cpu); >> + return; >> + } >> + >> + max_freq = amd_get_max_frequency(cpu); >> + if (max_freq < 0 || (u32)max_freq > U32_MAX / 1000) { >> + pr_warn("Invalid maximum frequency (%d) on CPU%d\n", >> + max_freq, cpu); >> + return; >> + } >> + >> + if (highest_perf < ref_highest_perf || >> + (highest_perf == ref_highest_perf && max_freq <= ref_max_freq)) > > So I don't get the second part of this condition. There can be CPUs with > same highest_perf bit different max_freq? > No, CPUs with the same highest_perf are not expected to have different maximum frequencies on the supported platforms. I will remove the maximum-frequency tie-breaker in the next revision. > Say you have: > > Performance Core : max_perf = 196; max_freq = 3000000KHz > Efficiency Core : max_perf = 196; max_freq = 2000000KHz > > (Hypothetical numbers) > > In this case, you'll have: > > amd_pstate_ref_highest_perf = 196 > amd_pstate_ref_freq_khz = 30000000KHz > > Continued below ... > >> + continue; >> + >> + ref_highest_perf = highest_perf; >> + ref_max_freq = max_freq; >> + } >> + >> + if (!ref_highest_perf) { >> + pr_warn("No reference CPU available for capacity scaling\n"); >> + return; >> + } >> + >> + amd_pstate_ref_highest_perf = ref_highest_perf; >> + amd_pstate_ref_freq_khz = ref_max_freq * 1000U; >> + >> + amd_pstate_cas = arch_enable_hybrid_capacity_scale(); >> +} >> + >> +static void amd_pstate_update_cpu_capacity(struct amd_cpudata *data, >> + bool highest_freq_available) >> +{ >> + unsigned long capacity, max_capacity, capacity_freq, base_freq; >> + int cpu = data->cpu; >> + >> + lockdep_assert_held(&sched_domains_mutex); >> + >> + if (highest_freq_available && amd_pstate_ref_freq_khz) { >> + capacity = data->max_freq; >> + max_capacity = amd_pstate_ref_freq_khz; >> + capacity_freq = capacity; >> + base_freq = max_capacity; >> + } else { >> + union perf_cached perf = READ_ONCE(data->perf); >> + >> + capacity = perf.highest_perf; >> + max_capacity = amd_pstate_ref_highest_perf; >> + capacity_freq = perf_to_freq(perf, data->nominal_freq, perf.highest_perf); > > So this is literally "data->max_freq" > >> + base_freq = perf_to_freq(perf, data->nominal_freq, max_capacity); > > And this would likely be equal to "amd_pstate_ref_freq_khz" > >> + } > > Making both those branch pretty much the same. Why isn't just the > frequency reference enough? > Yes, when maximum-frequency data is unavailable for this CPU, this expression is equivalent to data->max_freq, which was calculated using perf_to_freq(). However, that is a frequency estimate derived from CPPC performance values, not necessarily the CPU’s actual maximum attainable frequency. In the frequency-based branch, data->max_freq comes from amd_get_max_frequency() and represents the maximum attainable frequency independently of those performance values. On older hardware, the highest-performance values of 196 for performance cores and 130 for efficiency cores aligned reasonably with their relative maximum frequencies. On newer hardware, these values are 255 and 252, which no longer reflect the Fmax difference between the core types. Performance-based scaling therefore gives almost equal capacities, whereas using the maximum attainable frequencies gives capacities of 1024 and 718. Also, the fallback branch can be entered when only the reference CPU lacks frequency data. In that case, the current CPU’s data->max_freq may contain an actual Fmax, so it is not always interchangeable with this perf_to_freq() calculation. >> + >> + arch_set_cpu_capacity(cpu, capacity, max_capacity, capacity_freq, base_freq); > > ... > > And that means they'll have same capacity, but different frequency scale. > That reads a bit wrong to me. Different frequency scale will help cap the > PELT tracking but the CPUs themself will appear as same capacity which > would do the wrong thing. > > What do these highest_perf numbers look like on real hardware btw? > 255/254 for performance core and 252 efficiency core. >> + topology_set_cpu_scale(cpu, arch_scale_cpu_capacity(cpu)); >> +} >> + >> +static void amd_pstate_set_cpu_capacity(struct amd_cpudata *cpudata, >> + bool highest_freq_available) >> +{ >> + union perf_cached perf = READ_ONCE(cpudata->perf); >> + int cpu; >> + >> + lockdep_assert_cpus_held(); >> + >> + guard(mutex)(&sched_domains_mutex); >> + >> + if (perf.highest_perf > amd_pstate_ref_highest_perf) { > > Btw there is other side to this where all CPUs of the highest > capacity are offlined and you'll need to recaliberate the > reference again if you have efficiency and low-power cores. > If performance cores are kept offline at boot using maxcpus=, the current logic already handles this by selecting the highest-performance online CPU as the reference. For runtime offlining, I don't think recalibration is necessary. Offlining performance cores does not change the maximum capabilities of the remaining efficiency and low-power cores. Keeping the existing reference preserves their relative capacities, even if no online CPU then has a capacity of 1024. Is there a scheduler requirement that the highest-capacity online CPU must always be normalized to 1024? >> + amd_pstate_ref_highest_perf = perf.highest_perf; >> + amd_pstate_ref_freq_khz = highest_freq_available ? cpudata->max_freq : 0; >> + >> + for_each_possible_cpu(cpu) { >> + struct cpufreq_policy *policy; >> + >> + if (cpu == cpudata->cpu) >> + continue; >> + >> + policy = cpufreq_cpu_policy(cpu); >> + if (policy && policy->driver_data) >> + amd_pstate_update_cpu_capacity(policy->driver_data, >> + amd_pstate_ref_freq_khz && >> + amd_get_max_frequency(cpu) > 0); > > This is the most convoluted condition ^^^^ > > If this CPU has "highest_freq_available", doesn't that mean all the CPUs > in this system have "highest_freq_available"? > Ack, you're right. On the supported platforms, if maximum-frequency information is available for one CPU, it is available for all CPUs. I'll simplify the availability handling in the next patch revision. >> + } >> + } >> + >> + amd_pstate_update_cpu_capacity(cpudata, highest_freq_available); >> + x86_topology_update = true; > > I think this really calls for an arch side helper rather seting it > openly here. That should get rid of that CONFIG_SMP checks everywhere. > Thanks for the suggestion. Let me check whether an arch-side helper would simplify this and allow the redundant CONFIG_SMP checks to be removed. >> + WRITE_ONCE(amd_pstate_cas_initialized, true); >> +} >> + >> static void amd_pstate_update_limits(struct cpufreq_policy *policy) >> { >> struct amd_cpudata *cpudata; >