From: Hubert Mazur via ltp <ltp@lists.linux.it>
To: Linux Test Project <ltp@lists.linux.it>
Cc: Kazuhiro Inaba <kinaba@google.com>,
Hubert Mazur <hmazur@google.com>, Wake Liu <wakel@google.com>,
Grzegorz Jaszczyk <jaszczyk@google.com>
Subject: [LTP] [PATCH] sys_cpu_topology02: Drop upper bound on core_id
Date: Fri, 20 Nov 2026 09:34:44 +0000 [thread overview]
Message-ID: <20261120093444.609481-1-hmazur@google.com> (raw)
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
next reply other threads:[~2026-11-20 10:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 9:34 Hubert Mazur via ltp [this message]
2026-11-20 10:34 ` [LTP] sys_cpu_topology02: Drop upper bound on core_id linuxtestproject.agent
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120093444.609481-1-hmazur@google.com \
--to=ltp@lists.linux.it \
--cc=hmazur@google.com \
--cc=jaszczyk@google.com \
--cc=kinaba@google.com \
--cc=wakel@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.