From 7449d8120a05fc74d863b73df0773c46a69cfd83 Mon Sep 17 00:00:00 2001 From: Bing Han Date: Thu, 18 Aug 2022 15:35:24 +0800 Subject: [PATCH] ANDROID: vendor_hook: Add hook in si_swapinfo() This reverts commit 86be1a3d9f5a43437b9d1815a6014b4be96e1349 The hook android_vh_si_swapinfo is deleted, due to the symbol is not added to the abi list. The symbol is added to the abi list in patch:2183484. This patch is to add the hook android_vh_si_swapinfo again. Bug: 234214858 Bug: 203756332 Cc: Greg Kroah-Hartman Signed-off-by: Bing Han Change-Id: Ifd1e05f44ac04b67816618139badd5c2ee786b50 --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 3 +++ mm/swapfile.c | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 053ce75a212f..13c10551d922 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -443,5 +443,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_inactive_is_low); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_snapshot_refaults); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_account_swap_pages); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_unuse_swap_page); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_si_swapinfo); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_shmem_page_flag); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_pelt_multiplier); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 7c97213cd2de..213b14ea4cc6 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -245,6 +245,9 @@ DECLARE_HOOK(android_vh_account_swap_pages, DECLARE_HOOK(android_vh_unuse_swap_page, TP_PROTO(struct swap_info_struct *si, struct page *page), TP_ARGS(si, page)); +DECLARE_HOOK(android_vh_si_swapinfo, + TP_PROTO(struct swap_info_struct *si, bool *skip), + TP_ARGS(si, skip)); DECLARE_HOOK(android_vh_set_shmem_page_flag, TP_PROTO(struct page *page), TP_ARGS(page)); diff --git a/mm/swapfile.c b/mm/swapfile.c index fb712ff403c5..0aba6e4742d1 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3454,8 +3454,10 @@ void si_swapinfo(struct sysinfo *val) spin_lock(&swap_lock); for (type = 0; type < nr_swapfiles; type++) { struct swap_info_struct *si = swap_info[type]; + bool skip = false; - if ((si->flags & SWP_USED) && !(si->flags & SWP_WRITEOK)) + trace_android_vh_si_swapinfo(si, &skip); + if (!skip && (si->flags & SWP_USED) && !(si->flags & SWP_WRITEOK)) nr_to_be_unused += si->inuse_pages; } val->freeswap = atomic_long_read(&nr_swap_pages) + nr_to_be_unused;