ANDROID: vendor_hooks: account page-mapcount

Support five hooks as follows to account
the amount of multi-mapped pages in kernel:

- android_vh_show_mapcount_pages
- android_vh_do_traversal_lruvec
- android_vh_update_page_mapcount
- android_vh_add_page_to_lrulist
- android_vh_del_page_from_lrulist

Bug: 236578020
Signed-off-by: Peifeng Li <lipeifeng@oppo.com>
Change-Id: Ia2c7015aab442be7dbb496b8b630b9dff59ab935
This commit is contained in:
Peifeng Li
2022-06-23 14:15:35 +08:00
committed by Suren Baghdasaryan
parent 1d2287f56e
commit 3f775b9367
8 changed files with 129 additions and 23 deletions

View File

@@ -11,6 +11,10 @@
#include <linux/rwsem.h>
#include <linux/memcontrol.h>
#include <linux/highmem.h>
#ifndef __GENKSYMS__
#define PROTECT_TRACE_INCLUDE_PATH
#include <trace/hooks/mm.h>
#endif
/*
* The anon_vma heads a list of private "related" vmas, to scan if
@@ -194,7 +198,12 @@ void hugepage_add_new_anon_rmap(struct page *, struct vm_area_struct *,
static inline void page_dup_rmap(struct page *page, bool compound)
{
atomic_inc(compound ? compound_mapcount_ptr(page) : &page->_mapcount);
bool success = false;
if (!compound)
trace_android_vh_update_page_mapcount(page, true, compound, NULL, &success);
if (!success)
atomic_inc(compound ? compound_mapcount_ptr(page) : &page->_mapcount);
}
/*