android_kernel_google_msm/mm
Colin Cross 0fa571fe60 mm: add a field to store names for private anonymous memory
Userspace processes often have multiple allocators that each do
anonymous mmaps to get memory.  When examining memory usage of
individual processes or systems as a whole, it is useful to be
able to break down the various heaps that were allocated by
each layer and examine their size, RSS, and physical memory
usage.

This patch adds a user pointer to the shared union in
vm_area_struct that points to a null terminated string inside
the user process containing a name for the vma.  vmas that
point to the same address will be merged, but vmas that
point to equivalent strings at different addresses will
not be merged.

Userspace can set the name for a region of memory by calling
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, start, len, (unsigned long)name);
Setting the name to NULL clears it.

The names of named anonymous vmas are shown in /proc/pid/maps
as [anon:<name>] and in /proc/pid/smaps in a new "Name" field
that is only present for named vmas.  If the userspace pointer
is no longer valid all or part of the name will be replaced
with "<fault>".

The idea to store a userspace pointer to reduce the complexity
within mm (at the expense of the complexity of reading
/proc/pid/mem) came from Dave Hansen.  This results in no
runtime overhead in the mm subsystem other than comparing
the anon_name pointers when considering vma merging.  The pointer
is stored in a union with fieds that are only used on file-backed
mappings, so it does not increase memory usage.

Change-Id: Ie2ffc0967d4ffe7ee4c70781313c7b00cf7e3092
Signed-off-by: Colin Cross <ccross@android.com>
2013-10-11 10:02:06 -07:00
..
backing-dev.c bdi: use deferable timer for sync_supers task 2013-02-27 18:16:50 -08:00
bootmem.c bootmem/sparsemem: remove limit constraint in alloc_bootmem_section 2012-03-21 17:54:58 -07:00
bounce.c
cleancache.c
compaction.c cma: fix watermark checking 2013-03-15 17:06:38 -07:00
debug-pagealloc.c
dmapool.c
fadvise.c
failslab.c
filemap.c mm: Don't use CMA pages for writes 2013-03-07 15:23:35 -08:00
filemap_xip.c
fremap.c
highmem.c
huge_memory.c thp: optimize away unnecessary page table locking 2012-03-21 17:54:57 -07:00
hugetlb.c hugetlb: prevent BUG_ON in hugetlb_fault() -> hugetlb_cow() 2012-05-10 15:06:44 -07:00
hwpoison-inject.c
init-mm.c
internal.h cma: fix watermark checking 2013-03-15 17:06:38 -07:00
Kconfig mm: mmzone: MIGRATE_CMA migration type added 2013-02-27 18:14:01 -08:00
Kconfig.debug
kmemcheck.c
kmemleak-test.c
kmemleak.c
ksm.c ksm: cleanup: introduce find_mergeable_vma() 2012-03-21 17:54:59 -07:00
maccess.c
madvise.c mm: add a field to store names for private anonymous memory 2013-10-11 10:02:06 -07:00
Makefile mm: compaction: export some of the functions 2013-02-27 18:13:58 -08:00
memblock.c memblock: Add memblock_overlaps_memory() 2013-02-20 02:43:56 -08:00
memcontrol.c memcg,thp: fix res_counter:96 regression 2012-05-19 10:10:27 -07:00
memory-failure.c mm: page_isolation: MIGRATE_CMA isolation functions added 2013-02-27 18:14:02 -08:00
memory.c mm: Use correct define for CMA features 2013-03-07 15:23:58 -08:00
memory_hotplug.c mm: page_isolation: MIGRATE_CMA isolation functions added 2013-02-27 18:14:02 -08:00
mempolicy.c mm: add a field to store names for private anonymous memory 2013-10-11 10:02:06 -07:00
mempool.c
migrate.c mm: fix NULL ptr dereference in move_pages 2012-04-25 21:26:34 -07:00
mincore.c mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode 2012-03-21 17:54:54 -07:00
mlock.c mm: add a field to store names for private anonymous memory 2013-10-11 10:02:06 -07:00
mm_init.c
mmap.c mm: add a field to store names for private anonymous memory 2013-10-11 10:02:06 -07:00
mmu_context.c mm, counters: remove task argument to sync_mm_rss() and __sync_task_rss_stat() 2012-03-21 17:54:59 -07:00
mmu_notifier.c
mmzone.c
mprotect.c mm: add a field to store names for private anonymous memory 2013-10-11 10:02:06 -07:00
mremap.c
msync.c
nobootmem.c mm: nobootmem: fix sign extend problem in __free_pages_memory() 2012-05-10 15:06:44 -07:00
nommu.c kill mm argument of vm_munmap() 2012-04-21 01:58:20 -04:00
oom_kill.c signal: oom_kill_task: use SEND_SIG_FORCED instead of force_sig() 2012-03-23 16:58:41 -07:00
page-writeback.c Ext4 commits for 3.3 merge window; mostly cleanups and bug fixes 2012-03-28 10:02:55 -07:00
page_alloc.c mm: workaround for widevine playback failed 2013-05-22 07:57:36 +00:00
page_cgroup.c
page_io.c
page_isolation.c mm: page_isolation: MIGRATE_CMA isolation functions added 2013-02-27 18:14:02 -08:00
pagewalk.c mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode 2012-03-21 17:54:54 -07:00
percpu-km.c
percpu-vm.c
percpu.c kmemleak: Fix the kmemleak tracking of the percpu areas with !SMP 2012-05-09 10:13:29 -07:00
pgtable-generic.c thp: add HPAGE_PMD_* definitions for !CONFIG_TRANSPARENT_HUGEPAGE 2012-03-21 17:55:02 -07:00
prio_tree.c
process_vm_access.c
quicklist.c
readahead.c
rmap.c memcg: use new logic for page stat accounting 2012-03-21 17:55:01 -07:00
shmem.c ashmem: Add shmem_set_file to mm/shmem.c 2012-04-09 13:53:14 -07:00
slab.c Merge branch 'slab/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/penberg/linux 2012-03-28 15:04:26 -07:00
slob.c
slub.c slub: fix a memory leak in get_partial_node() 2013-03-15 17:09:26 -07:00
sparse-vmemmap.c
sparse.c msm: mm: Fix errors when turning on SPARSEMEM 2013-02-20 02:43:57 -08:00
swap.c mm: drain percpu lru add/rotate page-vectors on cpu hot-unplug 2012-03-21 17:54:58 -07:00
swap_state.c mm: fix s390 BUG by __set_page_dirty_no_writeback on swap 2012-04-23 18:19:22 -07:00
swapfile.c swapon: check validity of swap_flags 2012-03-28 17:14:35 -07:00
thrash.c
truncate.c mm for fs: add truncate_pagecache_range() 2012-03-28 17:14:35 -07:00
util.c procfs: mark thread stack correctly in proc/<pid>/maps 2012-03-21 17:54:58 -07:00
vmalloc.c mm: fix faulty initialization in vmalloc_init() 2013-02-20 02:43:59 -08:00
vmscan.c mm: fix up the vmscan stat in vmstat 2012-04-25 21:26:33 -07:00
vmstat.c mm: make counts of CMA free pages correct 2013-03-07 15:23:58 -08:00