linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zi Yan <ziy@nvidia.com>
To: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Wei Yang <richard.weiyang@gmail.com>,
	wang lian <lianux.mm@gmail.com>,
	David Hildenbrand <david@redhat.com>,
	linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Nico Pache <npache@redhat.com>,
	Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
	Barry Song <baohua@kernel.org>, Vlastimil Babka <vbabka@suse.cz>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>, Shuah Khan <shuah@kernel.org>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v2 2/3] selftests/mm: add check_folio_orders() helper.
Date: Mon, 11 Aug 2025 14:41:04 -0400	[thread overview]
Message-ID: <4A5AF314-A688-4E7C-B5F3-19E6D8093DD7@nvidia.com> (raw)
In-Reply-To: <f0711fe8-88e9-4634-98ee-1e37453a7e53@linux.alibaba.com>

On 11 Aug 2025, at 3:52, Baolin Wang wrote:

> On 2025/8/9 03:01, Zi Yan wrote:
>> The helper gathers an folio order statistics of folios within a virtual
>> address range and checks it against a given order list. It aims to provide
>> a more precise folio order check instead of just checking the existence of
>> PMD folios.
>>
>> Signed-off-by: Zi Yan <ziy@nvidia.com>
>> ---
>>   .../selftests/mm/split_huge_page_test.c       |   4 +-
>>   tools/testing/selftests/mm/vm_util.c          | 133 ++++++++++++++++++
>>   tools/testing/selftests/mm/vm_util.h          |   7 +
>>   3 files changed, 141 insertions(+), 3 deletions(-)
>>
>
> [snip]
>
>> +
>> +int check_folio_orders(char *vaddr_start, size_t len, int pagemap_file,
>> +			int kpageflags_file, int orders[], int nr_orders)
>> +{
>> +	int *vaddr_orders;
>> +	int status;
>> +	int i;
>> +
>> +	vaddr_orders = (int *)malloc(sizeof(int) * nr_orders);
>> +
>> +	if (!vaddr_orders)
>> +		ksft_exit_fail_msg("Cannot allocate memory for vaddr_orders");
>> +
>> +	memset(vaddr_orders, 0, sizeof(int) * nr_orders);
>> +	status = gather_folio_orders(vaddr_start, len, pagemap_file,
>> +				     kpageflags_file, vaddr_orders, nr_orders);
>> +	if (status)
>
> Missed calling free(vaddr_orders) before returning.
>
>> +		return status;
>> +
>> +	status = 0;
>> +	for (i = 0; i < nr_orders; i++)
>> +		if (vaddr_orders[i] != orders[i]) {
>> +			ksft_print_msg("order %d: expected: %d got %d\n", i,
>> +				       orders[i], vaddr_orders[i]);
>> +			status = -1;
>> +		}
>> +
>
> Ditto.
>
>> +	return status;
>> +}
>> +

Will add free() in the above two locations. Thank you for spotting them.

Best Regards,
Yan, Zi


  reply	other threads:[~2025-08-11 18:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-08 19:01 [PATCH v2 0/3] Better split_huge_page_test result check Zi Yan
2025-08-08 19:01 ` [PATCH v2 1/3] mm/huge_memory: add new_order and offset to split_huge_pages*() pr_debug Zi Yan
2025-08-09 18:45   ` Wei Yang
2025-08-10 16:55   ` Donet Tom
2025-08-11  1:32   ` wang lian
2025-08-11  6:45   ` Baolin Wang
2025-08-11  6:58   ` Barry Song
2025-08-11  7:55   ` David Hildenbrand
2025-08-08 19:01 ` [PATCH v2 2/3] selftests/mm: add check_folio_orders() helper Zi Yan
2025-08-09 20:18   ` Wei Yang
2025-08-11 18:39     ` Zi Yan
2025-08-11 21:28       ` Wei Yang
2025-08-10 16:49   ` Donet Tom
2025-08-11 18:40     ` Zi Yan
2025-08-11  7:52   ` Baolin Wang
2025-08-11 18:41     ` Zi Yan [this message]
2025-08-08 19:01 ` [PATCH v2 3/3] selftests/mm: check after-split folio orders in split_huge_page_test Zi Yan
2025-08-10 16:53   ` Donet Tom
2025-08-11 18:20     ` Zi Yan

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=4A5AF314-A688-4E7C-B5F3-19E6D8093DD7@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@redhat.com \
    --cc=dev.jain@arm.com \
    --cc=lianux.mm@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mhocko@suse.com \
    --cc=npache@redhat.com \
    --cc=richard.weiyang@gmail.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    /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