From: Sayali Patil <sayalip@linux.ibm.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Shuah Khan <shuah@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Ritesh Harjani <ritesh.list@gmail.com>
Cc: Zi Yan <ziy@nvidia.com>, Michal Hocko <mhocko@kernel.org>,
Oscar Salvador <osalvador@suse.de>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Dev Jain <dev.jain@arm.com>,
Liam.Howlett@oracle.com, linuxppc-dev@lists.ozlabs.org,
Miaohe Lin <linmiaohe@huawei.com>,
Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Subject: Re: [PATCH 2/2] selftests/mm: fix ksm NUMA merge test for systems with memoryless NUMA nodes
Date: Tue, 30 Jun 2026 15:04:32 +0530 [thread overview]
Message-ID: <d8fd276a-0666-4fdc-b7d0-cf2557a52cb7@linux.ibm.com> (raw)
In-Reply-To: <8663e05b-0e54-4c1a-a7d1-94e49f2ca178@kernel.org>
On 26/06/26 21:25, David Hildenbrand (Arm) wrote:
>>
>> +static int count_mem_nodes(void)
>> +{
>> + int node, count = 0;
>> +
>> + for (node = 0; node <= numa_max_node(); node++) {
>> + if (numa_node_size(node, NULL) > 0)
>> + count++;
>> + }
>> +
>> + return count;
>> +}
>> +
>
> Can we instead build upon our existing helpers get_first_mem_node() +
> get_next_mem_node() ?
>
> From 432774fb50237519c1c041e402fddfdf4b35aa2c Mon Sep 17 00:00:00 2001
> From: "David Hildenbrand (Arm)" <david@kernel.org>
> Date: Fri, 26 Jun 2026 17:52:21 +0200
> Subject: [PATCH] tmp
>
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
> ---
> tools/testing/selftests/mm/ksm_tests.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/ksm_tests.c b/tools/testing/selftests/mm/ksm_tests.c
> index a050f4840cfa3..2ebbb544c6711 100644
> --- a/tools/testing/selftests/mm/ksm_tests.c
> +++ b/tools/testing/selftests/mm/ksm_tests.c
> @@ -440,9 +440,9 @@ static int get_next_mem_node(int node)
> mem_node = i % (max_node + 1);
> node_size = numa_node_size(mem_node, NULL);
> if (node_size > 0)
> - break;
> + return mem_node;
> }
> - return mem_node;
> + return -ENODEV;
> }
>
> static int get_first_mem_node(void)
> @@ -455,8 +455,8 @@ static int check_ksm_numa_merge(int merge_type, int mapping, int prot, int timeo
> {
> void *numa1_map_ptr, *numa2_map_ptr;
> struct timespec start_time;
> + int first_node, second_node;
> int page_count = 2;
> - int first_node;
>
> if (clock_gettime(CLOCK_MONOTONIC_RAW, &start_time)) {
> ksft_perror("clock_gettime");
> @@ -467,17 +467,19 @@ static int check_ksm_numa_merge(int merge_type, int mapping, int prot, int timeo
> ksft_print_msg("NUMA support not enabled\n");
> return KSFT_SKIP;
> }
> - if (numa_num_configured_nodes() <= 1) {
> - ksft_print_msg("At least 2 NUMA nodes must be available\n");
> + first_node = get_first_mem_node();
> + second_node = get_next_mem_node(first_node);
> +
> + if (second_node < 0) {
> + ksft_print_msg("At least 2 NUMA nodes with memory must be available\n");
> return KSFT_SKIP;
> }
> if (ksm_write_sysfs(KSM_FP("merge_across_nodes"), merge_across_nodes))
> return KSFT_FAIL;
>
> /* allocate 2 pages in 2 different NUMA nodes and fill them with the same data */
> - first_node = get_first_mem_node();
> numa1_map_ptr = numa_alloc_onnode(page_size, first_node);
> - numa2_map_ptr = numa_alloc_onnode(page_size, get_next_mem_node(first_node));
> + numa2_map_ptr = numa_alloc_onnode(page_size, second_node);
> if (!numa1_map_ptr || !numa2_map_ptr) {
> ksft_perror("numa_alloc_onnode");
> return KSFT_FAIL;
Hi David,
Thanks for review!
Yes, I updated the implementation in v2 to use the existing
get_first_mem_node() + get_next_mem_node() helper as suggested.
V2:https://lore.kernel.org/all/878cbc1dd24921d55049932dcd5fd6ee517557ca.1782811071.git.sayalip@linux.ibm.com/
prev parent reply other threads:[~2026-06-30 9:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 12:40 [PATCH 0/2] selftests/mm: avoid false failures in hugetlb and KSM tests Sayali Patil
2026-06-25 12:40 ` [PATCH 1/2] selftests/mm: handle EINVAL when configuring gigantic hugepages Sayali Patil
2026-06-26 14:48 ` Usama Arif
2026-06-30 9:35 ` Sayali Patil
2026-06-25 12:40 ` [PATCH 2/2] selftests/mm: fix ksm NUMA merge test for systems with memoryless NUMA nodes Sayali Patil
2026-06-26 15:55 ` David Hildenbrand (Arm)
2026-06-30 9:34 ` Sayali Patil [this message]
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=d8fd276a-0666-4fdc-b7d0-cf2557a52cb7@linux.ibm.com \
--to=sayalip@linux.ibm.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@kernel.org \
--cc=osalvador@suse.de \
--cc=ritesh.list@gmail.com \
--cc=shuah@kernel.org \
--cc=venkat88@linux.ibm.com \
--cc=ziy@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox