From 74be75dd1061fb9f7bb18123652d6f986a433233 Mon Sep 17 00:00:00 2001 From: Charan Teja Kalla Date: Mon, 1 Jul 2024 17:10:18 +0530 Subject: [PATCH] ANDROID: mm: madvise: vendor hook to tune page flags Users can proactively reclaim the pages of an app once it is in background using the system calls, like madvise. But it may be possible that such pages turn out to be the workingset page in the conventional LRU which while swapping can result into accounting of PSI events. Although this PSI events is an indication that wrong pages are being madvised, one can also argue that he is aware of what he is doing using madvise. For such clients, add the vendor hook to tune page flags, such as clearing the Workingset during swapout so that PSI might not get accounyted during swapin. Bug: 350429581 Change-Id: I675c57f63a918c5a23df8273006426d0e611c5c5 Signed-off-by: Charan Teja Kalla --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 3 +++ mm/madvise.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 9abc0d1f53a3..383b0404742a 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -101,6 +101,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rtmutex_waiter_prio); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rtmutex_wait_start); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rtmutex_wait_finish); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rt_mutex_steal); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_cold_or_pageout_page); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_opt_spin_start); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_opt_spin_finish); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_can_spin_on_owner); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 4b0da560a4f0..6603dafabfd3 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -240,6 +240,9 @@ DECLARE_HOOK(android_vh_uprobes_replace_page, DECLARE_HOOK(android_vh_shmem_swapin_folio, TP_PROTO(struct folio *folio), TP_ARGS(folio)); +DECLARE_HOOK(android_vh_madvise_cold_or_pageout_page, + TP_PROTO(bool pageout, struct page *page), + TP_ARGS(pageout, page)); #endif /* _TRACE_HOOK_MM_H */ /* This part must be outside protection */ diff --git a/mm/madvise.c b/mm/madvise.c index d084cea48ffe..e445135ed4c1 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -413,6 +413,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, tlb_remove_pmd_tlb_entry(tlb, pmd, addr); } + trace_android_vh_madvise_cold_or_pageout_page(pageout, page); ClearPageReferenced(page); test_and_clear_page_young(page); if (pageout) { @@ -519,6 +520,7 @@ regular_page: * As a side effect, it makes confuse idle-page tracking * because they will miss recent referenced history. */ + trace_android_vh_madvise_cold_or_pageout_page(pageout, page); ClearPageReferenced(page); test_and_clear_page_young(page); if (pageout) {