mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-12 04:15:21 +02:00
ANDROID: mm: create vendor hooks for memory reclaim
we try to adjust page reclaim operations based on the running task and kernel memory pressure. Thus, we want to create some vendor hooks into kernel6.1. Firstly, we add ADNRROID_VENDOR_DATA into the struct scan_control, special operations would be performed based on this special scan option. We measure the importance of the current process in the system and obtain its weight, which is recorded in ANDROID_VENDOR_DATA. The hook function: trace_android_vh_modify_scan_control is added inside of the function modify_scan_control() to adjust reclaim operations based on memory pressure. The hook function: trace_android_vh_should_continue_reclaim is added inside of the function shrink_node() to decide if page_reclaim would continue or not based on memory pressure. The hook function: trace_android_vh_file_is_tiny_bypass is added into the function prepare_scan_count() to decide if the file pages should be skipped in condition to file refualts and memory pressure. Bug: 347648912 Change-Id: I1efe9d3e866f37b0295c7cd94ec8ca0117a9bd4a Signed-off-by: Dezhi Huang <huangdezhi@hihonor.com>
This commit is contained in:
parent
3ebe062ee3
commit
047f3eded8
|
@ -317,6 +317,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_thread_read);
|
|||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_free_proc);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_thread_release);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_read_done);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_modify_scan_control);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_should_continue_reclaim);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_file_is_tiny_bypass);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_signal);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_folio_look_around_ref);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_look_around);
|
||||
|
|
|
@ -36,7 +36,18 @@ DECLARE_HOOK(android_vh_tune_scan_type,
|
|||
DECLARE_HOOK(android_vh_page_referenced_check_bypass,
|
||||
TP_PROTO(struct folio *folio, unsigned long nr_to_scan, int lru, bool *bypass),
|
||||
TP_ARGS(folio, nr_to_scan, lru, bypass));
|
||||
|
||||
DECLARE_HOOK(android_vh_modify_scan_control,
|
||||
TP_PROTO(u64 *ext, unsigned long *nr_to_reclaim,
|
||||
struct mem_cgroup *target_mem_cgroup,
|
||||
bool *file_is_tiny, bool *may_writepage),
|
||||
TP_ARGS(ext, nr_to_reclaim, target_mem_cgroup, file_is_tiny, may_writepage));
|
||||
DECLARE_HOOK(android_vh_should_continue_reclaim,
|
||||
TP_PROTO(u64 *ext, unsigned long *nr_to_reclaim,
|
||||
unsigned long *nr_reclaimed, bool *continue_reclaim),
|
||||
TP_ARGS(ext, nr_to_reclaim, nr_reclaimed, continue_reclaim));
|
||||
DECLARE_HOOK(android_vh_file_is_tiny_bypass,
|
||||
TP_PROTO(bool file_is_tiny, bool *bypass),
|
||||
TP_ARGS(file_is_tiny, bypass));
|
||||
#endif /* _TRACE_HOOK_VMSCAN_H */
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
||||
|
|
28
mm/vmscan.c
28
mm/vmscan.c
|
@ -2976,6 +2976,7 @@ static void prepare_scan_count(pg_data_t *pgdat, struct scan_control *sc)
|
|||
{
|
||||
unsigned long file;
|
||||
struct lruvec *target_lruvec;
|
||||
bool bypass = false;
|
||||
|
||||
if (lru_gen_enabled())
|
||||
return;
|
||||
|
@ -3037,6 +3038,11 @@ static void prepare_scan_count(pg_data_t *pgdat, struct scan_control *sc)
|
|||
else
|
||||
sc->cache_trim_mode = 0;
|
||||
|
||||
|
||||
trace_android_vh_file_is_tiny_bypass(sc->file_is_tiny, &bypass);
|
||||
if (bypass)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Prevent the reclaimer from falling into the cache trap: as
|
||||
* cache pages start out inactive, every cache fault will tip
|
||||
|
@ -6523,6 +6529,7 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat,
|
|||
unsigned long pages_for_compaction;
|
||||
unsigned long inactive_lru_pages;
|
||||
int z;
|
||||
bool continue_reclaim = true;
|
||||
|
||||
/* If not in reclaim/compaction mode, stop */
|
||||
if (!in_reclaim_compaction(sc))
|
||||
|
@ -6565,6 +6572,11 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat,
|
|||
if (can_reclaim_anon_pages(NULL, pgdat->node_id, sc))
|
||||
inactive_lru_pages += node_page_state(pgdat, NR_INACTIVE_ANON);
|
||||
|
||||
trace_android_vh_should_continue_reclaim(&sc->android_vendor_data1,
|
||||
&sc->nr_to_reclaim, &sc->nr_reclaimed, &continue_reclaim);
|
||||
if (!continue_reclaim)
|
||||
return false;
|
||||
|
||||
return inactive_lru_pages > pages_for_compaction;
|
||||
}
|
||||
|
||||
|
@ -6917,6 +6929,20 @@ static void snapshot_refaults(struct mem_cgroup *target_memcg, pg_data_t *pgdat)
|
|||
target_lruvec->refaults[WORKINGSET_FILE] = refaults;
|
||||
}
|
||||
|
||||
static void modify_scan_control(struct scan_control *sc)
|
||||
{
|
||||
bool file_is_tiny = false, may_writepage = true;
|
||||
|
||||
trace_android_vh_modify_scan_control(&sc->android_vendor_data1,
|
||||
&sc->nr_to_reclaim, sc->target_mem_cgroup, &file_is_tiny,
|
||||
&may_writepage);
|
||||
|
||||
if (file_is_tiny)
|
||||
sc->file_is_tiny = true;
|
||||
if (!may_writepage)
|
||||
sc->may_writepage = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the main entry point to direct page reclaim.
|
||||
*
|
||||
|
@ -6940,6 +6966,8 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
|
|||
pg_data_t *last_pgdat;
|
||||
struct zoneref *z;
|
||||
struct zone *zone;
|
||||
|
||||
modify_scan_control(sc);
|
||||
retry:
|
||||
delayacct_freepages_start();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user