From nobody Mon Mar 23 21:25:00 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; 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=1773334542; cv=none; d=zohomail.com; s=zohoarc; b=ZaDn7r7AuvUjavxjWQm+WTWAuQ82/mW0RFgdaf5fv7kcHnKP4bxyDEHRmUyna4nqvXggHKtRTw5IWyA28kPauUAEoudsVascsTMX5sRBiwio5Ig1OOIawOHnb3ISXSWbgo0tx9ni7Dv8jOmOocdICTHhNp0p54Yb6KucLb7YdVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773334542; 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=YORkC10FLOdP4ZPuyWf26dj7CDdAeRGQhEwwoPkwu48=; b=CdbJS3B9VgSo5kHwutsIhqiwN1+NkBvwT8BWJMraXf1dRg+dmU7mLCxNqJbMLr7shQSs5I90N4tFoasG7VL5GVYc2sOptPLRhDUN7Wfris94rO1Qy33ITRraPzkwCw5dASSYwBamKKpZ/iuWws+3wYJT6LRs7wulPZcc99/ld0M= 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 1773334542138327.00976240612476; Thu, 12 Mar 2026 09:55:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1252764.1549324 (Exim 4.92) (envelope-from ) id 1w0jJn-0000Qs-Cy; Thu, 12 Mar 2026 16:55:27 +0000 Received: by outflank-mailman (output) from mailman id 1252764.1549324; Thu, 12 Mar 2026 16:55:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0jJn-0000Ql-AI; Thu, 12 Mar 2026 16:55:27 +0000 Received: by outflank-mailman (input) for mailman id 1252764; Thu, 12 Mar 2026 16:55:26 +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 1w0jJm-0000EC-CS for xen-devel@lists.xenproject.org; Thu, 12 Mar 2026 16:55:26 +0000 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [2a00:1450:4864:20::42e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 43f8a4e1-1e34-11f1-b164-2bf370ae4941; Thu, 12 Mar 2026 17:55:25 +0100 (CET) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-439c56e822eso1282164f8f.2 for ; Thu, 12 Mar 2026 09:55:25 -0700 (PDT) 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-439fe228986sm7866764f8f.35.2026.03.12.09.55.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Mar 2026 09:55:23 -0700 (PDT) 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: 43f8a4e1-1e34-11f1-b164-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1773334525; x=1773939325; 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=YORkC10FLOdP4ZPuyWf26dj7CDdAeRGQhEwwoPkwu48=; b=bwiC1ev88ZAmCC54nAdIPSUgd+azdNzx3ds6x8WyxKX3Ax7saCHi20rYp6kDb8/TrY hXt5zrd2ojJSutiB7v6exc/iyZeddbYmlr5kcSJCQl93n+lpEatj87+JBYkDhP13VIEb Cbv6GlnDpReFYpSeLxzcXcfRpgmgH0KIffll7H3onFFspzWXxuflKt2/tNIi1DuaRN9d VnlsScMo7N/CWpt2vjBL5VufYHd3GUIrU0IM4fRPZ5JIYTn41DspDJrYec367fprp8Or 7i8nZJ173QcRCvuqAZ3/nNu4IA3un/hP7Sn9Fu0n3dv7/AOBCkZl6n5pW6flFg/4uD4s +MCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773334525; x=1773939325; 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=YORkC10FLOdP4ZPuyWf26dj7CDdAeRGQhEwwoPkwu48=; b=w2p3Nik7v6BlayR4kEtIeSQApfsLGHFB0jfvUVsfmWhgYKuqyAb09fBN0unLWt9ygT R1P7zLTuXYuuSOIVuE9TG1Wd8akPQCnlgl9HNuJ7GADJbARy1Z9wdL4vP6+2vyf1elTn 1Q7CRceo1a8PJQ7NKV0SPFhrOJey4M1ND09OOTSCsv369tM7y3Fne94P3o4gN8Su2pOL VaR/NVBYKY0qDJHrL11UwKE2DzCFbkLb/PfcZNuiF9XY39hE/VVsgX+KFiCrt33dCcLE GFxg8RRdnexzlMcovIZUFgn95kUNhDE4VPRv/4kTRB7MHU0cBTFQb1lsvHqp38YtcK2u PmfQ== X-Gm-Message-State: AOJu0YzoHnYEs0iLXBCsBBnbw946/UBqQvPCI9aDliRGzP+QCdlmz4s4 GWuR1pQLOacPvrvAZsjGPGQpzilT7NcDqt0PZ/ktPtc/Fv4Sd1yjF0opzeUjzAd6qqOEJX+2+2Z lWa4= X-Gm-Gg: ATEYQzxfgaNc6sK6VbBTGeP0E1ObaeNadbnMnHafZRXJGl0UkSvupVrnfgQHf0bGMiW B9dG2ocYER+FV9xmUXsYnJfphBbUHv/6KvwUDceOQ/2u/e6xreF0PeUe3PAbIe9D2DmP5/Lj/If Xn/xh8jdLuDaigSIiOa8H5VX51+a6jbJ7wFaQPY/JNuCJZhd8lTtotN717VhkCZVqp945RaNut/ HFYwThBh0tHEk8kKUvCBNNAwDiPZlqKydXaeMZxkxp9o5piJoTV8sLxgCWHOG0Sw44wVjcOo6af uwpPF8SAHJksyhIWAe3TJXbRhVgCuSNqEshCjPiRSqMbCPzTHSpz7WUw9o3fV/NoSrKHh4XJvGR 7vVw92mgrOH4po1W6FOnU30+DAfrxPcM4NnXAvHDjZDymCbZbJVBltOpJT9wwsiKvE41nuQHbrj pyAeA89nNeJkJlXJPI34nCN2/N/DgH8fTxAqQqH7By6NeRFSq5NKwQxpsNh7D0OqBGHyUnjT96i CRU+cnQ6iq2fAoxHP0wYPqaDg== X-Received: by 2002:a05:6000:178b:b0:439:b7c9:2edc with SMTP id ffacd0b85a97d-43a04dc0b96mr751381f8f.48.1773334524773; Thu, 12 Mar 2026 09:55:24 -0700 (PDT) Message-ID: <5d12d537-7c6b-4730-b963-a4a9e13a7413@suse.com> Date: Thu, 12 Mar 2026 17:55:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 3/9] x86/mwait-idle: latch struct idle_cpu contents From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <7b7a677e-a5b9-42c8-beec-3c506b4eac52@suse.com> 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: <7b7a677e-a5b9-42c8-beec-3c506b4eac52@suse.com> Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1773334544796154100 Content-Type: text/plain; charset="utf-8" Rather than storing a pointer (and needing to keep all struct instances in memory post-init), and rather than (like the Linux counterpart has it) keeping individual variables, simply copy the respective structure instance. By implication, subsequent updates now need doing to the copy. Signed-off-by: Jan Beulich --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -107,14 +107,14 @@ struct idle_cpu { enum c1e_promotion c1e_promotion; }; =20 -static const struct idle_cpu *__ro_after_init icpu; +static struct idle_cpu __ro_after_init icpu; =20 -static const struct cpuidle_state { +struct cpuidle_state { char name[16]; unsigned int flags; unsigned int exit_latency; /* in US */ unsigned int target_residency; /* in US */ -} *__ro_after_init cpuidle_state_table; +}; =20 #define CPUIDLE_FLAG_DISABLED 0x1 /* @@ -1097,7 +1097,7 @@ static void cf_check mwait_idle(void) * leave_mm() to avoid costly and often unnecessary wakeups * for flushing the user TLB's associated with the active mm. */ - if (cpuidle_state_table[].flags & CPUIDLE_FLAG_TLB_FLUSHED) + if (icpu.state_table[].flags & CPUIDLE_FLAG_TLB_FLUSHED) leave_mm(cpu); #endif =20 @@ -1139,7 +1139,7 @@ static void cf_check auto_demotion_disab u64 msr_bits; =20 rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits); - msr_bits &=3D ~(icpu->auto_demotion_disable_flags); + msr_bits &=3D ~icpu.auto_demotion_disable_flags; wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits); } =20 @@ -1371,10 +1371,10 @@ static void __init ivt_idle_state_table_ /* 1 and 2 socket systems use default ivt_cstates */ break; case 2: case 3: - cpuidle_state_table =3D ivt_cstates_4s; + icpu.state_table =3D ivt_cstates_4s; break; default: - cpuidle_state_table =3D ivt_cstates_8s; + icpu.state_table =3D ivt_cstates_8s; break; } } @@ -1525,14 +1525,12 @@ static void __init adl_idle_state_table_ adl_l_cstates[1].flags |=3D CPUIDLE_FLAG_DISABLED; =20 /* Disable C1E by clearing the "C1E promotion" bit. */ - idle_cpu_adl.c1e_promotion =3D C1E_PROMOTION_DISABLE; - idle_cpu_adl_l.c1e_promotion =3D C1E_PROMOTION_DISABLE; + icpu.c1e_promotion =3D C1E_PROMOTION_DISABLE; return; } =20 /* Make sure C1E is enabled by default */ - idle_cpu_adl.c1e_promotion =3D C1E_PROMOTION_ENABLE; - idle_cpu_adl_l.c1e_promotion =3D C1E_PROMOTION_ENABLE; + icpu.c1e_promotion =3D C1E_PROMOTION_ENABLE; } =20 /* @@ -1593,6 +1591,7 @@ static int __init mwait_idle_probe(void) { unsigned int eax, ebx, ecx; const struct x86_cpu_id *id; + const struct idle_cpu *idle_cpu; const char *str; =20 if (boot_cpu_data.vendor !=3D X86_VENDOR_INTEL) @@ -1627,8 +1626,8 @@ static int __init mwait_idle_probe(void) =20 pr_debug(PREFIX "MWAIT substates: %#x\n", mwait_substates); =20 - icpu =3D id->driver_data; - cpuidle_state_table =3D icpu->state_table; + idle_cpu =3D id->driver_data; + icpu =3D *idle_cpu; =20 if (boot_cpu_has(X86_FEATURE_XEN_ARAT)) lapic_timer_reliable_states =3D LAPIC_TIMER_ALWAYS_RELIABLE; @@ -1647,7 +1646,7 @@ static int __init mwait_idle_probe(void) const char *ss; =20 do { - const struct cpuidle_state *state =3D icpu->state_table; + const struct cpuidle_state *state =3D idle_cpu->state_table; unsigned int bit =3D 1; =20 ss =3D strchr(str, ','); @@ -1679,10 +1678,10 @@ static int __init mwait_idle_probe(void) =20 static void mwait_idle_cpu_tweak(unsigned int cpu, bool bsp) { - if (icpu->auto_demotion_disable_flags) + if (icpu.auto_demotion_disable_flags) on_selected_cpus(cpumask_of(cpu), auto_demotion_disable, NULL, 1); =20 - switch (icpu->c1e_promotion) { + switch (icpu.c1e_promotion) { case C1E_PROMOTION_DISABLE: on_selected_cpus(cpumask_of(cpu), c1e_promotion_disable, NULL, 1); break; @@ -1735,11 +1734,11 @@ static int cf_check mwait_idle_cpu_init( =20 dev->count =3D 1; =20 - for (cstate =3D 0; cpuidle_state_table[cstate].target_residency; ++cstate= ) { + for (cstate =3D 0; icpu.state_table[cstate].target_residency; ++cstate) { unsigned int num_substates, hint, state; struct acpi_processor_cx *cx; =20 - hint =3D flg2MWAIT(cpuidle_state_table[cstate].flags); + hint =3D flg2MWAIT(icpu.state_table[cstate].flags); state =3D MWAIT_HINT2CSTATE(hint) + 1; =20 if (state > max_cstate) { @@ -1755,10 +1754,10 @@ static int cf_check mwait_idle_cpu_init( continue; =20 /* if state marked as disabled, skip it */ - if (cpuidle_state_table[cstate].flags & + if (icpu.state_table[cstate].flags & CPUIDLE_FLAG_DISABLED) { printk(XENLOG_DEBUG PREFIX "state %s is disabled\n", - cpuidle_state_table[cstate].name); + icpu.state_table[cstate].name); continue; } =20 @@ -1776,15 +1775,15 @@ static int cf_check mwait_idle_cpu_init( cx->type =3D state; cx->address =3D hint; cx->entry_method =3D ACPI_CSTATE_EM_FFH; - cx->latency =3D cpuidle_state_table[cstate].exit_latency; + cx->latency =3D icpu.state_table[cstate].exit_latency; cx->target_residency =3D - cpuidle_state_table[cstate].target_residency; - if ((cpuidle_state_table[cstate].flags & + icpu.state_table[cstate].target_residency; + if ((icpu.state_table[cstate].flags & CPUIDLE_FLAG_IRQ_ENABLE) && /* cstate_restore_tsc() needs to be a no-op */ boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) cx->irq_enable_early =3D true; - if (cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_IBRS) + if (icpu.state_table[cstate].flags & CPUIDLE_FLAG_IBRS) cx->ibrs_disable =3D true; =20 dev->count++; @@ -1825,7 +1824,7 @@ int __init mwait_idle_init(struct notifi =20 void mwait_idle_resume(void) { - if (!icpu) + if (!icpu.state_table) return; =20 mwait_idle_cpu_tweak(smp_processor_id(), true);