Re: [PATCH v2] selftests/mm: Simplify byte pattern checking in mremap_test
From: Mike Rapoport
Date: Wed Apr 15 2026 - 02:01:05 EST
On Wed, Apr 15, 2026 at 10:15:09AM +0530, Dev Jain wrote:
> The original version of mremap_test (7df666253f26: "kselftests: vm: add
> mremap tests") validated remapped contents byte-by-byte and printed a
> mismatch index in case the bytes streams didn't match. That was rather
> inefficient, especially also if the test passed.
>
> Later, commit 7033c6cc9620 ("selftests/mm: mremap_test: optimize
> execution time from minutes to seconds using chunkwise memcmp") used
> memcmp() on bigger chunks, to fallback to byte-wise scanning to detect
> the problematic index only if it discovered a problem.
>
> However, the implementation is overly complicated (e.g., get_sqrt() is
> currently not optimal) and we don't really have to report the exact
> index: whoever debugs the failing test can figure that out.
>
> Let's simplify by just comparing both byte streams with memcmp() and not
> detecting the exact failed index.
>
> Reported-by: Sarthak Sharma <sarthak.sharma@xxxxxxx>
> Tested-by: Sarthak Sharma <sarthak.sharma@xxxxxxx>
> Signed-off-by: Dev Jain <dev.jain@xxxxxxx>
> ---
> Applies on mm-unstable.
>
> v1->v2:
> - Simplify patch description
>
> v1:
> - https://lore.kernel.org/all/20260410143031.148173-1-dev.jain@xxxxxxx/
>
> tools/testing/selftests/mm/mremap_test.c | 109 +++--------------------
> 1 file changed, 10 insertions(+), 99 deletions(-)
I like it :)
Acked-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
--
Sincerely yours,
Mike.