From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Audra Mitchell <audra@redhat.com>
Cc: jocolema@redhat.com, raquini@redhat.com,
Andrew Morton <akpm@linux-foundation.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Shuah Khan <shuah@kernel.org>,
Colin Ian King <colin.i.king@gmail.com>,
Muhammad Usama Anjum <usama.anjum@arm.com>,
Andrei Vagin <avagin@google.com>,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] selftests/mm: Fix soft-dirty kselftest supported check
Date: Tue, 11 Aug 2026 18:11:04 +0200 [thread overview]
Message-ID: <db04536b-a98f-4025-a095-9ca49de10e12@kernel.org> (raw)
In-Reply-To: <20260806181843.1839943-3-audra@redhat.com>
On 8/6/26 20:17, Audra Mitchell wrote:
> On architectures with separate user address space, such as s390 or
> those without an MMU, the soft-dirty kselftest may fail when checking
> to see if the feature is supported.
>
> # --------------------
> # running ./soft-dirty
> # --------------------
> # TAP version 13
> # 1..15
> # Bail out! PAGEMAP_SCAN succeeded unexpectedly
> # # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
> # [FAIL]
> not ok 1 soft-dirty # exit=1
> # SUMMARY: PASS=0 SKIP=0 FAIL=1
>
> The soft-dirty test will initate an ioctl with the PAGEMAP_SCAN flag with
> an invalid address for the page_region. This is done intentionally to
> have the ioctl return with an expected EFAULT and with the correct
> categories returned.
>
> However, on architectures with separate user address space, such as s390 or
> those without an MMU, the call to __access_ok (used to validate the
> variables provided with the ioctl) will always return true and we will not
> fail as expected.
>
> if (IS_ENABLED(CONFIG_ALTERNATE_USER_ADDRESS_SPACE) ||
> !IS_ENABLED(CONFIG_MMU))
> return true;
>
> Let's simplify the check for PAGEMAP_SCAN and provide a valid page_region
> address so that we get a non-errno return if it is supported.
>
> Fixes: 600bca580579 ("selftests/mm: check that PAGEMAP_SCAN returns correct categories")
>
> Signed-off-by: Audra Mitchell <audra@redhat.com>
> ---
> tools/testing/selftests/mm/vm_util.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c
> index 6b65bd0a1e0b..4a8e339a7403 100644
> --- a/tools/testing/selftests/mm/vm_util.c
> +++ b/tools/testing/selftests/mm/vm_util.c
> @@ -66,20 +66,25 @@ static uint64_t pagemap_scan_get_categories(int fd, char *start)
> }
>
> /* `start` is any valid address. */
Acked to dropping that.
> -static bool pagemap_scan_supported(int fd, char *start)
> +static bool pagemap_scan_supported(int fd)
> {
> + const size_t pagesize = getpagesize();
> static int supported = -1;
> - int ret;
> + struct page_region r;
> + void *test_area;
>
> if (supported != -1)
> return supported;
>
> - /* Provide an invalid address in order to trigger EFAULT. */
> - ret = __pagemap_scan_get_categories(fd, start, (struct page_region *) ~0UL);
> - if (ret == 0)
> - ksft_exit_fail_msg("PAGEMAP_SCAN succeeded unexpectedly\n");
> -
> - supported = errno == EFAULT;
> + test_area = mmap(0, pagesize, PROT_READ | PROT_WRITE,
> + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
> + if (test_area == MAP_FAILED) {
> + ksft_print_msg("WARN: mmap() failed: %s\n", strerror(errno));
> + supported = 0;
You can really just
ksft_exit_fail_msg("mmap() failed\n");
here, because this is one of the things that really should never fail.
Which leaves us with:
test_area = mmap(0, pagesize, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (test_area == MAP_FAILED)
ksft_print_msg("WARN: mmap() failed: %s\n", strerror(errno));
supported = __pagemap_scan_get_categories(fd, test_area, &r) >= 0;
munmap(test_area, pagesize);
--
Cheers,
David
next prev parent reply other threads:[~2026-08-11 16:11 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 18:42 [PATCH] selftests/mm: Fix soft-dirty kselftest supported check Audra Mitchell
2026-02-24 16:15 ` David Hildenbrand (Arm)
2026-03-17 15:08 ` Audra Mitchell
2026-03-18 8:17 ` David Hildenbrand (Arm)
2026-03-19 18:59 ` Audra Mitchell
2026-03-20 11:26 ` David Hildenbrand (Arm)
2026-03-20 18:39 ` [PATCH V2] " Audra Mitchell
2026-03-20 18:39 ` [PATCH] " Audra Mitchell
2026-03-20 20:53 ` Andrew Morton
2026-03-23 11:56 ` David Hildenbrand (Arm)
2026-03-24 23:23 ` Andrew Morton
2026-03-24 23:24 ` Andrew Morton
2026-03-25 16:23 ` Audra Mitchell
2026-03-27 10:08 ` David Hildenbrand (Arm)
[not found] ` <20260806181843.1839943-1-audra@redhat.com>
2026-08-06 18:17 ` [PATCH 1/2] Correct __pagemap_scan_get_categories return value Audra Mitchell
2026-08-06 19:27 ` Andrew Morton
2026-08-11 16:08 ` David Hildenbrand (Arm)
2026-08-06 18:17 ` [PATCH 2/2] selftests/mm: Fix soft-dirty kselftest supported check Audra Mitchell
2026-08-06 18:46 ` Andrew Morton
2026-08-11 16:11 ` David Hildenbrand (Arm) [this message]
2026-03-27 10:52 ` [PATCH] " Lorenzo Stoakes (Oracle)
2026-03-27 10:58 ` Lorenzo Stoakes (Oracle)
2026-03-27 11:15 ` Lorenzo Stoakes (Oracle)
2026-03-27 11:14 ` Lorenzo Stoakes (Oracle)
2026-03-31 16:32 ` Audra Mitchell
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=db04536b-a98f-4025-a095-9ca49de10e12@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=audra@redhat.com \
--cc=avagin@google.com \
--cc=colin.i.king@gmail.com \
--cc=jocolema@redhat.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=raquini@redhat.com \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=usama.anjum@arm.com \
--cc=vbabka@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.