Re: [PATCH v11 1/6] selftests/mm: make file helpers return errors

From: Sarthak Sharma

Date: Fri Sep 18 2026 - 08:35:07 EST




On 9/18/26 4:52 PM, Sarthak Sharma wrote:
> Change read_file(), write_file(), read_num(), write_num() and
> write_num_ignore_einval() in vm_util.c to report failures to callers
> instead of exiting from the helper.
>
> Make read_file() return a negative errno on failure and 0 on success, so
> callers can distinguish a successful read from an I/O error. Also make
> read_num() reject negative and malformed values.
>
> Keep write_num_ignore_einval() silent for -EINVAL while returning other
> errors to its caller.
>
> Update callers to print diagnostics and fail wherever required. Modify
> a comment which implies write_num() uses ksft_exit_fail_msg(). Also add
> a helper print_file_access_error() in hugepage_settings.c to print
> TAP-compatible errors without a kselftest dependency. This prepares the
> helpers to be moved to tools/lib/mm without a kselftest dependency.
>
> Acked-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> Tested-by: Muhammad Usama Anjum <usama.anjum@xxxxxxx>
> Signed-off-by: Sarthak Sharma <sarthak.sharma@xxxxxxx>
> ---
Hi Andrew!

This fixes an MM selftest build failure in patch 1/6: read_num() changed
its interface, but hugetlb_nr_resv_pages() was missed during the caller
conversion. I'm sorry for missing this.

Can you please apply this fixlet after this patch and before the next
one? Sorry for the inconvenience again.