From: Sarthak Sharma <sarthak.sharma@arm.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: 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>,
John Hubbard <jhubbard@nvidia.com>,
Kalesh Singh <kaleshsingh@google.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Park Tae-sun <ts930@dgu.ac.kr>,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RESEND 1/9] selftests/mm: mremap_test: use kselftest helpers
Date: Tue, 29 Sep 2026 14:42:47 +0530 [thread overview]
Message-ID: <498b8fc3-ef39-424c-81b1-aa4bfdb7eac7@arm.com> (raw)
In-Reply-To: <6c349d10-2160-4166-8b63-3d60b42a5b69@kernel.org>
Hi David!
On 9/29/26 1:28 PM, David Hildenbrand (Arm) wrote:
> On 9/24/26 07:00, Sarthak Sharma wrote:
>> mremap_test currently uses a lot of fprintf() and perror()
>> calls. It also uses a variable "failures" to track the number
>> of failed table driven tests.
>>
>> Use ksft_print_msg() and ksft_perror() for diagnostics.
>> Remove the variable "failures" and let kselftest counters
>> handle the final exit status. Use ksft_finished() at
>> the end instead of manually checking if failures > 0. Replace
>>
>> if (success)
>> ksft_test_result_pass(...);
>> else
>> ksft_test_result_fail(...);
>>
>> calls with ksft_test_result(success, ...);
>>
>> Also correct the duplicated "mremap" in "mremap move within
>> range" and the spelling of "dontunmap".
>>
>> Signed-off-by: Sarthak Sharma <sarthak.sharma@arm.com>
>> ---
>
> [...]
>
>> #endif /* __NR_userfaultfd */
>>
>> @@ -1124,7 +1096,7 @@ static void mremap_move_1mb_from_start(unsigned int pattern_seed,
>> void *new_ptr = mremap(src + SIZE_MB(1), SIZE_MB(1), SIZE_MB(1),
>> MREMAP_MAYMOVE | MREMAP_FIXED, dest + SIZE_MB(1));
>> if (new_ptr == MAP_FAILED) {
>> - perror("mremap");
>> + ksft_perror("mremap");
>> success = 0;
>> goto out;
>> }
>> @@ -1145,59 +1117,49 @@ static void mremap_move_1mb_from_start(unsigned int pattern_seed,
>>
>> out:
>> if (src && munmap(src, c.region_size) == -1)
>
> While at it ... why the comparison with -1. And why do we worry about munmap()
> failing at all? We generally ignore these errors on the exit path, as it's
> unlikely we would ever hit them, and there isn't a lot we can do.
>
> So maybe just remove printing errors entirely?
>
> if (src)
> munmap(src, c.region_size)
Yup, this check is not supposed to be on the exit path. I'll fix this.
>
> ...
>
>> - perror("munmap src");
>> + ksft_perror("munmap src");
>>
>> if (dest && munmap(dest, c.region_size) == -1)
>> - perror("munmap dest");
>> + ksft_perror("munmap dest");
>>
>> - if (success)
>> - ksft_test_result_pass("%s\n", test_name);
>> - else
>> - ksft_test_result_fail("%s\n", test_name);
>> + ksft_test_result(success, "%s\n", test_name);
>> }
>
> [...]
>
>> static void usage(const char *cmd)
>> {
>> - fprintf(stderr,
>> - "Usage: %s [[-t <threshold_mb>] [-p <pattern_seed>]]\n"
>> - "-t\t only validate threshold_mb of the remapped region\n"
>> - " \t if 0 is supplied no threshold is used; all tests\n"
>> - " \t are run and remapped regions validated fully.\n"
>> - " \t The default threshold used is 4MB.\n"
>> - "-p\t provide a seed to generate the random pattern for\n"
>> - " \t validating the remapped region.\n", cmd);
>> + ksft_print_msg("Usage: %s [[-t <threshold_mb>] [-p <pattern_seed>]]\n", cmd);
>> + ksft_print_msg("-t\t only validate threshold_mb of the remapped region\n");
>> + ksft_print_msg(" \t if 0 is supplied no threshold is used; all tests\n");
>> + ksft_print_msg(" \t are run and remapped regions validated fully.\n");
>> + ksft_print_msg(" \t The default threshold used is 4MB.\n");
>> + ksft_print_msg("-p\t provide a seed to generate the random pattern for\n");
>> + ksft_print_msg(" \t validating the remapped region.\n");
>> }
>
> That looks odd, as we will now print this as "# ". I would have assumed that
> removing all parameters as the first patch would make things cleaner?
>
> So as a first patch I think we should just remove the parameters entirely. They
> are unused by our infrastrcture:
>
> run_vmtests.sh:CATEGORY="mremap" run_test ./mremap_test
>
> Does anything speak against that?
Okay, I'd kept the 7th and 8th patch of the series for that. I'll make
them the first and second ones then, this will remove all this churn.
Or maybe remove all parameters altogether in the first patch itself.
>
>>
>> static int parse_args(int argc, char **argv, unsigned int *threshold_mb,
>> @@ -1232,7 +1194,6 @@ static int parse_args(int argc, char **argv, unsigned int *threshold_mb,
>> #define MAX_PERF_TEST 3
>> int main(int argc, char **argv)
>> {
>> - int failures = 0;
>> unsigned int i;
>> int run_perf_tests;
>> unsigned int threshold_mb = VALIDATION_DEFAULT_THRESHOLD;
>> @@ -1260,7 +1221,7 @@ int main(int argc, char **argv)
>> pattern_seed = (unsigned int) time(&t);
>>
>> if (parse_args(argc, argv, &threshold_mb, &pattern_seed) < 0)
>> - exit(EXIT_FAILURE);
>> + ksft_exit_fail_msg("Invalid arguments\n");
>>
>> ksft_print_msg("Test configs:\n");
>> ksft_print_msg("threshold_mb=%u\n", threshold_mb);
>> @@ -1282,7 +1243,7 @@ int main(int argc, char **argv)
>> rand_addr = (char *)mmap(NULL, rand_size, PROT_READ | PROT_WRITE,
>> MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>> if (rand_addr == MAP_FAILED) {
>> - perror("mmap");
>> + ksft_perror("mmap");
>> ksft_exit_fail_msg("cannot mmap rand_addr\n");
>
> Would be better combined like:
>
> ksft_exit_fail_msg("cannot mmap rand_addr: %s\n", strerror(errno));
>
> ?
Yup, or maybe with a ksft_exit_fail_perror() directly. Will change.
next prev parent reply other threads:[~2026-09-29 9:12 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 5:00 [PATCH RESEND 0/9] selftests/mm: improve mremap_test Sarthak Sharma
2026-09-24 5:00 ` [PATCH RESEND 1/9] selftests/mm: mremap_test: use kselftest helpers Sarthak Sharma
2026-09-29 7:58 ` David Hildenbrand (Arm)
2026-09-29 9:12 ` Sarthak Sharma [this message]
2026-09-24 5:00 ` [PATCH RESEND 2/9] selftests/mm: mremap_test: skip test when userfaultfd is unavailable Sarthak Sharma
2026-09-29 8:00 ` David Hildenbrand (Arm)
2026-09-29 9:17 ` Sarthak Sharma
2026-09-24 5:00 ` [PATCH RESEND 3/9] selftests/mm: mremap_test: fail unexpected mremap successes Sarthak Sharma
2026-09-29 8:17 ` David Hildenbrand (Arm)
2026-09-24 5:00 ` [PATCH RESEND 4/9] selftests/mm: mremap_test: correct multiple VMA range size Sarthak Sharma
2026-09-24 5:00 ` [PATCH RESEND 5/9] selftests/mm: mremap_test: fail on data corruption Sarthak Sharma
2026-09-24 5:00 ` [PATCH RESEND 6/9] selftests/mm: mremap_test: replace random data with deterministic pattern Sarthak Sharma
2026-09-24 5:00 ` [PATCH RESEND 7/9] selftests/mm: mremap_test: remove perf tests and timing Sarthak Sharma
2026-09-24 5:00 ` [PATCH RESEND 8/9] selftests/mm: mremap_test: remove validation threshold Sarthak Sharma
2026-09-24 5:00 ` [PATCH RESEND 9/9] selftests/mm: mremap_test: strengthen multi VMA validation Sarthak Sharma
2026-09-29 5:54 ` [PATCH RESEND 0/9] selftests/mm: improve mremap_test Sarthak Sharma
2026-09-29 7:32 ` Kalesh Singh
2026-09-29 7:47 ` David Hildenbrand (Arm)
2026-09-29 9:05 ` Sarthak Sharma
2026-09-29 8:36 ` Lorenzo Stoakes (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=498b8fc3-ef39-424c-81b1-aa4bfdb7eac7@arm.com \
--to=sarthak.sharma@arm.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=david@kernel.org \
--cc=jhubbard@nvidia.com \
--cc=kaleshsingh@google.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=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=ts930@dgu.ac.kr \
--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 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®