From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D082606A33B for ; Wed, 2 Dec 2026 08:22:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=lists.linux.it header.i=@lists.linux.it header.a=rsa-sha256 header.s=picard header.b=Ne516eIz; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=PhHFOOWd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.linux.it; i=@lists.linux.it; q=dns/txt; s=picard; t=1796199735; h=date : in-reply-to : mime-version : references : message-id : to : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : from : reply-to : cc : content-type : content-transfer-encoding : sender : from; bh=KXiKq7RSFUGAvRHyykpRFpG2Dh6sgqyakTS8+aId3m8=; b=Ne516eIzQ1FHX2f1Bty681HYWPtPBkA8S7QI2vBjBmJCDgXMtE6pGEDpQQhQ3p1+kzRUf aI8IsdVDytwniX011zZyvIp6xz4K+8IPOyrjVg3lFlSqydgDR6Kbg1jDbKshKCJjjJq6zGC ywwHC3W1vTYPGb5xEv0ZQYtfZ+5drVM= Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D05B23E7475 for ; Wed, 2 Dec 2026 09:22:15 +0100 (CET) Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id F07623E743C for ; Wed, 2 Dec 2026 09:21:40 +0100 (CET) Received: from mail-wm1-x346.google.com (mail-wm1-x346.google.com [IPv6:2a00:1450:4864:20::346]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 5982B600BD9 for ; Wed, 2 Dec 2026 09:21:40 +0100 (CET) Received: by mail-wm1-x346.google.com with SMTP id 5b1f17b1804b1-4a4654add56so87881115e9.2 for ; Wed, 02 Dec 2026 00:21:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796199700; x=1796804500; darn=lists.linux.it; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=h2NGwmaMR+NiVP8fPmVekL9VwOAAUQqhUTB/mCWLKug=; b=PhHFOOWdjlESGLednfa9wrQlO9F0ZN+MpN6F1YkUtsGkfVAnmALFYog1Gjp6ww7I9h RhULnrplhgNUKRNLUwM9hrOxjHtPZNSBWrCWvVAlkBeZAFrBBFo2nme9J2dqMsdqP28f G7KGap1HuNPNMHIHjO0Ru6bXpsGKp18tPLll4ygu4GkgEVwgXgdeqy/otkYzlYen5BWS pCYC+GLrCgsaV4rJa8f+NLmkxDAVThoBygU8T9syh7pGEB9udoHYp2aDpxFIcpsfgjmA 0qL13oH1cZkD2eHPwi1iolwVlgNxZQa1/zzKYMaalgBRPH7o7LKdbAqhAIPRb7Nz/GkA IfPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796199700; x=1796804500; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=h2NGwmaMR+NiVP8fPmVekL9VwOAAUQqhUTB/mCWLKug=; b=BiThfviSJJMF325JBm5fR1scxq6xh/1AfO8MA9dqZDtqElfSmjD2daC4YEcsjHiCYU UE7R+mrQuGBW5sdhYJNoTKqPkuD2bw3q23jaorif6yizk2b/lhuqXkcOw0/WPQe+o8qM kzSIFRJbimtUM2BiyTyeM9Bjc6qogT46OX6pRUTAxhVFpuLY2FBuZQ1jTbKBocza6hTD /ipQ9UC4ki37D5ma3q89kYylJRq/HEea7efSwcoNIqxIsPRZLJ1W5B2Y+Ye/zW3Aslpv 9nugWzaBpD1hFoOU8YdH468FMWmXYuQPEWj8Fyjj+jVe238k14r4ZmQf3Kah2ESrWhuo h1rg== X-Gm-Message-State: APuU4Z9/dwUXwRqlfsv1NkAf84m4gzazZzgb1TFIks4vig4IwkXe8QXe +oq5EMb20jLiRepw6gr+GCoZDHCbxxDY9gNm20fl/8DZOph0xe74DhL3zjXSIqUFbUfyq+uAC0O IkAVZBkZr0R+2TyFwjAWYAJW6MT8BxaaCf8xDBra9XX1WIolnxpU34hyoTQ0YP1AOzhEQSpS5y2 GmMEk1eE0GCqrUuRpILu/WMASfo1lTRr4= X-Received: from wrun18.prod.google.com ([2002:a5d:6612:0:b0:4c7:ffb:3596]) (user=hmazur job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1389:b0:4af:83ad:8f70 with SMTP id 5b1f17b1804b1-4bb88924f66mr777421985e9.35.1796199699590; Wed, 02 Dec 2026 00:21:39 -0800 (PST) Date: Wed, 2 Dec 2026 08:21:38 +0000 In-Reply-To: <20261120093444.609481-1-hmazur@google.com> X-Archived-By: Mime-Version: 1.0 References: <20261120093444.609481-1-hmazur@google.com> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261202082138.529331-1-hmazur@google.com> To: Linux Test Project X-Spam-Status: No, score=-24.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Virus-Scanned: clamav-milter 1.0.9 at in-5.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2] sys_cpu_topology02: Drop upper bound on core_id X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Archive: List-Post: List-Help: List-Subscribe: , From: Hubert Mazur via ltp Reply-To: Hubert Mazur Cc: Hubert Mazur , Kazuhiro Inaba , Wake Liu , Grzegorz Jaszczyk Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "ltp" 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 --- Changes since v1: - Rebased onto commit b603b3a875a9 ("sys_cpu_topology02: Use kernel_tree to link to git.kernel.org"). - Wrapped Documentation/ABI/stable/sysfs-devices-system-cpu in the :kernel_tree: Sphinx role. - Kept poss_max_id and the tst_is_virt(VIRT_ANY) / pkg_max_id check in do_test(), since they are still used to bound physical_package_id on bare metal (omitted Petr's conditional Reviewed-by pending confirmation on keeping that check). .../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 ae7694aa9..0abae33bf 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 @@ * 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 + * :kernel_tree:`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