ANDROID: vendor_hooks: protect multi-mapcount pages in kernel

Support two hooks as follows to protect multi-mapcount pages in kernel:

- trace_android_vh_page_should_be_protect
- trace_android_vh_mapped_page_try_sorthead

Bug: 236578020
Signed-off-by: Peifeng Li <lipeifeng@oppo.com>
Change-Id: I688aceabf17d9de2feac7c3ad7144d307de6ef29
This commit is contained in:
Peifeng Li
2022-06-23 15:15:46 +08:00
committed by Suren Baghdasaryan
parent 3f775b9367
commit e56f8712cf
4 changed files with 22 additions and 0 deletions

View File

@@ -1020,6 +1020,11 @@ static enum page_references page_check_references(struct page *page,
{
int referenced_ptes, referenced_page;
unsigned long vm_flags;
bool should_protect = false;
trace_android_vh_page_should_be_protected(page, &should_protect);
if (unlikely(should_protect))
return PAGEREF_ACTIVATE;
referenced_ptes = page_referenced(page, 1, sc->target_mem_cgroup,
&vm_flags);
@@ -2057,6 +2062,7 @@ static void shrink_active_list(unsigned long nr_to_scan,
int file = is_file_lru(lru);
struct pglist_data *pgdat = lruvec_pgdat(lruvec);
bool bypass = false;
bool should_protect = false;
lru_add_drain();
@@ -2091,6 +2097,13 @@ static void shrink_active_list(unsigned long nr_to_scan,
}
}
trace_android_vh_page_should_be_protected(page, &should_protect);
if (unlikely(should_protect)) {
nr_rotated += thp_nr_pages(page);
list_add(&page->lru, &l_active);
continue;
}
trace_android_vh_page_referenced_check_bypass(page, nr_to_scan, lru, &bypass);
if (bypass)
goto skip_page_referenced;