ANDROID: mm: add vendor hooks to adjust memory reclamation
Add vendor hooks to adjust page reclamation operations based on the running task and kernel memory pressure. Determine if file pages should be skipped in response to file faults and memory pressure. Bug: 350865007 Change-Id: I39c223876ef82af443407234e35f39bcbbeb17cb Signed-off-by: Yang Yang <yang.yang@vivo.com> Signed-off-by: ying zuxin <11154159@vivo.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
#undef CREATE_TRACE_POINTS
|
||||
#include <trace/hooks/vmscan.h>
|
||||
#include <trace/hooks/fs.h>
|
||||
|
||||
/*
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
#include <linux/rmap.h>
|
||||
#include "internal.h"
|
||||
|
||||
#undef CREATE_TRACE_POINTS
|
||||
#include <trace/hooks/vmscan.h>
|
||||
|
||||
/*
|
||||
* 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)) {
|
||||
|
||||
+11
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user