From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Song Hu <husong@kylinos.cn>,
akpm@linux-foundation.org, usama.anjum@arm.com
Cc: linux-mm@kvack.org, shuah@kernel.org, ljs@kernel.org,
liam@infradead.org, vbabka@kernel.org, rppt@kernel.org,
surenb@google.com, mhocko@suse.com, peterx@redhat.com,
sarthak.sharma@arm.com, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test
Date: Thu, 10 Sep 2026 11:33:20 +0200 [thread overview]
Message-ID: <316d740f-a942-4acb-a8a4-fb646effff91@kernel.org> (raw)
In-Reply-To: <20260825085756.63030-3-husong@kylinos.cn>
On 8/25/26 10:57, Song Hu wrote:
> mremap_test calls ksft_set_plan() without ksft_print_header(), and its
> get_mmap_min_addr() skip path uses a bare exit(KSFT_SKIP) that prints no
> TAP line, so its output is not valid KTAP. Add the header and switch
> the skip to ksft_exit_skip().
>
> Also fix two more KTAP compliance issues spotted in review:
>
> - get_mmap_min_addr() calls strerror(errno) after fclose(), which may
> clobber errno; save errno before fclose() instead.
>
> - Some ksft_*() messages embed "\n\t", so the text after each embedded
> newline is printed without the "# " prefix. Split those into separate
> messages.
>
> And cache mmap_min_addr in main() before ksft_set_plan(), so that the
> skip paths in get_mmap_min_addr() are taken before the plan is set; a
> skip after the plan leaves the run with fewer tests than planned.
>
> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Reviewed-by: Sarthak Sharma <sarthak.sharma@arm.com>
> Reviewed-by: Muhammad Usama Anjum <usama.anjum@arm.com>
> Tested-by: Muhammad Usama Anjum <usama.anjum@arm.com>
> Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> Signed-off-by: Song Hu <husong@kylinos.cn>
> ---
> tools/testing/selftests/mm/mremap_test.c | 43 ++++++++++++++----------
> 1 file changed, 25 insertions(+), 18 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c
> index 131d9d6db867..ab5420f2e875 100644
> --- a/tools/testing/selftests/mm/mremap_test.c
> +++ b/tools/testing/selftests/mm/mremap_test.c
> @@ -111,18 +111,17 @@ static unsigned long long get_mmap_min_addr(void)
> return addr;
>
> fp = fopen("/proc/sys/vm/mmap_min_addr", "r");
> - if (fp == NULL) {
> - ksft_print_msg("Failed to open /proc/sys/vm/mmap_min_addr: %s\n",
> - strerror(errno));
> - exit(KSFT_SKIP);
> - }
> + if (!fp)
> + ksft_exit_skip("Failed to open /proc/sys/vm/mmap_min_addr: %s\n",
> + strerror(errno));
>
> n_matched = fscanf(fp, "%llu", &addr);
> if (n_matched != 1) {
> - ksft_print_msg("Failed to read /proc/sys/vm/mmap_min_addr: %s\n",
> - strerror(errno));
> + int err = errno;
> +
> fclose(fp);
Why the local variable? And why the fclose() ?
ksft_exit_skip() will just exit the process and clean up, why clean up manually?
In other words, why not just drop the fclose?
> - exit(KSFT_SKIP);
> + ksft_exit_skip("Failed to read /proc/sys/vm/mmap_min_addr: %s\n",
> + strerror(err));
> }
>
> fclose(fp);
> @@ -1164,10 +1163,11 @@ static void run_mremap_test_case(struct test test_case, int *failures,
> rand_addr);
>
> if (remap_time < 0) {
> - if (test_case.expect_failure)
> - ksft_test_result_xfail("%s\n\tExpected mremap failure\n",
> - test_case.name);
Why can't we just drop the \n\t ?
> - else {
> + if (test_case.expect_failure) {
> + ksft_print_msg("%s: expected mremap failure\n",
> + test_case.name);
> + ksft_test_result_xfail("%s\n", test_case.name);
> + } else {
> ksft_test_result_fail("%s\n", test_case.name);
> *failures += 1;
> }
> @@ -1177,11 +1177,13 @@ static void run_mremap_test_case(struct test test_case, int *failures,
> * was faulted in.
> */
> if (threshold_mb == VALIDATION_NO_THRESHOLD ||
> - test_case.config.region_size <= threshold_mb * _1MB)
> - ksft_test_result_pass("%s\n\tmremap time: %12lldns\n",
> - test_case.name, remap_time);
Same question, why not drop the \n\t ?
--
Cheers,
David
next prev parent reply other threads:[~2026-09-10 9:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 8:57 [PATCH v4 0/3] selftests/mm: TAP output and global-state fixes Song Hu
2026-08-25 8:57 ` [PATCH v4 1/3] selftests/mm: emit TAP header in uffd-wp-mremap Song Hu
2026-09-10 9:28 ` David Hildenbrand (Arm)
2026-08-25 8:57 ` [PATCH v4 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test Song Hu
2026-09-10 9:33 ` David Hildenbrand (Arm) [this message]
2026-08-25 8:57 ` [PATCH v4 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline Song Hu
2026-08-25 9:06 ` Song Hu
2026-08-25 9:24 ` Muhammad Usama Anjum
2026-09-10 9:36 ` David Hildenbrand (Arm)
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=316d740f-a942-4acb-a8a4-fb646effff91@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=husong@kylinos.cn \
--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=peterx@redhat.com \
--cc=rppt@kernel.org \
--cc=sarthak.sharma@arm.com \
--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.