Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Fenghua Yu <fenghuay@nvidia.com>
To: Xiaochen Shen <shenxiaochen@open-hieco.net>,
	tony.luck@intel.com, reinette.chatre@intel.com, bp@alien8.de,
	shuah@kernel.org, skhan@linuxfoundation.org
Cc: babu.moger@amd.com, james.morse@arm.com, Dave.Martin@arm.com,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v2 2/3] selftests/resctrl: Fix a division by zero error on Hygon
Date: Fri, 5 Dec 2025 10:53:00 -0800	[thread overview]
Message-ID: <00ec47f1-194b-4d85-8c8b-3200b918e1d3@nvidia.com> (raw)
In-Reply-To: <20251205092544.2685728-3-shenxiaochen@open-hieco.net>

Hi, Xiaochen,

On 12/5/25 01:25, 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@open-hieco.net>
> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
> ---
>   tools/testing/selftests/resctrl/resctrlfs.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/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 = cache_cpus / node_cpus;
>   
> +		/*
> +		 * On certain Hygon platforms:

nit. This situation could happen on other platforms than Hygon. Maybe 
it's better to have a more generic comment here?
		 * On some platforms (e.g. Hygon),

Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>

> +		 * cache_cpus < node_cpus, the calculated snc_mode is 0.
> +		 *
> +		 * Set snc_mode = 1 to indicate that SNC mode is not
> +		 * supported on the platform.
> +		 */
> +		if (!snc_mode)
> +			snc_mode = 1;
> +
>   		if (snc_mode > 1)
>   			ksft_print_msg("SNC-%d mode discovered.\n", snc_mode);
>   	}
Thanks.
-Fenghua

  reply	other threads:[~2025-12-05 18:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-05  9:25 [PATCH v2 0/3] selftests/resctrl: Add Hygon CPUs support and bug fixes Xiaochen Shen
2025-12-05  9:25 ` [PATCH v2 1/3] selftests/resctrl: Add CPU vendor detection for Hygon Xiaochen Shen
2025-12-05 19:28   ` Fenghua Yu
2025-12-08  8:01     ` Xiaochen Shen
2025-12-08 17:57       ` Reinette Chatre
2025-12-09  6:10         ` Xiaochen Shen
2025-12-09 23:02           ` Reinette Chatre
2025-12-09 23:42             ` Luck, Tony
2025-12-10  0:30               ` Reinette Chatre
2025-12-10  4:46             ` Xiaochen Shen
2025-12-05  9:25 ` [PATCH v2 2/3] selftests/resctrl: Fix a division by zero error on Hygon Xiaochen Shen
2025-12-05 18:53   ` Fenghua Yu [this message]
2025-12-08  2:27     ` Xiaochen Shen
2025-12-05  9:25 ` [PATCH v2 3/3] selftests/resctrl: Fix non-contiguous CBM check for Hygon Xiaochen Shen
2025-12-05 19:39   ` Fenghua Yu
2025-12-05 21:30     ` Reinette Chatre
2025-12-05 21:51       ` Fenghua Yu
2025-12-08  8:06     ` Xiaochen Shen

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=00ec47f1-194b-4d85-8c8b-3200b918e1d3@nvidia.com \
    --to=fenghuay@nvidia.com \
    --cc=Dave.Martin@arm.com \
    --cc=babu.moger@amd.com \
    --cc=bp@alien8.de \
    --cc=james.morse@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=reinette.chatre@intel.com \
    --cc=shenxiaochen@open-hieco.net \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox