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=40.93.198.45 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796027052; b=JpLMLQ7mx+TIQeXb/sUmlL4AKy6Z0nWRhKdAsXOwnPLeZwPXzxOs1Q7kSRoxRl2UZONO p2i9VcElnDmKAHNPFY4WAFtTgqc4Yu2ueMe4zPfN6LaNaTfd2qtpfZtk/+G22WJZy2UPQ Z48Yu1s3MOnNUb9FS/2cSTofn2xdqxdRkydy6ZhnTQ2VjOA4RIlfj75ff71BUgkpLxCv8 2dgF+azdwuqQtc4QxZdN7oNbxmJYbcqxDnV7txr+SDTqMQtnLXXZ3P7CBTM+pdcAGlQv4 6aUY0DcdduriSlfblif90+oi5HPpCmuGNxCkobEo33SSr0UG4TH5VBGS/VUUJJ7o1jQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796027052; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:Message-ID:Date:MIME-Version:User-Agent:Subject:To: References:Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-EOPAttributedMessage: 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-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=IQLAmeDajJJQ71k+vheK4m8JOvmKddDjb4rtSVpEyaM=; b=xCQDthw8fFCVAhk3O++wqVi/L9eBw27NVBnvibboOycWaTkBJSCDgcA/5u/8cHFhGUNd pPA/X5ksVtnuMp7n7wxtTLasQ9ktTy4bVXDUG7WKvMo83LbLSTPPjGMXSeaFsZWxs3cK2 f0+oOC2K7pq9EFKnf7vuOomgGNbPOZZl72+Uh7Txk+Bwi/TAKHDqPL2hGbglZ2LVfQ3Nz K5Tid+UwStLIjXsRkvLk5SU5zW6uZ/LAZcjvZSX/T6g024njYMUtNfclFifITF8L64jQ1 bocwbK0VKEWxwuOh0E/yA6L6ZKmvLOWCEhNbdzYDGZj01/mqcyY0Wwya2cxRmwe4cGg== 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="1/N06+1A"; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.198.45 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010045.outbound.protection.outlook.com [40.93.198.45]) (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 81941606A31C; Mon, 30 Nov 2026 08:24:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 81941606A31C 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=1/N06+1A ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o2+9PDNDzk4C3Gx+vWX2/DBJM8RgvI92IhvpVt0s0X/mG5DmVEi1PbgTAYjs7Y58qY2tfLmV4eyf19Z61XSedNLX7CGk/9r8Mg7Rbv1qUKd6uzS5jFIaOsrL6OKaGjx6cerJVqLNPYnya2dIQOBNItNtZFTTR3AaIWKV5NQ0KbZLYmyXZjEhxlQUUgsrdMDAhQIE8+IaJCneXzL1Z3L+2zmiema4Gn+EsIiL9jbcSlRFaYSyhYCkO90SxX6UAMHhpNvqVNb0UHhb5AWcUqiVcxqhTKTwPRRVMRt6qq73QlS6ZtfNOrtV6S66iFc2b9WUxUpp05EcX1oZzmSSdOyJDQ== 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=IQLAmeDajJJQ71k+vheK4m8JOvmKddDjb4rtSVpEyaM=; b=oTqA25N9mVNh1eR+xEvbZY0dRVsIk1gfv1kLkHc3t4PS7Cwv2pqAsVoW8dcyzOTjAc8SrcNV0sCLBrv4sBAy2ByzTn0oAnhwDuxIO3fvmUoth2tBigk0Rb01XJR885+nUtcWul4f+Xp5O4/MoMH2mLsxH8f7Ups6dMiNz5ZLmmXWT3X4i8PkKcXNd855sZZGvdBviWJP41IZ93SBzrPrIfh/bI7HjbKcKkoFt8qvpagGbzcO8+I+Z2j6tcHXSDSo2uOEWB2dlOjiQhVlMQPA6BCjEI9c523CNvFbDg5S7JDnxLLwAiVWu64hchY2DdTHI0o9IrUilWl/YeL1BJ90DQ== 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=IQLAmeDajJJQ71k+vheK4m8JOvmKddDjb4rtSVpEyaM=; b=1/N06+1Ai1KJp7dO0/iXDWc8iSuCxBub91u64HfHFJ5EfDLiAStny0OS7c5i52OKJgJd6CMWNoL9UYgL4Mno42SJ3cmRKOFEboCzf5XLr/HQ3YghDh85dKgB2QQ5/+rJyOmDpA+izoL6YCobf2x7I9GMvlo/Y17lopdx5xVvRzA= Received: from CH2PR11CA0027.namprd11.prod.outlook.com (2603:10b6:610:54::37) by SACPR12MB069464.namprd12.prod.outlook.com (2603:10b6:806:541::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Mon, 30 Nov 2026 08:24:07 +0000 Received: from CH7PEPF00000017.namprd21.prod.outlook.com (2603:10b6:610:54:cafe::3) by CH2PR11CA0027.outlook.office365.com (2603:10b6:610:54::37) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.13 via Frontend Transport; Mon, 30 Nov 2026 08:24:07 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; 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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by CH7PEPF00000017.mail.protection.outlook.com (10.167.244.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.615.2 via Frontend Transport; Mon, 30 Nov 2026 08:24:07 +0000 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Mon, 30 Nov 2026 02:24:06 -0600 Received: from [10.136.42.27] (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.57 via Frontend Transport; Mon, 30 Nov 2026 02:24:03 -0600 Message-ID: <7fb17998-e523-4264-91af-0af3c25b0143@amd.com> Date: Mon, 30 Nov 2026 13:54:02 +0530 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/3] cpufreq: amd-pstate: Set asymmetric CPU capacity on hybrid platforms To: Vishal Badole , , , , , , , , , , References: <20261125172031.741740-1-Vishal.Badole@amd.com> <20261125172031.741740-3-Vishal.Badole@amd.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <20261125172031.741740-3-Vishal.Badole@amd.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH7PEPF00000017:EE_|SACPR12MB069464:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ec74a5f-ef85-4b6f-a347-08df4ebb4d82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700016|1800799024|23010399003|11063799006|4143699003|261009223027099003|22082099003|18002099003|921020|10067099003|56012099006|261102130727099003|261028144727099003|261026140227099003|261026121527099003|261022105027099003; X-Microsoft-Antispam-Message-Info: 7UuGP1iG+In13pFzA4eW2sL4zIIhch3OlYypsX2h3W0II/zPnfsm5Q5W4Z4bOtGjF1qMWRyYT6HioEDOYyCcRecl5FDF8R3LBxGnlKFPnqGY1i1lUU4Hb2lRvJT1+JCuvDBuhdmyUF1bY2VUNf3Gh4f3ImrgB/iYJ4lg5EdXQFiA0odZnL23kZbWwptNX2HAW4Lwed6WUSSXey0l1k7FULxO54dYfcST8X0cQZyCayTvFactTMA1JMpKxXhfWCmKPbKK9Bg1+AkeKBEzrbUmOkHw7LOrNS5lUCIhMKMYywHSwjpLHphiS2CIj0BPMOc1tXmNpieTho60DPoWs0XS7N9UxcLSZXKH6XA7jRwFyZqbB5AwpGfchEUXRaldPKkygmV3qZSv1ptAqbFwfjPCur3B43CZmXi/ZN0j1ZKDEd4NzvD2l5o6fxNF726vr7ZugF4Abr39aan1OlmDZ8c5RwTclXsIM48Dm77p4ntPGC3Q5FH5DaQNwvXHla3jgt9utvmOwOXUb0NwZoCVQWIOT/wa96hxqHe8DLKy8NcMzW7KDxits2R7aeBjAGGJVKKVrfjLdjS2lUIYW2nlfg5SUtQnIXbq7yFjxW3gqxE7apLhINi6S/I4uIm4XFIQokVqWF4jIcd0O6T9ld2boAEppTkePbvz6GmQ4aplLcPncuO2yTXJl6BCTJIwflNpEu+Jca6fjClpDRb3fwyWwmJ3W6ZWCVGVPbWgYHq9V3SwWYFrWpsrd1XarFnUPL2nfIpr X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(36860700016)(1800799024)(23010399003)(11063799006)(4143699003)(261009223027099003)(22082099003)(18002099003)(921020)(10067099003)(56012099006)(261102130727099003)(261028144727099003)(261026140227099003)(261026121527099003)(261022105027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wRtRbnsdHGzFdm0ZsAt6pLazpKvEEjAOZ1XchDn7f762var7v+3boMtLYiVdkUhRfHZLvvoxKKO80pU/8DGLah9lf1RrAANYxtgGHD3Fc7bWX7lPLB3WM7GC4mOmVtBwdSW4hMgfbINB+dRcwbbfaRUuh6tApiKWfPf5SL9qpnNCyKDr2YtlkG+8CC/STycxewNQOoaDcv+doLxrS5/u8SXo1PMGXj2t10LjRNHSpcEEUcQfjt7C4e65Rj99AT/4SARByEB2gJAcNWEe3gbbks4VMCZyn3GIoK4WdmSGp5tv3FsATOjdWtz/cSQ0g3BxSYdlHEY9xdcEa+9r8TLxslyti4iU7WvnBHRsTAxXRUFb2vyRlkxyVFlFhQYHNxObT7/GLmMmYxTDiiZwCGZYXaj5sNZ4NgGukyImwvJStHYL0pUXczuUjpYLYPi0rM7J X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2026 08:24:07.5600 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ec74a5f-ef85-4b6f-a347-08df4ebb4d82 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH7PEPF00000017.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SACPR12MB069464 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? 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? > + > + 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? > + 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. > + 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"? > + } > + } > + > + 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. > + WRITE_ONCE(amd_pstate_cas_initialized, true); > +} > + > static void amd_pstate_update_limits(struct cpufreq_policy *policy) > { > struct amd_cpudata *cpudata; -- Thanks and Regards, Prateek