From f6f18f7ffab8097bbc72ba2b555327ddfc115066 Mon Sep 17 00:00:00 2001 From: Bing Han Date: Sat, 11 Jun 2022 16:06:16 +0800 Subject: [PATCH] ANDROID: vendor_hook: Add hook in swap_slots Provide a vendor hook android_vh_swap_slot_cache_active to pass the active status of swap_slots_cache. This status will be used in the process of reclaiming the pages that is required to be reclaimed to a specified swap location. Bug: 234214858 Signed-off-by: Bing Han Change-Id: I8211760e0f37fe4a514f6ceaae9993925da8cd6d --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 3 +++ mm/swap_slots.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 1f30d49f345b..b35324b886c0 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_swap_slot_cache_active); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_drain_slots_cache_cpu); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_swap_slot_cache); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_swap_slot); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index c6f0f726392c..ae93f1916273 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -177,6 +177,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_swap_slot_cache_active, + TP_PROTO(bool swap_slot_cache_active), + TP_ARGS(swap_slot_cache_active)); DECLARE_HOOK(android_vh_drain_slots_cache_cpu, TP_PROTO(struct swap_slots_cache *cache, unsigned int type, bool free_slots, bool *skip), diff --git a/mm/swap_slots.c b/mm/swap_slots.c index 365493578163..a200aafc0a36 100644 --- a/mm/swap_slots.c +++ b/mm/swap_slots.c @@ -55,6 +55,7 @@ static void deactivate_swap_slots_cache(void) { mutex_lock(&swap_slots_cache_mutex); swap_slot_cache_active = false; + trace_android_vh_swap_slot_cache_active(false); __drain_swap_slots_cache(SLOTS_CACHE|SLOTS_CACHE_RET); mutex_unlock(&swap_slots_cache_mutex); } @@ -63,6 +64,7 @@ static void reactivate_swap_slots_cache(void) { mutex_lock(&swap_slots_cache_mutex); swap_slot_cache_active = true; + trace_android_vh_swap_slot_cache_active(true); mutex_unlock(&swap_slots_cache_mutex); }