linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Colin Cross <ccross@google.com>
To: Kyungmin Park <kmpark@infradead.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Linux-MM <linux-mm@kvack.org>,
	Android Kernel Team <kernel-team@android.com>,
	John Stultz <john.stultz@linaro.org>,
	Hyunhee Kim <hyunhee.kim@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Tomasz Stanislawski <t.stanislaws@samsung.com>
Subject: Re: RFC: named anonymous vmas
Date: Fri, 21 Jun 2013 22:20:02 -0700	[thread overview]
Message-ID: <CAMbhsRSz-eP-8UwMRsNXah3QDY1jUUhCctDH5RvcL=_VMwi2=Q@mail.gmail.com> (raw)
In-Reply-To: <CAH9JG2Uif-d-osTsCT-EqKw+ZWJ1S-rFJA-nQ9nkqTH7sbcSsQ@mail.gmail.com>

On Fri, Jun 21, 2013 at 10:12 PM, Kyungmin Park <kmpark@infradead.org> wrote:
> On Sat, Jun 22, 2013 at 8:42 AM, Colin Cross <ccross@google.com> wrote:
>> One of the features of ashmem (drivers/staging/android/ashmem.c) that
>> hasn't gotten much discussion about moving out of staging is named
>> anonymous memory.
>>
>> In Android, ashmem is used for three different features, and most
>> users of it only care about one feature at a time.  One is volatile
>> ranges, which John Stultz has been implementing.  The second is
>> anonymous shareable memory without having a world-writable tmpfs that
>> untrusted apps could fill with files.  The third and most heavily used
>> feature within the Android codebase is named anonymous memory, where a
>> region of anonymous memory can have a name associated with it that
>> will show up in /proc/pid/maps.  The Dalvik VM likes to use this
>
> Good to know it. I didn't know ashmem provides these features.
> we are also discussing these requirement internally. and study how to
> show who request these anon memory and which callback is used for it.
>
>> feature extensively, even for memory that will never be shared and
>> could easily be allocated using an anonymous mmap, and even malloc has
>> used it in the past.  It provides an easy way to collate memory used
>> for different purposes across multiple processes, which Android uses
>> for its "dumpsys meminfo" and "librank" tools to determine how much
>> memory is used for java heaps, JIT caches, native mallocs, etc.
> Same requirement for app developers. they want to know what's the
> meaning these anon memory is allocated and how to find out these anon
> memory is allocated at their codes.
>>
>> I'd like to add this feature for anonymous mmap memory.  I propose
>> adding an madvise2(unsigned long start, size_t len_in, int behavior,
>> void *ptr, size_t size) syscall and a new MADV_NAME behavior, which
>> treats ptr as a string of length size.  The string would be copied
>> somewhere reusable in the kernel, or reused if it already exists, and
>> the kernel address of the string would get stashed in a new field in
>> struct vm_area_struct.  Adjacent vmas would only get merged if the
>> name pointer matched, and naming part of a mapping would split the
>> mapping.  show_map_vma would print the name only if none of the other
>> existing names rules match.
> Do you want to create new syscall? can it use current madvise and only
> allow this feature at linux only?
> As you know it's just hint and it doesn't break existing memory behaviors.

The existing madvise syscall only takes a single int to modify the
vma, which is not enough to pass a pointer to a string.

  reply	other threads:[~2013-06-22  5:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-21 23:42 RFC: named anonymous vmas Colin Cross
2013-06-22  5:12 ` Kyungmin Park
2013-06-22  5:20   ` Colin Cross [this message]
2013-06-22 10:31 ` Christoph Hellwig
2013-06-22 17:30   ` Colin Cross
     [not found]     ` <kq4v0b$p8p$3@ger.gmane.org>
2013-06-24 11:48       ` Christoph Hellwig
2013-06-24 17:26         ` Colin Cross
2013-06-24 23:45           ` John Stultz
2013-07-14  0:57         ` Sam Ben
2013-08-01  8:29     ` Christoph Hellwig
2013-08-01  8:36       ` Rich Felker
2013-08-02 15:11         ` Christoph Hellwig
2013-08-03 23:54         ` KOSAKI Motohiro
2013-07-14  0:27 ` Sam Ben

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='CAMbhsRSz-eP-8UwMRsNXah3QDY1jUUhCctDH5RvcL=_VMwi2=Q@mail.gmail.com' \
    --to=ccross@google.com \
    --cc=hyunhee.kim@samsung.com \
    --cc=john.stultz@linaro.org \
    --cc=kernel-team@android.com \
    --cc=kmpark@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=m.szyprowski@samsung.com \
    --cc=t.stanislaws@samsung.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).