ANDROID: vendor_hook: Add hook to abort reclaim and compaction
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 Change-Id: I4b637cbd2b37235eec27a985a9b5b95598247c59 Signed-off-by: shenjiangjiang <shenjiangjiang@oppo.com>
This commit is contained in:
@@ -426,6 +426,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_highpage_movable_gfp_adjust);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_anon_gfp_adjust);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_dma_buf_stats_teardown);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_cold_or_pageout);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_cold_or_pageout_abort);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_retry);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_encrypt_page);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_init_aes_encrypt);
|
||||
@@ -442,6 +443,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_one_page_bypass);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_use_cma_first_check);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_slab_page_alloced);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kmalloc_order_alloced);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compact_finished);
|
||||
/*
|
||||
* For type visibility
|
||||
*/
|
||||
|
||||
@@ -217,6 +217,12 @@ DECLARE_HOOK(android_vh_slab_page_alloced,
|
||||
DECLARE_HOOK(android_vh_kmalloc_order_alloced,
|
||||
TP_PROTO(struct page *page, size_t size, gfp_t flags),
|
||||
TP_ARGS(page, size, flags));
|
||||
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 */
|
||||
|
||||
@@ -45,6 +45,11 @@ static inline void count_compact_events(enum vm_event_item item, long delta)
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include <trace/events/compaction.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))
|
||||
#define pageblock_start_pfn(pfn) block_start_pfn(pfn, pageblock_order)
|
||||
@@ -2084,6 +2089,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)) {
|
||||
@@ -2183,7 +2189,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;
|
||||
|
||||
@@ -328,8 +328,10 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
|
||||
struct page *page = NULL;
|
||||
LIST_HEAD(page_list);
|
||||
bool allow_shared = false;
|
||||
bool abort_madvise = false;
|
||||
|
||||
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_cold_or_pageout(vma, &allow_shared);
|
||||
|
||||
Reference in New Issue
Block a user