From nobody Mon Jan 26 07:40:45 2026 Delivered-To: importer@patchew.org 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 (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; 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; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1769074951; cv=none; d=zohomail.com; s=zohoarc; b=OQKDL2FOErtMV/Ta/WkCaSxjLicKCGmeyMk8EocDAxQMf6mpAoJ00Z/n7xGr/7/t4OA5rZIZhcUKRBfuvOC1Y3mUSbJB3IAoUWaPp14uEuKCPEaQr4EgGOj+wnpJv2tEh4Penj2eFXPw3pULYqEoGcHK+zv1aqz3Ez6V3/vX2cc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769074951; 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=+LBvT2kvUK3KCeIm+D2kNPm3jZj59Qe7BGo6Y0fvc0k=; b=J3Xg9JdqcvsXZdVvAD50eyXUzb8bYaueckZdISQ9C8xtQTlnA9Nh4utBUOGnLCROqffo8OxUi0vmaU8+pUHm1QT9UsIC2TO0ygbGtP/NfyPGLQ+INCrzg3AnJHOOhpJjSr8rgl1ftFTNV2KlYRXlndPiAi0i8Io34DAY7s1zijo= ARC-Authentication-Results: i=1; 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; 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 1769074951554924.7508310251909; Thu, 22 Jan 2026 01:42:31 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1210599.1522238 (Exim 4.92) (envelope-from ) id 1virCg-0000NQ-DO; Thu, 22 Jan 2026 09:42:14 +0000 Received: by outflank-mailman (output) from mailman id 1210599.1522238; Thu, 22 Jan 2026 09:42:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1virCg-0000NJ-9e; Thu, 22 Jan 2026 09:42:14 +0000 Received: by outflank-mailman (input) for mailman id 1210599; Thu, 22 Jan 2026 09:42:12 +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 1virCe-0000Cq-BI for xen-devel@lists.xenproject.org; Thu, 22 Jan 2026 09:42:12 +0000 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [2a00:1450:4864:20::429]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 9f1d9ebf-f776-11f0-9ccf-f158ae23cfc8; Thu, 22 Jan 2026 10:42:10 +0100 (CET) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-42fed090e5fso489641f8f.1 for ; Thu, 22 Jan 2026 01:42:10 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43569921dddsm45228367f8f.6.2026.01.22.01.42.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Jan 2026 01:42:08 -0800 (PST) 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: 9f1d9ebf-f776-11f0-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1769074929; x=1769679729; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=+LBvT2kvUK3KCeIm+D2kNPm3jZj59Qe7BGo6Y0fvc0k=; b=ZQ7RTcvJWN/9IWjMf0le5/e1893FOvXUdmt6HIq+6SeBW0bcNFkojfNvnlLoAjIPNs Fz1WyR9eb1oR2d7NRUEOABbgcDgs5E5fSWT1rDmgjHsAL3ta2stdzT/Cja/GQxH2+Qze Ho9NyaXP4VU5GzIkBNCi4mDTxRfywJSAJgVxlK7YsWmOcnz3LfhYvAvQfHzmvYfFnKFY txCcxp+7WQdUCdnw9BFaI2WHxAqW2VwXmY9B+dGMVAxxwOuV7Nz7Yiw48oCSXubqLNLo iGHsjoH+pIV+73AHsaKrCbsWQzsJ+W5hZIz9+xFa34rfspZwL7Z2HsQCr3lrwWw9jwJA 0NHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769074929; x=1769679729; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+LBvT2kvUK3KCeIm+D2kNPm3jZj59Qe7BGo6Y0fvc0k=; b=KjC+RjN2t+h1Lhn8hs5dLlHuJl3IusPHGJZPnI6tvC0BlhtuCHLWyrZLRGbqI3hENf vPyr9/oNGa/3GqVoaAQfUnTR5w2V6+Mkps/ZheA+i11XVxcmafjnDbF99FBXVuYdYbgM 4Pe9UzfkxT45h1Bt1YtueVWsEzeaTmzLknk5LGpKb8YisN+pTd9Gg5Uz722gXeJgW9sq 2gTnFNRWGj6f2BdqVvRKc6a5/dfwJVX96a4SJIXeAAhowv2+RVwekLmFZ7H7QK0k6E8L XjVkTA52jjqCz/X6BOdGb+AGpitJ7gI9qknbfZXy/r4J4jU6YAEL3feNIqpVj4gukeDl e2Zw== X-Gm-Message-State: AOJu0YyLFmOh6aZtWzutGDWjM8LQsLlMP1DZsCaCdoqESB/k5EZxv5Oh itRHZtF64yicd9l/22UAL0cmrTYgPQEhu2w4pR5dbUmZnOUSibVEZwim5sKNfE+64M/P/GxVaRH OSnY= X-Gm-Gg: AZuq6aISpUGEvU/hDxWdK5cyErne06KZ18GDbK7qbpnOYgLRmwHkljY0qzKmgHUhgdd AB2xJWis44ZSXYWe896GaOGwy/DQu7EKQBsLWBjgI6M4WeB3fxORZBmhOqowjHUtxXvS5V75rnZ lcyMKvGqzCXvTNYTP2ckuObkBWV8VaikxMGh1R/467gqZdOWZK1gba/tW0ri25utUT7pu9xML+4 7zUJjBJEe3KcdVJqskDlJQ4BSkQ9WyL9fCMKF+EtdUu++ABBXkT545BPLZ6CQAPgnxf3dPY3Keb lTQ+qjPRZ4v1tFyIyBNs8c3X9ckfMIWedxlbxWRzPFqRxYVRBraxEJJ6eitWOqLRQI/3jRfJ0Q9 SJwdpcN6ZQO1R95VqZbtK5DIjvRC1iZ0JjPg7VHyfS7E6IudyDaa6fDU4PkCo5Cf6CYNB2+s8Uh MBcjaL/rNtAJBYoVHgoU7uiDY110PkkQ8z8/J3CzP2m8IifzXKjj9G+sQCoAPz9uFhnkvoqmtfk uQ= X-Received: by 2002:a05:6000:430d:b0:435:95dc:b8ca with SMTP id ffacd0b85a97d-43595dcbaacmr11899384f8f.40.1769074929068; Thu, 22 Jan 2026 01:42:09 -0800 (PST) Message-ID: Date: Thu, 22 Jan 2026 10:42:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 1/5] cpufreq: eliminate cpufreq_drv_data[] From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1769074954217154100 Content-Type: text/plain; charset="utf-8" Possibly many slots of it may be unused (all of them when the HWP or CPPC drivers are in use), as it's always strictly associated with the CPU recorded in a policy (irrespective of that CPU intermediately being taken offline). It is shared by all CPUs sharing a policy. We could therefore put the respective pointers in struct cpufreq_policy, but even that level of indirection is pointless. Embed the driver data structure directly in the policy one. Signed-off-by: Jan Beulich Reviewed-by: Jason Andryuk --- v2: Re-base, use union. --- a/xen/arch/x86/acpi/cpufreq/acpi.c +++ b/xen/arch/x86/acpi/cpufreq/acpi.c @@ -174,17 +174,18 @@ static u32 get_cur_val(const cpumask_t * return 0; =20 policy =3D per_cpu(cpufreq_cpu_policy, cpu); - if (!policy || !cpufreq_drv_data[policy->cpu]) + if ( !policy ) return 0; =20 - switch (cpufreq_drv_data[policy->cpu]->arch_cpu_flags) { + switch ( policy->drv_data.acpi.arch_cpu_flags ) + { case SYSTEM_INTEL_MSR_CAPABLE: cmd.type =3D SYSTEM_INTEL_MSR_CAPABLE; cmd.addr.msr.reg =3D MSR_IA32_PERF_STATUS; break; case SYSTEM_IO_CAPABLE: cmd.type =3D SYSTEM_IO_CAPABLE; - perf =3D cpufreq_drv_data[policy->cpu]->acpi_data; + perf =3D policy->drv_data.acpi.acpi_data; cmd.addr.io.port =3D perf->control_register.address; cmd.addr.io.bit_width =3D perf->control_register.bit_width; break; @@ -210,9 +211,8 @@ static unsigned int cf_check get_cur_fre if (!policy) return 0; =20 - data =3D cpufreq_drv_data[policy->cpu]; - if (unlikely(data =3D=3D NULL || - data->acpi_data =3D=3D NULL || data->freq_table =3D=3D NULL)) + data =3D &policy->drv_data.acpi; + if ( !data->acpi_data || !data->freq_table ) return 0; =20 return extract_freq(get_cur_val(cpumask_of(cpu)), data); @@ -252,7 +252,7 @@ static int cf_check acpi_cpufreq_target( struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation) { - struct acpi_cpufreq_data *data =3D cpufreq_drv_data[policy->cpu]; + struct acpi_cpufreq_data *data =3D &policy->drv_data.acpi; struct processor_performance *perf; struct cpufreq_freqs freqs; cpumask_t online_policy_cpus; @@ -262,10 +262,8 @@ static int cf_check acpi_cpufreq_target( unsigned int j; int result =3D 0; =20 - if (unlikely(data =3D=3D NULL || - data->acpi_data =3D=3D NULL || data->freq_table =3D=3D NULL)) { + if ( !data->acpi_data || !data->freq_table ) return -ENODEV; - } =20 if (policy->turbo =3D=3D CPUFREQ_TURBO_DISABLED) if (target_freq > policy->cpuinfo.second_max_freq) @@ -331,11 +329,9 @@ static int cf_check acpi_cpufreq_target( =20 static int cf_check acpi_cpufreq_verify(struct cpufreq_policy *policy) { - struct acpi_cpufreq_data *data; struct processor_performance *perf; =20 - if (!policy || !(data =3D cpufreq_drv_data[policy->cpu]) || - !processor_pminfo[policy->cpu]) + if ( !policy || !processor_pminfo[policy->cpu] ) return -EINVAL; =20 perf =3D &processor_pminfo[policy->cpu]->perf; @@ -343,7 +339,8 @@ static int cf_check acpi_cpufreq_verify( cpufreq_verify_within_limits(policy, 0, perf->states[perf->platform_limit].core_frequency * 1000); =20 - return cpufreq_frequency_table_verify(policy, data->freq_table); + return cpufreq_frequency_table_verify(policy, + policy->drv_data.acpi.freq_table= ); } =20 static unsigned long @@ -379,17 +376,11 @@ static int cf_check acpi_cpufreq_cpu_ini unsigned int i; unsigned int valid_states =3D 0; unsigned int cpu =3D policy->cpu; - struct acpi_cpufreq_data *data; + struct acpi_cpufreq_data *data =3D &policy->drv_data.acpi; unsigned int result =3D 0; struct cpuinfo_x86 *c =3D &cpu_data[policy->cpu]; struct processor_performance *perf; =20 - data =3D xzalloc(struct acpi_cpufreq_data); - if (!data) - return -ENOMEM; - - cpufreq_drv_data[cpu] =3D data; - data->acpi_data =3D &processor_pminfo[cpu]->perf; =20 perf =3D data->acpi_data; @@ -406,23 +397,18 @@ static int cf_check acpi_cpufreq_cpu_ini if (cpufreq_verbose) printk("xen_pminfo: @acpi_cpufreq_cpu_init," "HARDWARE addr space\n"); - if (!cpu_has(c, X86_FEATURE_EIST)) { - result =3D -ENODEV; - goto err_unreg; - } + if ( !cpu_has(c, X86_FEATURE_EIST) ) + return -ENODEV; data->arch_cpu_flags =3D SYSTEM_INTEL_MSR_CAPABLE; break; default: - result =3D -ENODEV; - goto err_unreg; + return -ENODEV; } =20 data->freq_table =3D xmalloc_array(struct cpufreq_frequency_table, (perf->state_count+1)); - if (!data->freq_table) { - result =3D -ENOMEM; - goto err_unreg; - } + if ( !data->freq_table ) + return -ENOMEM; =20 /* detect transition latency */ policy->cpuinfo.transition_latency =3D 0; @@ -480,23 +466,14 @@ static int cf_check acpi_cpufreq_cpu_ini return result; =20 err_freqfree: - xfree(data->freq_table); -err_unreg: - xfree(data); - cpufreq_drv_data[cpu] =3D NULL; + XFREE(data->freq_table); =20 return result; } =20 static int cf_check acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy) { - struct acpi_cpufreq_data *data =3D cpufreq_drv_data[policy->cpu]; - - if (data) { - cpufreq_drv_data[policy->cpu] =3D NULL; - xfree(data->freq_table); - xfree(data); - } + XFREE(policy->drv_data.acpi.freq_table); =20 return 0; } --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c @@ -35,8 +35,6 @@ =20 #include =20 -struct acpi_cpufreq_data *cpufreq_drv_data[NR_CPUS]; - struct perf_pair { union { struct { --- a/xen/arch/x86/acpi/cpufreq/powernow.c +++ b/xen/arch/x86/acpi/cpufreq/powernow.c @@ -84,16 +84,14 @@ static int cf_check powernow_cpufreq_tar struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation) { - struct acpi_cpufreq_data *data =3D cpufreq_drv_data[policy->cpu]; + struct acpi_cpufreq_data *data =3D &policy->drv_data.acpi; struct processor_performance *perf; unsigned int next_state; /* Index into freq_table */ unsigned int next_perf_state; /* Index into perf table */ int result; =20 - if (unlikely(data =3D=3D NULL || - data->acpi_data =3D=3D NULL || data->freq_table =3D=3D NULL)) { + if ( !data->acpi_data || !data->freq_table ) return -ENODEV; - } =20 perf =3D data->acpi_data; result =3D cpufreq_frequency_table_target(policy, @@ -187,11 +185,9 @@ static void cf_check get_cpu_data(void * =20 static int cf_check powernow_cpufreq_verify(struct cpufreq_policy *policy) { - struct acpi_cpufreq_data *data; struct processor_performance *perf; =20 - if (!policy || !(data =3D cpufreq_drv_data[policy->cpu]) || - !processor_pminfo[policy->cpu]) + if ( !policy || !processor_pminfo[policy->cpu] ) return -EINVAL; =20 perf =3D &processor_pminfo[policy->cpu]->perf; @@ -199,7 +195,8 @@ static int cf_check powernow_cpufreq_ver cpufreq_verify_within_limits(policy, 0,=20 perf->states[perf->platform_limit].core_frequency * 1000); =20 - return cpufreq_frequency_table_verify(policy, data->freq_table); + return cpufreq_frequency_table_verify(policy, + policy->drv_data.acpi.freq_table= ); } =20 static int cf_check powernow_cpufreq_cpu_init(struct cpufreq_policy *polic= y) @@ -207,18 +204,12 @@ static int cf_check powernow_cpufreq_cpu unsigned int i; unsigned int valid_states =3D 0; unsigned int cpu =3D policy->cpu; - struct acpi_cpufreq_data *data; + struct acpi_cpufreq_data *data =3D &policy->drv_data.acpi; unsigned int result =3D 0; struct processor_performance *perf; struct amd_cpu_data info; struct cpuinfo_x86 *c =3D &cpu_data[policy->cpu]; =20 - data =3D xzalloc(struct acpi_cpufreq_data); - if (!data) - return -ENOMEM; - - cpufreq_drv_data[cpu] =3D data; - data->acpi_data =3D &processor_pminfo[cpu]->perf; =20 info.perf =3D perf =3D data->acpi_data; @@ -230,8 +221,7 @@ static int cf_check powernow_cpufreq_cpu if (cpumask_weight(policy->cpus) !=3D 1) { printk(XENLOG_WARNING "Unsupported sharing type %d (%u CPUs)\n= ", policy->shared_type, cpumask_weight(policy->cpus)); - result =3D -ENODEV; - goto err_unreg; + return -ENODEV; } } else { cpumask_copy(policy->cpus, cpumask_of(cpu)); @@ -240,21 +230,16 @@ static int cf_check powernow_cpufreq_cpu /* capability check */ if (perf->state_count <=3D 1) { printk("No P-States\n"); - result =3D -ENODEV; - goto err_unreg; + return -ENODEV; } =20 - if (perf->control_register.space_id !=3D perf->status_register.space_i= d) { - result =3D -ENODEV; - goto err_unreg; - } + if ( perf->control_register.space_id !=3D perf->status_register.space_= id ) + return -ENODEV; =20 data->freq_table =3D xmalloc_array(struct cpufreq_frequency_table,=20 (perf->state_count+1)); - if (!data->freq_table) { - result =3D -ENOMEM; - goto err_unreg; - } + if ( !data->freq_table ) + return -ENOMEM; =20 /* detect transition latency */ policy->cpuinfo.transition_latency =3D 0; @@ -300,23 +285,14 @@ static int cf_check powernow_cpufreq_cpu return result; =20 err_freqfree: - xfree(data->freq_table); -err_unreg: - xfree(data); - cpufreq_drv_data[cpu] =3D NULL; + XFREE(data->freq_table); =20 return result; } =20 static int cf_check powernow_cpufreq_cpu_exit(struct cpufreq_policy *polic= y) { - struct acpi_cpufreq_data *data =3D cpufreq_drv_data[policy->cpu]; - - if (data) { - cpufreq_drv_data[policy->cpu] =3D NULL; - xfree(data->freq_table); - xfree(data); - } + XFREE(policy->drv_data.acpi.freq_table); =20 return 0; } --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -38,8 +38,6 @@ struct acpi_cpufreq_data { unsigned int arch_cpu_flags; }; =20 -extern struct acpi_cpufreq_data *cpufreq_drv_data[NR_CPUS]; - struct cpufreq_cpuinfo { unsigned int max_freq; unsigned int second_max_freq; /* P1 if Turbo Mode is on */ @@ -82,6 +80,10 @@ struct cpufreq_policy { * -1 for disable, 1 for enabled * See CPUFREQ_TURBO_* below for defines */ unsigned int policy; /* CPUFREQ_POLICY_* */ + + union { + struct acpi_cpufreq_data acpi; + } drv_data; }; DECLARE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_policy); From nobody Mon Jan 26 07:40:45 2026 Delivered-To: importer@patchew.org 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 (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; 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; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1769074968; cv=none; d=zohomail.com; s=zohoarc; b=MMbmsegw7MKNOmX27s3SrYto2Yycx5XxU3ZEJZqkzLokEzbT+k+RdVn5kOMLIl0hx4FsPsv3tKgkbx3RXUR5BM8HuFEEb5EuZU4yr546rdCMrkBsVlLeGB4sWJwZHp5NOPPSr9lM63r10UUvMQtSjg+M0VUyHT9xENCUoOjux00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769074968; 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=9YAbpFp0YVR8E7C5PwaC48OUfTxt5vy1yYtA+A0DwVE=; b=SDW9kFqmIe+H92SmJixEmdXl/IPPuLIRKwyZdiBplWRSOtTvOSFNH21DL5kXYENRV00stIK1whzgNpKZjIeKOOXOOffJQiyR6kdBRUvVXQuu9j8hNhv0LqV7cist26Z6nuBq4Kl//7ug+bSK+0lcEiz3n02Paqztsv7I9Cp0EfQ= ARC-Authentication-Results: i=1; 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; 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 1769074968943621.181310136841; Thu, 22 Jan 2026 01:42:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1210605.1522247 (Exim 4.92) (envelope-from ) id 1virD1-0000nQ-NY; Thu, 22 Jan 2026 09:42:35 +0000 Received: by outflank-mailman (output) from mailman id 1210605.1522247; Thu, 22 Jan 2026 09:42:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1virD1-0000nJ-Ks; Thu, 22 Jan 2026 09:42:35 +0000 Received: by outflank-mailman (input) for mailman id 1210605; Thu, 22 Jan 2026 09:42:35 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1virD1-0000n5-6R for xen-devel@lists.xenproject.org; Thu, 22 Jan 2026 09:42:35 +0000 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [2a00:1450:4864:20::432]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ac6b6b62-f776-11f0-b15e-2bf370ae4941; Thu, 22 Jan 2026 10:42:32 +0100 (CET) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-435a517be33so472792f8f.0 for ; Thu, 22 Jan 2026 01:42:32 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4356997e664sm39449748f8f.30.2026.01.22.01.42.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Jan 2026 01:42:31 -0800 (PST) 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: ac6b6b62-f776-11f0-b15e-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1769074951; x=1769679751; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=9YAbpFp0YVR8E7C5PwaC48OUfTxt5vy1yYtA+A0DwVE=; b=NWG42c/AGxEXOQb/sedzm9pwIcypv9/oZBbQlAU+M++XKeWD0LVrKpTi4T8HXyG+bu VzyMLfz0t1Xga+eGeb/3AMEyH5tNAjWCf7wZHfCunQ6I3gf6ba293p9YKVc7VgjNBJs4 JWjE+huUVpBiH38UCHdO8PMQO5it9U2eSA/tXuljzwm5019avzuQXiTrpiV8KNvLF+k6 ZNL3Z61186UFmYLWpi6+KsVaeCR+kQq33V6PDW/hBgA9lZUEerRBi+FZQvDaH2eTu/SN /8YEipnQfiefmRH5OMcTwzVw+RgfE167DCBPRPzwtxW9p1YcTlmaH2OiM9WH/LASIJnv lpnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769074951; x=1769679751; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9YAbpFp0YVR8E7C5PwaC48OUfTxt5vy1yYtA+A0DwVE=; b=mr5oEXhGYcIQ2UfO44TF/BKIDjAnk6NxUOoTraqPlkJ3R+saNfKutZmvW1bQcfFTco vF1RNXn8Nv76Nu3dtIC5T/0gcK4qXkjcOEMG1DV1QWra+HMJW6MBCCiH+3/bnxghlJkQ 5QnOsqGj0cVvf8LRD1vdswZ/pIPwY/MwtUDPfEFEshdLyHYqD9qPVwYm0J3rHffkwbEl pyBottSfLAKrbzdx5yh/9cgjr7woeI5H2a0Uo7tzC+hL3/3DO55a03/sma6siKstLHEr AdiIt6C3FKvrTF8flA6Z0MDQd4mIG1Z2jnpOQCH73zncMHympHX83EeS+YCRDr/CSoUz KjuA== X-Gm-Message-State: AOJu0YwMugu+OZYl17S8GZmTx2CP6LeRbx7eBTD3ra76kyMrfghlyUcH 7AAKEPGzfdEjNDAKQGiB9cIQ6DZJOItxaN/9wRV2DIcMWZ7HW8PXmQnOAxo1c9eeXhBXlpOAtaB KZLI= X-Gm-Gg: AZuq6aKTbZkTRcUK+fJfUI/yeAhXSukA9a071r2dM5dvwr6jhNW/81PgLEuLR/h6/ks Ovf1CUSb6rJw4F4kBEHDLCql3tmOj27r4OSLa27x4lM8/ZO8u6Fm70l0JO3SmJMDFwuKUQG6HcO VceEjwBcXz/Mnn1ZR+G546GfSp7rrCLelFUUHhp6UqSKcFseU7H3JkXTWFaL8zm/nw2LoAu/8Af X7fF4FTvCwhPC4WBsCMpLPEEeKTTiqfo52CBAcIk/uLQ4dk6F8gBMEFBS/6aDgYPx5h/5ESmB3L 3S7H0+OHTLIEkcmIclz4Fk6BM5HVD8Oahan05vqneN5nxLG2UhLTxLHjbeokpiaYfEwnyYy5DQB QRZFAbJ8YtqVd48RrcXjFclv2Tsm35dd4gGDDEz++mWCyInpI9rcQwz4E7oFn+sZXMBEf/NpKf0 F3xaDGxzSaxwF2G+3H5qk9wwsht8oZIy33XAMowUPEE3/43smD09J64yznnJK1mzX12zI1MOl4G 5Vn68QFWAEU+g== X-Received: by 2002:a05:6000:40ce:b0:435:9612:2d3b with SMTP id ffacd0b85a97d-43596122f2amr12716492f8f.44.1769074951391; Thu, 22 Jan 2026 01:42:31 -0800 (PST) Message-ID: <8441ada5-e2ed-4d79-822c-ecf1ce3c9484@suse.com> Date: Thu, 22 Jan 2026 10:42:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 2/5] cpufreq/hwp: move driver data into policy From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Jason Andryuk References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1769074970954158500 Content-Type: text/plain; charset="utf-8" Share space with the ACPI and powernow drivers, avoiding a separate allocation for each CPU. Except for get_hwp_para() all use sites already have the policy available, and this one function can simply be brought closer to its sibling set_hwp_para(). This then also eliminates the concern over hwp_cpufreq_cpu_init() being called for all CPUs, or a CPU going offline that's recorded in policy->cpu (which would result in accesses of per-CPU data of offline CPUs). Signed-off-by: Jan Beulich --- hwp_cpufreq_target() still requires policy->cpu to be online, though. --- a/xen/arch/x86/acpi/cpufreq/hwp.c +++ b/xen/arch/x86/acpi/cpufreq/hwp.c @@ -22,50 +22,6 @@ static bool __read_mostly feature_hdc; =20 static bool __ro_after_init opt_cpufreq_hdc =3D true; =20 -union hwp_request -{ - struct - { - unsigned int min_perf:8; - unsigned int max_perf:8; - unsigned int desired:8; - unsigned int energy_perf:8; - unsigned int activity_window:10; - bool package_control:1; - unsigned int :16; - bool activity_window_valid:1; - bool energy_perf_valid:1; - bool desired_valid:1; - bool max_perf_valid:1; - bool min_perf_valid:1; - }; - uint64_t raw; -}; - -struct hwp_drv_data -{ - union - { - uint64_t hwp_caps; - struct - { - unsigned int highest:8; - unsigned int guaranteed:8; - unsigned int most_efficient:8; - unsigned int lowest:8; - unsigned int :32; - } hw; - }; - union hwp_request curr_req; - int ret; - uint16_t activity_window; - uint8_t minimum; - uint8_t maximum; - uint8_t desired; - uint8_t energy_perf; -}; -static DEFINE_PER_CPU_READ_MOSTLY(struct hwp_drv_data *, hwp_drv_data); - #define hwp_err(cpu, fmt, args...) \ printk(XENLOG_ERR "HWP: CPU%u error: " fmt, cpu, ## args) #define hwp_info(fmt, args...) printk(XENLOG_INFO "HWP: " fmt, ## args) @@ -212,7 +168,7 @@ static bool __init hwp_available(void) =20 static int cf_check hwp_cpufreq_verify(struct cpufreq_policy *policy) { - struct hwp_drv_data *data =3D per_cpu(hwp_drv_data, policy->cpu); + struct hwp_drv_data *data =3D &policy->drv_data.hwp; =20 if ( !cpu_has_hwp_activity_window && data->activity_window ) { @@ -226,8 +182,8 @@ static int cf_check hwp_cpufreq_verify(s =20 static void cf_check hwp_write_request(void *info) { - const struct cpufreq_policy *policy =3D info; - struct hwp_drv_data *data =3D this_cpu(hwp_drv_data); + struct cpufreq_policy *policy =3D info; + struct hwp_drv_data *data =3D &policy->drv_data.hwp; union hwp_request hwp_req =3D data->curr_req; =20 data->ret =3D 0; @@ -247,7 +203,7 @@ static int cf_check hwp_cpufreq_target(s unsigned int relation) { unsigned int cpu =3D policy->cpu; - struct hwp_drv_data *data =3D per_cpu(hwp_drv_data, cpu); + struct hwp_drv_data *data =3D &policy->drv_data.hwp; /* Zero everything to ensure reserved bits are zero... */ union hwp_request hwp_req =3D { .raw =3D 0 }; =20 @@ -338,7 +294,7 @@ static void hwp_get_cpu_speeds(struct cp static void cf_check hwp_init_msrs(void *info) { struct cpufreq_policy *policy =3D info; - struct hwp_drv_data *data =3D this_cpu(hwp_drv_data); + struct hwp_drv_data *data =3D &policy->drv_data.hwp; uint64_t val; =20 /* @@ -406,23 +362,15 @@ static int cf_check hwp_cpufreq_cpu_init static bool __read_mostly first_run =3D true; static union hwp_request initial_req; unsigned int cpu =3D policy->cpu; - struct hwp_drv_data *data; - - data =3D xzalloc(struct hwp_drv_data); - if ( !data ) - return -ENOMEM; + struct hwp_drv_data *data =3D &policy->drv_data.hwp; =20 policy->governor =3D &cpufreq_gov_hwp; =20 - per_cpu(hwp_drv_data, cpu) =3D data; - on_selected_cpus(cpumask_of(cpu), hwp_init_msrs, policy, 1); =20 if ( data->curr_req.raw =3D=3D -1 ) { hwp_err(cpu, "Could not initialize HWP properly\n"); - per_cpu(hwp_drv_data, cpu) =3D NULL; - xfree(data); return -ENODEV; } =20 @@ -450,11 +398,6 @@ static int cf_check hwp_cpufreq_cpu_init =20 static int cf_check hwp_cpufreq_cpu_exit(struct cpufreq_policy *policy) { - struct hwp_drv_data *data =3D per_cpu(hwp_drv_data, policy->cpu); - - per_cpu(hwp_drv_data, policy->cpu) =3D NULL; - xfree(data); - return 0; } =20 @@ -467,8 +410,8 @@ static int cf_check hwp_cpufreq_cpu_exit */ static void cf_check hwp_set_misc_turbo(void *info) { - const struct cpufreq_policy *policy =3D info; - struct hwp_drv_data *data =3D per_cpu(hwp_drv_data, policy->cpu); + struct cpufreq_policy *policy =3D info; + struct hwp_drv_data *data =3D &policy->drv_data.hwp; uint64_t msr; =20 data->ret =3D 0; @@ -499,7 +442,7 @@ static int cf_check hwp_cpufreq_update(u { on_selected_cpus(cpumask_of(cpu), hwp_set_misc_turbo, policy, 1); =20 - return per_cpu(hwp_drv_data, cpu)->ret; + return policy->drv_data.hwp.ret; } #endif /* CONFIG_PM_OP */ =20 @@ -516,12 +459,12 @@ hwp_cpufreq_driver =3D { }; =20 #ifdef CONFIG_PM_OP -int get_hwp_para(unsigned int cpu, +int get_hwp_para(const struct cpufreq_policy *policy, struct xen_get_cppc_para *cppc_para) { - const struct hwp_drv_data *data =3D per_cpu(hwp_drv_data, cpu); + const struct hwp_drv_data *data =3D &policy->drv_data.hwp; =20 - if ( data =3D=3D NULL ) + if ( !data->maximum ) return -ENODATA; =20 cppc_para->features =3D @@ -542,11 +485,10 @@ int get_hwp_para(unsigned int cpu, int set_hwp_para(struct cpufreq_policy *policy, struct xen_set_cppc_para *set_cppc) { - unsigned int cpu =3D policy->cpu; - struct hwp_drv_data *data =3D per_cpu(hwp_drv_data, cpu); + struct hwp_drv_data *data =3D &policy->drv_data.hwp; bool cleared_act_window =3D false; =20 - if ( data =3D=3D NULL ) + if ( !data->maximum ) return -ENOENT; =20 /* Validate all parameters - Disallow reserved bits. */ --- a/xen/drivers/acpi/pm-op.c +++ b/xen/drivers/acpi/pm-op.c @@ -80,10 +80,12 @@ static int read_scaling_available_govern static int get_cpufreq_cppc(unsigned int cpu, struct xen_get_cppc_para *cppc_para) { + const struct cpufreq_policy *policy =3D + per_cpu(cpufreq_cpu_policy, cpu); int ret =3D -ENODEV; =20 - if ( hwp_active() ) - ret =3D get_hwp_para(cpu, cppc_para); + if ( policy && hwp_active() ) + ret =3D get_hwp_para(policy, cppc_para); =20 return ret; } --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -38,6 +38,42 @@ struct acpi_cpufreq_data { unsigned int arch_cpu_flags; }; =20 +struct hwp_drv_data { + union { + uint64_t hwp_caps; + struct { + unsigned int highest:8; + unsigned int guaranteed:8; + unsigned int most_efficient:8; + unsigned int lowest:8; + unsigned int :32; + } hw; + }; + union hwp_request { + struct { + unsigned int min_perf:8; + unsigned int max_perf:8; + unsigned int desired:8; + unsigned int energy_perf:8; + unsigned int activity_window:10; + bool package_control:1; + unsigned int :16; + bool activity_window_valid:1; + bool energy_perf_valid:1; + bool desired_valid:1; + bool max_perf_valid:1; + bool min_perf_valid:1; + }; + uint64_t raw; + } curr_req; + int ret; + uint16_t activity_window; + uint8_t minimum; + uint8_t maximum; + uint8_t desired; + uint8_t energy_perf; +}; + struct cpufreq_cpuinfo { unsigned int max_freq; unsigned int second_max_freq; /* P1 if Turbo Mode is on */ @@ -83,6 +119,7 @@ struct cpufreq_policy { =20 union { struct acpi_cpufreq_data acpi; + struct hwp_drv_data hwp; } drv_data; }; DECLARE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_policy); @@ -286,7 +323,7 @@ bool hwp_active(void); static inline bool hwp_active(void) { return false; } #endif =20 -int get_hwp_para(unsigned int cpu, +int get_hwp_para(const struct cpufreq_policy *policy, struct xen_get_cppc_para *cppc_para); int set_hwp_para(struct cpufreq_policy *policy, struct xen_set_cppc_para *set_cppc); From nobody Mon Jan 26 07:40:45 2026 Delivered-To: importer@patchew.org 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 (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; 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; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1769075004; cv=none; d=zohomail.com; s=zohoarc; b=GFkbOfvHa4CLIqHdvl/eTyRxeT7wU0hfBIHZpROUq1BLGBg+kUq85J33etsupsajdH0+KbPEV93034fsAjqOuRY1NESDZw7cIHgDfiYOOY+GjT646E+M5o0lIAb+tWZ6KTqvWdn69kdsrGC9/P7XMAlQDHDYoHY3SiX/fMeH5Q4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769075004; 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=uV5LcusP8Do+2RUwQ8ia4mLDrNFGaesbuxHKzbM03Ek=; b=T6JIb/lYvEU8X0sddl31hdcpPcOLvYEzfQqrGQyiT1kQfC0Q4FszIO4BJtMZmy3izYmG/ovYuQrJjtbjbiq5IwbT8f7xrptNYSBDtt98NrkzjixYFXbVd+FT+p0G4Ldupl4Fw++kEf8B/fEQ/CWR0aqM8aUri4DdjJqnHq7JRjY= ARC-Authentication-Results: i=1; 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; 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 176907500411588.46679960566757; Thu, 22 Jan 2026 01:43:24 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1210618.1522257 (Exim 4.92) (envelope-from ) id 1virDT-0001Os-WC; Thu, 22 Jan 2026 09:43:04 +0000 Received: by outflank-mailman (output) from mailman id 1210618.1522257; Thu, 22 Jan 2026 09:43:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1virDT-0001Ol-T5; Thu, 22 Jan 2026 09:43:03 +0000 Received: by outflank-mailman (input) for mailman id 1210618; Thu, 22 Jan 2026 09:43:02 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1virDS-0000n5-Pp for xen-devel@lists.xenproject.org; Thu, 22 Jan 2026 09:43:02 +0000 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [2a00:1450:4864:20::431]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id be0b3283-f776-11f0-b15e-2bf370ae4941; Thu, 22 Jan 2026 10:43:01 +0100 (CET) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-432d256c2e6so672963f8f.3 for ; Thu, 22 Jan 2026 01:43:01 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4358e24cef3sm18577240f8f.0.2026.01.22.01.43.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Jan 2026 01:43:00 -0800 (PST) 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: be0b3283-f776-11f0-b15e-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1769074981; x=1769679781; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=uV5LcusP8Do+2RUwQ8ia4mLDrNFGaesbuxHKzbM03Ek=; b=WbezmzfJQrEaY/fpVT29xyQOe8m1VPRviGyI1i5lES6K4MRad4/EOxmTBoTw+3F+px aKBJHlXw90NpOots4NuFMbodaOEKp3jJpFfJZd+Rz/+8v6M9zRezm2FyhRvckO0ILD2C HPiCATrX9+LDuoC1MWB8tpCphbdqYGmld7173saCGaCZVXc7kV8uKggL4H81vBE68QMY mIkUpV9Ev6MTTitSFSa1AgFQi+u0LgP64QegzPe5QGmjtdyFSBmakgdZwGSqRcuFbtcY xsGREcAteU1TjQ3fZeYHnRO7HHrRNHY1JQk/Os4zlq7Ot8lcr/vpYOadf2RT2zGdqWDz YF7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769074981; x=1769679781; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uV5LcusP8Do+2RUwQ8ia4mLDrNFGaesbuxHKzbM03Ek=; b=muhkaso9OkzSrQKs+zJUROm2OBQ0jHh/b3pu3G+RV2812FwUKuDDTcLz5LwtqvKaR6 KucxDn7skMtZW3x7sZslcekCFPXwpkDqk3kes9KNcEQBIEttF0ipdGuRvTNbekxaF6Yl cffZ/HcFPgrIhG8gUvjDeXmMoKPDYxTsTTfHuNc5X0o6l9Dyd8ySWqwUlSR2pLi6KerU CELXAZyaJTtZGstfAkewrcMJy3YfjFerSwKwN0Usv7fKCYq04xykPiDUFvRkeDGTeweo rr1Crnxk+ivHCSV/jwIywGA5+iTj+2BC036XvGLUGwGWQlovGyDGfA/cPecKqo4BSEyU Recg== X-Gm-Message-State: AOJu0Yzs0DwxziR3HrcqFXK4wRFOch6d31U4S59Jtj5AmEDEphpBdvgf ndqC2tvMjjwEbqJz6lSBytxzeVLg4gjOL2bgrp+sAxshys5QWHDJkzGei+evXyPYo/x0LLhE47g o5Vw= X-Gm-Gg: AZuq6aKAMfUGbM20nMwWZdiwgZQYXIrqWfspQZrwWexVuylEnZ3805eRN4XFOrGjYwa ty2dMEzpdlvVtS2d6DkcQAht7jyw0usL8yiljWa9hf91cbeavmiuc+zapWC6tKoGRP1YpKMwq/q CpCLlqtobOXtSp59qnQq8+s7cOyNRgtToEjdV9AN0qlHQp4vquTMn6Xw+SNZ/RTvm3z6wD5JEe1 wp6t0KrA2FImXSTH1i6uXyf5OO6ZzYLwOfFF0SsItJmhIrQdqpuBfzMdtOQZwxlcDcvwHz+gNKY clTgto9kPkg5zXBKWeUPgnT9Rt+VrYzNJZcu0usKrUsQT7AVerKnB9qq4gyYG8Au3q0erWirUsi 5rzvDqJTU/gzt0H9W0ZlsFXG9JdG0tJxdud2w+K494Jv10mQtBWfY2SPkYkoDCJpt88V0Ec0vhO HL2Z/PbyjrHfjBguiP61aN0uSzzbZcEL1XFDmNVM3uQVsts/gLrlyk7sJTQHiir1CRdUiP9ZjrE MY= X-Received: by 2002:a5d:5cca:0:b0:435:9691:d525 with SMTP id ffacd0b85a97d-4359691d56amr11311318f8f.13.1769074980896; Thu, 22 Jan 2026 01:43:00 -0800 (PST) Message-ID: <519e16df-150a-4336-95dc-b26b8332a884@suse.com> Date: Thu, 22 Jan 2026 10:42:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 3/5] cpufreq/amd-cppc: move driver data into policy From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Penny Zheng References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1769075005103158500 Content-Type: text/plain; charset="utf-8" Share space with the ACPI, powernow, and HWP drivers, avoiding a separate allocation for each CPU. This then also reduces the concern over amd_cppc_cpufreq_cpu_init() being called for all CPUs, or a CPU going offline that's recorded in policy->cpu (which would result in accesses of per-CPU data of offline CPUs). Signed-off-by: Jan Beulich Reviewed-by: Penny Zheng --- amd_cppc_cpufreq_target() (together with amd_cppc_write_request()) still requires policy->cpu to be online, though. --- a/xen/arch/x86/acpi/cpufreq/amd-cppc.c +++ b/xen/arch/x86/acpi/cpufreq/amd-cppc.c @@ -31,81 +31,6 @@ }) =20 /* - * Field highest_perf, nominal_perf, lowest_nonlinear_perf, and lowest_perf - * contain the values read from CPPC capability MSR. They represent the li= mits - * of managed performance range as well as the dynamic capability, which m= ay - * change during processor operation - * Field highest_perf represents highest performance, which is the absolute - * maximum performance an individual processor may reach, assuming ideal - * conditions. This performance level may not be sustainable for long - * durations and may only be achievable if other platform components - * are in a specific state; for example, it may require other processors be - * in an idle state. This would be equivalent to the highest frequencies - * supported by the processor. - * Field nominal_perf represents maximum sustained performance level of the - * processor, assuming ideal operating conditions. All cores/processors are - * expected to be able to sustain their nominal performance state - * simultaneously. - * Field lowest_nonlinear_perf represents Lowest Nonlinear Performance, wh= ich - * is the lowest performance level at which nonlinear power savings are - * achieved. Above this threshold, lower performance levels should be - * generally more energy efficient than higher performance levels. So in - * traditional terms, this represents the P-state range of performance lev= els. - * Field lowest_perf represents the absolute lowest performance level of t= he - * platform. Selecting it may cause an efficiency penalty but should reduce - * the instantaneous power consumption of the processor. So in traditional - * terms, this represents the T-state range of performance levels. - * - * Field max_perf, min_perf, des_perf store the values for CPPC request MS= R. - * Software passes performance goals through these fields. - * Field max_perf conveys the maximum performance level at which the platf= orm - * may run. And it may be set to any performance value in the range - * [lowest_perf, highest_perf], inclusive. - * Field min_perf conveys the minimum performance level at which the platf= orm - * may run. And it may be set to any performance value in the range - * [lowest_perf, highest_perf], inclusive but must be less than or equal to - * max_perf. - * Field des_perf conveys performance level Xen governor is requesting. An= d it - * may be set to any performance value in the range [min_perf, max_perf], - * inclusive. In active mode, des_perf must be zero. - * Field epp represents energy performance preference, which only has mean= ing - * when active mode is enabled. The EPP is used in the CCLK DPM controller - * to drive the frequency that a core is going to operate during short per= iods - * of activity, called minimum active frequency, It could contatin a range= of - * values from 0 to 0xff. An EPP of zero sets the min active frequency to - * maximum frequency, while an EPP of 0xff sets the min active frequency to - * approxiately Idle frequency. - */ -struct amd_cppc_drv_data -{ - const struct xen_processor_cppc *cppc_data; - union { - uint64_t raw; - struct { - unsigned int lowest_perf:8; - unsigned int lowest_nonlinear_perf:8; - unsigned int nominal_perf:8; - unsigned int highest_perf:8; - unsigned int :32; - }; - } caps; - union { - uint64_t raw; - struct { - unsigned int max_perf:8; - unsigned int min_perf:8; - unsigned int des_perf:8; - unsigned int epp:8; - unsigned int :32; - }; - } req; - - int err; -}; - -static DEFINE_PER_CPU_READ_MOSTLY(struct amd_cppc_drv_data *, - amd_cppc_drv_data); -/* * Core max frequency read from PstateDef as anchor point * for freq-to-perf transition */ @@ -279,11 +204,11 @@ static void cf_check amd_cppc_write_requ wrmsrl(MSR_AMD_CPPC_REQ, data->req.raw); } =20 -static void amd_cppc_write_request(unsigned int cpu, uint8_t min_perf, - uint8_t des_perf, uint8_t max_perf, - uint8_t epp) +static void amd_cppc_write_request(struct cpufreq_policy *policy, + uint8_t min_perf, uint8_t des_perf, + uint8_t max_perf, uint8_t epp) { - struct amd_cppc_drv_data *data =3D per_cpu(amd_cppc_drv_data, cpu); + struct amd_cppc_drv_data *data =3D &policy->drv_data.amd_cppc; uint64_t prev =3D data->req.raw; =20 data->req.min_perf =3D min_perf; @@ -295,15 +220,15 @@ static void amd_cppc_write_request(unsig if ( prev =3D=3D data->req.raw ) return; =20 - on_selected_cpus(cpumask_of(cpu), amd_cppc_write_request_msrs, data, 1= ); + on_selected_cpus(cpumask_of(policy->cpu), amd_cppc_write_request_msrs, + data, 1); } =20 static int cf_check amd_cppc_cpufreq_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation) { - unsigned int cpu =3D policy->cpu; - const struct amd_cppc_drv_data *data =3D per_cpu(amd_cppc_drv_data, cp= u); + const struct amd_cppc_drv_data *data =3D &policy->drv_data.amd_cppc; uint8_t des_perf; int res; =20 @@ -320,7 +245,7 @@ static int cf_check amd_cppc_cpufreq_tar * may actually cause an efficiency penalty, So when deciding the min_= perf * value, we prefer lowest nonlinear performance over lowest performan= ce. */ - amd_cppc_write_request(policy->cpu, data->caps.lowest_nonlinear_perf, + amd_cppc_write_request(policy, data->caps.lowest_nonlinear_perf, des_perf, data->caps.highest_perf, /* Pre-defined BIOS value for passive mode */ per_cpu(epp_init, policy->cpu)); @@ -330,7 +255,7 @@ static int cf_check amd_cppc_cpufreq_tar static void cf_check amd_cppc_init_msrs(void *info) { struct cpufreq_policy *policy =3D info; - struct amd_cppc_drv_data *data =3D this_cpu(amd_cppc_drv_data); + struct amd_cppc_drv_data *data =3D &policy->drv_data.amd_cppc; uint64_t val; unsigned int min_freq =3D 0, nominal_freq =3D 0, max_freq; =20 @@ -431,24 +356,16 @@ static void amd_cppc_boost_init(struct c =20 static int cf_check amd_cppc_cpufreq_cpu_exit(struct cpufreq_policy *polic= y) { - XVFREE(per_cpu(amd_cppc_drv_data, policy->cpu)); - return 0; } =20 static int amd_cppc_cpufreq_init_perf(struct cpufreq_policy *policy) { unsigned int cpu =3D policy->cpu; - struct amd_cppc_drv_data *data; - - data =3D xvzalloc(struct amd_cppc_drv_data); - if ( !data ) - return -ENOMEM; + struct amd_cppc_drv_data *data =3D &policy->drv_data.amd_cppc; =20 data->cppc_data =3D &processor_pminfo[cpu]->cppc_data; =20 - per_cpu(amd_cppc_drv_data, cpu) =3D data; - on_selected_cpus(cpumask_of(cpu), amd_cppc_init_msrs, policy, 1); =20 /* @@ -506,8 +423,7 @@ static void amd_cppc_prepare_policy(stru uint8_t *max_perf, uint8_t *min_perf, uint8_t *epp) { - const struct amd_cppc_drv_data *data =3D per_cpu(amd_cppc_drv_data, - policy->cpu); + const struct amd_cppc_drv_data *data =3D &policy->drv_data.amd_cppc; =20 /* * On default, set min_perf with lowest_nonlinear_perf, and max_perf @@ -560,7 +476,7 @@ static int cf_check amd_cppc_epp_set_pol =20 amd_cppc_prepare_policy(policy, &max_perf, &min_perf, &epp); =20 - amd_cppc_write_request(policy->cpu, min_perf, + amd_cppc_write_request(policy, min_perf, 0 /* no des_perf in active mode */, max_perf, epp); return 0; --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -74,6 +74,78 @@ struct hwp_drv_data { uint8_t energy_perf; }; =20 +/* + * Field highest_perf, nominal_perf, lowest_nonlinear_perf, and lowest_perf + * contain the values read from CPPC capability MSR. They represent the li= mits + * of managed performance range as well as the dynamic capability, which m= ay + * change during processor operation + * Field highest_perf represents highest performance, which is the absolute + * maximum performance an individual processor may reach, assuming ideal + * conditions. This performance level may not be sustainable for long + * durations and may only be achievable if other platform components + * are in a specific state; for example, it may require other processors be + * in an idle state. This would be equivalent to the highest frequencies + * supported by the processor. + * Field nominal_perf represents maximum sustained performance level of the + * processor, assuming ideal operating conditions. All cores/processors are + * expected to be able to sustain their nominal performance state + * simultaneously. + * Field lowest_nonlinear_perf represents Lowest Nonlinear Performance, wh= ich + * is the lowest performance level at which nonlinear power savings are + * achieved. Above this threshold, lower performance levels should be + * generally more energy efficient than higher performance levels. So in + * traditional terms, this represents the P-state range of performance lev= els. + * Field lowest_perf represents the absolute lowest performance level of t= he + * platform. Selecting it may cause an efficiency penalty but should reduce + * the instantaneous power consumption of the processor. So in traditional + * terms, this represents the T-state range of performance levels. + * + * Field max_perf, min_perf, des_perf store the values for CPPC request MS= R. + * Software passes performance goals through these fields. + * Field max_perf conveys the maximum performance level at which the platf= orm + * may run. And it may be set to any performance value in the range + * [lowest_perf, highest_perf], inclusive. + * Field min_perf conveys the minimum performance level at which the platf= orm + * may run. And it may be set to any performance value in the range + * [lowest_perf, highest_perf], inclusive but must be less than or equal to + * max_perf. + * Field des_perf conveys performance level Xen governor is requesting. An= d it + * may be set to any performance value in the range [min_perf, max_perf], + * inclusive. In active mode, des_perf must be zero. + * Field epp represents energy performance preference, which only has mean= ing + * when active mode is enabled. The EPP is used in the CCLK DPM controller + * to drive the frequency that a core is going to operate during short per= iods + * of activity, called minimum active frequency, It could contatin a range= of + * values from 0 to 0xff. An EPP of zero sets the min active frequency to + * maximum frequency, while an EPP of 0xff sets the min active frequency to + * approxiately Idle frequency. + */ +struct amd_cppc_drv_data { + const struct xen_processor_cppc *cppc_data; + union { + uint64_t raw; + struct { + unsigned int lowest_perf:8; + unsigned int lowest_nonlinear_perf:8; + unsigned int nominal_perf:8; + unsigned int highest_perf:8; + unsigned int :32; + }; + } caps; + union { + uint64_t raw; + struct { + unsigned int max_perf:8; + unsigned int min_perf:8; + unsigned int des_perf:8; + unsigned int epp:8; + unsigned int :32; + }; + } req; + + int err; +}; + struct cpufreq_cpuinfo { unsigned int max_freq; unsigned int second_max_freq; /* P1 if Turbo Mode is on */ @@ -120,6 +192,7 @@ struct cpufreq_policy { union { struct acpi_cpufreq_data acpi; struct hwp_drv_data hwp; + struct amd_cppc_drv_data amd_cppc; } drv_data; }; DECLARE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_policy); From nobody Mon Jan 26 07:40:45 2026 Delivered-To: importer@patchew.org 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 (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; 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; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1769075033; cv=none; d=zohomail.com; s=zohoarc; b=N3B9f0OYTnlFMsCmHXVLd1m0iJhJQc4RwDRT3sQDA+tj/yc1BX+UZBGn1E0JOupz4Rq5zhH0VBmLNHg4tZbjjJguE3zESZvTapfP0a5suAv6X//YHfk0AECbKF+LaJp1ozp7Dy4nyG0ca0/FGZbcdT15ZEMwjieGY5PUVN9p+UU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769075033; 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=fLtQAXdQpvWtzRgQd0SjG5ynKciIprq6k8v637TMVBw=; b=DpljWSkNtcgXWme2dMoKD8L1S0sv2kSAW/CymfYsRmXRcO9IvqtgKVr5VuC71zz6ft6NUEJ0m02VV3Cw+ExWQn+WQkkiyd29mqv71W1Tgnk5U4atI0vyNpxVRG6nAf6RQD4VC4ev7TtIUKf2asKPPNUFM1PhNgxSQqKy0WdNGOg= ARC-Authentication-Results: i=1; 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; 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 1769075033665210.27561470155422; Thu, 22 Jan 2026 01:43:53 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1210627.1522268 (Exim 4.92) (envelope-from ) id 1virDz-0001uE-Bu; Thu, 22 Jan 2026 09:43:35 +0000 Received: by outflank-mailman (output) from mailman id 1210627.1522268; Thu, 22 Jan 2026 09:43:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1virDz-0001u7-8U; Thu, 22 Jan 2026 09:43:35 +0000 Received: by outflank-mailman (input) for mailman id 1210627; Thu, 22 Jan 2026 09:43:33 +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 1virDx-0000Cq-Ij for xen-devel@lists.xenproject.org; Thu, 22 Jan 2026 09:43:33 +0000 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [2a00:1450:4864:20::332]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d00f037f-f776-11f0-9ccf-f158ae23cfc8; Thu, 22 Jan 2026 10:43:31 +0100 (CET) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-47eddddcdcfso4122285e9.1 for ; Thu, 22 Jan 2026 01:43:31 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4359f4a7ac7sm10309584f8f.20.2026.01.22.01.43.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Jan 2026 01:43:31 -0800 (PST) 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: d00f037f-f776-11f0-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1769075011; x=1769679811; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=fLtQAXdQpvWtzRgQd0SjG5ynKciIprq6k8v637TMVBw=; b=LzdoENZUScrhFuFxf7Fjc/dTAWkpXES6wuoLMMAQYHVEwzxI+uSjrujMk5E6023rCf wlmp5Th0QqT/LjFgPQY/0f2hBhy89wO5U1mMPwh4yK/60aKn/2LXqBZ0mFuJqkw/v8XZ tJAHJW3oNgsRo6BfnDQjTJ8JcInIjdxuuxutUbuZsMYu/kR4mKnwtBWpdeGTcNO0bxak lXsoCr/HgPEX/oe60Z65PFgiuO8DT9JCYFvub+fBqbRQZuSF0k/3gmIqFzCAkVod7rUw tiKOwh9y45fiS3q2dwqT1zzUO4Z37aogiQWy8kgndE92yobVqx2/CrYqgakTrO4Q4gEH Oirg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769075011; x=1769679811; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fLtQAXdQpvWtzRgQd0SjG5ynKciIprq6k8v637TMVBw=; b=KPc/L3f1K93oNVNT5KUMf35kOZuOscb/eTfgMfFCfWZWdYEGLU2FTEmniYcL/sfnKh YtsSz5kBBKE2DJGZjKN9L0DzHlf1gT73rIpn31mXbKnm3BFFO6OAqhUqtlOp+ZKFZL3N RB0Pyaj6/YKgik2zXYqOJGQnmAI86pnfICldVs29iok7EsZ0g6KESSimVrgaxJaGsyJg netmr+xgYdR9gBG+HK9GUULYo3Fc3/Lqa6X9rxcFxOpnkm0xz29C/17p7A7Q/AqUG8cq TwjjbZVHosODfoIA9akyENHaeT8JJS7gwJi20tiAo/NjaVE+9wrPEDun4fO9YEJWVyyg 5tcQ== X-Gm-Message-State: AOJu0YxEG7BUZ4JIxIC+rCRHDZ9A5AprxY+dCA/WboJjVYDHBFHLI45l Lb2LdbFBn7ZfQoC85GCHH4xnEROtRTK2gT6FUA3E41cMZBjNez3cm+QLhbajtqmsWaMVpdWtVku rxgo= X-Gm-Gg: AZuq6aLYPk4CTeh28aZF0JeLo7M36Meib01rtsU3kd6CXxiuuHuTYHkRdJk4pq7BCl9 FqcV0Fcs/PtPFQzVAFbKlWz2rXxdOtDAySodVJj8YsVZ3FZm7H7u3rBERz5hfpFWuO5tuh6617e OoyBpSvvZaW1COEDhErTbx5FzpD9cylZ3WwTE8X3G4CApYu3nVYWE9ct1M7TINrMkl4n0B+98gn X3TkDvajRp+YhYXB3cxtNOUdtJj25SUGGHzzdK/1iLCDw5PL6fQUy7vG0Jrrh29cqk1H2e3rhvs DdnBXfcoVvH43UIlsuZC6GrCOy1bDk84kwVRuOT2cVursCBzBmbLgcKXrdg4rj6brEVKZx/eu7x VQxQN6227FLta9uc7GydHzt02UZ3jiL1a8rhwkB17VKH/lVmY1gPuHJ0RPC/ej7LbVXtcpsLKcz FyqSVMZbZI40kt0roiPaQWA50fxyYXVGI16lnP1Xlz6FpXNyWX6JjKKmajw5ULr8yzi50aJxXw4 T8= X-Received: by 2002:a05:600c:6215:b0:47a:9560:5944 with SMTP id 5b1f17b1804b1-480432c4b7cmr79750625e9.34.1769075011276; Thu, 22 Jan 2026 01:43:31 -0800 (PST) Message-ID: <18639925-4e8f-4d58-a850-291d7ac0e6da@suse.com> Date: Thu, 22 Jan 2026 10:43:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 4/5] cpufreq/amd-cppc: move epp_init into driver data From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Penny Zheng References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1769075035214158500 Content-Type: text/plain; charset="utf-8" No reason for it to be a separate per-CPU item; it's connected to a struct cpufreq_policy instance just like other driver data. This further reduces the concern over amd_cppc_cpufreq_cpu_init() being called for all CPUs, or a CPU going offline that's recorded in policy->cpu (which would result in accesses of per-CPU data of offline CPUs). Signed-off-by: Jan Beulich Reviewed-by: Penny Zheng --- a/xen/arch/x86/acpi/cpufreq/amd-cppc.c +++ b/xen/arch/x86/acpi/cpufreq/amd-cppc.c @@ -35,7 +35,6 @@ * for freq-to-perf transition */ static DEFINE_PER_CPU_READ_MOSTLY(unsigned int, pxfreq_mhz); -static DEFINE_PER_CPU_READ_MOSTLY(uint8_t, epp_init); #ifndef NDEBUG static bool __ro_after_init opt_active_mode; #else @@ -248,7 +247,7 @@ static int cf_check amd_cppc_cpufreq_tar amd_cppc_write_request(policy, data->caps.lowest_nonlinear_perf, des_perf, data->caps.highest_perf, /* Pre-defined BIOS value for passive mode */ - per_cpu(epp_init, policy->cpu)); + data->epp_init); return 0; } =20 @@ -326,7 +325,7 @@ static void cf_check amd_cppc_init_msrs( =20 /* Store pre-defined BIOS value for passive mode */ rdmsrl(MSR_AMD_CPPC_REQ, val); - this_cpu(epp_init) =3D MASK_EXTR(val, AMD_CPPC_EPP_MASK); + data->epp_init =3D MASK_EXTR(val, AMD_CPPC_EPP_MASK); =20 return; =20 @@ -465,7 +464,7 @@ static void amd_cppc_prepare_policy(stru break; =20 default: - *epp =3D per_cpu(epp_init, policy->cpu); + *epp =3D data->epp_init; break; } } --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -143,6 +143,8 @@ struct amd_cppc_drv_data { }; } req; =20 + uint8_t epp_init; + int err; }; From nobody Mon Jan 26 07:40:45 2026 Delivered-To: importer@patchew.org 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 (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; 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; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1769075312; cv=none; d=zohomail.com; s=zohoarc; b=kLg4p4VnGWNFxwfimgN+/oXtzVimFkb1oOtWYeun7wZwp8Ahl2Bq5P9WrtqYgXgTT/7uHg3IuVm1UwdeW7Mxbii9t/J4eaOXVXQfhrEcPHQh4PNS/QbXVTip3VynH4l2ILkP5NPEPVZQzZCJpB/Fa+eE1d0qbVT3gPljgI32GdI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769075312; 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=b6ZgQHfjrDjWEfMOq63jsxR+PhNdjaZ5C3nYexbwyrk=; b=Fo4h4jRACk1AblxBQlpwxSTPwR773PlIvhJ/na/QLyyf+jbQsWOggobs1ssxjOoQREkkuPtaYZOCNVp4sPmMdhXCwRwnEYGqZFQRbGz//MdzXtFc6nwHgmcCglEFCBEjT7grpSESI/rlDK+A7PuOnT5scyTMN13lC0vfRPouehA= ARC-Authentication-Results: i=1; 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; 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 1769075312507162.4529297543396; Thu, 22 Jan 2026 01:48:32 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1210640.1522278 (Exim 4.92) (envelope-from ) id 1virIQ-0002uB-SD; Thu, 22 Jan 2026 09:48:10 +0000 Received: by outflank-mailman (output) from mailman id 1210640.1522278; Thu, 22 Jan 2026 09:48:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1virIQ-0002u4-Ot; Thu, 22 Jan 2026 09:48:10 +0000 Received: by outflank-mailman (input) for mailman id 1210640; Thu, 22 Jan 2026 09:48:08 +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 1virEI-0000Cq-UU for xen-devel@lists.xenproject.org; Thu, 22 Jan 2026 09:43:54 +0000 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [2a00:1450:4864:20::331]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id dcbeb970-f776-11f0-9ccf-f158ae23cfc8; Thu, 22 Jan 2026 10:43:53 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-47fedb7c68dso7544205e9.2 for ; Thu, 22 Jan 2026 01:43:53 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48042b6a3e2sm51107065e9.1.2026.01.22.01.43.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Jan 2026 01:43:52 -0800 (PST) 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: dcbeb970-f776-11f0-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1769075032; x=1769679832; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=b6ZgQHfjrDjWEfMOq63jsxR+PhNdjaZ5C3nYexbwyrk=; b=WWPRZnDyYKIE6CYBNkSihkY4kPKFBzzPCPIKO99ioJ12UwC0rZ5GGoe/CnD+gPMCZS ZkDssxYdhW1FE3jIaF+B6LNsdkKhtF8JuA7+1WvQDb1E4pHT4B5Cg9ZVWZzeDBcRJt/F J7HvuX4OvorlZZZpMux6ukRpWaj4O0qcUbgONu+ggNt7qk4qBfYROCFeEuegvDhQvtFh 8+0VFOsNVGI7J2HPeJSp6IfUvDWZup2zD+QxNBzVV2M4Jgjjemr61m5fl6lomsF4yl4F Q3YGeVnzKIUybE/bfW3YmG/7vk5s8nNSBaYBQIBTkEt1+m4I4Q9dQ5/0xBuyw74ag6tO rc2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769075032; x=1769679832; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=b6ZgQHfjrDjWEfMOq63jsxR+PhNdjaZ5C3nYexbwyrk=; b=shoruM9WxfBJoGC+qj74RzGegsm4LSnwuixmqDGn1RvpQ9/DmNVaNUiNdj0PMUd3+y soy/81DFC37tfsxaqoI0rSbwhwk1HtEH0Z93NSJVMyIIy0XdtFjJqhPZnmpzG/FpnSek kaw0ZWd+PcpGjHZIiCfWOM9YBbvYX/6YWDunUMGBC5JOXZS6vB4Ajyy48Qq/QXwtMYbp Xvl5MeX+ScCV9tanqhtLjtjL/lQ1ZML022OKQ47IlPNToBv+6resxu5Zgm4BV8G27BJ4 eboQeRxk9eRi7fwb0qtJZYpY4HG2SQtNRbnbakLhqaRpQ7Ur2IfJvwf4wi5Cr1HjtpUO gt4A== X-Gm-Message-State: AOJu0Yw+uEuTnh7STHF6Pg6vf5/QroX+Q7BpjnOQ28A4qp3zTEeZ0kaO 7QbWLoN/cT1C3TU0VWU40sX9dGQzEERnweJ+CkMfQ34KIYg8AQ40EqeSuojBxjsEubUe8LzXbKh XF+k= X-Gm-Gg: AZuq6aLkNToiUNYWiYUEi3+S1YRgY5c396sOYo/T7Nc7a/NxYAEI71ARL0SS/ghAg85 kqLbhkauvpMmMELsW/OqXY7X2dO1NaGocPigHMlaDdabUU3Fi5xpAVZIaofH0IxazKT+cTNMLF/ v1fMo2rKF2ZWAc1m7vG2pVva9b+l1qwqQ7UHSiXufBntTufONTu0TYeoKsNfYYmbzz1rOgQErPl lxUrAMNLtC2CNll0b+u+nOFeiPg5JCXnzbHiiWBo1x4PCo/AgohcXvAn5jc/ckgNJXMZxaCLz31 5IT6rUwgFOHo1hz9FWrWCndMyibv6d+xK0TN2YJy0nfHvkhaOIL7iAUEoV0tZDLqvms82UYhD8W 4MyfJOtPWjGg4wz1q7+lKUobQ+GxNxnCkW6FcOgU0IDab1gUlIV9DTXyq6/2Nrk+AkJvd7H14yT XVzkhFirQk18NgPGA45Jl/08veEO4Ro/N1uPpFfrzBFAyU3zQp/nS6Xo6vkIOgYbB1GN4eSL+wP Kc= X-Received: by 2002:a05:600c:8b67:b0:47d:3ffb:16c9 with SMTP id 5b1f17b1804b1-4801e342091mr235179655e9.23.1769075032572; Thu, 22 Jan 2026 01:43:52 -0800 (PST) Message-ID: <715604a8-265b-4832-8001-1a2dbdc870bb@suse.com> Date: Thu, 22 Jan 2026 10:43:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 5/5] cpufreq/amd-cppc: move pxfreq_mhz into driver data From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Penny Zheng References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1769075314695158500 Content-Type: text/plain; charset="utf-8" No reason for it to be a separate per-CPU item; it's connected to a struct cpufreq_policy instance just like other driver data. This also eliminates the concern over amd_cppc_cpufreq_cpu_init() being called for all CPUs, or a CPU going offline that's recorded in policy->cpu (which would result in accesses of per-CPU data of offline CPUs). Signed-off-by: Jan Beulich Reviewed-by: Penny Zheng --- a/xen/arch/x86/acpi/cpufreq/amd-cppc.c +++ b/xen/arch/x86/acpi/cpufreq/amd-cppc.c @@ -30,11 +30,6 @@ printk(XENLOG_DEBUG "AMD-CPPC: CPU%u " fmt, cpu, ## args); \ }) =20 -/* - * Core max frequency read from PstateDef as anchor point - * for freq-to-perf transition - */ -static DEFINE_PER_CPU_READ_MOSTLY(unsigned int, pxfreq_mhz); #ifndef NDEBUG static bool __ro_after_init opt_active_mode; #else @@ -117,7 +112,7 @@ static int amd_cppc_khz_to_perf(const st { /* Read Processor Max Speed(MHz) as anchor point */ mul =3D data->caps.highest_perf; - div =3D this_cpu(pxfreq_mhz); + div =3D data->pxfreq_mhz; if ( !div ) return -EOPNOTSUPP; } @@ -160,7 +155,7 @@ static int amd_get_cpc_freq(const struct } =20 /* Read Processor Max Speed(MHz) as anchor point */ - mul =3D this_cpu(pxfreq_mhz); + mul =3D data->pxfreq_mhz; if ( !mul ) return -EOPNOTSUPP; div =3D data->caps.highest_perf; @@ -287,7 +282,7 @@ static void cf_check amd_cppc_init_msrs( } =20 amd_process_freq(&cpu_data[policy->cpu], - NULL, NULL, &this_cpu(pxfreq_mhz)); + NULL, NULL, &data->pxfreq_mhz); =20 data->err =3D amd_get_cpc_freq(data, data->cppc_data->cpc.lowest_mhz, data->caps.lowest_perf, &min_freq); --- a/xen/include/acpi/cpufreq/cpufreq.h +++ b/xen/include/acpi/cpufreq/cpufreq.h @@ -145,6 +145,12 @@ struct amd_cppc_drv_data { =20 uint8_t epp_init; =20 + /* + * Core max frequency read from PstateDef as anchor point + * for freq-to-perf transition + */ + unsigned int pxfreq_mhz; + int err; };