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 <quic_charante@quicinc.com>
This commit is contained in:
Charan Teja Kalla
2024-07-01 17:10:18 +05:30
committed by Suren Baghdasaryan
parent 7fc3794962
commit 74be75dd10
3 changed files with 6 additions and 0 deletions

View File

@@ -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);

View File

@@ -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 */

View File

@@ -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) {