From patchwork Tue Oct 13 23:57:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11836523 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A60A61C for ; Tue, 13 Oct 2020 23:57:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 58BE42222F for ; Tue, 13 Oct 2020 23:57:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="vgROMv6+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 58BE42222F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9A77C940014; Tue, 13 Oct 2020 19:57:07 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 95926940012; Tue, 13 Oct 2020 19:57:07 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F613940014; Tue, 13 Oct 2020 19:57:07 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id 524D2940012 for ; Tue, 13 Oct 2020 19:57:07 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E1926180AD811 for ; Tue, 13 Oct 2020 23:57:06 +0000 (UTC) X-FDA: 77368565652.14.boat52_541827027207 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id BC7611822987B for ; Tue, 13 Oct 2020 23:57:06 +0000 (UTC) X-Spam-Summary: 1,0,0,3f2b83ae32dc4c1a,d41d8cd98f00b204,akpm@linux-foundation.org,,RULES_HIT:41:355:379:800:960:966:967:973:988:989:1260:1345:1359:1381:1431:1437:1534:1542:1711:1730:1747:1777:1792:2196:2199:2393:2525:2559:2563:2682:2685:2859:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3743:3865:3866:3867:3871:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4385:5007:6238:6261:6630:6653:7576:9010:9025:9545:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12679:12986:13161:13229:13846:14181:14721:21080:21451:21627:21939:21990:30034:30054:30055:30056:30064,0,RBL:198.145.29.99:@linux-foundation.org:.lbl8.mailshell.net-62.2.0.100 64.100.201.201;04yfwt7ygmsq564xto4k5apb6dt9yycw7hfdccj49dx8cdowknd5bjhqnwnciji.736zirrp7bo36akow33drfzdh7rdoxu5bm6jffyakws35skfgizo59xzyzgm3eg.e-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Cu stom_rul X-HE-Tag: boat52_541827027207 X-Filterd-Recvd-Size: 3720 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Tue, 13 Oct 2020 23:57:06 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 35EF82222F; Tue, 13 Oct 2020 23:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602633425; bh=k8c3Giqeum18oGsHJgSDLZGVc1nE6cMOwBhly+gWPHw=; h=Date:From:To:Subject:In-Reply-To:From; b=vgROMv6+m4WZyj8dQ9I1Q27S6kwunYNT/Q82SGnOF9JR4N4nLr4Fyn42p4Pr0pZW1 QCcK4zwsh48L0cFVJh9EHEu2g/QHyo7rMqCCWStnL1ZLL6+3Zme4FvaMm+WVtwhWbX b+KeOauWkHTy/Ir77MLsQh/xqwRdcFyBe6qbne/0= Date: Tue, 13 Oct 2020 16:57:04 -0700 From: Andrew Morton To: akpm@linux-foundation.org, jhubbard@nvidia.com, linux-mm@kvack.org, mgorman@techsingularity.net, mm-commits@vger.kernel.org, shuah@kernel.org, sjayaram@akamai.com, torvalds@linux-foundation.org Subject: [patch 158/181] selftests/vm: 8x compaction_test speedup Message-ID: <20201013235704.hIueoK69M%akpm@linux-foundation.org> In-Reply-To: <20201013164658.3bfd96cc224d8923e66a9f4e@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: John Hubbard Subject: selftests/vm: 8x compaction_test speedup This patch reduces the running time for compaction_test from about 27 sec, to 3.3 sec, which is about an 8x speedup. These numbers are for an Intel x86_64 system with 32 GB of DRAM. The compaction_test.c program was spending most of its time doing mmap(), 1 MB at a time, on about 25 GB of memory. Instead, do the mmaps 100 MB at a time. (Going past 100 MB doesn't make things go much faster, because other parts of the program are using the remaining time.) Link: https://lkml.kernel.org/r/20201002080621.551044-2-jhubbard@nvidia.com Signed-off-by: John Hubbard Acked-by: Sri Jayaramappa Cc: Shuah Khan Cc: Mel Gorman Signed-off-by: Andrew Morton --- tools/testing/selftests/vm/compaction_test.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) --- a/tools/testing/selftests/vm/compaction_test.c~selftests-vm-8x-compaction_test-speedup +++ a/tools/testing/selftests/vm/compaction_test.c @@ -18,7 +18,8 @@ #include "../kselftest.h" -#define MAP_SIZE 1048576 +#define MAP_SIZE_MB 100 +#define MAP_SIZE (MAP_SIZE_MB * 1024 * 1024) struct map_list { void *map; @@ -165,7 +166,7 @@ int main(int argc, char **argv) void *map = NULL; unsigned long mem_free = 0; unsigned long hugepage_size = 0; - unsigned long mem_fragmentable = 0; + long mem_fragmentable_MB = 0; if (prereq() != 0) { printf("Either the sysctl compact_unevictable_allowed is not\n" @@ -190,9 +191,9 @@ int main(int argc, char **argv) return -1; } - mem_fragmentable = mem_free * 0.8 / 1024; + mem_fragmentable_MB = mem_free * 0.8 / 1024; - while (mem_fragmentable > 0) { + while (mem_fragmentable_MB > 0) { map = mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_LOCKED, -1, 0); if (map == MAP_FAILED) @@ -213,7 +214,7 @@ int main(int argc, char **argv) for (i = 0; i < MAP_SIZE; i += page_size) *(unsigned long *)(map + i) = (unsigned long)map + i; - mem_fragmentable--; + mem_fragmentable_MB -= MAP_SIZE_MB; } for (entry = list; entry != NULL; entry = entry->next) {