From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02F8BC4363D for ; Fri, 2 Oct 2020 08:07:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 884D720719 for ; Fri, 2 Oct 2020 08:07:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="o/OoG1IJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 884D720719 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F2F9F6B005D; Fri, 2 Oct 2020 04:07:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EDF5B6B006C; Fri, 2 Oct 2020 04:07:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1D416B006E; Fri, 2 Oct 2020 04:07:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id B41AE6B005D for ; Fri, 2 Oct 2020 04:07:04 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 50C35181AE873 for ; Fri, 2 Oct 2020 08:07:04 +0000 (UTC) X-FDA: 77326254768.11.tray59_5409856271a2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 2DAF9180F8B80 for ; Fri, 2 Oct 2020 08:07:04 +0000 (UTC) X-HE-Tag: tray59_5409856271a2 X-Filterd-Recvd-Size: 4269 Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Fri, 2 Oct 2020 08:07:03 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Fri, 02 Oct 2020 01:06:49 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 2 Oct 2020 08:06:24 +0000 Received: from sandstorm.nvidia.com (10.124.1.5) by mail.nvidia.com (172.20.187.18) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Fri, 2 Oct 2020 08:06:24 +0000 From: John Hubbard To: Andrew Morton CC: Shuah Khan , LKML , , , John Hubbard Subject: [PATCH 1/1] selftests/vm: 8x compaction_test speedup Date: Fri, 2 Oct 2020 01:06:21 -0700 Message-ID: <20201002080621.551044-2-jhubbard@nvidia.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201002080621.551044-1-jhubbard@nvidia.com> References: <20201002080621.551044-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1601626009; bh=Ntx8Ri/1CPTa9H9QwVpmWKo8Bl+lnYBsuI8bdqZxJ5c=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=o/OoG1IJ89o/To3O5xOF1hwH7PD3vheBI22pWRct7jiG5lkZAytwJSFMia1mVrZBI o1FyM/Sxc/HqML+oXsxsAgR6tUTnfg3O37RKuB87eyZuTQdFpHFf8RpCwTmMDy9RjG WZS2PuyHr4mpuBFlSC55jLpUbbiVc9gNFcbvQe9be3RuwbD40tJsFw73CN6KHxZD4i i89oAl3Ta2oQOTKIiW9FyoDB6hVeic6kyNhB/5g5t1d5F1oJ+wy5OVvMuJhtSX3vfu q/ATmf1+WrfhI24e2/bVJUwg6aSrakR2l/Ou/SSbXKS10Eugx+LRsaZBN+9UTLQM6C 8A/vu5l7h/c1Q== 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: 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.) Signed-off-by: John Hubbard --- tools/testing/selftests/vm/compaction_test.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/vm/compaction_test.c b/tools/testing/s= elftests/vm/compaction_test.c index bcec71250873..9b420140ba2b 100644 --- a/tools/testing/selftests/vm/compaction_test.c +++ b/tools/testing/selftests/vm/compaction_test.c @@ -18,7 +18,8 @@ =20 #include "../kselftest.h" =20 -#define MAP_SIZE 1048576 +#define MAP_SIZE_MB 100 +#define MAP_SIZE (MAP_SIZE_MB * 1024 * 1024) =20 struct map_list { void *map; @@ -165,7 +166,7 @@ int main(int argc, char **argv) void *map =3D NULL; unsigned long mem_free =3D 0; unsigned long hugepage_size =3D 0; - unsigned long mem_fragmentable =3D 0; + long mem_fragmentable_MB =3D 0; =20 if (prereq() !=3D 0) { printf("Either the sysctl compact_unevictable_allowed is not\n" @@ -190,9 +191,9 @@ int main(int argc, char **argv) return -1; } =20 - mem_fragmentable =3D mem_free * 0.8 / 1024; + mem_fragmentable_MB =3D mem_free * 0.8 / 1024; =20 - while (mem_fragmentable > 0) { + while (mem_fragmentable_MB > 0) { map =3D mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_LOCKED, -1, 0); if (map =3D=3D MAP_FAILED) @@ -213,7 +214,7 @@ int main(int argc, char **argv) for (i =3D 0; i < MAP_SIZE; i +=3D page_size) *(unsigned long *)(map + i) =3D (unsigned long)map + i; =20 - mem_fragmentable--; + mem_fragmentable_MB -=3D MAP_SIZE_MB; } =20 for (entry =3D list; entry !=3D NULL; entry =3D entry->next) { --=20 2.28.0