[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f0711fe8-88e9-4634-98ee-1e37453a7e53@linux.alibaba.com>
Date: Mon, 11 Aug 2025 15:52:25 +0800
From: Baolin Wang <baolin.wang@...ux.alibaba.com>
To: Zi Yan <ziy@...dia.com>, Wei Yang <richard.weiyang@...il.com>,
wang lian <lianux.mm@...il.com>, David Hildenbrand <david@...hat.com>,
linux-mm@...ck.org
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>, Nico Pache <npache@...hat.com>,
Ryan Roberts <ryan.roberts@....com>, Dev Jain <dev.jain@....com>,
Barry Song <baohua@...nel.org>, Vlastimil Babka <vbabka@...e.cz>,
Mike Rapoport <rppt@...nel.org>, Suren Baghdasaryan <surenb@...gle.com>,
Michal Hocko <mhocko@...e.com>, Shuah Khan <shuah@...nel.org>,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH v2 2/3] selftests/mm: add check_folio_orders() helper.
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@...dia.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;
> +}
> +
> /* If `ioctls' non-NULL, the allowed ioctls will be returned into the var */
> int uffd_register_with_ioctls(int uffd, void *addr, uint64_t len,
> bool miss, bool wp, bool minor, uint64_t *ioctls)
> diff --git a/tools/testing/selftests/mm/vm_util.h b/tools/testing/selftests/mm/vm_util.h
> index 1843ad48d32b..02e3f1e7065b 100644
> --- a/tools/testing/selftests/mm/vm_util.h
> +++ b/tools/testing/selftests/mm/vm_util.h
> @@ -18,6 +18,11 @@
> #define PM_SWAP BIT_ULL(62)
> #define PM_PRESENT BIT_ULL(63)
>
> +#define KPF_COMPOUND_HEAD BIT_ULL(15)
> +#define KPF_COMPOUND_TAIL BIT_ULL(16)
> +#define KPF_THP BIT_ULL(22)
> +
> +
> /*
> * Ignore the checkpatch warning, we must read from x but don't want to do
> * anything with it in order to trigger a read page fault. We therefore must use
> @@ -85,6 +90,8 @@ bool check_huge_shmem(void *addr, int nr_hpages, uint64_t hpage_size);
> int64_t allocate_transhuge(void *ptr, int pagemap_fd);
> unsigned long default_huge_page_size(void);
> int detect_hugetlb_page_sizes(size_t sizes[], int max);
> +int check_folio_orders(char *vaddr_start, size_t len, int pagemap_file,
> + int kpageflags_file, int orders[], int nr_orders);
>
> int uffd_register(int uffd, void *addr, uint64_t len,
> bool miss, bool wp, bool minor);
Powered by blists - more mailing lists