Re: [PATCH 2/3] selftests/resctrl: Fix a division by zero error on Hygon
From: Reinette Chatre
Date: Thu Dec 04 2025 - 19:56:29 EST
Hi Xiaochen,
On 12/4/25 4:38 AM, Xiaochen Shen wrote:
> 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 /= 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 with SNC enabled")
> Signed-off-by: Xiaochen Shen <shenxiaochen@xxxxxxxxxxxxxx>
> ---
Could you please include Shuah Khan <shuah@xxxxxxxxxx> and linux-kselftest@xxxxxxxxxxxxxxx
in resctrl selftest posts?
Reviewed-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Reinette