ANDROID: mm: add vendor hooks in madvise for swap entry

Add vendor hooks in madvise for swap entry
- android_vh_madvise_pageout_swap_entry
- android_vh_madvise_swapin_walk_pmd_entry
- android_vh_process_madvise_end

Bug: 284059805

Change-Id: Ic389244e343737a583286c20cadb6774efd8890c
Signed-off-by: Sooyong Suk <s.suk@samsung.com>
This commit is contained in:
Sooyong Suk 2023-05-23 10:27:13 +09:00 committed by Suren Baghdasaryan
parent c0cfeeaa88
commit aee36dd530
3 changed files with 21 additions and 3 deletions

View File

@ -284,3 +284,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_get_thermal_zone_device);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_thermal_power_cap);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_reclaim_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_failure_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_pageout_swap_entry);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_swapin_walk_pmd_entry);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_process_madvise_end);

View File

@ -64,16 +64,23 @@ struct slabinfo;
DECLARE_HOOK(android_vh_cache_show,
TP_PROTO(struct seq_file *m, struct slabinfo *sinfo, struct kmem_cache *s),
TP_ARGS(m, sinfo, s));
DECLARE_HOOK(android_vh_alloc_pages_reclaim_bypass,
TP_PROTO(gfp_t gfp_mask, int order, int alloc_flags,
int migratetype, struct page **page),
TP_ARGS(gfp_mask, order, alloc_flags, migratetype, page));
DECLARE_HOOK(android_vh_alloc_pages_failure_bypass,
TP_PROTO(gfp_t gfp_mask, int order, int alloc_flags,
int migratetype, struct page **page),
TP_ARGS(gfp_mask, order, alloc_flags, migratetype, page));
DECLARE_HOOK(android_vh_madvise_pageout_swap_entry,
TP_PROTO(swp_entry_t entry, int swapcount),
TP_ARGS(entry, swapcount));
DECLARE_HOOK(android_vh_madvise_swapin_walk_pmd_entry,
TP_PROTO(swp_entry_t entry),
TP_ARGS(entry));
DECLARE_HOOK(android_vh_process_madvise_end,
TP_PROTO(int behavior, ssize_t *ret),
TP_ARGS(behavior, ret));
#endif /* _TRACE_HOOK_MM_H */

View File

@ -31,6 +31,7 @@
#include <linux/swapops.h>
#include <linux/shmem_fs.h>
#include <linux/mmu_notifier.h>
#include <trace/hooks/mm.h>
#include <asm/tlb.h>
@ -219,6 +220,7 @@ static int swapin_walk_pmd_entry(pmd_t *pmd, unsigned long start,
entry = pte_to_swp_entry(pte);
if (unlikely(non_swap_entry(entry)))
continue;
trace_android_vh_madvise_swapin_walk_pmd_entry(entry);
page = read_swap_cache_async(entry, GFP_HIGHUSER_MOVABLE,
vma, index, false, &splug);
@ -350,6 +352,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
struct page *page = NULL;
LIST_HEAD(page_list);
bool pageout_anon_only_filter;
swp_entry_t entry;
if (fatal_signal_pending(current))
return -EINTR;
@ -440,8 +443,12 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
if (pte_none(ptent))
continue;
if (!pte_present(ptent))
if (!pte_present(ptent)) {
entry = pte_to_swp_entry(ptent);
trace_android_vh_madvise_pageout_swap_entry(entry,
swp_swapcount(entry));
continue;
}
page = vm_normal_page(vma, addr, ptent);
if (!page || is_zone_device_page(page))
@ -1518,6 +1525,7 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
iov_iter_advance(&iter, iovec.iov_len);
}
trace_android_vh_process_madvise_end(behavior, &ret);
ret = (total_len - iov_iter_count(&iter)) ? : ret;
release_mm: