ANDROID: vendor_hooks: Add hooks for lookaround

Add hooks for support lookaround in memory reclamation.

- android_vh_test_clear_look_around_ref
- android_vh_check_page_look_around_ref
- android_vh_look_around_migrate_page
- android_vh_look_around
Bug: 241079328

Signed-off-by: Peifeng Li <lipeifeng@oppo.com>
Change-Id: I9a606ae71d2f1303df3b02403b30bc8fdc9d06dd
This commit is contained in:
Peifeng Li
2022-09-13 19:07:41 +08:00
parent c762f435c0
commit f50f24e781
6 changed files with 23 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ struct readahead_control;
#endif /* __GENKSYMS__ */
struct cma;
struct swap_slots_cache;
struct page_vma_mapped_walk;
DECLARE_RESTRICTED_HOOK(android_rvh_set_skip_swapcache_flags,
TP_PROTO(gfp_t *flags),
@@ -268,6 +269,16 @@ DECLARE_HOOK(android_vh_alloc_pages_failure_bypass,
TP_PROTO(gfp_t gfp_mask, int order, int alloc_flags,
int migratetype, struct page **page),
TP_ARGS(gfp_mask, order, alloc_flags, migratetype, page));
DECLARE_HOOK(android_vh_test_clear_look_around_ref,
TP_PROTO(struct page *page),
TP_ARGS(page));
DECLARE_HOOK(android_vh_look_around_migrate_page,
TP_PROTO(struct page *old_page, struct page *new_page),
TP_ARGS(old_page, new_page));
DECLARE_HOOK(android_vh_look_around,
TP_PROTO(struct page_vma_mapped_walk *pvmw, struct page *page,
struct vm_area_struct *vma, int *referenced),
TP_ARGS(pvmw, page, vma, referenced));
/* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_MM_H */

View File

@@ -50,6 +50,9 @@ DECLARE_HOOK(android_vh_inactive_is_low,
DECLARE_HOOK(android_vh_snapshot_refaults,
TP_PROTO(struct lruvec *target_lruvec),
TP_ARGS(target_lruvec));
DECLARE_HOOK(android_vh_check_page_look_around_ref,
TP_PROTO(struct page *page, int *skip),
TP_ARGS(page, skip));
#endif /* _TRACE_HOOK_VMSCAN_H */
/* This part must be outside protection */
#include <trace/define_trace.h>

View File

@@ -56,6 +56,7 @@
#include <trace/events/migrate.h>
#undef CREATE_TRACE_POINTS
#include <trace/hooks/mm.h>
#include <trace/hooks/vmscan.h>
#include "internal.h"
@@ -606,6 +607,7 @@ void migrate_page_states(struct page *newpage, struct page *page)
SetPageChecked(newpage);
if (PageMappedToDisk(page))
SetPageMappedToDisk(newpage);
trace_android_vh_look_around_migrate_page(page, newpage);
/* Move dirty on pages not done by migrate_page_move_mapping() */
if (PageDirty(page))

View File

@@ -72,6 +72,7 @@
#include <linux/padata.h>
#include <linux/khugepaged.h>
#include <trace/hooks/mm.h>
#include <trace/hooks/vmscan.h>
#include <asm/sections.h>
#include <asm/tlbflush.h>
@@ -2403,6 +2404,7 @@ static void prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags
set_page_pfmemalloc(page);
else
clear_page_pfmemalloc(page);
trace_android_vh_test_clear_look_around_ref(page);
}
/*

View File

@@ -789,6 +789,7 @@ static bool page_referenced_one(struct page *page, struct vm_area_struct *vma,
}
if (pvmw.pte) {
trace_android_vh_look_around(&pvmw, page, vma, &referenced);
if (ptep_clear_flush_young_notify(vma, address,
pvmw.pte)) {
/*

View File

@@ -1022,12 +1022,16 @@ static enum page_references page_check_references(struct page *page,
unsigned long vm_flags;
bool should_protect = false;
bool trylock_fail = false;
int ret = 0;
trace_android_vh_page_should_be_protected(page, &should_protect);
if (unlikely(should_protect))
return PAGEREF_ACTIVATE;
trace_android_vh_page_trylock_set(page);
trace_android_vh_check_page_look_around_ref(page, &ret);
if (ret)
return ret;
referenced_ptes = page_referenced(page, 1, sc->target_mem_cgroup,
&vm_flags);
referenced_page = TestClearPageReferenced(page);