Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH] sys_cpu_topology02: Drop upper bound on core_id
@ 2026-11-20  9:34 Hubert Mazur via ltp
  2026-11-20 10:34 ` [LTP] " linuxtestproject.agent
  0 siblings, 1 reply; 2+ messages in thread
From: Hubert Mazur via ltp @ 2026-11-20  9:34 UTC (permalink / raw)
  To: Linux Test Project
  Cc: Kazuhiro Inaba, Hubert Mazur, Wake Liu, Grzegorz Jaszczyk

sys_cpu_topology02 currently checks that each online CPU's
/sys/devices/system/cpu/cpuN/topology/core_id is in the range
[0, poss_max_id], assuming that core_id is a dense 0-based index bounded
by the highest possible CPU id.

Per Linux Documentation/ABI/stable/sysfs-devices-system-cpu, core_id is:
"Typically it is the hardware platform's identifier (rather than the
kernel's). The actual value is architecture and platform dependent."

- On x86, arch/x86/kernel/cpu/topology_common.c derives core_id from the
  hardware APIC ID domain bits. On Intel hybrid CPUs, APIC IDs are
  sparsely allocated across core types and clusters; for example, on an
  8-CPU Intel hybrid system (possible: 0-7), core_id values are
  0, 4, 8, 12, 32, 33, 34, 35, causing sys_cpu_topology02 to fail on
  cpu2..cpu7:

  sys_cpu_topology02.c:83: TFAIL:
    /sys/devices/system/cpu/cpu2/topology/core_id = 8 out of range [0, 7]
    /sys/devices/system/cpu/cpu3/topology/core_id = 12 out of range [0, 7]
    /sys/devices/system/cpu/cpu4/topology/core_id = 32 out of range [0, 7]

- On arm64 with ACPI PPTT, drivers/acpi/pptt.c populates core_id from
  the firmware ACPI processor UID or the PPTT table byte offset, neither
  of which is bounded by the CPU count.

Drop the upper bound on core_id to LONG_MAX (preserving the >= 0
sanity check), update the test documentation comment accordingly, and
remove the now-unused poss_max_id parameter from check_cpu_topology().

Fixes: d19bf8f7dede ("testcases: sysfs: Add sys_cpu_topology02")
Signed-off-by: Hubert Mazur <hmazur@google.com>
---
 .../kernel/sysfs/devices/system/cpu/sys_cpu_topology02.c   | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/sysfs/devices/system/cpu/sys_cpu_topology02.c b/testcases/kernel/sysfs/devices/system/cpu/sys_cpu_topology02.c
index 7098da9f3..57353d9d1 100644
--- a/testcases/kernel/sysfs/devices/system/cpu/sys_cpu_topology02.c
+++ b/testcases/kernel/sysfs/devices/system/cpu/sys_cpu_topology02.c
@@ -22,8 +22,12 @@
  *   in sync on every architecture, and avoids a spurious failure if a
  *   sibling CPU is hot-unplugged concurrently with this test running.
  * - the CPU itself is contained in its own thread_siblings_list
- * - core_id is in [0, highest possible CPU id], since there can be at most
- *   as many cores as possible CPUs (every core has at least one thread)
+ * - core_id is non-negative. Per
+ *   Documentation/ABI/stable/sysfs-devices-system-cpu, core_id is typically
+ *   the hardware platform's identifier rather than a dense kernel index, so
+ *   it is not bounded by the highest possible CPU id (e.g. x86 derives it
+ *   from the hardware APIC ID, which is sparse on Intel hybrid CPUs, and
+ *   arm64 ACPI PPTT may export a firmware UID or table byte offset).
  * - physical_package_id is in [-1, highest possible CPU id] on physical
  *   hardware, or just at least -1 under virtualization (see below). -1 is a
  *   legitimate value here, not just a range extension for safety: per
@@ -66,7 +70,7 @@ static void check_self_in_threads(int cpu)
 		PATH_SYS_CPU "/cpu%d/topology/thread_siblings_list", cpu);
 }
 
-static void check_cpu_topology(int cpu, int poss_max_id, long pkg_max_id)
+static void check_cpu_topology(int cpu, long pkg_max_id)
 {
 	char sub[PATH_MAX], super[PATH_MAX];
 
@@ -80,7 +84,7 @@ static void check_cpu_topology(int cpu, int poss_max_id, long pkg_max_id)
 
 	tst_res(TINFO, "Checking cpu%d topology", cpu);
 
-	TST_SYSFS_ASSERT_RANGELL(0, poss_max_id,
+	TST_SYSFS_ASSERT_RANGELL(0, LONG_MAX,
 			       PATH_SYS_CPU "/cpu%d/topology/core_id", cpu);
 
 	TST_SYSFS_ASSERT_RANGELL(-1, pkg_max_id,
@@ -124,7 +128,7 @@ static void do_test(void)
 		pkg_max_id = poss_max_id;
 
 	for (cpu = 0; cpu <= max_id; cpu++)
-		check_cpu_topology(cpu, poss_max_id, pkg_max_id);
+		check_cpu_topology(cpu, pkg_max_id);
 }
 
 static struct tst_test test = {

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] sys_cpu_topology02: Drop upper bound on core_id
  2026-11-20  9:34 [LTP] [PATCH] sys_cpu_topology02: Drop upper bound on core_id Hubert Mazur via ltp
@ 2026-11-20 10:34 ` linuxtestproject.agent
  0 siblings, 0 replies; 2+ messages in thread
From: linuxtestproject.agent @ 2026-11-20 10:34 UTC (permalink / raw)
  To: Hubert Mazur; +Cc: ltp

Hi Hubert,

On Fri Nov 20 09:34:44 2026 +0000, Hubert Mazur wrote:
> sys_cpu_topology02: Drop upper bound on core_id

Verdict - Reviewed

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2026-11-20 10:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20  9:34 [LTP] [PATCH] sys_cpu_topology02: Drop upper bound on core_id Hubert Mazur via ltp
2026-11-20 10:34 ` [LTP] " linuxtestproject.agent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox