ANDROID: mm: create vendor hooks for page alloc

Add vendor hook inside of get_page_from_freelist() to check
and modify the watermark in some special situations.
Additional page flag bit will be set for future identification.

Separately, a vendor hook inside of page_add_new_anon_rmap()
is added to set the referenced bit in some situations, e.g.
if the special bit in the page flag mentioned before is set,
we will give this page one more chance before it gets reclaimed.

Bug: 279793368
Change-Id: I363853a050a87201f6f368ccc580485dddd6c6b6
Signed-off-by: Dezhi Huang <huangdezhi@hihonor.com>
This commit is contained in:
Dezhi Huang
2023-05-19 09:58:01 +08:00
committed by Todd Kjos
parent 3abed61c35
commit 784f566942
4 changed files with 14 additions and 0 deletions

View File

@@ -239,6 +239,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_reply);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_trans);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmap_region);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_try_to_unmap_one);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_get_page_wmark);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_add_new_anon_rmap);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_event);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_group);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpufreq_acct_update_power);

View File

@@ -30,6 +30,13 @@ DECLARE_HOOK(android_vh_try_to_unmap_one,
TP_PROTO(struct folio *folio, struct vm_area_struct *vma,
unsigned long addr, void *arg, bool ret),
TP_ARGS(folio, vma, addr, arg, ret));
DECLARE_HOOK(android_vh_get_page_wmark,
TP_PROTO(unsigned int alloc_flags, unsigned long *page_wmark),
TP_ARGS(alloc_flags, page_wmark));
DECLARE_HOOK(android_vh_page_add_new_anon_rmap,
TP_PROTO(struct page *page, struct vm_area_struct *vma,
unsigned long address),
TP_ARGS(page, vma, address));
#endif /* _TRACE_HOOK_MM_H */

View File

@@ -84,6 +84,9 @@
#include "page_reporting.h"
#include "swap.h"
#undef CREATE_TRACE_POINTS
#include <trace/hooks/mm.h>
/* Free Page Internal flags: for internal, non-pcp variants of free_pages(). */
typedef int __bitwise fpi_t;
@@ -4319,6 +4322,7 @@ retry:
}
mark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK);
trace_android_vh_get_page_wmark(alloc_flags, &mark);
if (!zone_watermark_fast(zone, order, mark,
ac->highest_zoneidx, alloc_flags,
gfp_mask)) {

View File

@@ -1270,6 +1270,7 @@ void page_add_new_anon_rmap(struct page *page,
}
__mod_lruvec_page_state(page, NR_ANON_MAPPED, nr);
__page_set_anon_rmap(page, vma, address, 1);
trace_android_vh_page_add_new_anon_rmap(page, vma, address);
}
/**