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

removed android_vh_madvise_pageout_swap_entry()
renamed android_vh_process_madvise()

Bug: 284059805

This is partial cherry-pick of https://android-review.googlesource.com/c/kernel/common/+/2601992.
Other part of this patch is already merged with https://android-review.googlesource.com/c/kernel/common/+/3064546.

This reintroduces android_vh_madvise_pageout_swap_entry() with additional param.

Bug: 351175506
Change-Id: I2ed34dce86f5ed1a1168bede28a8cc2667b621cf
Signed-off-by: Sooyong Suk <s.suk@samsung.corp-partner.google.com>
This commit is contained in:
Sooyong Suk 2024-07-05 17:35:50 +09:00 committed by Suren Baghdasaryan
parent 970642eb2d
commit 9db4e9899b
3 changed files with 10 additions and 1 deletions

View File

@ -384,6 +384,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_scan_type);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_queue_request_and_unlock); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_queue_request_and_unlock);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_fuse_request_end); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_fuse_request_end);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpuset_fork); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpuset_fork);
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_madvise_swapin_walk_pmd_entry);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_process_madvise); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_process_madvise);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_smaps_pte_entry); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_smaps_pte_entry);

View File

@ -194,6 +194,9 @@ DECLARE_HOOK(android_vh_cache_show,
DECLARE_HOOK(android_vh_customize_alloc_gfp, DECLARE_HOOK(android_vh_customize_alloc_gfp,
TP_PROTO(gfp_t *alloc_gfp, unsigned int order), TP_PROTO(gfp_t *alloc_gfp, unsigned int order),
TP_ARGS(alloc_gfp, order)); TP_ARGS(alloc_gfp, order));
DECLARE_HOOK(android_vh_madvise_pageout_swap_entry,
TP_PROTO(swp_entry_t entry, int swapcount, void *priv),
TP_ARGS(entry, swapcount, priv));
DECLARE_HOOK(android_vh_madvise_swapin_walk_pmd_entry, DECLARE_HOOK(android_vh_madvise_swapin_walk_pmd_entry,
TP_PROTO(swp_entry_t entry), TP_PROTO(swp_entry_t entry),
TP_ARGS(entry)); TP_ARGS(entry));

View File

@ -373,6 +373,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
LIST_HEAD(folio_list); LIST_HEAD(folio_list);
bool pageout_anon_only_filter; bool pageout_anon_only_filter;
int nr; int nr;
swp_entry_t entry;
if (fatal_signal_pending(current)) if (fatal_signal_pending(current))
return -EINTR; return -EINTR;
@ -467,8 +468,12 @@ regular_folio:
if (pte_none(ptent)) if (pte_none(ptent))
continue; 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), NULL);
continue; continue;
}
folio = vm_normal_folio(vma, addr, ptent); folio = vm_normal_folio(vma, addr, ptent);
if (!folio || folio_is_zone_device(folio)) if (!folio || folio_is_zone_device(folio))