From: Matthew Wilcox <willy@infradead.org>
To: David Wang <00107082@163.com>
Cc: liam.howlett@oracle.com, akpm@linux-foundation.org,
ankitag@nvidia.com, bagasdotme@gmail.com, chunn@nvidia.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
regressions@lists.linux.dev, surenb@google.com
Subject: Re: [REGRESSION]: mmap performance regression starting with k-6.1
Date: Sun, 26 Nov 2023 13:47:18 +0000 [thread overview]
Message-ID: <ZWNMZr9QMSBDc0gd@casper.infradead.org> (raw)
In-Reply-To: <20231126071854.19490-1-00107082@163.com>
On Sun, Nov 26, 2023 at 03:18:54PM +0800, David Wang wrote:
> I add memory access between mmap and munmap to the simple stress, and timeit.
It's still not a very good benchmark ...
> My test code now is:
>
> #define MAXN 1024
> struct { void* addr; size_t n; } maps[MAXN];
> void accessit(char *addr, size_t n) {
> for (int i=0; i<n; i+=128) addr[i]=i;
> }
> int main() {
> int i, n, k, r;
> void *p;
> for (i=0; i<MAXN; i++) {
> n = 1024*((rand()%32)+1);
> p = mmap(NULL, n, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
So 'n' is now a number between 1kB and 32kB. That's not terribly
realistic; I'd say you want to be more like
n = 4096 * ((rand() % 512) + 1));
> for (i=0; i<10000000; i++) {
> k = rand()%MAXN;
> #ifdef PAGE_FAULT
> accessit((char*)maps[k].addr, maps[k].n);
> #endif
> r = munmap(maps[k].addr, maps[k].n);
> if (r) {
> perror("fail to munmap");
> return -1;
> }
> n = 1024*((rand()%32)+1);
> p = mmap(NULL, n, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
Are you simulating something a real application actually does?
Because this all seems very weird and micro-benchmark to me. The real
applications we've benchmarked see a speedup so I'm not thrilled about
chasing down something that no real application does.
In terms of what's going on in the kernel, for each loop, you're calling
munmap(), taking between 1 and 8 page faults, then calling mmap().
That may just be too few page faults to see the benefit of the maple tree.
next prev parent reply other threads:[~2023-11-26 13:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 20:03 [REGRESSION]: mmap performance regression starting with k-6.1 Chun Ng
2023-11-23 1:18 ` Bagas Sanjaya
2023-11-23 3:06 ` Chun Ng
2023-11-23 5:01 ` Bagas Sanjaya
2023-11-23 5:07 ` Bagas Sanjaya
2023-11-23 14:34 ` Liam R. Howlett
2023-11-24 5:08 ` Linux regression tracking #update (Thorsten Leemhuis)
[not found] ` <20231126071854.19490-1-00107082@163.com>
2023-11-26 13:47 ` Matthew Wilcox [this message]
2023-11-23 15:38 ` Matthew Wilcox
2023-11-24 0:15 ` Bagas Sanjaya
2023-11-24 1:04 ` Matthew Wilcox
2023-11-24 11:52 ` Greg KH
2023-11-24 15:06 ` Matthew Wilcox
2023-11-24 15:13 ` Greg KH
2023-11-24 15:29 ` Linux regression tracking (Thorsten Leemhuis)
2023-11-25 1:50 ` Chun Ng
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=ZWNMZr9QMSBDc0gd@casper.infradead.org \
--to=willy@infradead.org \
--cc=00107082@163.com \
--cc=akpm@linux-foundation.org \
--cc=ankitag@nvidia.com \
--cc=bagasdotme@gmail.com \
--cc=chunn@nvidia.com \
--cc=liam.howlett@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=regressions@lists.linux.dev \
--cc=surenb@google.com \
/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;
as well as URLs for NNTP newsgroup(s).