This is to replace occurrences of get_allocated_vmalloc_memory().
Splitting into libmeminfo already found a bug with current code which
failed to account for memory allocated by modules due to addition of
the extra [%module_name%] in __builtin_return_address().
See: https://elixir.bootlin.com/linux/latest/source/kernel/kallsyms.c#L373
Also improves the performance a bit in the process.
Bug: 119639955
Bug: 111694435
Test: libmeminfo_test 1 --gtest_filter=SysMemInfoParser.TestVmallocInfo
Test: libmeminfo_benchmark --benchmark_filter=BM_VmallocInfo_*
Result:
----------------------------------------------------------------
Benchmark Time CPU Iterations
----------------------------------------------------------------
BM_VmallocInfo_old_fixed 459239 ns 457268 ns 1532
BM_VmallocInfo_new 386032 ns 384353 ns 1821
----------------------------------------------------------------
Change-Id: I1b6606ac73b5cc2dac31d24487b462ec9abfb2ef
Signed-off-by: Sandeep Patil <sspatil@google.com>
The new variant is primarily used in framework. See: go/ag/5780400
for usage. Also add tests, benchmarks and fix several issues found in SysMemInfo
class.
New benchmark results are:
--------------------------------------------------------------
Benchmark Time CPU Iterations
--------------------------------------------------------------
BM_ReadMemInfo_old 7726 ns 7696 ns 90201
BM_ReadMemInfo_new 7554 ns 7525 ns 90358
BM_ZramTotal_old 6446 ns 6406 ns 108361
BM_ZramTotal_new 6529 ns 6488 ns 106545
BM_MemInfoWithZram_old 14485 ns 14412 ns 48492
BM_MemInfoWithZram_new 20572 ns 20459 ns 33438
--------------------------------------------------------------
The reason for BM_MemInfoWithZram_new shows worse numbers is because
the new API also tries to find more than 1 zram device (if it exists).
The old implementation hard coded everything to "/sys/block/zram0/"
Test: libmeminfo_test 1
Bug: 114325007
Bug: 111694435
Change-Id: I246d9e9a54986ee9b2542d1eaac79ecf7310b23a
Signed-off-by: Sandeep Patil <sspatil@google.com>
Adds procmeminfo API to get the vector of swap_offsets
if SWAP is enabled on the device.
Bug: 114325007
Bug: 111694435
Test: libmeminfo_test 1
Change-Id: If0b52d042749a5bcb2c87aa2cb1595190d4769b1
Signed-off-by: Sandeep Patil <sspatil@google.com>
The library is expected to be a unified place for all components to read
both global and per-process memory accounting form kernel including
getting the working set. This change adds the PageInfo, MemInfo and
ProcMemInfo classes and verifies the implementation against libpagemap
for correctness.
Adds a procmem2 tool show the usage.
TODO: Plumbing in os_debug, add vmastats, zoneinfo etc parsing.
Test: libmeminfo_test 1
Test: procmem2 1
Test: procmem2 -h -W 1
Test: procmem2 -h -w 1
Test: libmeminfo_benchmark
Bug: 111694435
Bug: 114325007
Change-Id: I280440b1dc26a498170686d10fcf63f953a0dcbd
Signed-off-by: Sandeep Patil <sspatil@google.com>