diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 9dcb68bb0587..af6674181ffd 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -427,6 +427,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_vfs_fsync_range); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_fcntl); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_evict); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_vmscan_kswapd_done); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shrink_folio_list); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_inode_lru_isolate); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_invalidate_mapping_pagevec); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_reclaim_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_failure_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_vmalloc_stack); diff --git a/fs/inode.c b/fs/inode.c index bfd5d7929979..1897b03bdbdf 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -25,6 +25,7 @@ #include "internal.h" #undef CREATE_TRACE_POINTS +#include #include /* @@ -889,6 +890,7 @@ static enum lru_status inode_lru_isolate(struct list_head *item, { struct list_head *freeable = arg; struct inode *inode = container_of(item, struct inode, i_lru); + bool skip = false; /* * We are inverting the lru lock/inode->i_lock here, so use a @@ -897,6 +899,12 @@ static enum lru_status inode_lru_isolate(struct list_head *item, if (!spin_trylock(&inode->i_lock)) return LRU_SKIP; + trace_android_vh_inode_lru_isolate(inode, &skip); + if (skip) { + spin_unlock(&inode->i_lock); + return LRU_SKIP; + } + /* * Inodes can get referenced, redirtied, or repopulated while * they're already on the LRU, and this can make them diff --git a/include/trace/hooks/vmscan.h b/include/trace/hooks/vmscan.h index 3e6e49aa5ca6..57d4a8afa7e3 100644 --- a/include/trace/hooks/vmscan.h +++ b/include/trace/hooks/vmscan.h @@ -21,6 +21,16 @@ DECLARE_HOOK(android_vh_check_folio_look_around_ref, DECLARE_HOOK(android_vh_tune_swappiness, TP_PROTO(int *swappiness), TP_ARGS(swappiness)); +DECLARE_HOOK(android_vh_shrink_folio_list, + TP_PROTO(struct folio *folio, bool dirty, bool writeback, + bool *activate, bool *keep), + TP_ARGS(folio, dirty, writeback, activate, keep)); +DECLARE_HOOK(android_vh_inode_lru_isolate, + TP_PROTO(struct inode *inode, bool *skip), + TP_ARGS(inode, skip)); +DECLARE_HOOK(android_vh_invalidate_mapping_pagevec, + TP_PROTO(struct address_space *mapping, bool *skip), + TP_ARGS(mapping, skip)); DECLARE_HOOK(android_vh_modify_scan_control, TP_PROTO(u64 *ext, unsigned long *nr_to_reclaim, struct mem_cgroup *target_mem_cgroup, diff --git a/mm/truncate.c b/mm/truncate.c index 12f9e3219acd..bd46dcb591bc 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -24,6 +24,9 @@ #include #include "internal.h" +#undef CREATE_TRACE_POINTS +#include + /* * Regular page slots are stabilized by the page lock even without the tree * itself locked. These unlocked entries need verification under the tree @@ -488,6 +491,11 @@ unsigned long mapping_try_invalidate(struct address_space *mapping, unsigned long count = 0; int i; bool xa_has_values = false; + bool skip = false; + + trace_android_vh_invalidate_mapping_pagevec(mapping, &skip); + if (skip) + return count; folio_batch_init(&fbatch); while (find_lock_entries(mapping, &index, end, &fbatch, indices)) { diff --git a/mm/vmscan.c b/mm/vmscan.c index 119527bc64e0..b3c02528b9ce 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1124,6 +1124,8 @@ retry: enum folio_references references = FOLIOREF_RECLAIM; bool dirty, writeback; unsigned int nr_pages; + bool activate = false; + bool keep = false; cond_resched(); @@ -1152,6 +1154,15 @@ retry: * folios if the tail of the LRU is all dirty unqueued folios. */ folio_check_dirty_writeback(folio, &dirty, &writeback); + + trace_android_vh_shrink_folio_list(folio, dirty, writeback, + &activate, &keep); + if (activate) + goto activate_locked; + + if (keep) + goto keep_locked; + if (dirty || writeback) stat->nr_dirty += nr_pages;