From 7222a0b29b2a530921486bdff962b93b2f02b916 Mon Sep 17 00:00:00 2001 From: Bing Han Date: Fri, 10 Jun 2022 18:45:31 +0800 Subject: [PATCH] ANDROID: vendor_hook: Add hooks in free_swap_slot() Provide a vendor hook to replace the function free_swap_slot, adding the free_swap_slot process of pages swapped to the specified swap location(i.e., the reserved expended memory) Bug: 234214858 Signed-off-by: Bing Han Change-Id: Idd6d0007e64d56d556d1234a8b931fce06031809 --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 3 +++ mm/swap_slots.c | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 2aa6618d10ae..ade852aa0f9c 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -416,6 +416,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_referenced_one_end); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_count_pswpin); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_count_pswpout); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_count_swpout_vm_event); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_swap_slot); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_isolated_for_reclaim); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_inactive_is_low); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_snapshot_refaults); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index dd040e1d1ced..a33a701e8ee4 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -176,6 +176,9 @@ DECLARE_HOOK(android_vh_count_pswpout, DECLARE_HOOK(android_vh_count_swpout_vm_event, TP_PROTO(struct swap_info_struct *sis, struct page *page, bool *skip), TP_ARGS(sis, page, skip)); +DECLARE_HOOK(android_vh_free_swap_slot, + TP_PROTO(swp_entry_t entry, struct swap_slots_cache *cache, bool *skip), + TP_ARGS(entry, cache, skip)); DECLARE_HOOK(android_vh_page_isolated_for_reclaim, TP_PROTO(struct mm_struct *mm, struct page *page), TP_ARGS(mm, page)); diff --git a/mm/swap_slots.c b/mm/swap_slots.c index 0357fbe70645..25b5f0c6d44b 100644 --- a/mm/swap_slots.c +++ b/mm/swap_slots.c @@ -274,8 +274,12 @@ static int refill_swap_slots_cache(struct swap_slots_cache *cache) int free_swap_slot(swp_entry_t entry) { struct swap_slots_cache *cache; + bool skip = false; cache = raw_cpu_ptr(&swp_slots); + trace_android_vh_free_swap_slot(entry, cache, &skip); + if (skip) + return 0; if (likely(use_swap_slot_cache && cache->slots_ret)) { spin_lock_irq(&cache->free_lock); /* Swap slots cache may be deactivated before acquiring lock */