From: Matthew Wilcox <willy@infradead.org>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: akpm@linux-foundation.org, Liam.Howlett@oracle.com,
vbabka@suse.cz, lstoakes@gmail.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH] mm: batch unlink_file_vma calls in free_pgd_range
Date: Sun, 19 May 2024 00:31:20 +0100 [thread overview]
Message-ID: <Zkk6SCZl70o3WXpW@casper.infradead.org> (raw)
In-Reply-To: <20240518062005.76129-1-mjguzik@gmail.com>
On Sat, May 18, 2024 at 08:20:05AM +0200, Mateusz Guzik wrote:
> Execs of dynamically linked binaries at 20-ish cores are bottlenecked on
> the i_mmap_rwsem semaphore, while the biggest singular contributor is
> free_pgd_range inducing the lock acquire back-to-back for all
> consecutive mappings of a given file.
>
> Tracing the count of said acquires while building the kernel shows:
> [1, 2) 799579 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
> [2, 3) 0 | |
> [3, 4) 3009 | |
> [4, 5) 3009 | |
> [5, 6) 326442 |@@@@@@@@@@@@@@@@@@@@@ |
This makes sense. A snippet of /proc/self/maps:
7f0a44725000-7f0a4474b000 r--p 00000000 fe:01 100663437 /usr/lib/x86_64-linux-gnu/libc.so.6
7f0a4474b000-7f0a448a0000 r-xp 00026000 fe:01 100663437 /usr/lib/x86_64-linux-gnu/libc.so.6
7f0a448a0000-7f0a448f4000 r--p 0017b000 fe:01 100663437 /usr/lib/x86_64-linux-gnu/libc.so.6
7f0a448f4000-7f0a448f8000 r--p 001cf000 fe:01 100663437 /usr/lib/x86_64-linux-gnu/libc.so.6
7f0a448f8000-7f0a448fa000 rw-p 001d3000 fe:01 100663437 /usr/lib/x86_64-linux-gnu/libc.so.6
so we frequently have the same file mmaped five times in a row.
> The lock remains the main bottleneck, I have not looked at other spots
> yet.
You're not the first to report high contention on this lock.
https://lore.kernel.org/all/20240202093407.12536-1-JonasZhou-oc@zhaoxin.com/
for example.
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index b6bdaa18b9e9..443d0c55df80 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
I do object to this going into mm.h. mm/internal.h would be better.
I haven't reviewed the patch in depth, but I don't have a problem with
the idea. I think it's only a stopgap and we really do need a better
data structure than this.
next prev parent reply other threads:[~2024-05-18 23:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-18 6:20 Mateusz Guzik
2024-05-18 23:31 ` Matthew Wilcox [this message]
2024-05-19 10:07 ` Mateusz Guzik
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=Zkk6SCZl70o3WXpW@casper.infradead.org \
--to=willy@infradead.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lstoakes@gmail.com \
--cc=mjguzik@gmail.com \
--cc=vbabka@suse.cz \
/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