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:
committed by
Suren Baghdasaryan
parent
09ebd2be6e
commit
ce8b55bb08
@@ -429,3 +429,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_traversal_lruvec);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_update_page_mapcount);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_add_page_to_lrulist);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_del_page_from_lrulist);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_should_be_protected);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mark_page_accessed);
|
||||
|
||||
@@ -107,6 +107,12 @@ DECLARE_HOOK(android_vh_show_mapcount_pages,
|
||||
DECLARE_HOOK(android_vh_do_traversal_lruvec,
|
||||
TP_PROTO(struct lruvec *lruvec),
|
||||
TP_ARGS(lruvec));
|
||||
DECLARE_HOOK(android_vh_page_should_be_protected,
|
||||
TP_PROTO(struct page *page, bool *should_protect),
|
||||
TP_ARGS(page, should_protect));
|
||||
DECLARE_HOOK(android_vh_mark_page_accessed,
|
||||
TP_PROTO(struct page *page),
|
||||
TP_ARGS(page));
|
||||
|
||||
#endif /* _TRACE_HOOK_MM_H */
|
||||
|
||||
|
||||
@@ -445,6 +445,7 @@ void mark_page_accessed(struct page *page)
|
||||
return;
|
||||
}
|
||||
|
||||
trace_android_vh_mark_page_accessed(page);
|
||||
if (!PageReferenced(page)) {
|
||||
SetPageReferenced(page);
|
||||
} else if (PageUnevictable(page)) {
|
||||
|
||||
13
mm/vmscan.c
13
mm/vmscan.c
@@ -1256,6 +1256,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);
|
||||
@@ -2387,6 +2392,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();
|
||||
|
||||
@@ -2421,6 +2427,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;
|
||||
|
||||
Reference in New Issue
Block a user