ANDROID: vendor hooks: Add hooks to adjust page alloc water mark
When allocating memory, we can adjust the water level to open a fast allocation channel for some important foreground processes, while allowing less important background processes to wait. Bug: 405889864 Change-Id: I71d709c8c782aa614d2c9e1d3150ce14a0106acb Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.corp-partner.google.com>
This commit is contained in:
committed by
Suren Baghdasaryan
parent
c23618753d
commit
1588efb8b0
@@ -451,4 +451,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_kcompactd_cpu_online);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_direct_reclaim_begin);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_direct_reclaim_end);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_read_fault);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_alloc_pages_reclaim_start);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_alloc_pages_reclaim_cycle_end);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_bd_link_disk_holder);
|
||||
|
||||
@@ -399,7 +399,15 @@ DECLARE_HOOK(android_vh_customize_alloc_gfp,
|
||||
DECLARE_HOOK(android_vh_mm_kcompactd_cpu_online,
|
||||
TP_PROTO(int cpu),
|
||||
TP_ARGS(cpu));
|
||||
|
||||
DECLARE_HOOK(android_rvh_alloc_pages_reclaim_start,
|
||||
TP_PROTO(gfp_t gfp_mask, int order, int *alloc_flags),
|
||||
TP_ARGS(gfp_mask, order, alloc_flags));
|
||||
DECLARE_HOOK(android_rvh_alloc_pages_reclaim_cycle_end,
|
||||
TP_PROTO(gfp_t gfp_mask, int order, int *alloc_flags,
|
||||
unsigned long *did_some_progress, int *no_progress_loops,
|
||||
unsigned long direct_reclaim_retries),
|
||||
TP_ARGS(gfp_mask, order, alloc_flags, did_some_progress,
|
||||
no_progress_loops, direct_reclaim_retries));
|
||||
#endif /* _TRACE_HOOK_MM_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
|
||||
@@ -4560,6 +4560,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
|
||||
int retry_loop_count = 0;
|
||||
u64 stime = 0;
|
||||
bool should_alloc_retry = false;
|
||||
unsigned long direct_reclaim_retries = 0;
|
||||
|
||||
if (unlikely(nofail)) {
|
||||
/*
|
||||
@@ -4622,6 +4623,9 @@ restart:
|
||||
if (alloc_flags & ALLOC_KSWAPD)
|
||||
wake_all_kswapds(order, gfp_mask, ac);
|
||||
|
||||
if (can_direct_reclaim && !direct_reclaim_retries && !(current->flags & PF_MEMALLOC))
|
||||
trace_android_rvh_alloc_pages_reclaim_start(gfp_mask, order, &alloc_flags);
|
||||
|
||||
/*
|
||||
* The adjusted alloc_flags might result in immediate success, so try
|
||||
* that first
|
||||
@@ -4731,6 +4735,9 @@ retry:
|
||||
if (page)
|
||||
goto got_pg;
|
||||
|
||||
if (direct_reclaim_retries < ULONG_MAX)
|
||||
direct_reclaim_retries++;
|
||||
|
||||
/* Try direct reclaim and then allocating */
|
||||
page = __alloc_pages_direct_reclaim(gfp_mask, order, alloc_flags, ac,
|
||||
&did_some_progress);
|
||||
@@ -4756,6 +4763,9 @@ retry:
|
||||
!(gfp_mask & __GFP_RETRY_MAYFAIL)))
|
||||
goto nopage;
|
||||
|
||||
trace_android_rvh_alloc_pages_reclaim_cycle_end(gfp_mask, order,
|
||||
&alloc_flags, &did_some_progress, &no_progress_loops, direct_reclaim_retries);
|
||||
|
||||
if (should_reclaim_retry(gfp_mask, order, ac, alloc_flags,
|
||||
did_some_progress > 0, &no_progress_loops))
|
||||
goto retry;
|
||||
|
||||
Reference in New Issue
Block a user