mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
ANDROID: vendor_hooks: add hooks for exting task's swp_entrys
The process exit time is mainly caused by freeing its swp_entrys. When low memory triggers to kill lots of processes exit simultaneously, there is a problem of CPU high load occupied by the exiting processes. This feature is used to asynchronously maintain and release the swp_entrys of the exiting process to accelerate the efficiency of the exiting process. Bug: 364480846 Bug: 340798358 Change-Id: I6fc0b813e7ac6a0796e08ce7a17d5ff3ab2b799b Signed-off-by: Justin Jiang <justinjiang@vivo.corp-partner.google.com>
This commit is contained in:
committed by
Matthias Männich
parent
03a4ae5d99
commit
9eca8763c1
@@ -442,3 +442,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_folio_trylock_clear);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_folio_trylock_set);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_handle_trylock_failed_folio);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_hibernate_state);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_swapmem_gather_init);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_swapmem_gather_add_bypass);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_swapmem_gather_finish);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_swapmem_gather_init);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_swapmem_gather_finish);
|
||||
|
||||
@@ -246,6 +246,21 @@ DECLARE_HOOK(android_vh_shmem_swapin_folio,
|
||||
DECLARE_HOOK(android_vh_madvise_cold_or_pageout_page,
|
||||
TP_PROTO(bool pageout, struct page *page),
|
||||
TP_ARGS(pageout, page));
|
||||
DECLARE_HOOK(android_vh_swapmem_gather_init,
|
||||
TP_PROTO(struct mm_struct *mm),
|
||||
TP_ARGS(mm));
|
||||
DECLARE_HOOK(android_vh_swapmem_gather_add_bypass,
|
||||
TP_PROTO(struct mm_struct *mm, swp_entry_t entry, bool *bypass),
|
||||
TP_ARGS(mm, entry, bypass));
|
||||
DECLARE_HOOK(android_vh_swapmem_gather_finish,
|
||||
TP_PROTO(struct mm_struct *mm),
|
||||
TP_ARGS(mm));
|
||||
DECLARE_HOOK(android_vh_oom_swapmem_gather_init,
|
||||
TP_PROTO(struct mm_struct *mm),
|
||||
TP_ARGS(mm));
|
||||
DECLARE_HOOK(android_vh_oom_swapmem_gather_finish,
|
||||
TP_PROTO(struct mm_struct *mm),
|
||||
TP_ARGS(mm));
|
||||
#endif /* _TRACE_HOOK_MM_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
|
||||
@@ -1426,6 +1426,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
|
||||
pte_t *start_pte;
|
||||
pte_t *pte;
|
||||
swp_entry_t entry;
|
||||
bool bypass = false;
|
||||
|
||||
tlb_change_page_size(tlb, PAGE_SIZE);
|
||||
again:
|
||||
@@ -1498,6 +1499,9 @@ again:
|
||||
if (!should_zap_cows(details))
|
||||
continue;
|
||||
rss[MM_SWAPENTS]--;
|
||||
trace_android_vh_swapmem_gather_add_bypass(mm, entry, &bypass);
|
||||
if (bypass)
|
||||
goto skip;
|
||||
if (unlikely(!free_swap_and_cache(entry)))
|
||||
print_bad_pte(vma, addr, ptent, NULL);
|
||||
} else if (is_migration_entry(entry)) {
|
||||
@@ -1517,6 +1521,7 @@ again:
|
||||
/* We should have covered all the swap entry types */
|
||||
WARN_ON_ONCE(1);
|
||||
}
|
||||
skip:
|
||||
pte_clear_not_present_full(mm, addr, pte, tlb->fullmm);
|
||||
zap_install_uffd_wp_if_needed(vma, addr, pte, details, ptent);
|
||||
} while (pte++, addr += PAGE_SIZE, addr != end);
|
||||
|
||||
@@ -3329,9 +3329,11 @@ void exit_mmap(struct mm_struct *mm)
|
||||
lru_add_drain();
|
||||
flush_cache_mm(mm);
|
||||
tlb_gather_mmu_fullmm(&tlb, mm);
|
||||
trace_android_vh_swapmem_gather_init(mm);
|
||||
/* update_hiwater_rss(mm) here? but nobody should be looking */
|
||||
/* Use ULONG_MAX here to ensure all VMAs in the mm are unmapped */
|
||||
unmap_vmas(&tlb, &mm->mm_mt, vma, 0, ULONG_MAX, vma->vm_end, ULONG_MAX, false);
|
||||
trace_android_vh_swapmem_gather_finish(mm);
|
||||
mmap_read_unlock(mm);
|
||||
|
||||
/*
|
||||
|
||||
@@ -53,6 +53,9 @@
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include <trace/events/oom.h>
|
||||
|
||||
#undef CREATE_TRACE_POINTS
|
||||
#include <trace/hooks/mm.h>
|
||||
|
||||
static int sysctl_panic_on_oom;
|
||||
static int sysctl_oom_kill_allocating_task;
|
||||
static int sysctl_oom_dump_tasks = 1;
|
||||
@@ -525,6 +528,7 @@ bool __oom_reap_task_mm(struct mm_struct *mm)
|
||||
*/
|
||||
set_bit(MMF_UNSTABLE, &mm->flags);
|
||||
|
||||
trace_android_vh_oom_swapmem_gather_init(mm);
|
||||
for_each_vma(vmi, vma) {
|
||||
if (vma->vm_flags & (VM_HUGETLB|VM_PFNMAP))
|
||||
continue;
|
||||
@@ -557,6 +561,7 @@ bool __oom_reap_task_mm(struct mm_struct *mm)
|
||||
tlb_finish_mmu(&tlb);
|
||||
}
|
||||
}
|
||||
trace_android_vh_oom_swapmem_gather_finish(mm);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user