From nobody Fri Dec 19 17:55:47 2025 Received: from out28-148.mail.aliyun.com (out28-148.mail.aliyun.com [115.124.28.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4DE22D47EF for ; Thu, 4 Dec 2025 12:54:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.28.148 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764852882; cv=none; b=mu4x3itidA6bw5uJvzlqwYZ9XdgZ8hpmm3wXeLAXf7vQU+geJO0wRREThYeVpJ6dqi+2lvtuVLbi9X6m9NlgLf5csmF4qm47Fj0Ou46PxrL9CCGth27L1sazEqwqckB0ptBdNApsmQc+8aPXttCVupdmiNgK4E2CVg6g+XSdAZc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764852882; c=relaxed/simple; bh=3BmtIOIP+Irez+lMYsdyrX2HlvMPJ1YT+eAVPsYSjvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jExYlQqER7CGVelDpqN4hIeO5m1GN2FCKN4XLw0tFPk+7nWRG5A/67rhtCIIw1d0A18jjpjP6irfbKfcxNR8ehc0T8sF9euPY+e/KJgZ2nE2dGL0wwudzuk3MHspDbjDTxZD/Ug+9wCKy6179hylVQwhHB/gup0FAeDqVKtrQA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=open-hieco.net; spf=pass smtp.mailfrom=open-hieco.net; arc=none smtp.client-ip=115.124.28.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=open-hieco.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=open-hieco.net Received: from localhost.localdomain(mailfrom:shenxiaochen@open-hieco.net fp:SMTPD_---.fcqdLc5_1764851933 cluster:ay29) by smtp.aliyun-inc.com; Thu, 04 Dec 2025 20:38:55 +0800 From: Xiaochen Shen To: tony.luck@intel.com, reinette.chatre@intel.com, bp@alien8.de, fenghuay@nvidia.com Cc: babu.moger@amd.com, james.morse@arm.com, Dave.Martin@arm.com, x86@kernel.org, linux-kernel@vger.kernel.org, shenxiaochen@open-hieco.net Subject: [PATCH 1/3] selftests/resctrl: Add CPU vendor detection for Hygon Date: Thu, 4 Dec 2025 20:38:14 +0800 Message-ID: <20251204123816.2802393-2-shenxiaochen@open-hieco.net> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251204123816.2802393-1-shenxiaochen@open-hieco.net> References: <20251204123816.2802393-1-shenxiaochen@open-hieco.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The resctrl selftest currently fails on Hygon CPUs that support Platform QoS features, printing the error: "# Can not get vendor info..." This occurs because vendor detection is missing for Hygon CPUs. Fix this by extending the CPU vendor detection logic to include Hygon's vendor ID. Signed-off-by: Xiaochen Shen --- tools/testing/selftests/resctrl/resctrl.h | 1 + tools/testing/selftests/resctrl/resctrl_tests.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/self= tests/resctrl/resctrl.h index cd3adfc14969..df2a59e0141e 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -38,6 +38,7 @@ */ #define ARCH_INTEL 1 #define ARCH_AMD 2 +#define ARCH_HYGON 3 =20 #define END_OF_TESTS 1 =20 diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testin= g/selftests/resctrl/resctrl_tests.c index 5154ffd821c4..9bf35f3beb6b 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -42,6 +42,8 @@ static int detect_vendor(void) vendor_id =3D ARCH_INTEL; else if (s && !strcmp(s, ": AuthenticAMD\n")) vendor_id =3D ARCH_AMD; + else if (s && !strcmp(s, ": HygonGenuine\n")) + vendor_id =3D ARCH_HYGON; =20 fclose(inf); free(res); --=20 2.47.3 From nobody Fri Dec 19 17:55:47 2025 Received: from out28-74.mail.aliyun.com (out28-74.mail.aliyun.com [115.124.28.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6863F33ADBF for ; Thu, 4 Dec 2025 12:54:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.28.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764852886; cv=none; b=V2jP2Vp8aOWVTq1XlTuivzCZJFOfYIW6CAlSVkwi/RldSQ7OZO1TC/ZZd9FS9gs8WDEGzp/8/aqsLzr/c67L0SwyDRExZOPuBZP0JZX0ZO2IYwT4oUKIOKiB65LH65ar42m9PRCo4GrtOBHMikbWXmMc2irT1Qdgdt7hxlaFtmo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764852886; c=relaxed/simple; bh=5HluE/OJBzH5/xGQiEDcCuDjz+mpxA0ShvC+6bNLf1w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W9Pc2ACoedDLuAtXd3FoilhDHhdGUYo5H9cXiR4PHB126STPY/yLSNWm2ch6y9DVTYjcLSduMud/4mqlwjsEJIJgep/yMdNZl00n+a5HA5iPmUdrbrvU3ydsl0/IsKZ5Uhu0A/81Sze0aUT4fbVLdDSVxd+YAme8w38njurjNis= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=open-hieco.net; spf=pass smtp.mailfrom=open-hieco.net; arc=none smtp.client-ip=115.124.28.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=open-hieco.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=open-hieco.net Received: from localhost.localdomain(mailfrom:shenxiaochen@open-hieco.net fp:SMTPD_---.fcqdLfM_1764851936 cluster:ay29) by smtp.aliyun-inc.com; Thu, 04 Dec 2025 20:38:58 +0800 From: Xiaochen Shen To: tony.luck@intel.com, reinette.chatre@intel.com, bp@alien8.de, fenghuay@nvidia.com Cc: babu.moger@amd.com, james.morse@arm.com, Dave.Martin@arm.com, x86@kernel.org, linux-kernel@vger.kernel.org, shenxiaochen@open-hieco.net Subject: [PATCH 2/3] selftests/resctrl: Fix a division by zero error on Hygon Date: Thu, 4 Dec 2025 20:38:15 +0800 Message-ID: <20251204123816.2802393-3-shenxiaochen@open-hieco.net> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251204123816.2802393-1-shenxiaochen@open-hieco.net> References: <20251204123816.2802393-1-shenxiaochen@open-hieco.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit a1cd99e700ec ("selftests/resctrl: Adjust effective L3 cache size with SNC= enabled") introduced the snc_nodes_per_l3_cache() function to detect the Intel Sub-NUMA Clustering (SNC) feature by comparing #CPUs in node0 with #CPUs sharing LLC with CPU0. The function was designed to return: (1) >1: SNC mode is enabled. (2) 1: SNC mode is not enabled or not supported. However, on certain Hygon CPUs, #CPUs sharing LLC with CPU0 is actually less than #CPUs in node0. This results in snc_nodes_per_l3_cache() returning 0 (calculated as cache_cpus / node_cpus). This leads to a division by zero error in get_cache_size(): *cache_size /=3D snc_nodes_per_l3_cache(); Causing the resctrl selftest to fail with: "Floating point exception (core dumped)" Fix the issue by ensuring snc_nodes_per_l3_cache() returns 1 when SNC mode is not supported on the platform. Fixes: a1cd99e700ec ("selftests/resctrl: Adjust effective L3 cache size wit= h SNC enabled") Signed-off-by: Xiaochen Shen Reviewed-by: Reinette Chatre --- tools/testing/selftests/resctrl/resctrlfs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/se= lftests/resctrl/resctrlfs.c index 195f04c4d158..2b075e7334bf 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -243,6 +243,16 @@ int snc_nodes_per_l3_cache(void) } snc_mode =3D cache_cpus / node_cpus; =20 + /* + * On certain Hygon platforms: + * cache_cpus < node_cpus, the calculated snc_mode is 0. + * + * Set snc_mode =3D 1 to indicate that SNC mode is not + * supported on the platform. + */ + if (!snc_mode) + snc_mode =3D 1; + if (snc_mode > 1) ksft_print_msg("SNC-%d mode discovered.\n", snc_mode); } --=20 2.47.3 From nobody Fri Dec 19 17:55:47 2025 Received: from out28-194.mail.aliyun.com (out28-194.mail.aliyun.com [115.124.28.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A344B346798 for ; Thu, 4 Dec 2025 13:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.28.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764855625; cv=none; b=uCF/5V/LsI3LvNdEfJ6bGbpkIiSgK/pcTQongFR2rM4xXym834U7KH///QR0Ju2Gl5VtDrWlgpFWwXY70YbM+hiRmaERtzvAe4fWA6sv3I+QivP68SrccD4Shig5u+m9egWKboJVGilmOgshYHqDPHdbhC9BygkgExMWo18kaVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764855625; c=relaxed/simple; bh=VWx38NFrIJ0jhAc1U4XU4nDDaU59fsQ+vKAmPcCu/6k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JxyzymrjJR+Mn4RWu7Q3+O1PkOlMcZrFd42UlLt/S9idAqkiSqsu9D0zZCncYnb+mxdHMtW43tUm1UAvv/HP996sOdEvAhIUGQzT+X2nlKZCMyjcuCpu1ht6RNeT8tmMP1f0pVTQGZG97XzQjodkTYGDopPNBwKYZt5f3rfU+JA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=open-hieco.net; spf=pass smtp.mailfrom=open-hieco.net; arc=none smtp.client-ip=115.124.28.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=open-hieco.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=open-hieco.net Received: from localhost.localdomain(mailfrom:shenxiaochen@open-hieco.net fp:SMTPD_---.fcqdLih_1764851939 cluster:ay29) by smtp.aliyun-inc.com; Thu, 04 Dec 2025 20:39:01 +0800 From: Xiaochen Shen To: tony.luck@intel.com, reinette.chatre@intel.com, bp@alien8.de, fenghuay@nvidia.com Cc: babu.moger@amd.com, james.morse@arm.com, Dave.Martin@arm.com, x86@kernel.org, linux-kernel@vger.kernel.org, shenxiaochen@open-hieco.net Subject: [PATCH 3/3] selftests/resctrl: Fix non-contiguous CBM check for Hygon Date: Thu, 4 Dec 2025 20:38:16 +0800 Message-ID: <20251204123816.2802393-4-shenxiaochen@open-hieco.net> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251204123816.2802393-1-shenxiaochen@open-hieco.net> References: <20251204123816.2802393-1-shenxiaochen@open-hieco.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The resctrl selftest currently fails on Hygon CPUs that always supports non-contiguous CBM, printing the error: "# Hardware and kernel differ on non-contiguous CBM support!" This occurs because the arch_supports_noncont_cat() function lacks vendor detection for Hygon CPUs, preventing proper identification of their non-contiguous CBM capability. Fix this by adding Hygon vendor ID detection to arch_supports_noncont_cat(). Signed-off-by: Xiaochen Shen Reviewed-by: Reinette Chatre --- tools/testing/selftests/resctrl/cat_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/sel= ftests/resctrl/cat_test.c index 94cfdba5308d..59a0f80fdc5a 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -290,8 +290,8 @@ static int cat_run_test(const struct resctrl_test *test= , const struct user_param =20 static bool arch_supports_noncont_cat(const struct resctrl_test *test) { - /* AMD always supports non-contiguous CBM. */ - if (get_vendor() =3D=3D ARCH_AMD) + /* AMD and Hygon always supports non-contiguous CBM. */ + if (get_vendor() =3D=3D ARCH_AMD || get_vendor() =3D=3D ARCH_HYGON) return true; =20 #if defined(__i386__) || defined(__x86_64__) /* arch */ --=20 2.47.3