Thread (29 messages) 29 messages, 8 authors, 2021-09-03

Re: [PATCH v8 3/3] mm: add anonymous vma name refcounting

From: Suren Baghdasaryan <surenb@google.com>
Date: 2021-08-28 21:14:08
Also in: linux-fsdevel, linux-mm, lkml

On Fri, Aug 27, 2021 at 10:28 PM Kees Cook [off-list ref] wrote:
On Fri, Aug 27, 2021 at 12:18:58PM -0700, Suren Baghdasaryan wrote:
quoted
While forking a process with high number (64K) of named anonymous vmas the
overhead caused by strdup() is noticeable. Experiments with ARM64 Android
device show up to 40% performance regression when forking a process with
64k unpopulated anonymous vmas using the max name lengths vs the same
process with the same number of anonymous vmas having no name.
Introduce anon_vma_name refcounted structure to avoid the overhead of
copying vma names during fork() and when splitting named anonymous vmas.
When a vma is duplicated, instead of copying the name we increment the
refcount of this structure. Multiple vmas can point to the same
anon_vma_name as long as they increment the refcount. The name member of
anon_vma_name structure is assigned at structure allocation time and is
never changed. If vma name changes then the refcount of the original
structure is dropped, a new anon_vma_name structure is allocated
to hold the new name and the vma pointer is updated to point to the new
structure.
With this approach the fork() performance regressions is reduced 3-4x
times and with usecases using more reasonable number of VMAs (a few
thousand) the regressions is not measurable.
I like the refcounting; thank you!

Since patch2 adds a lot of things that are changed by patch3; maybe
combine them?
I thought it would be easier to review with the main logic being
written using a basic type (string) first and then replace the basic
type with a more complex refcounted structure. Also, if someone would
like to rerun the tests and measure the regression of strdup vs
refcounting approach, keeping this patch separate makes it easier to
set up these tests.
If that's not convenient I can absolutely squash them together.
--
Kees Cook
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help