From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Anshuman Khandual <anshuman.khandual@arm.com>, linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Lorenzo Stoakes <ljs@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC] mm: Add KUNIT test for ptval_bytes_to_hex_str()
Date: Thu, 1 Oct 2026 09:45:01 +0200 [thread overview]
Message-ID: <2f7a38e0-1e85-4983-9bc5-adea49f44cbc@kernel.org> (raw)
In-Reply-To: <20260929120530.3394073-1-anshuman.khandual@arm.com>
On 9/29/26 14:05, Anshuman Khandual wrote:
> Add KUnit tests for ptval_bytes_to_hex_str() to verify conversion of 32-bit
> 64-bit, and 128-bit (when supported) page table entry values into printable
> hexadecimal strings.
>
> Add a new PTVAL_HEX_STR_KUNIT_TEST option to enable the tests.
>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: David Hildenbrand <david@kernel.org>
> Cc: Lorenzo Stoakes <ljs@kernel.org>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> This patch applies on v7.3-rc5 after the following series
>
> https://lore.kernel.org/linux-mm/20260831054331.625505-1-anshuman.khandual@arm.com/
>
> mm/Kconfig | 11 +++
> mm/Makefile | 1 +
> mm/tests/ptval_hex_string_kunit.c | 111 ++++++++++++++++++++++++++++++
> 3 files changed, 123 insertions(+)
> create mode 100644 mm/tests/ptval_hex_string_kunit.c
>
> diff --git a/mm/Kconfig b/mm/Kconfig
> index 604c58199acbf..f68bf26b98c83 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -1511,6 +1511,17 @@ config LAZY_MMU_MODE_KUNIT_TEST
>
> If unsure, say N.
>
> +config PTVAL_HEX_STR_KUNIT_TEST
> + bool "KUnit tests for pgtable entry string conversion" if !KUNIT_ALL_TESTS
> + depends on KUNIT
> + default KUNIT_ALL_TESTS
> + help
> + Enable this option to check that ptval_bytes_to_hex_str() is able
> + convert given pgtable entry value in bytes into hex strings which
> + could be printed.
> +
> + If unsure, say N.
That's a bit fine grained :)
Could we somehow pack this under another existing / more generic test? We don't
want one new test for every new function :)
An alternative would be to use mm/debug_vm_pgtable.c to just run 3 tests at
runtime as well.
> +
> source "mm/damon/Kconfig"
>
> endmenu
> diff --git a/mm/Makefile b/mm/Makefile
> index e7245cb88c665..d08b8bd01917b 100644
> --- a/mm/Makefile
> +++ b/mm/Makefile
> @@ -147,4 +147,5 @@ obj-$(CONFIG_SHRINKER_DEBUG) += shrinker_debug.o
> obj-$(CONFIG_EXECMEM) += execmem.o
> obj-$(CONFIG_TMPFS_QUOTA) += shmem_quota.o
> obj-$(CONFIG_LAZY_MMU_MODE_KUNIT_TEST) += tests/lazy_mmu_mode_kunit.o
> +obj-$(CONFIG_PTVAL_HEX_STR_KUNIT_TEST) += tests/ptval_hex_string_kunit.o
> obj-$(CONFIG_MEM_ALLOC_PROFILING) += alloc_tag.o
> diff --git a/mm/tests/ptval_hex_string_kunit.c b/mm/tests/ptval_hex_string_kunit.c
> new file mode 100644
> index 0000000000000..45c203cfb49ae
> --- /dev/null
> +++ b/mm/tests/ptval_hex_string_kunit.c
> @@ -0,0 +1,111 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <kunit/test.h>
> +#include <linux/pgtable.h>
> +
> +struct ptval_str {
> + u64 val;
> + const char *str;
> +};
> +
> +static struct ptval_str ptval_u32_tests[] = {
> + { .val = 0x1234abcd, .str = "1234abcd"},
Isn't a single test like this enough. Why would we need the other ones?
So I think this could all get condensed quite a bit (including the test
functions, a single one should be sufficient if we really only end up with 3 tests).
--
Cheers,
David
next prev parent reply other threads:[~2026-10-01 7:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 12:05 Anshuman Khandual
2026-10-01 7:45 ` David Hildenbrand (Arm) [this message]
2026-10-01 8:56 ` Anshuman Khandual
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=2f7a38e0-1e85-4983-9bc5-adea49f44cbc@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@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
all inboxes | Powered by JetHome®