ANDROID: vendor_hooks: Allow shared pages reclaim via MADV_PAGEOUT

Add a hook in madvise_cold_or_pageout_pte_range() to allow
vendor modules to influence the shared pages reclaim.

Bug: 242678506
Change-Id: I269a385b59f7291c2e96478674bb3d05f94584cb
Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
This commit is contained in:
Pavankumar Kondeti
2022-09-26 18:36:10 +05:30
committed by Treehugger Robot
parent ec736ca13a
commit 99e3951ea4
3 changed files with 8 additions and 1 deletions

View File

@@ -402,6 +402,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_hibernation_swap);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_cpu_resume);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_hib_resume_bdev);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_dma_buf_stats_teardown);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_cold_or_pageout);
/*
* For type visibility

View File

@@ -150,6 +150,9 @@ DECLARE_HOOK(android_vh_rmqueue,
DECLARE_HOOK(android_vh_kmalloc_slab,
TP_PROTO(unsigned int index, gfp_t flags, struct kmem_cache **s),
TP_ARGS(index, flags, s));
DECLARE_HOOK(android_vh_madvise_cold_or_pageout,
TP_PROTO(struct vm_area_struct *vma, bool *allow_shared),
TP_ARGS(vma, allow_shared));
#endif /* _TRACE_HOOK_MM_H */
/* This part must be outside protection */

View File

@@ -31,6 +31,7 @@
#include <linux/swapops.h>
#include <linux/shmem_fs.h>
#include <linux/mmu_notifier.h>
#include <trace/hooks/mm.h>
#include <asm/tlb.h>
@@ -324,10 +325,12 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
spinlock_t *ptl;
struct page *page = NULL;
LIST_HEAD(page_list);
bool allow_shared = false;
if (fatal_signal_pending(current))
return -EINTR;
trace_android_vh_madvise_cold_or_pageout(vma, &allow_shared);
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
if (pmd_trans_huge(*pmd)) {
pmd_t orig_pmd;
@@ -443,7 +446,7 @@ regular_page:
}
/* Do not interfere with other mappings of this page */
if (page_mapcount(page) != 1)
if (!allow_shared && page_mapcount(page) != 1)
continue;
VM_BUG_ON_PAGE(PageTransCompound(page), page);