linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dev Jain <dev.jain@arm.com>
To: akpm@linux-foundation.org
Cc: shuah@kernel.org, linux-mm@kvack.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	kaleshsingh@google.com, jhubbard@nvidia.com,
	Anshuman.Khandual@arm.com, Dev Jain <dev.jain@arm.com>
Subject: [PATCH 0/3] selftests/mm: mremap_test: Optimizations and style fixes
Date: Sat, 30 Mar 2024 23:05:54 +0530	[thread overview]
Message-ID: <20240330173557.2697684-1-dev.jain@arm.com> (raw)

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(-)

-- 
2.34.1



             reply	other threads:[~2024-03-30 17:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-30 17:35 Dev Jain [this message]
2024-03-30 17:35 ` [PATCH 1/3] selftests/mm: mremap_test: Optimize using pre-filled random array and memcpy Dev Jain
2024-03-30 17:35 ` [PATCH 2/3] selftests/mm: mremap_test: Optimize execution time from minutes to seconds using chunkwise memcmp Dev Jain
2024-03-30 17:35 ` [PATCH 3/3] selftests/mm: mremap_test: Use sscanf to parse /proc/self/maps Dev Jain

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=20240330173557.2697684-1-dev.jain@arm.com \
    --to=dev.jain@arm.com \
    --cc=Anshuman.Khandual@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=jhubbard@nvidia.com \
    --cc=kaleshsingh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shuah@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