All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/srat: Conditional apic_id vs MAX_LOCAL_APIC comparison
@ 2025-02-28  5:18 WangYuli
  2025-02-28  9:32 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: WangYuli @ 2025-02-28  5:18 UTC (permalink / raw)
  To: dave.hansen, luto, peterz, tglx, mingo, bp, x86, hpa
  Cc: linux-kernel, zhanjun, niecheng1, chenlinxuan, WangYuli,
	Huacai Chen, Wentao Guan

The apic_id employed within the acpi_numa_processor_affinity_init()
function is derived from the acpi_srat_cpu_affinity structure defined
in acpi/actbl3.h.

When CONFIG_X86_X2APIC is not enabled, its maximum value is limited
to 255. It is only capable of exceeding 256 and 32768 —  which
corresponds to the definition of MAX_LOCAL_APIC — when CONFIG_X86_X2APIC
is activated.

Consequently, with CONFIG_X86_X2APIC disabled, this code segment will
elicit the compiler's "-Wtautological-constant-out-of-range-compare"
warning, as a variable capped at 255 can never satisfy a condition
requiring it to be greater than or equal to 256 or 32768.

Compiling the kernel with the W=1e flag will, in this scenario, lead
to compilation failure.

Suggested-by: Huacai Chen <chenhuacai@loongson.cn>
Co-developed-by: Wentao Guan <guanwentao@uniontech.com>
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Signed-off-by: WangYuli <wangyuli@uniontech.com>
---
 arch/x86/mm/srat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/mm/srat.c b/arch/x86/mm/srat.c
index 6f8e0f21c710..93e5bcc58ead 100644
--- a/arch/x86/mm/srat.c
+++ b/arch/x86/mm/srat.c
@@ -90,10 +90,12 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
 	else
 		apic_id = pa->apic_id;
 
+#ifdef CONFIG_X86_X2APIC
 	if (apic_id >= MAX_LOCAL_APIC) {
 		printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%02x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
 		return;
 	}
+#endif /* CONFIG_X86_X2APIC */
 
 	set_apicid_to_node(apic_id, node);
 	node_set(node, numa_nodes_parsed);
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-03  3:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-28  5:18 [PATCH] x86/srat: Conditional apic_id vs MAX_LOCAL_APIC comparison WangYuli
2025-02-28  9:32 ` Ingo Molnar
2025-03-03  3:42   ` WangYuli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.