Skip to content

selftests/mm: mremap_test: Optimizations and style fixes

Dev Jain linux-kselftest linux-mm lkml 1 version Applied

Status from this message: [merged mm-stable] selftests-mm-mremap_test-use-sscanf-to-parse-proc-self-maps.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 0 repliesApplied 3/3

Patches in v1 All 3 applied

#Subject and filesSizeRepliesApplied
1/3selftests/mm: mremap_test: Optimize using pre-filled random array and memcpytools/testing/selftests/mm/mremap_test.c+53 -250 repliesApplied
2/3selftests/mm: mremap_test: Optimize execution time from minutes to seconds using chunkwise memcmptools/testing/selftests/mm/mremap_test.c+91 -210 repliesApplied
3/3selftests/mm: mremap_test: Use sscanf to parse /proc/self/mapstools/testing/selftests/mm/mremap_test.c+11 -70 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] selftests/mm: mremap_test: Optimizations and style fixes

The mremap_test, in a worst case controlled by the -t flag, does a for loop iteration in orders of GB. Without compromising on the stdout report, the aim is to reduce this time.

A pre-filled random buffer is allocated based on the seed, replacing repetitive rand() calls. The byte pattern in the memory locations is set through memcpy() from the random buffer.

Replacing the loop for printing the mismatch index to stdout, employ an efficient algorithm by breaking the comparison into chunks, use the highly optimized memcmp() library function, and when a mismatch does occur, only then do a brute force iteration.

Also, use sscanf() to parse /proc/self/maps for consistency across files.

Execution time results (x86 system):
./mremap_test
Original: 3 seconds
After change: 0.8 seconds

./mremap_test -t100
Original: 17 seconds
After change: 2 seconds

./mremap_test -t0 (worst case):
Original: 9:40 minutes
After change: 45 seconds

Dev Jain (3):
selftests/mm: mremap_test: Optimize using pre-filled random array and
memcpy
selftests/mm: mremap_test: Optimize execution time from minutes to
seconds using chunkwise memcmp
selftests/mm: mremap_test: Use sscanf to parse /proc/self/maps

 tools/testing/selftests/mm/mremap_test.c | 204 +++++++++++++++++------
 1 file changed, 153 insertions(+), 51 deletions(-)
Signature · 1 line
2.34.1