From patchwork Sat Mar 30 17:35:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dev Jain X-Patchwork-Id: 13611620 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA8B7C6FD1F for ; Sat, 30 Mar 2024 17:37:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 03DEF6B007B; Sat, 30 Mar 2024 13:37:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F14736B0083; Sat, 30 Mar 2024 13:37:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF7846B0085; Sat, 30 Mar 2024 13:37:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C1D9C6B007B for ; Sat, 30 Mar 2024 13:37:38 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 79D651C07AB for ; Sat, 30 Mar 2024 17:37:38 +0000 (UTC) X-FDA: 81954412596.06.91A3C9B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 9E58D2000E for ; Sat, 30 Mar 2024 17:37:36 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711820257; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=pVHaPlPbtFB12IKh2vVFy33+pdB3sJRjDe0kiVaBLZI=; b=RpKCU0VyHZVljk91HLvgElsMS2a9DzQgd6X2FAAxPmBGg1uLCXedrMaPKFDSpdP0qlQsAE r5OgqU41i1DbFB9H3hfNI38XH+ntn1ZfGulc8Tp8DJk/TcFJHG0dTTR8iAzoNjQf1JUzCc zYzezizQ+OVpIHmGUy+N+D9pJXGb9+c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711820257; a=rsa-sha256; cv=none; b=Ed70vVuWn65Bh7lcwsAW1iTVLo9J7myWmgbOczKGDPcThEQ6vEPnpC9CqTHG0C+jTcCpjH AwV+jksricEh5b/tF45Yn164wOut/iis17rvCMYfcPBub/ukZ6kBCZopkXNle7nnemHkwa W04+/O06J0KeDwGfFGW97Wc/L6Upatc= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of dev.jain@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=dev.jain@arm.com; dmarc=pass (policy=none) header.from=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 52ADF106F; Sat, 30 Mar 2024 10:38:08 -0700 (PDT) Received: from e116581.. (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 23DC23F7B4; Sat, 30 Mar 2024 10:37:30 -0700 (PDT) From: Dev Jain 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 Subject: [PATCH 0/3] selftests/mm: mremap_test: Optimizations and style fixes Date: Sat, 30 Mar 2024 23:05:54 +0530 Message-Id: <20240330173557.2697684-1-dev.jain@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 9E58D2000E X-Rspam-User: X-Stat-Signature: ygrd8b4kez8wjq3crh91ke9kcrohg57d X-Rspamd-Server: rspam03 X-HE-Tag: 1711820256-914548 X-HE-Meta: U2FsdGVkX188XiDa4NZvBPTWud8vfFK98XUFPq87N+qxFLkJis+XUtOjquZTqwa38Wa6PAvoEPndyz+bS+sDAh4PMW6gZBVxuodA9scFgOkVo0Q+HnJcSCzGFOSQMK8uY8CA23VNNcMQQnW4vFrKTkD+iSDGqINSAfg3jmzHLN6t1qLqfEqHdpqF+UyoKUK5sKLdqQYoahvYmt9Wrxm05wewFS/SPL3c8D2823yuO0HbtXy3naoFzaDyyzRGnxHP/wtfHcnhwnygZI1e19/3ywIaVovpj/jRicBJ0Bmu6bAP/fkTTAJFaFDfgm+AlWYFp2rrBVDP3wAiYo1nJ7KiNn1nZDIOv5vm35flA2uMYqYWb+LG53g66ae6dWuZpZNoc8LBSHsVCiL75SZaB1oaTDtX/9eIIzAdGSrUlBjHCahfYPp2SbkpzbC7upwaEzQAN9IjCooh0qAfl4p3xMrfwXFgpxEHBKMBrFu+kQu8DdB14AZDO3yGCCSyv0zy+C3XyNtAJn9EOJc/GOFuhVh2PIhafqlfL6T9BU7esjz7NPdKwe5RuWpZ6jlCgaexXE20c7sUFjK3gsIRVEsSG8u13IeRrFxn9lI94S4bEBECFl7l9ud7xh3MfgJxdTWWEoaeUd7nKejY71p96O5mthxhM2wcYUONZOqP0I5fro8ebxkZ7wp9qr91lZIKGHfHXwt538qIHH4ACtsC5DufNveBW3tP3kKrhqYsmHKIv4M+Ha0gmfc19KOWpO1Cp82PMi+4CiR8FonDr1zAR47Wo+uQNVDLDsIS7syhxvalHzGNEyO8OlTCj2aoYb0W3h20y6DMwFqBNvnIvY8dBp7MHNYnMM7rv9Kjo2GRur4DmAKkNmtnuneOXBWKNbxyCwN1L9hH+6upHyTuCI5XyouHA3PFy89CQkjJFhZBUSG2s4fFDc0AahPY6LY72mfs4XTix5FHsqSANp+rBRMg3RRE6vO AhKaAUF0 cynGcNWAifkG4mLE6riqEkUHOP+DZxjJWSfEL8Twy/KD/gNRD3P27oS3AM2siGRDvyJWVSC4UNlK5f3FTYAkOZmE5lUKBqOltTz27py2iRzzEvXksUTAKBSQNIbTaniHFvwoFq725zPm7fc8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000076, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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(-)