mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-18 23:29:57 +02:00
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>
This commit is contained in:
parent
6d955b09ac
commit
b0807745d4
|
@ -357,6 +357,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_direct_reclaim_enter);
|
|||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_direct_reclaim_exit);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_may_oom_exit);
|
||||
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_customize_alloc_gfp);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpu_capacity_show);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shmem_swapin_folio);
|
||||
|
|
10
fs/inode.c
10
fs/inode.c
|
@ -24,6 +24,9 @@
|
|||
#include <trace/events/writeback.h>
|
||||
#include "internal.h"
|
||||
|
||||
#undef CREATE_TRACE_POINTS
|
||||
#include <trace/hooks/vmscan.h>
|
||||
|
||||
/*
|
||||
* Inode locking rules:
|
||||
*
|
||||
|
@ -807,6 +810,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
|
||||
|
@ -815,6 +819,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
|
||||
|
|
|
@ -28,6 +28,16 @@ DECLARE_HOOK(android_vh_vmscan_kswapd_done,
|
|||
TP_PROTO(int node_id, unsigned int highest_zoneidx, unsigned int alloc_order,
|
||||
unsigned int reclaim_order),
|
||||
TP_ARGS(node_id, highest_zoneidx, alloc_order, reclaim_order));
|
||||
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));
|
||||
|
||||
enum scan_balance;
|
||||
DECLARE_HOOK(android_vh_tune_scan_type,
|
||||
|
|
|
@ -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
|
||||
|
@ -516,6 +519,11 @@ unsigned long mapping_try_invalidate(struct address_space *mapping,
|
|||
unsigned long ret;
|
||||
unsigned long count = 0;
|
||||
int i;
|
||||
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
mm/vmscan.c
11
mm/vmscan.c
|
@ -1750,6 +1750,8 @@ retry:
|
|||
enum folio_references references = FOLIOREF_RECLAIM;
|
||||
bool dirty, writeback;
|
||||
unsigned int nr_pages;
|
||||
bool activate = false;
|
||||
bool keep = false;
|
||||
|
||||
cond_resched();
|
||||
|
||||
|
@ -1783,6 +1785,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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user