The new scudo allocator creates a huge map in 64 bit address space. Some
tests would get the usage stats of all maps, but only really cared about
a small set of maps. In this case, provide a method to only get the usage
stats for the maps you care about.
Test: Unit tests pass.
Change-Id: Ie845e47a8c789a57bf689c9f0e5878a921640e30
Add VMA flags into showmap report so that we can distinguish different
sections of an executable or a library.
Bug: 138148041
Test: showmap -v <PID>
Change-Id: Ic1a13accbea447548c75a0c54d750280e40c6de8
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Add vts_core_meminfo_test to vts-core suite and transfer to test it
by using base GTest.
Bug: 132702215
Test: atest vts_core_meminfo_test
Change-Id: Ia7924179cde0b79a6787b3533259ea8e90594585
Add VMA flags into procmem report so that we can distinguish different
sections of an executable or a library.
Bug: 138148041
Test: procmem -h <PID>
Change-Id: I062464aa1f1c508bcc8ef05a6d9cfad9a4318d95
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Also fix bugs that made it not compile on host. Motivation is to be
able to analyze smaps files easily on the host.
Test: showmap -f maps.txt
Bug: 137034556
Change-Id: I7b8ca1237ce1ec17d02cd5217c73b62ee978cb05
Some code only wants to use PageMap to determine whether pages are
mapped in to memory. Modify the code to optimize this path.
Changes:
- Add a function that doesn't read all of usage stats data for every
map. This operation is extremely expensive, and some code doesn't
care about it.
- Optimize the PageMap call to do a single read instead of a single
read per page.
- Add unit tests for these changes.
Bug: 136245508
Test: Ran new unit tests.
Test: Ran procrank and verified data looks good.
Test: Ran DexDiag art tests.
Change-Id: I37d03f2584551d26cb20be3abacdb958111d4eca
Add '-a' commandline option to show the old complete table that shows
dmabuf x process grid.
Bug: 135668399
Test: dmabuf_dump
Test: dmabuf_dump -h
Test: dmabuf_dump -a
Test: dmabuf_dump -a 123
Test: dmabuf_dump 123 456
Test: dmabuf_dump <pid>
Change-Id: If228c97baa375c515d94baf3b5be674cfcc09919
Signed-off-by: Sandeep Patil <sspatil@google.com>
- Get rid of the PSS number that didn't make sense.
- Fix double counting in per-process size when buffers had file
descriptors and mmap'ed
- Make the output much more readable
- Print totals where they make sense.
- Dont print per-process fd and map refs separately, total ref count per
process is sufficient.
Bug: 135668399
Test: dmabuf_dump (on AOSP blueline)
Change-Id: I10dc0a332d49110dd68f0eaa94a326679361deea
Signed-off-by: Sandeep Patil <sspatil@google.com>
The scudo memory allocator will allocate a large virtual memory address
that causes procrank to allocate a huge amount of data. Modify so it
caches the data a bit at a time.
Remove some allocations that are not necessary since the data is only used
in the first loop.
Fix a few pread64 checks against the actual bytes read, rather than the
read is < 0.
Fix sort by rss in procrank.
Bug: 135694447
Test: Ran unit tests (only one unit test actually runs the modified code).
Test: Ran the old version of procrank using a static libmeminfo and verified
Test: that the same data is found as the new version.
Change-Id: I8adc169b5607ec994ff13a9e161a479350d84c4d
procrank's usage in its output shows 20x increase from
last year. This is because it is keeping the process
maps around until termination. Fix that by getting rid
of ProcMemInfo objects when done parsing /proc/<pid>/maps,pagemap.
Note that the total allocations do not change and have not necessarily
regressed from Pie.
Bug: 130672819
Test: adb shell procrank | grep 'procrank\|cmdline'
Change-Id: Ib7bf960ed1d053347fcfc0c8aee9019607a1eb01
Signed-off-by: Sandeep Patil <sspatil@google.com>
procrank currently fails if a process gets killed while it is reading
the stats. This behavior is a regression from the previous version of
procrank and is often undesired.
Change procrank to silently ignore the process if it detects that it had
been killed while reading the stats. If the process is still around,
then print a warning about it and continue to read stats for other
processes in the system.
Bug: 130177765
Test: Tested by deliberately killing specific process in ProcessRecord()
constructor
Change-Id: I701808c3226bb9b3a350ccf8e67fb29b59b0d4e0
Signed-off-by: Sandeep Patil <sspatil@google.com>
librank was calling std::vector::find_if in nested loops when iterating
through processes and maps.
Changed the implementation to use std::map::insert, this resulted in
a significant improvement to execution speed.
Test: time librank on crosshatch
Before: 1m22.57s real 1m15.87s user 0m05.79s system
After: 0m03.85s real 0m00.88s user 0m02.92s system
Bug: 124523194
Change-Id: I2b519d0bfd7f7929c6c4c6c2374794cb1a744585
Signed-off-by: Erick Reyes <erickreyes@google.com>
The vendor partition does not give dmabuf_dump enough permissions to
retrieve shared buffer information for all processes. Move it to product
partition where it can be invoked from platform's dumpstate.
Bug: 63860998
Change-Id: I73957f59943d1e49fcb59abb723aad4eeeaa4172
Signed-off-by: Erick Reyes <erickreyes@google.com>
Adjust all callbacks to include the inode number as well.
Fixes: 123532375
Test: libprocinfo_test
Test: libdmabufinfo_test
Test: libmeminfo_test
Change-Id: I71fd75d90d5ee44585011c5ae654a1dd7e185458
Signed-off-by: Sandeep Patil <sspatil@google.com>
Test: build with master-art manifest
Exempt-From-Owner-Approval: Required for unbreaking ART development.
Change-Id: I6afc0e5444dfa21532a4c802f8c463091cab2b11
Fixes:
system/core/libmeminfo/libdmabufinfo/tools/dmabuf_dump.cpp:109:39: error: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]
Test: lunch aosp_arm-eng && m dmabuf_dump
Change-Id: Ie605d9b94f5eff888f6a64801512216253a6babb
dmabuf_dump had a hard dependency on debugfs to gather the initial list
of buffers for all proceses, make it optional.
Change-Id: I1d271297c0ad6124b321a1ee8aa01d3e88ca9fed
Signed-off-by: Erick Reyes <erickreyes@google.com>
Removed dependency on libc++fs and changed liblog to shared linkage to
cope with build errors derived from the change.
Removed dmabuf_dump unnecessary dependencies and made it soc_specific.
Removed reference to std::filesystem::is_symlink to workaround the
following error when linking with the library:
ld.lld: error: undefined symbol:
std::__1::__fs::filesystem::__symlink_status(std::__1::__fs::filesystem::path
const&, std::__1::error_code*)
>>> referenced by filesystem:1743
(external/libcxx/include/filesystem:1743)
>>>
dmabufinfo.o:(android::dmabufinfo::AppendDmaBufInfo(int,
std::__1::vector<android::dmabufinfo::DmaBuffer,
std::__1::allocator<android::dmabufinfo::DmaBuffer> >*)) in archive
Bug: 63860998
Change-Id: Ieafdc87c64f153625df9e21fc8299292b2447aef
Signed-off-by: Erick Reyes <erickreyes@google.com>
Adding tool to dump the dmabuf information using the dmabufinfo library.
Test: run "dmabuf_dump" and "dmabuf_dump <pid>" on crosshatch
Bug: 63860998
Change-Id: I16fe0a701deb5086ca0e1a8ceecb70dbc17934e6
Signed-off-by: Erick Reyes <erickreyes@google.com>
The number of references to a buffer total_refs was not accounting for
a process holding multiple references to the same buffer.
Also, clarify AppendDmaBufInfo functionality in comments
Change-Id: I044a18acad1570492a925d51b9464d5b0e60ca35
Signed-off-by: Erick Reyes <erickreyes@google.com>
Add some test to verify the refcount and fd reference is correct when
the dma_buf is shared between processes.
Bug; 63860998
Test: libdmabufinfo_test
Change-Id: Id22e68e7a65820f19847b2faab11c78e6d942d92
Change the dmabufinfo library to handle multiple references to the same
buffer across PIDs by doing these changes:
- Add function AppendDmaBufInfo: appends the information for a specific
PID to an existing DmaBuffer vector
- Change the way fd/map references to a buffer belonging to a PID are
stored in DmaBuffer from vector<pid_t> to unorderedmap<pid_t, int>
- When parsing proc/%pid/{maps|fds}, look up the buffer by inode and
update the data if found
Test: builds
Bug: 63860998
Change-Id: If22feea772f182086ae3446b46d626a750674b1f
Signed-off-by: Erick Reyes <erickreyes@google.com>
Remove all tests that validated libmeminfo against the libpagemap
implementation and make libmeminfo_test self sufficient.
Bug: 111694435
Bug: 113035067
Test: libmeminfo_test
Change-Id: I21b9a0e2c71ef3f1f672a3b1de8080c0c36b4bfe
Signed-off-by: Sandeep Patil <sspatil@google.com>
This is the userspace component for the improved shared memory buffer
tracking.
A new static library called libdmabufinfo will provide APIs to parse dmabuf
debugfs entries. The library can also map and read the file descriptors
per process to cross-reference the global data per process.
This change only adds a global API to read dmabuf stats from debugfs.
Bug: 63860998
Test: dmabufinfo_test
Change-Id: Ib0deedc73337a70875e03e07d3e9a692c4c33e63
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Erick Reyes <erickreyes@google.com>
Signed-off-by: Sandeep Patil <sspatil@google.com>
Also adds a tool to make use of this if it exists call 'wsstop'
Bug: 111694435
Test: wsstop -d 3 -n 100 1
Change-Id: I50415f0bdc09c09b5b414cf0e4fff8f2907c5823
Signed-off-by: Sandeep Patil <sspatil@google.com>
There is no need for the vmalloc reader to be in the sysmeminfo object.
The caller has to create the SysMemInfo object for no reason right now.
Bug: 111694435
Test: libmeminfo_test 1
Change-Id: I263c08c169ea6caf2221bfb915b26ef3c0b1c20c
Signed-off-by: Sandeep Patil <sspatil@google.com>
.. and make sure we have some helper methods exposed to the clients
to do some basic checks for the pagemap values. For example, to check
if the page is present or swapped.
Bug: 111694435
Test: libmeminfo_test 1 --gtest_filter=ValidateProcMemInfo.TestPageMap
Test: libmeminfo_test 1
Change-Id: Ic6ae91f4214b42346f3d0b54164a43ac79d5ade1
Signed-off-by: Sandeep Patil <sspatil@google.com>
Enables procrank, procmem, librank and showmap.
Only showmap gets built into the default builds.
Bug: 111694435
Test: builds
Test: showmap exists in final builds
Change-Id: Ib5901aa2bd4ccc6aa3d02915fda92f8320651315
Signed-off-by: Sandeep Patil <sspatil@google.com>
The test has become invalid due to addition of IsSmapsRollupSupported()
and its internal usage by SmapsOrRollup() method. The method now returns
success and returns statistics even if 'smaps_rollup' doesn't exist. It
does that by internally checking for it's existence and falls back to
using /proc/<pid>/smaps
Bug: 111694435
Test: mma -j
Change-Id: I1983a23f1f617aee126bc66a4c1fbd4abb50f565
Signed-off-by: Sandeep Patil <sspatil@google.com>