Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1637477pxk; Fri, 2 Oct 2020 15:07:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIDuQHdfMJMtiMNRYeUm6+CYJFjf1oArvaRPL1QpDwxYXaYsdStNgVkmJRV11uKy8O2jMV X-Received: by 2002:a17:906:275b:: with SMTP id a27mr4470607ejd.190.1601676472345; Fri, 02 Oct 2020 15:07:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601676472; cv=none; d=google.com; s=arc-20160816; b=FLWr1flVET6kQU2BFXm7AYbm8XqeQlOy8FVT3PT2N5LiZKCM/clYULr+b1vTx6qvT6 v0/LpmG3VoLzsJIFdLSKeaneIMyXbyGEOiA1D46cb5olQcvWNYETZvKcpElNkzOYF0JB UI5r4LXRNbx4xGyDLZYYLuxk1yKwkpYIJz0+IZZPHPk5M/JJz4dbIVuRveLAiI6i/lV5 B+t29KAT3osT/6LzaW/bsW8ZxltPTGMBpeFZrpQ1PyhaHj1h5DBbPhkZI/5/2RYosc4X 5D4EPTaNccCOYUbVU8suGKLiBDITCaMTpy6QctjTZpPoTtNOpPdqZ3MZxc1WeZACIOfT LBHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=/rEvfFln/HJrzDeIt7tVTUaV2UFiTnZ4314brnY/TNs=; b=zsVh+paHdEH+YQgpAi4NK6udvHM/ay42i9ijZ5h+NF+ecEg1rn2LDL0xuMsfXZvbnI V86MwgtFiyfRz1beRDUDAUlVahIqvKG1Vm/ay6Nxbc/2yGMjXBEB9qro16uYgK36Ojw2 Xby5fhFMLyqvxrzSoWpVZInJiAINZCw4U+Z5u8Z0Q0FFcdvnpNQLixHaOMUsIYonc/ZO zJD0Ode7ANQh2h2A7wU0nt2s2h1qR52AvtvkAmZqr7dHEG4e7H4bquVdVKWq3DOM9Gtn dVBvNzg6w87XsJ0NeA7vDbKI6BWGbV4RU183dzyM67SB5+Pm/nk8NKaDlDkWC5BtgfLV JIjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gDd85F52; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i25si1904571eds.204.2020.10.02.15.07.17; Fri, 02 Oct 2020 15:07:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gDd85F52; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725778AbgJBWFW (ORCPT + 99 others); Fri, 2 Oct 2020 18:05:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:34682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725446AbgJBWFW (ORCPT ); Fri, 2 Oct 2020 18:05:22 -0400 Received: from X1 (c-76-21-107-111.hsd1.ca.comcast.net [76.21.107.111]) (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 AD27C20719; Fri, 2 Oct 2020 22:05:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601676322; bh=A/PUNC/h74mMFqFuFyQBZzOM4+GqXQWYyk2J9FTBXHU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gDd85F52dSGYlWT7WLjb6cPPYCWvYOjIS1DAhkHOAS81iXNE3o1e1VQntR7DqkM0x ud10WxaijIbe9zMe/BQYIddIVa2H5Eaib8MiYft0L1YO+xxfhMCf8rfHr/TC2PhIjq wcTv0vTS+IYJxrh6oaonopzTcGeq75KcRrd8cQNE= Date: Fri, 2 Oct 2020 15:05:20 -0700 From: Andrew Morton To: John Hubbard Cc: Shuah Khan , LKML , , , Sri Jayaramappa Subject: Re: [PATCH 1/1] selftests/vm: 8x compaction_test speedup Message-Id: <20201002150520.2ea3db53d88f8d10ba8348c9@linux-foundation.org> In-Reply-To: <20201002080621.551044-2-jhubbard@nvidia.com> References: <20201002080621.551044-1-jhubbard@nvidia.com> <20201002080621.551044-2-jhubbard@nvidia.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2 Oct 2020 01:06:21 -0700 John Hubbard wrote: > 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.) Seems nice. It's been 5 years, but hopefully Sri is still at Akamai? > --- a/tools/testing/selftests/vm/compaction_test.c > +++ b/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) { > -- > 2.28.0 >