Reapply "ANDROID: vendor_hook: Add hook to abort reclaim and compaction"
This reverts commit 003ff5810d36661534de1db33b1393ae809dcffe. We need to abort the reclaim/compaction by sending signal(such as SIGUSR2) to the reclaim thread, or just abort when cpu-usage is too-high or free-mem is enough. Bug: 289987875 Bug: 356961335 Change-Id: I70b23b72f312f49ecffae676f5eea4711bea085c Signed-off-by: shenjiangjiang <shenjiangjiang@oppo.com> Signed-off-by: zhangxiangzhe <zhangxiangzhe@xiaomi.com> (cherry picked from commit 4fcd8ef925f78f520a325060f6a01cdcccbf147f)
This commit is contained in:
committed by
Treehugger Robot
parent
2a5729e149
commit
eaaf6b8ef5
@@ -428,6 +428,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_new_page);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_pageout_return_error);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_process_madvise_return_error);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_pageout_bypass);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_cold_or_pageout_abort);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_pages_prepare_bypass);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_pages_ok_bypass);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_split_large_folio_bypass);
|
||||
@@ -517,6 +518,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_clear_rwsem_writer_owned);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_read_trylock_failed);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compaction_exit);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compaction_try_to_compact_exit);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compact_finished);
|
||||
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);
|
||||
|
||||
@@ -450,6 +450,12 @@ DECLARE_HOOK(android_vh_mm_may_oom_exit,
|
||||
DECLARE_HOOK(android_vh_calculate_totalreserve_pages,
|
||||
TP_PROTO(bool *skip),
|
||||
TP_ARGS(skip));
|
||||
DECLARE_HOOK(android_vh_compact_finished,
|
||||
TP_PROTO(bool *abort_compact),
|
||||
TP_ARGS(abort_compact));
|
||||
DECLARE_HOOK(android_vh_madvise_cold_or_pageout_abort,
|
||||
TP_PROTO(struct vm_area_struct *vma, bool *abort_madvise),
|
||||
TP_ARGS(vma, abort_madvise));
|
||||
#endif /* _TRACE_HOOK_MM_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
|
||||
+8
-1
@@ -69,6 +69,11 @@ static inline bool is_via_compact_memory(int order) { return false; }
|
||||
#include <trace/hooks/compaction.h>
|
||||
#include <trace/hooks/mm.h>
|
||||
|
||||
#undef CREATE_TRACE_POINTS
|
||||
#ifndef __GENKSYMS__
|
||||
#include <trace/hooks/mm.h>
|
||||
#endif
|
||||
|
||||
#define block_start_pfn(pfn, order) round_down(pfn, 1UL << (order))
|
||||
#define block_end_pfn(pfn, order) ALIGN((pfn) + 1, 1UL << (order))
|
||||
|
||||
@@ -2297,6 +2302,7 @@ static enum compact_result __compact_finished(struct compact_control *cc)
|
||||
unsigned int order;
|
||||
const int migratetype = cc->migratetype;
|
||||
int ret;
|
||||
bool abort_compact = false;
|
||||
|
||||
/* Compaction run completes if the migrate and free scanner meet */
|
||||
if (compact_scanners_met(cc)) {
|
||||
@@ -2383,7 +2389,8 @@ static enum compact_result __compact_finished(struct compact_control *cc)
|
||||
}
|
||||
|
||||
out:
|
||||
if (cc->contended || fatal_signal_pending(current))
|
||||
trace_android_vh_compact_finished(&abort_compact);
|
||||
if (cc->contended || fatal_signal_pending(current) || abort_compact)
|
||||
ret = COMPACT_CONTENDED;
|
||||
|
||||
return ret;
|
||||
|
||||
+3
-1
@@ -353,10 +353,12 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
|
||||
LIST_HEAD(folio_list);
|
||||
bool pageout_anon_only_filter;
|
||||
unsigned int batch_count = 0;
|
||||
bool abort_madvise = false;
|
||||
int nr;
|
||||
int ret = 0;
|
||||
|
||||
if (fatal_signal_pending(current))
|
||||
trace_android_vh_madvise_cold_or_pageout_abort(vma, &abort_madvise);
|
||||
if (fatal_signal_pending(current) || abort_madvise)
|
||||
return -EINTR;
|
||||
|
||||
trace_android_vh_madvise_pageout_bypass(mm, pageout, &ret);
|
||||
|
||||
Reference in New Issue
Block a user