From: Suren Baghdasaryan <surenb@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Colin Cross <ccross@google.com>,
Sumit Semwal <sumit.semwal@linaro.org>,
Michal Hocko <mhocko@suse.com>,
Dave Hansen <dave.hansen@intel.com>,
Kees Cook <keescook@chromium.org>,
Matthew Wilcox <willy@infradead.org>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
Vlastimil Babka <vbabka@suse.cz>,
Johannes Weiner <hannes@cmpxchg.org>,
Jonathan Corbet <corbet@lwn.net>,
Al Viro <viro@zeniv.linux.org.uk>,
Randy Dunlap <rdunlap@infradead.org>,
Kalesh Singh <kaleshsingh@google.com>,
Peter Xu <peterx@redhat.com>,
rppt@kernel.org, Peter Zijlstra <peterz@infradead.org>,
Catalin Marinas <catalin.marinas@arm.com>,
vincenzo.frascino@arm.com,
Chinwen Chang <chinwen.chang@mediatek.com>,
Axel Rasmussen <axelrasmussen@google.com>,
Andrea Arcangeli <aarcange@redhat.com>,
Jann Horn <jannh@google.com>,
apopple@nvidia.com, John Hubbard <jhubbard@nvidia.com>,
Yu Zhao <yuzhao@google.com>, Will Deacon <will@kernel.org>,
fenghua.yu@intel.com, thunder.leizhen@huawei.com,
Hugh Dickins <hughd@google.com>,
feng.tang@intel.com, Jason Gunthorpe <jgg@ziepe.ca>,
Roman Gushchin <guro@fb.com>,
Thomas Gleixner <tglx@linutronix.de>,
krisman@collabora.com, Chris Hyser <chris.hyser@oracle.com>,
Peter Collingbourne <pcc@google.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Jens Axboe <axboe@kernel.dk>,
legion@kernel.org, Rolf Eike Beer <eb@emlix.com>,
Cyrill Gorcunov <gorcunov@gmail.com>, Pavel Machek <pavel@ucw.cz>,
Muchun Song <songmuchun@bytedance.com>,
Viresh Kumar <viresh.kumar@linaro.org>,
Thomas Cedeno <thomascedeno@google.com>,
sashal@kernel.org, cxfcosmos@gmail.com,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
LKML <linux-kernel@vger.kernel.org>,
linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-mm <linux-mm@kvack.org>,
kernel-team <kernel-team@android.com>
Subject: Re: [PATCH v10 2/3] mm: add a field to store names for private anonymous memory
Date: Wed, 6 Oct 2021 19:50:38 -0700 [thread overview]
Message-ID: <CAJuCfpGMKPmVx8ADwFOyRPYfYKCuOHCUzr2o-vq0GZGSVj20Dw@mail.gmail.com> (raw)
In-Reply-To: <20211006193940.c261f21fcd14b4b52aae1fbc@linux-foundation.org>
On Wed, Oct 6, 2021 at 7:39 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Mon, 4 Oct 2021 09:21:42 -0700 Suren Baghdasaryan <surenb@google.com> wrote:
>
> > > > > The name pointers are not shared between vmas even if they contain the
> > > > > same name. The name pointer is stored in a union with fields that are
> > > > > only used on file-backed mappings, so it does not increase memory usage.
> > > > >
> > > > > The patch is based on the original patch developed by Colin Cross, more
> > > > > specifically on its latest version [1] posted upstream by Sumit Semwal.
> > > > > It used a userspace pointer to store vma names. In that design, name
> > > > > pointers could be shared between vmas. However during the last upstreaming
> > > > > attempt, Kees Cook raised concerns [2] about this approach and suggested
> > > > > to copy the name into kernel memory space, perform validity checks [3]
> > > > > and store as a string referenced from vm_area_struct.
> > > > > One big concern is about fork() performance which would need to strdup
> > > > > anonymous vma names. Dave Hansen suggested experimenting with worst-case
> > > > > scenario of forking a process with 64k vmas having longest possible names
> > > > > [4]. I ran this experiment on an ARM64 Android device and recorded a
> > > > > worst-case regression of almost 40% when forking such a process. This
> > > > > regression is addressed in the followup patch which replaces the pointer
> > > > > to a name with a refcounted structure that allows sharing the name pointer
> > > > > between vmas of the same name. Instead of duplicating the string during
> > > > > fork() or when splitting a vma it increments the refcount.
> > > >
> > > > Generally, the patch adds a bunch of code which a lot of users won't
> > > > want. Did we bust a gut to reduce this impact? Was a standalone
> > > > config setting considered?
> > >
> > > I didn't consider a standalone config for this feature because when
> > > not used it has no memory impact at runtime. As for the image size, I
> > > built Linus' ToT with and without this patchset with allmodconfig and
>
> allnoconfig would be more interesting. People who want small kernels
> won't be using allmodconfig!
Sure, I will check that and report back.
>
> > > the sizes are:
> > > Without the patchset:
> > > $ size vmlinux
> > > text data bss dec hex filename
> > > 40763556 58424519 29016228 128204303 7a43e0f vmlinux
> > >
> > > With the patchset:
> > > $ size vmlinux
> > > text data bss dec hex filename
> > > 40765068 58424671 29016228 128205967 7a4448f vmlinux
> > >
> > > The increase seems quite small, so I'm not sure if it warrants a
> > > separate config option.
> >
> > Andrew, do you still think we need a separate CONFIG option? I fixed
> > the build issue when CONFIG_ADVISE_SYSCALLS=n and would like to post
> > the update but if you want to have a separate config then I can post
> > that together with the fix. Please let me know.
>
> I don't see much downside to the standalone option. More complexity
> for developers/testers, I guess. But such is life?
Sounds good to me. I will post a new version with a separate config if
we get over the objections of using numbers instead of strings.
Thanks!
>
> --
> To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com.
>
next prev parent reply other threads:[~2021-10-07 2:50 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 20:56 [PATCH v10 1/3] mm: rearrange madvise code to allow for reuse Suren Baghdasaryan
2021-10-01 20:56 ` [PATCH v10 2/3] mm: add a field to store names for private anonymous memory Suren Baghdasaryan
2021-10-01 23:08 ` Andrew Morton
2021-10-02 0:52 ` Suren Baghdasaryan
2021-10-04 16:21 ` Suren Baghdasaryan
2021-10-07 2:39 ` Andrew Morton
2021-10-07 2:50 ` Suren Baghdasaryan [this message]
2021-10-01 20:56 ` [PATCH v10 3/3] mm: add anonymous vma name refcounting Suren Baghdasaryan
2021-10-05 18:42 ` Pavel Machek
2021-10-05 19:14 ` Suren Baghdasaryan
2021-10-05 19:21 ` Kees Cook
2021-10-05 20:04 ` Pavel Machek
2021-10-05 20:43 ` Suren Baghdasaryan
2021-10-06 6:57 ` John Hubbard
2021-10-06 8:27 ` Michal Hocko
2021-10-06 9:27 ` David Hildenbrand
2021-10-06 15:01 ` Suren Baghdasaryan
2021-10-06 15:07 ` David Hildenbrand
2021-10-06 15:20 ` Suren Baghdasaryan
2021-10-07 2:29 ` Andrew Morton
2021-10-07 2:46 ` Suren Baghdasaryan
2021-10-07 2:53 ` Andrew Morton
2021-10-07 3:01 ` Suren Baghdasaryan
2021-10-07 7:27 ` David Hildenbrand
2021-10-07 7:33 ` David Hildenbrand
2021-10-07 15:42 ` Suren Baghdasaryan
2021-10-06 17:58 ` Pavel Machek
2021-10-06 18:18 ` Suren Baghdasaryan
2021-10-07 8:10 ` Michal Hocko
2021-10-07 8:41 ` Pavel Machek
2021-10-07 8:47 ` Rasmus Villemoes
2021-10-07 10:15 ` Pavel Machek
2021-10-07 16:04 ` Suren Baghdasaryan
2021-10-07 16:40 ` Michal Hocko
2021-10-07 16:58 ` Suren Baghdasaryan
2021-10-07 17:31 ` Michal Hocko
2021-10-07 17:50 ` Suren Baghdasaryan
2021-10-07 18:12 ` Kees Cook
2021-10-07 18:50 ` Suren Baghdasaryan
2021-10-07 19:02 ` John Hubbard
2021-10-07 21:32 ` Suren Baghdasaryan
2021-10-08 1:04 ` Liam Howlett
2021-10-08 7:25 ` Rasmus Villemoes
2021-10-08 7:43 ` David Hildenbrand
2021-10-08 21:13 ` Kees Cook
2021-10-08 6:34 ` Michal Hocko
2021-10-08 14:14 ` Dave Hansen
2021-10-08 14:57 ` Michal Hocko
2021-10-08 16:10 ` Suren Baghdasaryan
2021-10-08 20:58 ` Kees Cook
2021-10-11 8:36 ` Michal Hocko
2021-10-12 1:18 ` Suren Baghdasaryan
2021-10-12 1:20 ` Suren Baghdasaryan
2021-10-12 3:00 ` Johannes Weiner
2021-10-12 5:36 ` Suren Baghdasaryan
2021-10-12 18:26 ` Johannes Weiner
2021-10-12 18:52 ` Suren Baghdasaryan
2021-10-12 20:41 ` Johannes Weiner
2021-10-12 20:59 ` Suren Baghdasaryan
2021-10-12 7:36 ` Michal Hocko
2021-10-12 16:50 ` Suren Baghdasaryan
2021-10-12 7:43 ` David Hildenbrand
2021-10-12 17:01 ` Suren Baghdasaryan
2021-10-14 20:16 ` Suren Baghdasaryan
2021-10-15 8:03 ` David Hildenbrand
2021-10-15 16:30 ` Suren Baghdasaryan
2021-10-15 16:39 ` David Hildenbrand
2021-10-15 18:33 ` Suren Baghdasaryan
2021-10-15 17:45 ` Kees Cook
2021-10-07 7:59 ` Michal Hocko
2021-10-07 15:45 ` Suren Baghdasaryan
2021-10-07 16:37 ` Michal Hocko
2021-10-07 16:43 ` Suren Baghdasaryan
2021-10-07 17:25 ` Michal Hocko
2021-10-07 17:30 ` Suren Baghdasaryan
2021-10-04 7:03 ` [PATCH v10 1/3] mm: rearrange madvise code to allow for reuse Rolf Eike Beer
2021-10-04 16:18 ` Suren Baghdasaryan
2021-10-05 21:00 ` Liam Howlett
2021-10-05 21:30 ` Suren Baghdasaryan
2021-10-06 17:33 ` Liam Howlett
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=CAJuCfpGMKPmVx8ADwFOyRPYfYKCuOHCUzr2o-vq0GZGSVj20Dw@mail.gmail.com \
--to=surenb@google.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=axboe@kernel.dk \
--cc=axelrasmussen@google.com \
--cc=catalin.marinas@arm.com \
--cc=ccross@google.com \
--cc=chinwen.chang@mediatek.com \
--cc=chris.hyser@oracle.com \
--cc=corbet@lwn.net \
--cc=cxfcosmos@gmail.com \
--cc=dave.hansen@intel.com \
--cc=eb@emlix.com \
--cc=ebiederm@xmission.com \
--cc=feng.tang@intel.com \
--cc=fenghua.yu@intel.com \
--cc=gorcunov@gmail.com \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=jannh@google.com \
--cc=jgg@ziepe.ca \
--cc=jhubbard@nvidia.com \
--cc=kaleshsingh@google.com \
--cc=keescook@chromium.org \
--cc=kernel-team@android.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=krisman@collabora.com \
--cc=legion@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mhocko@suse.com \
--cc=pavel@ucw.cz \
--cc=pcc@google.com \
--cc=peterx@redhat.com \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.org \
--cc=rppt@kernel.org \
--cc=sashal@kernel.org \
--cc=songmuchun@bytedance.com \
--cc=sumit.semwal@linaro.org \
--cc=tglx@linutronix.de \
--cc=thomascedeno@google.com \
--cc=thunder.leizhen@huawei.com \
--cc=vbabka@suse.cz \
--cc=vincenzo.frascino@arm.com \
--cc=viresh.kumar@linaro.org \
--cc=viro@zeniv.linux.org.uk \
--cc=will@kernel.org \
--cc=willy@infradead.org \
--cc=yuzhao@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).